[FieldTrip] [Fieldtrip] Line noise Removal

Schoffelen, J.M. (Jan Mathijs) jan.schoffelen at donders.ru.nl
Mon Jul 2 17:47:48 CEST 2018


please have a look at the following piece of documentation:

http://www.fieldtriptoolbox.org/faq/why_is_there_a_residual_50hz_line-noise_component_after_applying_a_dft_filter?s[]=dftfilter<http://www.fieldtriptoolbox.org/faq/why_is_there_a_residual_50hz_line-noise_component_after_applying_a_dft_filter?s%5B%5D=dftfilter>

Jan-Mathijs

On 2 Jul 2018, at 00:21, Alessandro Orticoni <alessandro.orticoni at gmail.com<mailto:alessandro.orticoni at gmail.com>> wrote:

Dear Jan-Mathijs,

Thanks a lot for your reply and your tips.
Actually I've already segmented the data in 30 seconds epochs, and the reason why I did it is that these are sleep data: so I should keep this length because of the night scoring.
I tried to enlarge the notch too, but it still doesn't work; the spectra before and after the filtering are exactly the same.

Best,
Alessandro

Il giorno gio 28 giu 2018 alle ore 19:35 Schoffelen, J.M. (Jan Mathijs) <jan.schoffelen at donders.ru.nl<mailto:jan.schoffelen at donders.ru.nl>> ha scritto:
Dear Alessandro,

Given the code you provided it looks as if you have one single very long trial that you subject to dft-filtering. If the power line fluctuations actually do vary a bit in amplitude, which is likely (particularly given long sections of data), the pure 50 (or 60) Hz sinusoid will get some ‘bandwidth’, so the removal won’t be perfect. I’d recommend to call ft_redefinetrial first, and then do a second call to ft_preprocessing with the dftfilter switched on. Yet, I’d expect that with 30 s segments it still won’t work that well. In this case you could widen the notch a bit  by specifying cfg.dftfreq = 50+(-n:n)./30;, with n put to a small number, e.g. <=3. However, unless you have good reasons to have the data chopped in half-minute segments, I’d also consider to reduce this length, because you probably do not need to have a 1/30 Hz frequency resolution in your spectral decomposition.

Best wishes,
Jan-Mathijs

J.M.Schoffelen, MD PhD
Associate PI, VIDI-fellow - PI, language in interaction
Telephone: +31-24-3614793
Physical location: room 00.028
Donders Centre for Cognitive Neuroimaging, Nijmegen, The Netherlands




On 28 Jun 2018, at 16:22, Alessandro Orticoni <alessandro.orticoni at gmail.com<mailto:alessandro.orticoni at gmail.com>> wrote:

Dear experts,

I'm basically a beginner in coding with Fieldtrip, and I'm having a problem with line noise filtering.
I would like to remove it from the heart rate signal, and I tried just typing 'yes' at the option cfg.dftfilter.
But is doesn't seem to work, since the power spectrum contains the 50Hz and her harmonics even after the filtering.

You can find the code in the following lines:

%% ===FREQUENCY Pre Filtering VERIFICATION===
fs=data.fsample;

cfg = [];
cfg.output        = 'pow';
cfg.channel       = 'ECG 2';
cfg.method        = 'mtmfft';
cfg.taper         = 'hanning';
cfg.pad           = 'nextpow2';
cfg.foilim        = [0.3 fs/2]; % teorema di Nyquist
freq_epoched_Cz   = ft_freqanalysis(cfg, data_epoched_Cz);

%% ===Plot Spectra===
figure;
plot(freq_epoched_Cz.freq,mag2db(freq_epoched_Cz.powspctrm));

%% ===Filtering===
cfg            = [];
cfg.channel    = {'ECG 2'};
cfg.dftfilter  = 'yes';
ECG_Filtered   = ft_preprocessing(cfg,data_Cz);

cfg          = [];
cfg.length   = 30; % in seconds;
cfg.overlap  = 0;
data_epoched_ECG_Filtered = ft_redefinetrial(cfg, ECG_Filtered);

cfg = [];
cfg.output        = 'pow';
cfg.method        = 'mtmfft';
cfg.taper         = 'hanning';
cfg.pad           = 'nextpow2';
cfg.foilim        = [0.3 fs/2]; % teorema di Nyquist
freq_epoched_Cz_Filtered = ft_freqanalysis(cfg, data_epoched_ECG_Filtered);

%% ===Plot Spectra===
plot(freq_epoched_Cz_Filtered.freq,mag2db(freq_epoched_Cz_Filtered.powspctrm));

Thanks a lot.

Kind regards,
Alessandro Orticoni
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202




_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20180702/054b9454/attachment-0002.html>


More information about the fieldtrip mailing list