EEGLAB Removing Line Noise 60Hz and its Harmonics

36 views (last 30 days)
Gary Lin
Gary Lin on 1 Dec 2021
Answered: Star Strider on 1 Dec 2021
I am attempting to remove line noise and its harmonics from many EEG datasets. I have been using cleanline to do this. However, it does not work well sometimes for some datasets. For example, here are the log power spectral density plots before and after cleanline at 60, 120, 180, 240, 300, and 420 Hz.
Before Cleanline
After Cleanline
The code that I used is:
EEG = pop_cleanline(EEG, 'bandwidth',2,'chanlist',[1:68] ,'computepower',1,'linefreqs',[60:60:420] ,'newversion',0,'normSpectrum',0,'p',0.01,'pad',2,'plotfigures',0,'scanforlines',0,'sigtype','Channels','taperbandwidth',2,'tau',100,'verb',1,'winsize',4,'winstep',1);
I have also tried to use a notch filter with a lower edge of 55 and an upper edge of 65, but that does not work well.
Are there any suggestions on what other method of removing line noise and harmonics that I could try? Or is CleanLine the best method? Are there ways we can adjust the parameters of cleanline to allow it to work better?
I am relatively new to eeglab and any help is much appreciated :)

Answers (1)

Star Strider
Star Strider on 1 Dec 2021
Try something like this —
Fs = 1000; % Use Correct Sampling Frequency (Must Be Greater Than 370 Hz)
fcomb = [[55 59 61 64], [55 59 61 64]+60, [55 59 61 64]+120];
mags = [[1 0 1], [0 1], [0 1]];
dev = [[0.5 0.1 0.5], [0.1 0.5], [0.1 0.5]];
[n,Wn,beta,ftype] = kaiserord(fcomb,mags,dev,Fs);
hh = fir1(n,Wn,ftype,kaiser(n+1,beta),'noscale');
figure
freqz(hh, 1, 2^20, Fs)
set(subplot(2,1,1), 'XLim', [0 200]) % Zoom X-Axis
set(subplot(2,1,2), 'XLim', [0 200])
Extend the filter stopbands as much as necessary to cover all the 60 Hz harmonics in the signal. Be sure that ‘mags’ and ‘dev’ sections are added as well, This construction makes that straightforward.
The only downside to this sort of FIR filter design is that the signal being filtered must be at least 3 times as long as the filter (if I remember correctly), so it will not work for shorter signals.
The alternative is to use IIR filters (preferably ellliptic filters) in series. This is less convenient and more difficult to design, however the signals being filtered can be much shorter.
Regardless of the filter used, use the filtfilt function to do the actual signal filtering.
.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!