You are on page 1of 19

DIGITAL SIGNAL PROCESSING

(ECE2006)

Project report

Artifact Removal and Denoising in EEG signal


using ICA and S-transform

Submitted by:-

S.S.NITHISH SOORYA-19BEC0212
S.TARUN - 19BEC0661

1
Artifact Removal and Denoising in EEG signal
using ICA and S-transform

A project entitled for the completion of Digital Signal


Processing course

Under the guidance of


Dr.KALAIVANI.S
Assistant Professor (Senior)
Department of Communication Technology

SENSE
VIT University(Vellore)
Fall Semester 2021-2022

2
TABLE OF CONTENTS

S.No TOPIC Pg.no


1 ABSTRACT 4
2 INTRODUCTION 4
3 EEG 5
4 BLOCK DIAGRAM 6
5 METHODOLOGY 6
6 MATLAB CODE 9
7 RESULTS AND DISCUSSION 13
8 CONCLUSION 18
9 REFERENCES 19

3
ABSTRACT :-

Electroencephalographic data is often contaminated by


artifacts produced from non cerebral sources such as muscle activity,
eye movements and other electrical disturbances.Artifact removal and
noise suppression is essential prior to information extraction from
Electroencephalogram signals. Strong presence of artifactual activity
diminishes quality of EEG signals and causes error in feature extraction.
Hence, it is necessary to remove artifacts and additive noise from
contaminated EEG signals prior to feature extraction.

The proposed EEG correction technique finds its applicability


in disease diagnosis such as epilepsy detection, Parkinson’s disease and
mental state monitoring.The proposed methodology relies on two
distinct techniques such as Independent Component Analysis and
S-Transform.

INTRODUCTION:-

The electrical activity of the human brain is recorded


using several scalp mounted electrodes and the records are called
Electroencephalogram (EEG) signals. EEG can help diagnose a number of
conditions including epilepsy, sleep disorders and brain tumours. EEG
shares a wide range of applicability in distinct areas of clinical
importance. For instance, EEG is a valuable diagnostic tool which helps in
early detection of Alzheimer’s disease, epileptic seizures, Parkinson’s
disease and mental state monitoring.

These systems enable physically disabled persons to


control various assistive devices and applications such as robotic arm
and wheel chair.The Brain Communication Interface(BCI) is an artificial
communication channel between human brain and external world. It
uses brain power to command assistive applications and is being used as
an alternate method of communication by the patients of Amyotrophic
Lateral Sclerosis (ALS), spinal injuries and cerebral palsy.

4
EEG :-

EEG (Electroencephalography) is the recording of the brain’s


spontaneous electrical activity and provide the measurement Voltage
fluctuations of brain activity.The frequency of EEG signals range from
0.01 Hz to around 100 Hz, which can be divided into five frequency
bands, and four basic types.

Band Name Frequency (Hz) Interpretation

Delta <4 Deep sleep

Theta 4-8 Relaxed state and meditation

Alpha 8-13 Relaxed state of consciousness

Beta 13-30 active thinking

Gamma >35 Concentration

5
BLOCK DIAGRAM:-

METHODOLOGY:-

Preprocess n-channel EEG data , using conventional filtering


techniques to obtain preprocessed EEG data.
Perform ICA(Info-max) algorithm on the processed
n-channel EEG data , for separation of individual source
signals i.e ICs.
Visually inspect on these individual source signals and
select the artifactual ICs separately for denoising.
Calculate S-Transform(ST) coefficients P(i, j) of identified
artifactual ICs, in order to transform the artifactual activity in
time– frequency domain.
Denoise the artifactual ICs by performing spike zone
thresholding of certain ST coefficients P(i, j), which are having
higher magnitude than a calculated threshold value.
Invert the ST coefficient P(i, j) to obtain time domain ICs.This
step yields the denoised IC.

1) Pre-processing:

EEG signals are sampled at a frequency of 256 Hz.


Notch filter of 50Hz is preprocessed in the raw EEG data to
remove line noise produced by electrical wiring.

6
The frequency of EEG signals range from 4 Hz to around 45 Hz.
Use a band pass filter to pass the EEG data in this range of
frequency.

2)Independent component Analysis(ICA):

The aim of ICA is to separate mixed signals into original source


signals by using sensor observations.
The EEG data is assumed to be generated as per the following
model:
x(t) = A.s(t) + n(t)

x(t) = Mixed EEG data


s(t) = Independent sources
A = Mixing matrix
n(t) = Additive noise picked up by the EEG electrodes
The aim of ICA is to obtain the de-mixing matrix W to estimate
original sources
s(t) = W .x(t) (A = W^−1)
There are various methods to implement ICA such as Fast-ICA,
EFICA, INFOMAX,BGSEP,etc..Here INFOMAX algorithm is used for source
separation.

