EEG data classification between sick and non-sick using Classify in Matlab

Hello, and good day. I am doing a an EEG which I already have the 100 patients classified and the 5 classes (S, Z, O, N, F), and already put them with there respective frequencies (Gamma, Theta, Alpha, Beta, Delta, not in that order). i want to know how to classify the signal that i already have using the function classify in MatLab, this classification is to see who are sick and who are not. Next I will show you the context for more information.
This project will apply what has been seen in the course to develop an epilepsy detector from EEG signals. We will use as test data the epilepsy database of the University of Bonn. These data are grouped into five classes:
  • Class Z: superficial EEG of healthy patients with open eyes.
  • Class O: Surface EEG of healthy patients with closed eyes.
  • Class F: intracranial EEG base of patients with epilepsy measured in the epileptogenic zone.
  • Class N: intracranial EEG base of patients with epilepsy measured in the hemisphere opposite the epileptogenic zone.
  • Class S: intracranial EEG taken during the presence of epileptic activity.
For each class, there are 100 single-channel EEG records, with a duration of 23.6 seconds (4097 samples) and a sampling frequency of 173.61 Hz. The bandwidth of the signals is 0.5 Hz to 85 Hz.
Next I will present my code so far of the EEG
% Esta función toma como entrada un vector x, donde x es una señal de EEG
function R = EEG(D)
cd (['D:\Documents\MATLAB\EEG\RPDatos\RPDatos\' D])
files= dir([ D '*.txt' ]) ; % Carga archivos como estructuras
R=zeros(100,5);
for k = 1:100
i = 1 ;
tline = 0 ;
file_txt = fopen( files(k).name ) ; % Abre el k-esimo archivo en files
while ( tline ~= -1 );
tline = fgetl( file_txt );
if ( ~ischar( tline ) ) break,
end
x(i) = str2num ( tline ); % convierte el string en numero y asigna a y(i)
i = i + 1 ;
end
fclose( file_txt ) ; % cierra archivo
fs = 173.61;
n = 1024 ; % Next power of 2 from length of y
y = fft(x,n);
f = (0:n-1)*(fs/n);
power=abs(y)/n;
y0=fftshift(y);
f0=(-n/2:n/2-1)*(fs/n);
power0=abs(y0)/n;
y1 = f0(find(f0==0):length(f0));
y2 = power0(find(f0==0):length(f0));
Delta=y2(find((y1>=0.1)&(y1<=4)));
Delta=sum(Delta);
Theta=y2(find((y1>=4)&(y1<=7)));
Theta=sum(Theta);
Alfa=y2(find((y1>=7)&(y1<=12)));
Alfa=sum(Alfa);
Beta=y2(find((y1>=12)&(y1<=30)));
Beta=sum(Beta);
Gamma=y2(find((y1>=30)&(y1<=100)));
Gamma=sum(Gamma);
R1= [Delta , Theta , Alfa , Beta , Gamma];
R(k,:)=R1;
printmat(R, ['EEG clase ' D] ,...
'001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063 064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095 096 097 098 099 100',...
'Delta Theta Alfa Beta Gamma' );
SL = zeros(length(R));
group = ones(length(R));
legend('Enfermos','Sanos',...
'Location','NW')
[C] = classify(SL,group,'Quadratic');
hold on;
K = coeff(1,2).const;
L = coeff(1,2).linear;
Q = coeff(1,2).quadratic;
% Function to compute K + L*v + v'*Q*v for multiple vectors
% v=[x;y]. Accepts x and y as scalars or column vectors.
f = @(x,y) K + [x y]*L + sum(([x y]*Q) .* [x y], 2);
h2 = ezplot(f,[4.5 8 2 4]);
set(h2,'Color','m','LineWidth',2)
axis([4.5 8 2 4])
xlabel('Muestras')
ylabel('Tiempo')
title(['Clasificación de EEG entre Enfermos y Sanos' D],R);
end
cd ('D:\Documents\MATLAB\EEG')
xlswrite(['EEG Clase ' D, '.xls'],R)
save RZ.dat R -ascii -append;
end
I do not understand on how to use or to begin using the function Classify, so any help would be appreciated. If my question is still unclear to you don't mind and asking anything.
Thank you in advance.

1 Comment

I am trying to use it with svm classifier do the same, do you have the code

Sign in to comment.

Answers (0)

Categories

Products

Asked:

on 29 Nov 2016

Commented:

on 22 May 2022

Community Treasure Hunt

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

Start Hunting!