-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreaddata.m
More file actions
executable file
·103 lines (96 loc) · 3.88 KB
/
readdata.m
File metadata and controls
executable file
·103 lines (96 loc) · 3.88 KB
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
% function [error_vec N_vec] = readdata(expnr,subjidx)
%
% Returns the data of a particular subject in two vectors:
% error_vec : vector with estimation errors
% N_vec : vector with corresponding set sizes
%
% If you added your own data to getExperimentInfo.m, you should add code
% here to read those data from file.
function [error_vec N_vec] = readdata(expnr,subjidx)
% get information about file location and subject identifiers
expinfo = getExperimentInfo(expnr);
if expnr == 1
%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%
% Color experiment in Van den Berg et al. 2012 (PNAS) - response by scrolling %
%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%
files = dir([expinfo.datadir expinfo.subjids{subjidx} '*.mat']);
fprintf('Subject %s, reading %d files\n',expinfo.subjids{subjidx},length(files));
target_vec = [];
N_vec = [];
nontarget_vec = {};
resp_vec = [];
for ii=1:length(files)
load([expinfo.datadir files(ii).name]);
if ABBA_array(1)==1
resp_vec = [resp_vec recording1.sub_picked];
for jj=1:length(recording1.set_size)
N_vec(end+1) = recording1.set_size(jj);
target_vec(end+1) = recording1.c_array(recording1.test(jj),jj);
end
end
if ABBA_array(2)==1
resp_vec = [resp_vec recording2.sub_picked];
for jj=1:length(recording2.set_size)
N_vec(end+1) = recording2.set_size(jj);
target_vec(end+1) = recording2.c_array(recording2.test(jj),jj);
end
end
if ABBA_array(3)==1
resp_vec = [resp_vec recording3.sub_picked];
for jj=1:length(recording3.set_size)
N_vec(end+1) = recording3.set_size(jj);
target_vec(end+1) = recording3.c_array(recording3.test(jj),jj);
end
end
if ABBA_array(4)==1
resp_vec = [resp_vec recording4.sub_picked];
for jj=1:length(recording4.set_size)
N_vec(end+1) = recording4.set_size(jj);
target_vec(end+1) = recording4.c_array(recording4.test(jj),jj);
end
end
end
% convert [1,180] to [-pi,pi] range
target_vec = target_vec/180*2*pi-pi;
resp_vec = resp_vec/180*2*pi-pi;
error_vec = circ_dist(resp_vec,target_vec);
elseif expnr == 2
%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%
% Orientation experiment in Van den Berg et al. 2012 (PNAS) %
%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%
files = dir([expinfo.datadir expinfo.subjids{subjidx} '*.mat']);
fprintf('Subject %s, reading %d files\n',expinfo.subjids{subjidx},length(files));
N_vec = [];
resp_vec = [];
nontarget_vec = {};
target_vec = [];
for ii=1:length(files)
load([expinfo.datadir files(ii).name]);
for jj=1:5
if jj==1
data = block_one;
elseif jj==2
data = block_two;
elseif jj==3
data = block_three;
elseif jj==4
data = block_four;
elseif jj==5
data = block_five;
end
for kk=1:length(data.set_size)
N_vec(end+1) = data.set_size(kk);
resp_vec(end+1) = data.subject_responses(kk);
target_vec(end+1) = data.true_values(kk);
end
end
end
% convert [1,180] to [-pi,pi] range
target_vec = target_vec/180*2*pi-pi;
resp_vec = resp_vec/180*2*pi-pi;
error_vec = circ_dist(resp_vec,target_vec);
elseif expnr == 3
% Add code here to return the data for the specified subject
N_vec = [];
error_vec = [];
end