yalipan666 / OPTICAT_fieldtrip_Beta

fieldtrip version of OPTICAT
0 stars 0 forks source link

edge vs. cutoff of filter #1

Open olafdimigen opened 2 years ago

olafdimigen commented 2 years ago

Great, should be very useful to also have a Fieldtrip-compatible implementation of OPTICAT. I did not look at the code in detail (maybe good to mark the repo as "beta/in development" for now?), but one possible difference to the EEGLAB implementation worth considering is that EEGLAB defines the filter via the passband edge, whereas the default in FT appears to be the more common specification as filter cutoff, which can lead to larger differences in how strongly the data is filtered (e.g., with default pop_eegfiltnew() settings in EEGLAB, a HP-edge of "2 Hz" leads to a -6dB cutoff value of 1 Hz). Have not used FT for a some time, but I believe it may be possible to specify passband edges there as well. Otherwise, this might be worth noting in the comments regarding the defaults.

yalipan666 commented 2 years ago

Hi Olaf, thank you very much for pointing out the issue about filtering. In my original scripts, I used the default parameters of the high-pass filter from the filtertrip, where was Butterworth IIR filter with a filter order of 6. Now I've set the cfg.hpfilttype = 'firws'. And then fieldtrip calculates the transition width by calling fir_df.m, which is also used in EEGLAB pop_eegfiltnew() (or, you can manually set the highpass transition width by setting the parameter cfg.hpfiltdf). So now with the new version, when I high-pass filtering data with 2 Hz, the below content will showup in the matlab command window

Highpass filtering data: onepass-zerophase, order 1650, hamming-windowed sinc FIR cutoff (-6 dB) 2 Hz transition width 2.0 Hz, stopband 0-1.0 Hz, passband 3.0-500 Hz max. passband deviation 0.0022 (0.22%), stopband attenuation -53 dB

Hope this can fix the issue.