-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathanalysis_coding.m
executable file
·102 lines (76 loc) · 3.04 KB
/
analysis_coding.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
function results = analysis_coding(datadir,subjectFolders,subjFolder)
%% deal with stroopjs data
% Dorian Minors
% Created: SEP20
%
%
%% set up
fprintf('setting up %s\n', mfilename);
p = struct(); % keep some of our parameters tidy
d = struct(); % set up a structure for the data info
t = struct(); % set up a structure for temp data
% set up variables
p.savefilename = 'processed_data';
save_file = fullfile(datadir,subjectFolders{subjFolder},p.savefilename);
% make sure this legend is correct per the experiment - we code accuracy on the
% legend, not the experiment
%% get file information
theDir = dir(fullfile(datadir,subjectFolders{subjFolder}));
fileNames = {theDir.name};
d.results = {}; % init this
for i = 1:numel(fileNames)
thisName = regexp(fileNames{i}, '_', 'split');
if startsWith(thisName(1),'S') && ~any(contains(thisName,'Procedure')) && ~any(contains(thisName,'training')) && ~any(contains(thisName,'.wav'))
task = cellstr(thisName{4}); % task
stim = regexp(thisName{5},'.mat','split'); % stimulus
stim = stim(1);
tempFile = load([datadir,filesep,subjectFolders{subjFolder},filesep,fileNames{i}]);
tmpResults = tempFile.d.results;
tmpStimMat = tempFile.d.stimulus_matrix;
for block = 1:size(tmpResults,3)
for trial = 1:size(tmpResults,1)
stimIdx = tmpResults{trial,5,block};
d.results = [d.results;...
tmpResults(trial,1,block),... % task
tmpResults(trial,2,block),... % stimulus
trial,...
block,...
tmpResults(trial,3,block),... % rt
tmpStimMat(stimIdx,4),... % congruency
tmpStimMat(stimIdx,5),... % word
tmpStimMat(stimIdx,6),... % ink
tmpResults(trial,6,block)]; % size
end; clear trial
end; clear block
end
end
save(save_file);
results = d.results; % because matlab can't pass bits of structures?
disp('done coding subject');
%
% % init some results - same structure exists for each subject in d.subjects.results
% d.results.size = [];
% d.results.size_congruent = [];
% d.results.size_congruent_falsefont = [];
% d.results.size_congruent_font = [];
% d.results.size_incongruent = [];
% d.results.size_incongruent_falsefont = [];
% d.results.size_incongruent_font = [];
%
% d.results.colour = [];
% d.results.colour_congruent = [];
% d.results.colour_congruent_falsefont = [];
% d.results.colour_congruent_font = [];
% d.results.colour_incongruent = [];
% d.results.colour_incongruent_falsefont = [];
% d.results.colour_incongruent_font = [];
%
%
%
% fprintf('saving output from %s\n', mfilename);
% save(save_file,'d'); % save all data to a .mat file
function accuracy = accthis(data)
accuracy = sum(data)/length(data);
end
return
end