Infomax algorithm we havee used is based on the maximization of


entropy. This belongs to the The Minimization-of-Mutual information
(MMI) family of ICA algorithms. This kind of algorithm uses measures like
Kullback-Leibler Divergence and maximum entropy This algorithm of ICA
uses centering , whitening.

3)ARTIFACT DETECTION :

From the Independent components ,visually inspect on the


separated ICs and find the artifactual component from it.

To find the artifactual component,


i) If the signal consists of high and low peaks, then it is an artifactual
component which is caused by eye movements or eye blinks.
ii) If the signal is dense, then it must be an artifact caused by muscle
movements in the face.

7
After finding the particular artifactual component, it will be sent to
further denoising.

4) S-TRANSFORM :
When ICs are separated from the mixture of sources some
cerebral activity is also leaked in artifactual ICs, the complete rejection
of such ICs may yield errors in the reconstruction process.

In order to extract leaked cerebral information from


artifactual ICs and to suppress artifacts ST based denoising technique is
employed It preserves the absolutely referenced phase information of
the signal after removing the artifacts.To suppress artifactual activity,
thresholding is performed on ST coefficients.

where μ(c) denotes mean amplitude of ST coefficients over the signal,


σ(c) the standard deviation of amplitude,w’ denotes the weight given to
ST coefficients S(i, j),G is a gain applied to adjust the spike amplitude

Here weight w’ and gain G are set to w’ = 0.1 and G = 1 respectively

➢ Apply S transform on the artifactual IC.

➢ Find out the mean and standard deviation of the absolute values of
S-transform coefficients P(i,j) in the selected frequency band.

➢ Set the threshold function as: T=mean( |P(i,j)| ) + 2*std( |P(i,j)| )

➢ Set the multiplying factor w’=0.1

If |P(i,j)| ≥ T , then P(i,j) = P(i,j) *w’,

else P(i,j) = P(i,j) .

➢ After thresholding apply inverse S transform to obtain the denoised


IC

8
MATLAB CODE:-
clc
close all
clear all

%loading the data


load('S001R01_edfm.mat','val')
Fs = 256; % Sampling frequency
Data =val';
Data=Data(:,1:10);%10 channel data

%preprocessing using notch filter


Fnyq = Fs/2;
F_notch = 50; % Notch at 50 Hz
[b,a] = iirnotch(F_notch/Fnyq, F_notch/Fnyq/20);
Data = filter(b,a, Data);

% High Pass Filter


Fcut = 4;
[b,a] = ellip(1, 0.5, 20, Fcut/Fnyq, 'high');
Data = filter(b,a, Data);

%plotting
Data = Data';
figure('color','w');
PlotEEG(Data, Fs);
title('EEG Data');
xlabel('Time (s)')
%ICA
[ics, A, W] = infomax(Data);
figure('color','w');
PlotEEG(ics, Fs);
title('Independent Components');
xlabel('Time (s)')

%finding artifactual ICs by visual inspection

figure;
afc = inputdlg({'Artifact IC'},'Components to remove',1);
n = str2double(afc{1});
s=ics;

9
s=s(n,:);
PlotEEG(s,Fs);
grid on
title('Artifactual component');
xlabel('Time (s)')
x=s;

% Stockwell transform
ST=stran(x);
fc=16;
Wn=(2/Fs)*fc;
b=fir1(20,Wn,'low');
p=filter(b,1,ST);

%thersholdfuncton
T=mean(abs(p))+2*std(abs(p));
% multiplying factor
w=0.1;
[m,n]=size(p);
for i=1:m
for j=1:n
if(abs(p(i,j))>=T(1,j))
p(i,j)=p(i,j)*w;%thresholding
else
p(i,j)=p(i,j);
end
end
end

% inverse S-transform
IST=istran(p);

figure;
PlotEEG(IST,Fs);
title('Denoised IC');
xlabel('Time (s)')
ylabel('EEG amplitude(v)');
xlim([0.5 6]);
figure;
PlotEEG(s,Fs);

10
hold on;

PlotEEG(IST,Fs);
xlim([0.5 6]);
title('comparison plot');
legend('artifactual IC','denoised IC');
hold off;

function [signals, A, W] = infomax(mixes)

%size of the data


[N,P] = size(mixes);
% permute the data matrix
permute = randperm(P);
X = mixes(:,permute);
%centering
% subtract off the mean of each mixed source
X = X - repmat(mean(X,2),1,P);

%whitening
%decorrelating matrix
Wz = 2 * inv(sqrtm(cov(X')));
X = Wz * X;

%initializing the matrix


W = eye(N);

% de-mixing matrix
W = W * Wz;
% mixing matrix
A = inv(W);

% independent signals
signals = W * mixes;
end

% S transform function
function ST=stran(h)
[~,N]=size(h);
nhaf=fix(N/2);
odvn=1;

11
if nhaf*2==N;
odvn=0;
end
f=[0:nhaf -nhaf+1-odvn:-1]/N;
Hft=fft(h);
%Gaussian filter
invfk=[1./f(2:nhaf+1)]';
W=2*pi*repmat(f,nhaf,1).*repmat(invfk,1,N);
G=exp((-W.^2)/2); %Gaussian in freq domain
%Toeplitz matrix with the shifted fft(h)
HW=toeplitz(Hft(1:nhaf+1)',Hft);
% Exclude the first row
HW=[HW(2:nhaf+1,:)];
% Compute Stockwell Transform
ST=ifft(HW.*G,[],2);
st0=mean(h)*ones(1,N);
ST=[st0;ST];
end

%Inverse S transform
function out = istran(S)
N=size(S,2);
% perform the inner sum
for ii=1:size(S,1)
ss(ii)=sum(S(ii,:));
end
% fix the sign on the imaginary part
ss_real=real(ss);
ss_imag=imag(ss);
ss_imag(1:round(N/2))=-1*ss_imag(1:round(N/2));
ss=ss_real+(1i*ss_imag);
% time-domain signal
ist=real(ifft(ss));
%time series to original length
ts=resample(ist,2,1);
out=ts;
end

12
RESULTS AND DISCUSSION:

EEG DATA:

This is the plot of the 10 channels of EEG data imported from physionet
website where the data was recorded following the International 10–20
system of electrode placement.This data is preprocessed using notch
filter to remove 50 Hz line noise and passed through high pass filter to
suppress noises appearing below 4 Hz.EEG signals were sampled at 256
Hz.

13
INDEPENDENT COMPONENTS(ICs):

This is the plot of Independent Components(IC) Obtained after


performing infomax ICA algorithm.This algorithm is based on the
maximization of entropy.Mixing and demixing matrices are obtained by
performing this algorithm.Multiplying the demixing matrix with the
preprocessed EEG data produces the Independent Components(ICs).
ICA basically rearrange the sources(data) to new mixtures in such a way
that the true brain Sources will be in some components and artifacts in
other components.

14
ARTIFACTUAL IC:

Visual inspection(inspection using naked eye) is used to identify the


artifactual IC.Examining the Independent Components plot we can
clearly see a huge spike in 5th component which is basically a blink
artifact.This is the plot of the 5th IC

DENOISED IC:

15
This is the plot of denoised IC obtained.Stockwell transform(S-transform)
is used to transform the artifactual IC to time-frequency domain where
thresholding is performed.In thresholding process the artifactual IC is
multiplied with a weight(value=0.1) to suppress the spikes.After
supressing artifacts inverse Stockwell transform is performed to
transform the denoised Ic into time domain.

COMPARISON PLOT:

This is comparison plot between the artifactual IC and denoised IC.We


can observe the difference,after performing thresholding process spikes
are suppressed and signal is artifact clean.Stockwell Transform denoising
technique efficiently suppressed eye blink and other high frequency
artifacts, while preserved the useful EEG information.

16
QUANTITATIVE ANALYSIS:

We have used EEGLAB software to analyse our results

This is the plot of the 10 channels of sample EEG data after


preprocessing using notch and high pass filter in EEGLAB.

INDEPENDENT COMPONENT ANALYSIS:

17
This is the plot of Independent Components (Ics) obtained after
implementing infomax algorithm in EEGLAB.
By visual inspection we can observe component 7 is an artifactual
component since it has large spike which is basically a blink artifact.

This is the plot obtained after denoising ICs,Red denotes channels after
rejection,black denotes the channels before rejection.All the spikes are
suppressed after denoising in EEGLAB.

CONCLUSION:-

We have evaluated the performance of the proposed artifact


identification using ICA and the denoising method using S-transform for
removing artifacts from EEG signals. A raw EEG signal with sampling rate
256 Hz was considered for the analysis. The proposed EEG correction
technique finds its applicability in disease diagnosis such as epilepsy
detection, Parkinson’s disease and mental state monitoring.ICA helps in
detection of artifacts and S-Transform helps in denoising the artifactual
IC .The results are validated on simulated electroencephalogram signals

18
by quantitative evaluation analysis The proposed methodology of
artifact correction can be effectively applied for processing of
contaminated EEG data in a real time environment.

REFERENCES:

https://www.sciencedirect.com/science/article/abs/pii/S00457906163
01483

https://www.emerald.com/insight/content/doi/10.1016/j.aci.2018.08.
006/full/html#sec003

19

You might also like