[FieldTrip] [Fieldtrip] Line noise Removal

Schoffelen, J.M. (Jan Mathijs) jan.schoffelen at donders.ru.nl
Thu Jun 28 18:35:34 CEST 2018


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




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


More information about the fieldtrip mailing list