Last active
May 9, 2017 03:22
-
-
Save shravankumar147/767454d4cf70c5960200074dee2856a3 to your computer and use it in GitHub Desktop.
response_correct_fld0.05.mat, response_fld0.05_correct.mat both of these .mat files contains the index values for the correct responses of size 1470x1,1837x1 respectively. Using these we extract eegdata from S, and nback,ctype targets, along with processed_metadata. All these values are put together in a single mat file called data147.mat/data18…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
load('processed_target_response_2s.mat') | |
load('S1.mat') | |
load('etc\response_correct_fld0.05.mat') | |
nback_target = nback_target(idx); | |
ctype_target = ctype_target(idx); | |
processed_meta_2s = processed_meta_2s(idx,:); | |
eegdata = S; | |
save data1470.mat eegdata nback_target ctype_target processed_meta_2s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
load('processed_target_response_2s.mat') | |
load('S2.mat') | |
load('etc\response_fld0.05_correct.mat') % gives idx | |
nback_target = nback_target(idx); | |
ctype_target = ctype_target(idx); | |
processed_meta_2s = processed_meta_2s(idx,:); | |
eegdata = S; | |
save data1837.mat eegdata nback_target ctype_target processed_meta_2s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear all; | |
clc; | |
% loading Preprocessed_2s, which contains data | |
load('Preprocessed_response_2s.mat') | |
% loading correct respose indices | |
load('etc\response_fld0.05_correct.mat');%==>S2.mat | |
% load('etc\response_correct_fld0.05.mat');%==>S1.mat | |
S=[]; | |
for s = 1:length(Preprocessed_2s) | |
% if any(s==[3,4,12,23]) | |
% continue; | |
% end | |
% subjects exluded | |
if any(s ==[3,4,12,19,22,23,33,34]) | |
continue; | |
end | |
% extracting n-back features from the remaing subjects data | |
fprintf('Subject %d: Name: %s\n',s,Preprocessed_2s(s).subject) | |
s1 = Preprocessed_2s(s).data; | |
s1 = double(s1); | |
F2 = []; | |
for j = 1:size(s1,3) | |
F1 = []; | |
%fprintf('[Info]: epoch %d/%d\n',j,size(s1,3)); | |
for i = 1:size(s1,1) | |
x = s1(i,:,j); | |
f = nback_features(x); | |
F1 = [F1;f]; | |
end | |
F1 = F1'; | |
F1ravel = F1(:); | |
F2 = [F2;F1ravel']; | |
end | |
%NOTE: | |
% F2= (F2-min(F2)) ./ (max(F2)-min(F2)); %This is throwing error for me | |
% in 2016a | |
% Modified: | |
num = F2-min(min(F2)); | |
den = max(max(F2))-min(min(F2)); | |
F2 = num./den; | |
S = [S;F2]; | |
disp('#########################') | |
end | |
S=S(idx,:); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear all; | |
clc; | |
stype={'char','pos','bar','pie'}; | |
f=0; | |
for type=1:4 | |
load('data1837.mat'); %chage file to data1470.mat to load other data set | |
%% This is where I modified for version compatibility | |
idx = find(strcmp(processed_meta_2s(:,4),stype{type})); | |
%% | |
S=eegdata; | |
nback_target=nback_target(idx,:); | |
fprintf('Type : %s\n',stype{type}); | |
fprintf('Number of samples for..\n'); | |
fprintf('0,1,2,3 back respectively :%4d,%4d,%4d,%4d\n',size(find(nback_target==0),1),size(find(nback_target==1),1),size(find(nback_target==2),1),size(find(nback_target==3),1)); | |
a=size(find(nback_target==0),1); | |
b=size(find(nback_target==1),1); | |
c=size(find(nback_target==2),1); | |
d=size(find(nback_target==3),1); | |
e = sum([a b c d]); | |
fprintf('--------------------------------------------\n'); | |
fprintf(' Test Acc F1 score\n'); | |
for j=0:2 | |
for k=(j+1):3 | |
num1=j; | |
num2=k; | |
idx1=find(nback_target==num1); | |
idx2=find(nback_target==num2); | |
data1=S(idx1,:); | |
data2=S(idx2,:); | |
A=[data1;data2]; | |
Y=[ones(size(idx1,1),1); -1*ones(size(idx2,1),1)]; | |
ridx=randperm(size(Y,1)); | |
A=A(ridx,:); | |
Y=Y(ridx,:); | |
[w, gamma, train, test, trainf1, testf1, time, nu]=psvm(A,Y,10,0,false,1); | |
% [w gamma train test time nu] = n_psvm(A,Y,0.5,5); | |
fprintf('%d vs %d %10.2f %10.2f\n',num1,num2,test,testf1); | |
end | |
end | |
fprintf('--------------------------------------------\n'); | |
disp(e) | |
f =f+e; | |
end | |
disp(f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment