You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Repeated Epoch/Evoked cropping is not idempotent when include_tmax=False #9374
The epo.tmax should be set to 0.375 on the first and all subsequent iterations.
Actual results
Every loop iteration cuts off the last time sample of the epoch.
Additional information
Platform: Linux-5.4.0-72-generic-x86_64-with-glibc2.29
Python: 3.8.5 (default, Jan 27 2021, 15:41:15) [GCC 9.3.0]
Executable: /home/jan/dev/python/spot/spot_venv/bin/python
CPU: x86_64: 8 cores
Memory: Unavailable (requires "psutil" package)
mne: 0.24.dev0
numpy: 1.19.5 {blas=openblas, lapack=openblas}
scipy: 1.5.4
matplotlib: 3.3.4 {backend=module://backend_interagg}
sklearn: 0.23.2
numba: Not found
nibabel: 3.2.1
nilearn: Not found
dipy: Not found
cupy: Not found
pandas: 1.1.5
mayavi: Not found
pyvista: Not found
vtk: Not found
The cause of the issue is that when the tmax argument for crop is out of range of the Epoch, it is set to epo.tmax. However, this behaviour is (at least for me) unintuitive when include_tmax=False as I do not want to cut off the last time sample, if my desired interval is larger than the epoch.
Possible solution would be to set tmax to tmax + 1/sfreq when include_tmax=True and the desired tmax-crop is outside the epoch interval.
I think (for now) the fix needs to be done in the outer call in the crop function of the Epoch class, as in the _time_mask function we do not have the information whether tmax was set automatically or not.
However, using grep I found several calls to _time_mask that could have similar issues as Epoch. Could check the relevant sections tomorrow though.
changed the title [-]Repeated Epoch cropping is not idempotent when include_tmax=False[/-][+]Repeated Epoch/Evoked cropping is not idempotent when include_tmax=False[/+]on May 7, 2021
Activity
agramfort commentedon May 6, 2021
jsosulski commentedon May 6, 2021
Sure, I will submit a PR.
jsosulski commentedon May 6, 2021
I think (for now) the fix needs to be done in the outer call in the
cropfunction of the Epoch class, as in the_time_maskfunction we do not have the information whethertmaxwas set automatically or not.However, using
grepI found several calls to_time_maskthat could have similar issues as Epoch. Could check the relevant sections tomorrow though.[-]Repeated Epoch cropping is not idempotent when include_tmax=False[/-][+]Repeated Epoch/Evoked cropping is not idempotent when include_tmax=False[/+]jsosulski commentedon May 7, 2021
For posterity: the same issue is present for
Evoked