[Eeglablist] Setting correct parameters for pop_eegfiltnew()
Cedric Cannard
ccannard at protonmail.com
Fri Feb 24 19:03:56 PST 2023
Hi Alica,
You should find the information you need here: https://urldefense.com/v3/__https://eeglab.org/others/Firfilt_FAQ.html*q-what-are-passband-stopband-transition-bandwidth-cutoff-frequency-passband-rippleringing-and-stopband-rippleattenuation__;Iw!!Mih3wA!F-pP_eV2aUmVhhiaye8M18it4dhFIunRvHLwF8nn0CK5x2nHGaIXNdLlEy9-2bi7pkV16tIkJKUgpKGUt0Hd2yQOxA$
In brief, a notch filter is typically used to remove specific frequencies from a signal, while a bandpass filter is used to isolate a specific frequency range from a signal. But you can do both by applying a highpass and a lowpass filter one after the other, it's the same.
> 3) Do I need to specify anything for usefft, plotfreqz, minphase, or
usefftfilt?
usefft would be if your filter order is very large and will save you significant computing time.
plotfreqz will show you what the filter is doing, you should give it a try and see the differences that your parameters have.
minphase if for causal filtering (crucial if you're looking at pre-stimulus activity for example; see link I sent there is abundant information from Andreas Widmann on all this).
You can go to Tools > filter data > Windowed sync FIR filter and play with the parameters there (estimate order based on cutoff frequencies and transition bandwidths). However, you can just apply highpass 20 Hz and lowpass 1000 hz with the pop_eegfiltnew function (it will estimate the transition bandwidths and orders automatically). Then you can remove line noise with the cleanLine or zapline plugins.
Whatever you do, plot the power spectra and compare before/after filtering to see what you are doing to the data.
Cedric
------- Original Message -------
On Friday, February 24th, 2023 at 8:29 AM, Alica Rogojin <arogojin at research.baycrest.org> wrote:
> Hi there,
>
> Apologies for the double email - I think I may have figured it out but was
> hoping to confirm that I did this correctly.
>
> fs = 5000; %5000 Hz sampling rate
> df = 1; %requested transition band width of 1Hz (I'm not sure if this is
> reasonable or if I should have a larger transition band)
> filter order = 3.3/(1/5000) = 16,500
>
> 1) Bandpass filter of 25 - 1000 Hz means lower passband edge = 25.5 Hz and
> upper passband edge = 999.5 Hz (based on transition band of 1Hz)
>
> > > EEG = pop_eegfiltnew(EEG, 'locutoff', [], 'hicutoff', 25.5, 'filtorder',
>
> 16500, 'revfilt', 0) --> will give a 25 Hz highpass with 25.5 Hz passband
>
> edge
>
> > > EEG = pop_eegfiltnew(EEG, 'locutoff', 999.5, 'hicutoff', [],
>
> 'filtorder', 16500, 'revfilt', 0) --> will give a 1000 Hz lowpass with
>
> 999.5 Hz passband edge
>
> 2) Then using same transition band for a notch filter, would I need to set
> 'revfilt' to 1?
> This is where things get a bit confusing but for a notch filter of of
> 57-63Hz, would I do the following:
>
> > > EEG = pop_eegfiltnew(EEG, 'locutoff', [], 'hicutoff', 57.5, 'filtorder',
>
> 16500, 'revfilt', 1)
>
> > > EEG = pop_eegfiltnew(EEG, 'locutoff', 62.5, 'hicutoff', [], 'filtorder',
>
> 16500, 'revfilt', 1)
>
> 3) Do I need to specify anything for usefft, plotfreqz, minphase, or
> usefftfilt?
>
> Thank you!
> Alica
>
> On Fri, Feb 24, 2023 at 10:25 AM Alica Rogojin <
> arogojin at research.baycrest.org> wrote:
>
> > Hi there,
> >
> > I'm trying to use pop_eegfiltnew to filter EMG data from a muscle in the
> > hand, sampling rate = 5000Hz. I'd like to apply a bandpass filter (low
> > cutoff = 25Hz, high cutoff = 1000Hz) and a notch filter (60Hz), and have
> > the following:
> >
> > Bandpass filter -
> >
> > > > EEG = pop_eegfiltnew(EEG, 'locutoff', 25, 'hicutoff', 1000);
> >
> > Notch filter (revfilt = 1 to change bandpass filter to be a notch filter)
> > -
> >
> > > > EEG = pop_eegfiltnew(EEG, 'locutoff', 57, 'hicutoff', 63, 'revfilt', 1);
> >
> > However, looking into more posts about pop_eegfiltnew I feel that I may
> > have oversimplified and there may be more to this. Did I do this correctly?
> >
> > According to https://sccn.ucsd.edu/pipermail/eeglablist/2017/012297.html,
> > the numbers I used above are not actually cutoff frequencies but are
> > passband edges. They also mention calculating transition band widths to
> > get the correct cutoff frequency to use in pop_eegfiltnew. I'm a bit
> > confused as to how to do this and would appreciate any pointers. Same for
> > the notch filter.
> >
> > I also saw posts mentioning that I should not be creating a bandpass
> > filter with high and low cutoffs in one - that I should be doing this in
> > separate lines. Is this true?
> >
> > I would appreciate any help! Thank you,
> > Alica
>
> _______________________________________________
> Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
> To unsubscribe, send an empty email to eeglablist-unsubscribe at sccn.ucsd.edu
> For digest mode, send an email with the subject "set digest mime" to eeglablist-request at sccn.ucsd.edu
More information about the eeglablist
mailing list