`mne.Epochs` sends wrong log messages (1) on metdata, (2) when `decim` is passed
See original GitHub issuemne.Epochs
sends wrong log messages (1) on metdata, (2) when decim
is passed.
MWE:
Try first running this code:
import os
import mne
sample_data_folder = mne.datasets.sample.data_path()
sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample',
'sample_audvis_raw.fif')
raw = mne.io.read_raw_fif(sample_data_raw_file, verbose=False).crop(tmax=120)
raw.load_data()
raw.filter(h_freq=40, l_freq=None)
events = mne.find_events(raw, stim_channel='STI 014')
event_dict = {'auditory/left': 1, 'auditory/right': 2, 'visual/left': 3,
'visual/right': 4, 'face': 5, 'button': 32}
epochs = mne.Epochs(raw, events, tmin=-0.2, tmax=0.5, event_id=event_dict,
decim=1, preload=True)
print(epochs.times.shape)
This is the logged output, where I can see that the Not setting metadata
log is unnecessarily repeated.
On the last lines of the log, we see that 421 time points were loaded, and this is indeed the shape of .times
176 events found
Event IDs: [ 1 2 3 4 5 32]
Not setting metadata
Not setting metadata
176 matching events found
Setting baseline interval to [-0.19979521315838786, 0.0] sec
Applying baseline correction (mode: mean)
Created an SSP operator (subspace dimension = 3)
3 projection items activated
Loading data for 176 events and 421 original time points ...
1 bad epochs dropped
(421,)
Now change decim=1
in the mne.Epochs()
call above to decim=2
. I would expect the log
Loading data for 176 events and 421 original time points …
to change in terms of “original time points” loaded (should be half as many)
However, this is what we get:
This is the logged output, where the shape of .times
has indeed halved as expected, yet the log tells us that 421 time points were loaded.
176 events found
Event IDs: [ 1 2 3 4 5 32]
Not setting metadata
Not setting metadata
176 matching events found
Setting baseline interval to [-0.19979521315838786, 0.0] sec
Applying baseline correction (mode: mean)
Created an SSP operator (subspace dimension = 3)
3 projection items activated
Loading data for 176 events and 421 original time points ...
1 bad epochs dropped
(211,)
Needed actions
-
remove duplicate log message on setting metadata. Don’t really know where to fix, maybe around here: https://github.com/mne-tools/mne-python/blob/a3066f6eb3730d13d2dce632ff6cb5d4870fbe7f/mne/utils/mixin.py#L412-L418
-
adjust logging about loaded time points when creating epochs and decimating. Probably to be fixed somewhere around here: https://github.com/mne-tools/mne-python/blob/a3066f6eb3730d13d2dce632ff6cb5d4870fbe7f/mne/epochs.py#L1388-L1389
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (10 by maintainers)
Top GitHub Comments
Yes sorry, I originally wrote “less ambiguous” and went to replace it with “clearer” but only deleted part of the original 😃
I think probably yes? I would try making the change and see if any test breaks. Sometimes in our code we do have more than one assignment like this (where it seems like one is redundant) but it’s necessary for some weird reason like private function calling order… but usually in these cases we try to leave a comment saying “this looks redundant but it’s necessary because …”. If there is no such comment, it’s possibly just cruft / errant double-setting.
It would be good for example for TDD to make it so that you
or so
Or add a msg kwarg to the setter so you can say Adding instead of Replacing