[MRG] ENH, FIX: Add tmin/tmax parameters to get_data methods, fix bug in find_bads_ecg#9556
Conversation
|
I think I found a bug along the way, see this docstr of mne-python/mne/preprocessing/ica.py Lines 1251 to 1256 in 308a0ab
mne-python/mne/preprocessing/ica.py Lines 1305 to 1308 in 308a0ab Then in mne-python/mne/preprocessing/ecg.py Lines 379 to 385 in 308a0ab In particular, the error raised would be:
Just try it yourself by modifying our ICA tutorial, add a mne-python/tutorials/preprocessing/40_artifact_correction_ica.py Lines 402 to 404 in 308a0ab That should work. But now modify it to |
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
…thon into enh/get_data/tmin_tmax
sappelhoff
left a comment
There was a problem hiding this comment.
Okay, I think I am done here (ready for review/merge). I have one failure that I can't get to the bottom to: mne/tests/test_epochs.py::test_own_data FAILED [ 50%]
mne/tests/test_epochs.py:517: in test_own_data
assert epochs._data.flags['OWNDATA']
E assert False
One more point: I am using the following short snippet two-and-a-half times:
_validate_type(tmin, types=('numeric', None), item_name='tmin',
type_name="float, None")
_validate_type(tmax, types=('numeric', None), item_name='tmax',
type_name='float, None')
# handle tmin/tmax as start and stop indices into data array
n_times = self.times.size
start = 0 if tmin is None else self.time_as_index(tmin)[0]
stop = n_times if tmax is None else self.time_as_index(tmax)[0]
# truncate start/stop to the open interval [0, n_times]
start = min(max(0, start), n_times)
stop = min(max(0, stop), n_times)Should I turn that into a private function in mne.utils and import + use it? Or is it reasonably short / repeated few enough times to just ignore "DRY"? :-)
|
I would make it a private method in the TimeMixin in |
agreed, thanks for the suggestion, this is much better! |
|
Thanks @sappelhoff ! |
|
Amazing, thanks, @sappelhoff! |
* upstream/main: [MRG, ENH] Find aseg labels near montage (mne-tools#9545) Add label to colorbar in GAT plot [skip actions] (mne-tools#9582) [ENH, MRG] Encapsulate warp elec image in function (mne-tools#9544) [DOC, MRG] Add "info" to `docdict` (mne-tools#9574) [MRG] Add `units` parameter to get_data for Evoked (mne-tools#9578) [MRG, ENH] Get annotation description from snirf stim name (mne-tools#9575) [MRG] ENH, FIX: Add tmin/tmax parameters to get_data methods, fix bug in find_bads_ecg (mne-tools#9556)

closes #9548
Work in progressTo do
unitsparameter to get_data for Epochs #9553 to avoid conflictsfind_bads_ecg: [MRG] ENH, FIX: Add tmin/tmax parameters to get_data methods, fix bug in find_bads_ecg #9556 (comment)