Add low-pass filter to find_bad_channels_maxwell()#7983
Add low-pass filter to find_bad_channels_maxwell()#7983larsoner merged 5 commits intomne-tools:masterfrom
Conversation
The current approach to using `find_bad_channels_maxwell()` requires users to manually low-pass filter their data before passing it to the function. This is kind of cumbersome. This commit, therefore, adds a `h_freq` kwarg that sets the cutoff frequency of an automatically-applied low-pass filter. Passing `h_freq=None` disables filtering. If the input data has already been low-pass filtered, a helpful warning is emitted. We already have a similar API in `preprocessing.compute_proj_ecg()`, so this change makes things more consistent within the `preprocessing` module.
mne/preprocessing/maxwell.py
Outdated
| .. versionadded:: 0.20 | ||
| """ | ||
| if h_freq is not None: | ||
| if 'lowpass' in raw.info: |
There was a problem hiding this comment.
lowpass is always present but it can be None. I think you will warn all the time here.
What I would do is something like this:
if raw.info.get('lowpass') and raw.info['lowpass'] < 'lowpass'
There was a problem hiding this comment.
I've changed things in 94e5807, can you have a look?
|
-1 on this. There are lots of options for filtering. I don't see why we want to add this here |
|
(This was discussed in the original PR quite a bit, too) |
I do see your point, but I was feeling that we should provide a sane default here. Less typing and therefore fewer bugs in user code :) Similarly,
I will read up on this, thanks for the pointer. |
I actually consider that a kind of a deficiency in the design of One thing that might be okay is actually to use |
|
what convinces me is that it promotes best practices. If we think that by default users should filter below 40Hz it's a way to help users. ideally we should filter automatically with the best options to detect artifacts ... |
|
Makes sense. And also I was thinking about high-pass filtering, which can really mess with the performance. The low-pass characteristics I think it's less sensitive to. So I can live with this |
|
would you also suggest to high pass filter? what do you use yourself?
… |
|
No I don't high-pass, I just |
|
ok let's move on with just low pass for now
ok for you?
… |
| msg = (f'The input data has already been low-pass filtered with a ' | ||
| f'{raw.info["lowpass"]} Hz cutoff frequency, which is ' | ||
| f'below the requested cutoff of {h_freq} Hz. Not applying ' | ||
| f'low-pass filter.') |
There was a problem hiding this comment.
For this to be true you need to then set h_freq = None
There was a problem hiding this comment.
ahh wait nevermind, you don't need to because you actually just filter below!
|
Thanks @hoechenberger |
|
Great, thanks @larsoner |
`find_bad_channels_maxwell()` now automatically low-pass filters by default, thanks to mne-tools/mne-python#7983
`find_bad_channels_maxwell()` now automatically low-pass filters by default, thanks to mne-tools/mne-python#7983
* upstream/master: (21 commits) MRG: Add SSP projectors to Report (mne-tools#7991) BUG: Fix warning (mne-tools#8006) WIP: TFR Doc/test changes (mne-tools#7998) MAINT: Remove numpydoc test on 3.6 (mne-tools#8005) MAINT: Better error message for mismatch (mne-tools#8007) MRG: Allow removal of active projectors if channels they applied to have meanwhile been dropped (mne-tools#8003) MRG Freesurfer coordinate frame tutorial (mne-tools#7578) FIX: Fix stockwell checks (mne-tools#7996) MRG, ENH: Add array-spacing plugin and reorganize deps (mne-tools#7997) MRG, ENH: Reduce memory usage of Welch PSD (mne-tools#7994) STY: One more [ci skip] STY: Docstyle [ci skip] Report parsing (mne-tools#7990) MRG, ENH: BrainVision impedance parsing (mne-tools#7974) BUG: Fix missing source space points (mne-tools#7988) [MRG] Strip base directory name from Report captions when using parse_folder (mne-tools#7986) DOC: Update estimates [skip travis] (mne-tools#7987) DOC: Try to improve find_bad_channels_maxwell doc (mne-tools#7982) VIZ, BUG: fix tickmarks in evoked topomap colorbar (mne-tools#7980) Add low-pass filter to find_bad_channels_maxwell() (mne-tools#7983) ...
What does this implement/fix?
The current approach to using
find_bad_channels_maxwell()requires users to manually low-pass filter their data before passing it to the function. This is kind of cumbersome.This PR, therefore, adds a
h_freqkwarg that sets the cutoff frequency of an automatically-applied low-pass filter. Passingh_freq=Nonedisables filtering. If the input data has already been low-pass filtered, a helpful warning is emitted.We already have a similar API in
preprocessing.compute_proj_ecg(), so this change makes things more consistent within thepreprocessingmodule.