-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Ensure times at which chpi are fitted are valid samples #8827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I actually don't mind the fractional samples too much as it accurately reflects the center of the window (except at the edges, but this is by design I think). Instead the problem is maybe that WDYT? If you agree I feel free to give it a shot or I can push a commit to try it |
|
I simplified a bit in my explanation. The errors occurs in sfreq = 1000
tmax = times[-1] # 810.6805
tmax = int(round(tmax * sfreq)) / sfreq # 810.68
tmax += (0.5 if include_tmax else -0.5) / sfreq # 810.6804999999999999, uhoh! maybe |
To me this is just a symptom of the problem. We shouldn't have any time in |
|
... or we just use floor arithmetic for the window length, then for even-length windows instead of getting |
|
Clearly I am a bit conflicted on the right approach here as I am contradicting myself in these discussions... I think I'm happy with merging this as is, and at some point I might try to simplify the calculations so that there are fewer rounds and casts going on. If we can stick with ints longer I think the behavior and code will be clearer. |
|
I agree and will see if I can fix it higher up. |
|
This can actually not be fixed higher up. This is due to rounding errors. Perhaps we should just merge this because it works? |
|
Okay in it goes, someday maybe I'll try to simplify the logic but I don't think it should matter if we have to change by a sample or two. Thanks @wmvanvliet ! |
I encountered this while maxfiltering 40 subjects. Some subjects failed, claiming
Head position time points must be greater than first sample offset, but found 500.0005 < 500. A bit of a misleading error, as it was not the first time point that caused the problem, but the final time point.When the continuous head position is fitted through
compute_chpi_amplitudes, the first column of the result contains the times at which each fit was performed. However, these times were not necessarily aligned on the times of the original raw object, meaning some times fell in between two samples. This caused problems later on inmaxwell_filteras a check is done whether the times are all valid, as the final timestamp can be slightly larger than the final timestamp of the raw object.In this PR,
compute_chpi_amplitudesis changed to always produce times that are aligned with those in the original raw object.