mad-lab-fau / gaitmap

The Gait and Movement Analysis Package
https://gaitmap.readthedocs.io
Other
38 stars 2 forks source link

HMM pre-processing fails if sampling rate is not a multiple of 51.2 #59

Closed AKuederle closed 4 months ago

AKuederle commented 6 months ago

The "naive" upsampling implemnted here does not work with samplingrates that are not a even multiple

https://github.com/mad-lab-fau/gaitmap/blob/8510fe0be3298e95fb62b32414613cc9279091eb/gaitmap_mad/gaitmap_mad/stride_segmentation/hmm/_hmm_feature_transform.py#L261-L277

We should use proper interpolation using "nearest"

@HaMora @Aksei Jelena wanted to fix this I think? Any updates? And if she does not have time, could one of you have a look at that?

Aksei commented 5 months ago

I could take care of it. I am not 100% on this topic; never used the HMMs so far. My naive approach would be to use the script.signal.resample functionality instead of the np.repeat function.

@AKuederle @HaMora what di you think?

AKuederle commented 5 months ago

Seems reasonable. Does resample support a "nearest" option? Otherwise interpolate might do the job

Aksei commented 5 months ago

What do you mean with "nearest"? The green signal is the one that needs to be resampled, isn't it?

Unbenannt

AKuederle commented 5 months ago

I mean as a resample method. Because we need discrete values. With normal resample you would get float/in-between values

AKuederle commented 5 months ago

And yes, the green signal is the one that needs resampling

HaMora commented 5 months ago

Sorry for the late reply, I read your comments and followed your conversation. I think, as @AKuederle mentioned, if we do resampling, we might need to do some aligning to match the two signals. But I think if we give the length of the original signal instead of the len(downsampled) * target_sampling_rate/actual_sampling_rate (sort of interpolation) might be effective.

AKuederle commented 4 months ago

Resolved by #62