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

Notch filter #701

Closed claraElk closed 1 year ago

claraElk commented 1 year ago

Hi !

I am using the mne-bids-pipeline on my MEG dataset. I have seen that, at the moment, there is no possibility to add a notch filter in the preprocessing. I was wondering if this feature will be added to the pipeline soon and if not, if there is a possibility as a user to integrate it for our needs? I would like to remove the power line noise but I would like to avoid deleting all frequencies after 60 Hz as I might used them later when doing time-frequency analysis.

Thanks a lot!

welcome[bot] commented 1 year ago

Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴🏽‍♂️

agramfort commented 1 year ago

I can have a look in the coming days. Can you show me the line you use on your Raw data?

Message ID: @.***>

claraElk commented 1 year ago

Hi ! Here are the parameters I'm using now to filter my data :

mf_cal_fname = None
l_freq = 1.
h_freq = 120. 

I would like to add a notch filter to remove the power line noise occurring at 60 Hz and the related harmonics up to my low pass filter. Here is an exemple of the notch filter I would like to apply within this pipeline :

line_frequency = 60 
raw.notch_filter(
        np.arange(line_frequency, h_freq + 1, line_frequency),
        filter_length="auto",
        phase="zero",
        fir_design="firwin",
    )

Thank you!

hoechenberger commented 1 year ago

This sounds very reasonable to me and I expect we can add this to the pipeline without much trouble.

@agramfort I would suggest to put this in the existing frequency filter script, so the required changes to the existing code would be quite minimal.

In what order would we apply the filters though? Notch first, then our ordinary frequency filters? Or the other way around?

agramfort commented 1 year ago

yes !

I won't have time before a few days. Feel free to give it a try.

Message ID: @.***>