removing line frequency
Robert Oostenveld
r.oostenveld at FCDONDERS.RU.NL
Wed Apr 11 21:40:52 CEST 2007
Hi Sameer
On 10 Apr 2007, at 22:39, Sameer Walawalkar wrote:
> I have been removing line frequency using the notch filter so far
> and it works fine. However, my data shows lines at 120 and 180 Hz
> as well (line frequency in US is 60Hz).
>
> So I tried
>
> cfg.lnfreq = [60 120];
>
> It is accepted, but it does not work. Infact now, even the 60Hz
> notch filtering does not work.
>
> Is there a way to implement both?
if you look into private/preproc.m, you see that the function doing
the actual work is private/notchfilter. That function documents it as
if Fline is specified as 50, a band of 48-52 is filtered out
if Fline is specified as [low high], that band is filtered out
So hence your first specification works, the second indeed not (since
the 60 is at the border). Furthermore, that function also specifies a
default notch width of +- 2 Hz.
So you cannot pass multiple frequencies at the moment, but it is easy
to add
line 264 in private/preproc reads
if strcmp(cfg.lnfilter, 'yes'), dat = notchfilter(dat, fsample,
cfg.lnfreq, cfg.lnfiltord); end
line 265-... in private/preproc read
if strcmp(cfg.dftfilter, 'yes'),
for i=1:length(cfg.dftfreq)
% filter out the 50Hz noise, optionally also the 100 and 150 Hz
harmonics
dat = dftfilter(dat, fsample, cfg.dftfreq(i));
end
end
if you change the line 264 into something similar, like "for each
cfg.lnfreq do notchfilter", then you'll have what you want. I will
change it in the release version, it will be on the ftp version in a
few days.
If the sampling frequency of your MEG system is accurately specified,
and if your data segments are long enough, you can also use the
dftfilter. That is a much sharper filter (maximally sharp). It might
require filter padding though (cfg.padding in preprocessing). It is
especially usefull for frequency analysis with multitapering, for
timelocked analysis you won't see much benefit. You can read the
details on the method in the supplementary online material in our
2005 Science paper (see http://www2.ru.nl/fcdonders/fieldtrip/
doku.php?id=fieldtrip:publications).
best regards,
Robert
More information about the fieldtrip
mailing list