Open nadia-aghili opened 4 years ago
this is my code i don't have a good classification accuracy with this method, can you help me what's my problem?
28. > %% digital filtering
29. > N = 7794 ; f1 = 0.1 ; f2 = 10 ; Fs = 240 ;
30. > K1 = round((N*f1)/Fs) ; K2 = round((N*f2)/Fs) ;
31. > cc=11;
32. > FFT_X = fft(Signal2, [], 2);
33. > Filterd_FFT_X = zeros(85 , 7794 , cc);
34. > Filterd_FFT_X(: ,[K1:K2 , N-K2:N-K1] ,: ) = FFT_X (: , [K1:K2 , N-K2:N-K1] , : );
35. > Filterd_X = ifft(Filterd_FFT_X , [] , 2 ,'symmetric');
36. > Signal1=Filterd_X;
here is the issue I see in the preprocessing steps:
f1 = 0.1 ; f2 = 10
won't work. As mentioned in several papers, lower frequencies will make poorly conditionned covariance matrix. You want a minimal of f1 = 1
for P300 as the usual windows length is 1 second. Lower values of f1 means your signal is NOT zero mean. Zero mean is a necessary condition. f2 = 10
is a bit too low but it should be fine (I use 16 or 25 for better results).K1 = round((N*f1)/Fs/2) ; K2 = round((N*f2)/Fs/2) ; % don't forget to divide by 2
What do N
and cc
and why are they hardcoded ?
Usually, you want to avoid any hardcoded values. If N
is the total number of samples, just read it from your data.
69. > c=0;
70. > b=0;
71. > for i = 1:size(X_trains,1)
72. > if label(i,:)==1
73. > b=b+1;
74. > x1(b,:,:)=X_trains(i,:,:);
75. > else
76. > c=c+1;
77. > x2(c,:,:)=X_trains(i,:,:);
78. > end
79. >
80. > end
instead, use something like
x1 = X_trains(label == 1,:,:)
x2 = X_trains(label ~= 1,:,:)
If you want an example of how to do the super covariance matrix, just check that simple snippet (you can skip generate training-test set if you do it manually)