-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogfile_analysis.m
270 lines (159 loc) · 6.58 KB
/
logfile_analysis.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
clear all; close all;clc
% logfile dir
dir1='/autofs/space/taito_005/users/awmrc/fmri_log_files/';
% Notes:
%For the subj 001, we should use the files 001b, that is, the latter session.
%(Also I will have to look at this subject’s individual runs, as there may have occurred some “napping”.)
%Also, with better time, we can analyze the bias vs. d’. For example, in 014 to my recollection,
%there was a “negative bias”, which is acceptable: the subject only responded “yes” when they were absolutely sure.
load([dir1 'sorted_logfiles_basedontime.mat'])
files=sorted_files;
%total_trials=24;
for j=1:length(files)
fn=files{j};
[out1,out2]=importPresentationLog([dir1 fn]);
tt=strcmp(out2.code,'3');
out2.code(tt)=[];
tt=strcmp(out2.code,'rest');
out2.code(tt)=[];
tt=strcmp(out2.code,'ready');
out2.code(tt)=[];
tt=strcmp(out2.code,'respond');
out2.code(tt)=[];
codes=out2.code;
match=strncmp(codes,'match',5);
index_cor1=find(match==1);
truepositive=find(strcmp(codes,'1'));
count=0;
for i=1:length(index_cor1)
if sum(index_cor1(i)+1==truepositive)
count = count+1;
end
end
nonmatch=strncmp(codes,'nonmatch',8);
inval=strncmp(codes,'inval',5);
% miss=strncmp(codes,'miss',4);
%index_cor2=[find(nonmatch==1);find(inval==1);find(miss==1)];
index_cor2=[find(nonmatch==1);find(inval==1)];
truenegative=find(strcmp(codes,'2'));
countn=0;
for i=1:length(index_cor2)
if sum(index_cor2(i)+1==truenegative)
countn = countn+1;
end
end
total_trials=length(find(match))+length(find(nonmatch))+length(find(inval));
% (true positive + true negative)/total_trials
accuracy(j,1)=(count+countn)/total_trials;
clear codes match truepositive truenegative nonmatch inval index_cor1 index_cor2
end
k=1;
for i=1:4:length(files)
subj_ac(k,1)=mean(accuracy(i:i+3));
subj{k,1}=files{i}(1:9);
k=k+1;
end
%%
clear all; close all;clc
% logfile dir
dir1='/autofs/space/voima_001/users/awmrc/meg_log_files/';
% fid=fopen('/autofs/space/taito_005/users/fahimeh/doc/txt/list_meg_log.txt');
% C=textscan(fid,'%s');
%
% files=C{1,1};
load([dir1 'sorted_MEG_logfiles_basedontime.mat'])
files=sorted_files;
for j=1:length(files)
fn=files{j};
[out1,out2]=importPresentationLog([dir1 fn]);
codes=out2.code;
truepositive=sum(strcmp(codes(find(strncmp(codes,'match',5))+1),'1'));
truenegative=sum(strcmp(codes(find(strncmp(codes,'nonmatch',8))+1),'2'))+ sum(strcmp(codes(find(strncmp(codes,'inval',5))+1),'2'));
total_trials=length(find(strncmp(codes,'match',5)))+length(find(strncmp(codes,'nonmatch',8)))+length(find(strncmp(codes,'inval',5)));
% (true positive + true negative)/total_trials
accuracy(j,1)=(truepositive+truenegative)/total_trials;
clear codes truepositive truenegative
end
k=1;
for i=1:4:length(files)
subj_ac(k,1)=mean(accuracy(i:i+3,1));
subj{k,1}=files{i}(1:9);
k=k+1;
end
subj_ac([8,20])=[];
mean(subj_ac)
std(subj_ac)
%% testing impulse sound effect
clear all; close all;clc
% logfile dir
dir1='/autofs/space/voima_001/users/awmrc/meg_log_files/';
% fid=fopen('/autofs/space/taito_005/users/fahimeh/doc/txt/list_meg_log.txt');
% C=textscan(fid,'%s');
%
% files=C{1,1};
load([dir1 'sorted_MEG_logfiles_basedontime.mat'])
files=sorted_files;
for j=1:length(files)
fn=files{j};
[out1,out2]=importPresentationLog([dir1 fn]);
codes=out2.code;
%truepositive=sum(strcmp(codes(find(strncmp(codes,'match',5))+1),'1'));
% silent true positive
silent_ind=find(strncmp(codes,'match',5)).*strncmp(codes(find(strncmp(codes,'match',5))-1),'silent_impulse_sound',20);
silent=silent_ind(silent_ind~=0);
truepositive=sum(strcmp(codes(silent+1),'1'));
l1=length(silent);
clear silent silent_ind
% silent true negative
silent_ind=find(strncmp(codes,'nonmatch',8)).*strncmp(codes(find(strncmp(codes,'nonmatch',8))-1),'silent_impulse_sound',20);
silent=silent_ind(silent_ind~=0);
trueneg1 = sum(strcmp(codes(silent+1),'2'));
l2=length(silent);
clear silent silent_ind
silent_ind=find(strncmp(codes,'inval',5)).*strncmp(codes(find(strncmp(codes,'inval',5))-1),'silent_impulse_sound',20);
silent=silent_ind(silent_ind~=0);
trueneg2 = sum(strcmp(codes(silent+1),'2'));
l3=length(silent);
clear silent silent_ind
% truenegative=sum(strcmp(codes(find(strncmp(codes,'nonmatch',8))+1),'2'))+ sum(strcmp(codes(find(strncmp(codes,'inval',5))+1),'2'));
total_trials=l1+l2+l3;
% (true positive + true negative)/total_trials
accuracy_silent(j,1)=(truepositive+trueneg1+trueneg2)/total_trials;
clear codes truepositive trueneg1 trueneg2 l1 l2 l3 total_trials
end
%%
for j=1:length(files)
fn=files{j};
[out1,out2]=importPresentationLog([dir1 fn]);
codes=out2.code;
%truepositive=sum(strcmp(codes(find(strncmp(codes,'match',5))+1),'1'));
% silent true positive
silent_ind=find(strncmp(codes,'match',5)).*strncmp(codes(find(strncmp(codes,'match',5))-1),'impulse_sound',13);
silent=silent_ind(silent_ind~=0);
truepositive=sum(strcmp(codes(silent+1),'1'));
l1=length(silent);
clear silent silent_ind
% silent true negative
silent_ind=find(strncmp(codes,'nonmatch',8)).*strncmp(codes(find(strncmp(codes,'nonmatch',8))-1),'impulse_sound',13);
silent=silent_ind(silent_ind~=0);
trueneg1 = sum(strcmp(codes(silent+1),'2'));
l2=length(silent);
clear silent silent_ind
silent_ind=find(strncmp(codes,'inval',5)).*strncmp(codes(find(strncmp(codes,'inval',5))-1),'impulse_sound',13);
silent=silent_ind(silent_ind~=0);
trueneg2 = sum(strcmp(codes(silent+1),'2'));
l3=length(silent);
clear silent silent_ind
% truenegative=sum(strcmp(codes(find(strncmp(codes,'nonmatch',8))+1),'2'))+ sum(strcmp(codes(find(strncmp(codes,'inval',5))+1),'2'));
total_trials=l1+l2+l3;
% (true positive + true negative)/total_trials
accuracy_impulse(j,1)=(truepositive+trueneg1+trueneg2)/total_trials;
clear codes truepositive trueneg1 trueneg2 l1 l2 l3 total_trials
end
%%
k=1;
for i=1:4:length(files)
subj_ac(k,1)=mean(accuracy(i:i+3,1));
subj{k,1}=files{i}(1:9);
k=k+1;
end