Skip to content

Instantly share code, notes, and snippets.

@shravankumar147
Last active May 8, 2017 03:10
Show Gist options
  • Save shravankumar147/833f315d686e13c48ede9368c06462bd to your computer and use it in GitHub Desktop.
Save shravankumar147/833f315d686e13c48ede9368c06462bd to your computer and use it in GitHub Desktop.
This code will extract nback-features from the data. line 7,8 loads correct response indices. Modifications are from line 40-42, for MATLAB2016a version compatibility.
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');
% load('etc\response_correct_fld0.05.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,:);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment