Steps to implement ICA:

P1.

1, Open terminal type in matlab then type “eeglab” in the command line. press the “file” to load the data in the format of “.EEG” or load the data set in the format of “.Set”

  1. check the original data press “plot” then select “channel data (scroll)” use “setting” to change the parameter of display.
  1. If there is no change of the original data press “tool” then “run ICA” then it is no need to modify parameter press “ok”,it need couple hours to generate the ICA matrix.
  1. When the ICA is done check the components by select “plot” then select “component activiation (scroll) to check which components have the undesired component and remember the number of these components.
  1. reject these components by select the “tool” then “remove component” and type the components number which recorded in step 4 then press “ok”.
  1. Then can press either the “plot trials” or “plot ERP’s” to check the different between the original data and the rejection data since they have different color.
  1. After checking the result you press “accept” to save the result to a “.set” file. If you don’t satisfy about the result, you can press “not accept” to cancel then back to step 4 to recheck the components. then follow step 5, 6 ,7.
  1. Apply notch filter to the data. type the code in command line of MATLAB.

code:

>>

mydat=EEG.data;

newdata=zeros(size(mydat));

[Nchan, Nsamp,Ntrial]=size(mydat);

for trl=1:Ntrial;

newdata(:,:,trl)=preproc_bandstopfilter(mydat(:,:,trl),400,[55 65]); %400 is the sampling rate, and the number in [] is the cut edge frequency of the notch filter you want to use, example [55,65]%

end

EEG.data=newdata;

 

P2.

If you want to first apply the notch filter to the original data, you will do as follow step.

1. Open terminal type in matlab then type “eeglab” in the command line. press the “file” to load the data in the format of “.EEG” or load the data set in the format of “.Set”

  1. check the original data press “plot” then select “channel data (scroll)” use “setting” to change the parameter of display.
  1. Apply notch filter to the data. use the same code in step 8 of P1.

then follow the step 3-7 in P1.

 

P3.

Save the image in ERP between the original data and test data;

once you finish the components removal, you can save the ERP in .jpg format.

>>

for i=1:x;chan=i; % x is the number of channel which you want to plot%

figure;

ax(1)=subplot(x,1,1);plot(data1.times, mean(data1.data(chan,:,:),3));grid on; % data1, data2,… datax is the EEG data you want to compare%

title([‘data name’, num2str(i)]);

ax(2)=subplot(x,1,2);plot(data2.times, mean(data2.data(chan,:,:),3));grid on;

title([‘data name’, num2str(i)]);

ax(3)=subplot(x,1,3);plot(data3.times, mean(data3.data(chan,:,:),3));grid on;

title([‘data name’, num2str(i)]);

.

.

.

ax(x)=subplot(x,1,x);plot(datax.times, mean(datax.data(chan,:,:),3));grid on;

title([‘data name’, num2str(i)]);

.

 

min1=min(mean(data1.data(chan,:,:),3), mean(data2.data(chan,:,:),3)); % to calculate the min value of the EEG data%

min2=min(mean(data3.data(chan,:,:),3), mean(data4.data(chan,:,:),3));

min3=min(min1,mean(data4.data(chan,:,:),3));

minn=min(min3(:));

.

.

max1=max(mean(data1.data(chan,:,:),3), mean(data2.data(chan,:,:),3)); % to calculate the max value of the EEG data%

max2=max(mean(data3.data(chan,:,:),3), mean(data4.data(chan,:,:),3));

max3=max(max1,mean(data4.data(chan,:,:),3));

maxx=max(max3(:));

.

.

linkaxes(ax,’y’);

set(ax,’ylim’,[minn-1 maxx+1]);

filename=[‘path you want to save’ num2str(i) ‘.jpg’];

saveas(gcf,filename);

end