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
141 stars 67 forks source link

ENH: config has no option for rejection by flat #325

Closed dengemann closed 1 year ago

dengemann commented 3 years ago

I think it would be important to also pass the flat params to the the epoching script. Any thoughts? @drammock @hoechenberger @agramfort

hoechenberger commented 3 years ago

Yes, we could add that. I just didn't feel the need so far because I haven't actually encountered absolutely flat data in the wild in a channel that wasn't marked as "bad" anyway. Is this a thing that actually occurs?

dengemann commented 3 years ago

Yes :) otherwise I would not bother. E.g. in general anesthesia you can have burst suppression, which gives flat EEG.

hoechenberger commented 3 years ago

What I meant is, MNE's flat rejection looks for absolutely flat signals, i.e., where the amplitude difference between consecutive time points is exactly zero, if I'm not mistaken. Even if in your real-world setting EEG goes flat, I assume there are still minuscule fluctuations in the data, which would then not be classified as flat. I guess what I'm trying to say is that we first might need to make MNE's flat finding algorithm more robust, or add a new function to find and annotate flat segments with a certain tolerance. This is what I'd been working on recently, I have some code somewhere that is inspired by the flat-rejection part of find_bad_channels_maxwell. I can share it with you so we can see if it would do the job for you?

agramfort commented 3 years ago

see https://mne.tools/stable/generated/mne.Epochs.html

Rejection parameters based on flatness of signal. Valid keys are 'grad', 'mag', 'eeg', 'eog', 'ecg'. The values are floats that set the minimum acceptable peak-to-peak amplitude (PTP). If the PTP is smaller than this threshold, the epoch will be dropped. If None then no rejection is performed based on flatness of the signal.

it you set flat=dict(grad=1e-14) it will consider it flat if ptp is less than 1e-14 T/m

hoechenberger commented 3 years ago

Oh … the heck, what was I reading about then? 🤔 Anyway, this seems like a trivial fix then!

larsoner commented 1 year ago

Closing as dup of #446 because it says what function should be used