-
Notifications
You must be signed in to change notification settings - Fork 0
/
A000_convert_behavi_log_to_matrix.m
152 lines (118 loc) · 4.27 KB
/
A000_convert_behavi_log_to_matrix.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
clear all;close all;clc
% this script saves the behavior log data into matrices
% output: testing_behav_matrix, training_behav_matrix
subj = 7
patient_num = [ 39 57 66 63 44 83 84 85 87] ;
addpath('/mnt/yassamri/iEEG/sandra/analysis_pipeline_final')
cd(['/mnt/yassamri/iEEG/sandra/subj_' num2str(patient_num(subj))]) % go to patient log dir
filename = [num2str(patient_num(subj)) '_MDTO_log.txt']
MDTOlog = A000_import_log(filename)
%%
counter = 0;
for a = 1:size(MDTOlog,1) % loop thru throw
for b = 1:size(MDTOlog,2) % loop thru columns
if strcmp('ImageType',MDTOlog{a,b})
counter = counter+1
row(counter,:) =[a b]
end
if strcmp('Scores:', MDTOlog{a,b})
row_end = [a b]
end
end
end
%% start and end rows for training and testing tasks
Training_trial_row = [row(1,1)+1 row(2,1)-2];
Testing_trial_row = [row(2,1)+1 row_end(1,1)-1];
%%
%trial image imagetype responses rt
trial_length = length(Training_trial_row(1):Training_trial_row(2));
train_behav_data = cell(1,2);
% get trial num
train_behav_data{1}(1:trial_length,1) = MDTOlog{Training_trial_row(1),1}:MDTOlog{Training_trial_row(2),1};
% images
for a = 1:trial_length
counter = Training_trial_row(1)-1+a
% 2nd row: get image
train_behav_data{2}(a,:) = MDTOlog{counter,2}
% 3rd row: get image type
if strcmp('sR', MDTOlog{counter,3})
train_behav_data{3}(a,:) = 0 ; % convert sR to 0
else
train_behav_data{3}(a,:) = MDTOlog{counter,3};
end
% 4th row: get response
if ischar(MDTOlog{counter,4})
train_behav_data{4}(a,:) = nan;
else
train_behav_data{4}(a,:) = MDTOlog{counter,4};
end
% 5th row: get response time
if isempty(MDTOlog{counter,5})
train_behav_data{5}(a,:) = 0;
else
train_behav_data{5}(a,:) = MDTOlog{counter,5};
end
end
train_trials = (MDTOlog{Training_trial_row(1),1}:MDTOlog{Training_trial_row(2),1})';
train_images = train_behav_data{2};
train_image_type = train_behav_data{3};
train_response = train_behav_data{4};
train_RT = train_behav_data{5};
training_behav_matrix(:,1) = train_trials;
training_behav_matrix(:,2) = train_image_type;
training_behav_matrix(:,3) = train_response;
training_behav_matrix(:,4) = train_RT;
training_behav_matrix_label = {'trials' 'image_type' 'response' 'RT'}
%%
trial_length = length(Testing_trial_row(1):Testing_trial_row(2));
test_behav_data = cell(1,2);
% get trial num
test_behav_data{1}(1:trial_length,1) = MDTOlog{Testing_trial_row(1),1}:MDTOlog{Testing_trial_row(2),1};
% images
for a = 1:trial_length
counter = Testing_trial_row(1)-1+a
% 2nd row: get image
test_behav_data{2}(a,:) = MDTOlog{counter,2}
% 3rd row: get image type
if strcmp('sR', MDTOlog{counter,3})
test_behav_data{3}(a,:) = 0 ; % convert sR to 0
elseif strcmp('sF',MDTOlog{counter,3})
test_behav_data{3}(a,:) = 0.5 ; % convert sF to 0.5
else
test_behav_data{3}(a,:) = MDTOlog{counter,3};
end
% 5th row: get response
if ischar(MDTOlog{counter,5})
test_behav_data{4}(a,:) = nan;
else
test_behav_data{4}(a,:) = MDTOlog{counter,5};
end
% 6th row: get response time
if isempty(MDTOlog{counter,6})
test_behav_data{5}(a,:) = 0;
else
test_behav_data{5}(a,:) = str2num(MDTOlog{counter,6});
end
% 4th row: get response
if ischar(MDTOlog{counter,4})
test_behav_data{6}(a,:) = nan;
else
test_behav_data{6}(a,:) = MDTOlog{counter,4};
end
end
test_trials = (MDTOlog{Testing_trial_row(1),1}:MDTOlog{Testing_trial_row(2),1})';
test_images = test_behav_data{2};
test_image_type = test_behav_data{3};
test_response = test_behav_data{4};
test_RT = test_behav_data{5};
corr_response = test_behav_data{6};
testing_behav_matrix(:,1) = test_trials;
testing_behav_matrix(:,2) = test_image_type;
testing_behav_matrix(:,3) = test_response;
testing_behav_matrix(:,4) = test_RT;
testing_behav_matrix(:,5) = corr_response;
testing_behav_matrix_label = {'trials' 'image_type' 'response' 'RT' 'corr_response'}
%%
save(['behavior_subj' num2str(patient_num(subj))], 'training_behav_matrix','training_behav_matrix_label','train_images',...
'testing_behav_matrix', 'testing_behav_matrix_label', 'test_images')
clear all