How to remove blinking artifact from EDF data in MatLab ?
11 views (last 30 days)
Show older comments
I have created a script which converts edf data into matlab and then filters the data as well using FFT. I am doing spectral analysis but wanted to know how I can alter the script to remove blinking artificats from the eeg data? please see below for my script.
clc
clear all
close all
%Convert data from edf to Matlab
[header, data] = edfread('Subject11.edf');
fs = 128; % sampling rate of Emotiv EEG
%averaging to remove common noise
for i=1:14
datan(i,:)=data(i+2,:)-mean(data(3:16,:));
end
fmin = 20; % minimum passband frequency in Hz (High Gamma)
fmax = 30; % maximum passband frequency in Hz (High Gamma)
Rs = 20; % stopband attenuation in dB
Rp = 1; % passband ripples in dB
% for High gamma band
[order, Wn] = ellipord([fmin/(fs/2), fmax/(fs/2)], [(fmin-1)/(fs/2), (fmax+1)/(fs/2)], Rp, Rs);
[B,A] = ellip(order, Rp, Rs, [fmin/(fs/2), fmax/(fs/2)]);
%filtering of entire data into High Gamma band
data_hgamma = filtfilt(B,A,datan');
%segment - extract only the eeg when subject was listening to words using marker data from channel 36
%don't forget to keep the low noise and high noise data separate
val49=find(data(36,:)==49);
val50=find(data(36,:)==50);
val51=find(data(36,:)==51);
val52=find(data(36,:)==52);
for j=1:14
for i=1:96
EEG_hgamma(j,i,:)=data_hgamma(val50(i):0.5*128-1+val50(i),j);
end
end
%0 less noise, 1 more noise
noise_array = [1 0 0 0 0 1 0 1 0 1 0 1 1 1 0 0 0 1 0 1 1 1 0 0 0 1 0 1 1 1 0 0 0 1 0 1 0 0 0 0 1 1 1 1 1 1 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 1 0 0 0 0 0 1 1 1 0 0 0 1 0 0 0 0 1 1 0 1 0 1 0 1 0 0 1 1 0 1 1];
p=1; q=1;
for i=1:96
if(noise_array(i)==0)
EEGL_hgamma(:,p,:)= EEG_hgamma(:,i,:);
p=p+1;
else
EEGH_hgamma(:,q,:)= EEG_hgamma(:,i,:);
q=q+1;
end
end
%%%%%%%%write script for noisy EEG data removal
for j=1:14
for i=1:size(EEGH_hgamma,2)
Energy_EEGH(j,i)=var(EEGH_hgamma(j,i,:));
end
end
for j=1:14
for i=1:size(EEGL_hgamma,2)
Energy_EEGL(j,i)=var(EEGL_hgamma(j,i,:));
end
end
for j=1:14
[P(j),H(j),STATS(j,:)] = ranksum(Energy_EEGH(j,:),Energy_EEGL(j,:),'tail','right')
end
0 Comments
Answers (2)
Star Strider
on 9 Aug 2016
If you want to remove eye-blink artefacts from your EEG there are two options. There are papers that use wavelets to identify and remove them (do a PubMed search to find the ones most suitable to your data), or edit and remove them manually (as I had to when I was doing EEG research many years ago.) No specific signal processing technique other than wavelets can detect them with any degree of accuracy.
Note: I have never used wavelets for eye blink detection and removal. I read a few papers about it out of interest.
2 Comments
Star Strider
on 9 Aug 2016
You probably have to use a graphic editor in your EEG recording software. (That’s what I did.)
There may be some other File Exchange contributions that would allow you to do manually edit your EEG records, but since I never worked with EEG with MATLAB, you would have to search them out to find the one that best suits your needs.
asd
on 22 Nov 2016
If you looking for the simplest method for the real time detection of the eye blinking which can be simply implemented. you find it in the blog (Designing a simple eye-blink detection algorithm for EEG). I hope this is what you want.
0 Comments
See Also
Categories
Find more on EEG/MEG/ECoG in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!