<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Dear Alessandro,
<div class=""><br class="">
</div>
<div class="">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.</div>
<div class=""><br class="">
</div>
<div class="">Best wishes,</div>
<div class="">Jan-Mathijs</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
J.M.Schoffelen, MD PhD<br class="">
Associate PI, VIDI-fellow - PI, language in interaction<br class="">
Telephone: +31-24-3614793</div>
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Physical location: room 00.028</div>
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Donders Centre for Cognitive Neuroimaging, Nijmegen, The Netherlands<br class="">
<br class="">
<br class="">
</div>
</div>
</div>
</div>
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
<div>
<blockquote type="cite" class="">
<div class="">On 28 Jun 2018, at 16:22, Alessandro Orticoni <<a href="mailto:alessandro.orticoni@gmail.com" class="">alessandro.orticoni@gmail.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">Dear experts,
<div class=""><br class="">
</div>
<div class="">I'm basically a beginner in coding with Fieldtrip, and I'm having a problem with line noise filtering.</div>
<div class="">I would like to remove it from the heart rate signal, and I tried just typing 'yes' at the option cfg.dftfilter.</div>
<div class="">But is doesn't seem to work, since the power spectrum contains the 50Hz and her harmonics even after the filtering.</div>
<div class=""><br class="">
</div>
<div class="">You can find the code in the following lines:</div>
<div class=""><br class="">
</div>
<div class="">
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">%% ===FREQUENCY Pre Filtering VERIFICATION===</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">fs=data.fsample;</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class=""><br class="">
</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">cfg = [];</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">cfg.output = 'pow';</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">cfg.channel = 'ECG 2';</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">cfg.method = 'mtmfft';</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">cfg.taper = 'hanning';</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">cfg.pad = 'nextpow2';</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">cfg.foilim = [0.3 fs/2]; % teorema di Nyquist</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">freq_epoched_Cz = ft_freqanalysis(cfg, data_epoched_Cz);</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class=""><br class="">
</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">%% ===Plot Spectra===</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">figure;</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">plot(freq_epoched_Cz.freq,mag2db(freq_epoched_Cz.powspctrm));</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class=""><br class="">
</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">%% ===Filtering===</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">cfg = [];</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">cfg.channel = {'ECG 2'};</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">cfg.dftfilter = 'yes';</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">ECG_Filtered = ft_preprocessing(cfg,data_Cz);</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class=""><br class="">
</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">cfg = [];</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">cfg.length = 30; % in seconds;</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">cfg.overlap = 0;</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">data_epoched_ECG_Filtered = ft_redefinetrial(cfg, ECG_Filtered);</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class=""><br class="">
</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">cfg = [];</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">cfg.output = 'pow';</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">cfg.method = 'mtmfft';</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">cfg.taper = 'hanning';</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">cfg.pad = 'nextpow2';</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">cfg.foilim = [0.3 fs/2]; % teorema di Nyquist</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">freq_epoched_Cz_Filtered = ft_freqanalysis(cfg, data_epoched_ECG_Filtered);</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class=""><br class="">
</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">%% ===Plot Spectra===</font></div>
<div class=""><font face="monospace, monospace" size="1" color="#0b5394" class="">plot(freq_epoched_Cz_Filtered.freq,mag2db(freq_epoched_Cz_Filtered.powspctrm));</font></div>
</div>
<div class=""><br class="">
</div>
<div class="">Thanks a lot.</div>
<div class=""><br class="">
</div>
<div class="">Kind regards,</div>
<div class="">Alessandro Orticoni</div>
</div>
_______________________________________________<br class="">
fieldtrip mailing list<br class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br class="">
https://doi.org/10.1371/journal.pcbi.1002202</div>
</blockquote>
</div>
<br class="">
</div>
<br class="">
<br class="">
<div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<br class="">
</div>
</div>
</div>
</div>
</body>
</html>