[FieldTrip] Questions on High pass and Dft filtering

Ingrid Nieuwenhuis inieuwenhuis at berkeley.edu
Sat Jun 30 03:09:22 CEST 2012

Hi Phillipp and Jörn,

I'm pretty sure that the padding for filtering is data padding not zero 
padding, so this does make sense and should not bias the estimation of 
the 50Hz noise. My experience with the dft filter is that it works very 
will when the line noise is stable in amplitude, it sharply (the longer 
the data/padding the sharper the filter) filters out specifically the 
line noise. It can do this because the frequency of the line noise is so 

However, when the amplitude of the line noise varies (which it did in my 
data), this results in creating noise in frequencies outside 50Hz (if 
your interested in why, this piece of the FieldTrip wiki 
<http://fieldtrip.fcdonders.nl/example/crossfreq/phalow_amphigh> sheds 
some light on that), and the dft filter fails. I'm using a band stop 
around the line noise frequency and harmonics. I'd recommend plying with 
the values, and plotting to see which settings are appropriate for your 
specific circumstances. Below you can find a snipped of code I used to 
determine my settings.

Good luck,

------- code snippet -------
widths = [0.5 1 1.5 2 3 5 10];
orders = [2:6];

for iWidth = 1:length(widths)
     for iOrd = 1:length(orders)
         width = widths(iWidth);

         %preprocess data
         cfg = [];
         %cfg.event           = event;
         cfg.dataset         = [cur_path_MFF, 'NS_EMR_', subjStr, '_', 
         cfg.channel         = {'EOG*', 'EMG', 'EEG', '-E1', '-E9', 
'-E32', '-E8', '-E25', '-E129'};
         cfg.demean          = 'yes';
         cfg.hpfilter        = 'yes';
         cfg.hpfreq          = 0.3;
         cfg.hpfiltord       = 1;
         cfg.bsfilter        = 'yes';
         cfg.bsfiltord       = orders(iOrd);
         cfg.bsfreq          = [60-width 60+width; 120-width 120+width; 
180-width 180+width]; %note I'm in the US so have 60Hz line noise, you 
might have 50Hz
         cfg.pad             = 0.5;
         cfg.trl             = trl(1:100,:);
         data_S1_clean       = ft_preprocessing(cfg);

         %do freqanalysis
         cfg = [];
         cfg.channel    = ['EEG' BadChan];
         cfg.output     = 'pow';
         cfg.method     = 'mtmfft';
         cfg.taper      = 'hanning';
         cfg.foilim     = [30 200];
         freq_S1_clean = ft_freqanalysis(cfg, data_S1_clean);

         print(gcf, '-dpng', '-r300', [cur_path_fig, subjStr, '_', 
stages{iStage}, '_W', num2str(width*10),'_O', num2str(orders(iOrd))]);

         %zoom in around 60 hz;
         print(gcf, '-dpng', '-r300', [cur_path_fig, subjStr, 'zoomed_', 
stages{iStage}, '_W', num2str(width*10),'_O', num2str(orders(iOrd))]);

On 6/28/2012 7:45 AM, "Jörn M. Horschig" wrote:
> Hi Philipp,
>> The padding ensures that we only filter out a narrow 1/10 Hz wide 
>> frequency bin.
> sure, I didn't think about that - that's a pretty good reason to use 
> padding :) However, the estimation of the 50Hz noise will be biased by 
> the padded samples. I don't like the dftfilter anyway, and I am not 
> filtering either (the reason for me is that 50Hz noise should be 
> invariant to the experimental effects. I mostly investigate TFRs).
>>   but looking at averaged timelocked data for the subject, the data 
>> looks
>>   identical to the result I get using no filter at all, i.e., 
>> contaminated by
>>   strong line noise.
> I'm gonna look into this to see whether it is a bug or not. I'll let 
> you know soon.
> Best,
> Jörn

Ingrid Nieuwenhuis PhD
Postdoctoral Fellow
Sleep and Neuroimaging Laboratory
Department of Psychology
University of California, Berkeley
California 94720-1650
Tolman Hall, room 5305

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

More information about the fieldtrip mailing list