mne-tools / mne-bids-pipeline

Automatically process entire electrophysiological datasets using MNE-Python.
https://mne.tools/mne-bids-pipeline/
BSD 3-Clause "New" or "Revised" License
137 stars 65 forks source link

In sensor/apply_ica, we should not apply the ICA rejection threshold to the data before rejecting components #805

Closed hoechenberger closed 10 months ago

hoechenberger commented 10 months ago

We have a setting ica_reject to remove bad epochs before fitting ICA. The epochs we feed into ICA are separate from the epochs we want to clean: they're high-pass filtered and they have drop_bad(reject=ica_reject) applied. This ensures ICA can be fit on epochs without flux / voltage spikes etc

Now in the apply_ica step, when we load the "actual" epochs we wish to clean, instead of simply applying ICA, we first call drop_bad(reject=ica_reject) too. In my opinion this is a bug, as normally we should be assuming that applying ICA may at least remove some of those high-amplitude artifacts. But if we reject those epochs before cleaning them via ICA, they're gone forever.

https://github.com/mne-tools/mne-bids-pipeline/blob/1bc1e8226d70b10b6d3a76d69d355cd906775b39/mne_bids_pipeline/steps/preprocessing/_07a_apply_ica.py#L102-L115

I think we should remove the drop_bad() call here. Any remaining large-amplitude artifacts after ICA cleaning will be caught in the following step, preprocessing/ptp_reject.

In an EEG dataset I'm currently working with, applying the PTP rejection threshold before applying ICA leads to a loss of many epochs that could have been saved through ICA

cc @agramfort

larsoner commented 10 months ago

Agreed @hoechenberger feel free to fix it