-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRunGARPSubjectScript.m
149 lines (120 loc) · 5.92 KB
/
RunGARPSubjectScript.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
%This is a play ground for building the strcures for saving stuff
cd ('GARP') % Sets the current directory to GARP
%% Settings
%Load all of the task lists
load('scaledChoiceTasks.mat'); % Each row has two vlaues, the first number is for the amount of item1 on left, the second number is the amount of item1 on right
load('limitGARPTasks.mat'); % Each row has two vlaues, the first number is for the amount of item1, the second number is the amount of item2
load('juanset.mat'); % This is a 3D araay each (1:2,1:2,x) contains one set of numbers to use for a single GARP presentation
scaledChoiceTasks = scaledChoiceTasks; % Each row has two vlaues, the first number is for the amount of item1 on left, the second number is the amount of item1 on right
limitGARPTasks = limitGARPTasks; % Each row has two vlaues, the first number is for the amount of item1, the second number is the amount of item2
twoItemGARPTasks = juanset; % This is a 3D araay each (1:2,1:2,x) contains one set of numbers to use for a single GARP presentation
subjID = 2;
%**Design the task orders**
trialOrder = repeatedhistory(4,5,2,1,false); % This sets the order of the tasks
long = length(trialOrder); %The total number of trials that will be performed
short = long/4; %The number of each type of trial that will be performed
oneItemOrder = repeatedhistory(2,5,4,1,false); % This sets the order of the task types. This one isn't done like the others because there is only two types of trial (so they are couterbalenced). If they weren't counter ballences they would be very little variability in the order of the presentations.
scaledChoiceOrder = []; % The fixxed order that the scaled trials will be presented in. If there are more tials that need to be shown then we have, then a second list (random order) is made and concatinated on to the end of the old one.
i = 1;
while ceil(short/(length(scaledChoiceTasks))) >= i;
scaledChoiceOrder = cat(1,scaledChoiceOrder,randperm(length(scaledChoiceTasks)));
i = i + 1;
end
limitGARPOrder = []; % The fixxed order that the GARP limit trials will be presented in
i = 1;
while ceil(short/(length(limitGARPTasks))) >= i;
limitGARPOrder = cat(1,limitGARPOrder,randperm(length(limitGARPOrder)));
i = i + 1;
end
twoItemGARPOrder = []; %The fixxed order that the 2item GARP trials will be presented in
i = 1;
while ceil(short/(length(twoItemGARPTasks))) >= i;
twoItemGARPOrder = cat(1,twoItemGARPOrder,randperm(length(twoItemGARPOrder)));
i = i + 1;
end
% Picking the items
item1 = imread('juice.jpg');
item2 = imread('chips.jpg');
% Saving the settings settings
settings.recordfolder = 'records';
settings.subjID = subjID;
settings.trialOrder = trialOrder;
settings.oneItemOrder = oneItemOrder;
settings.scaledChoiceTasks = scaledChoiceTasks;
settings.scaledChoiceOrder = scaledChoiceOrder;
settings.limitGARPTasks = limitGARPTasks;
settings.limitGARPOrder = limitGARPOrder;
settings.twoItemGARPTasks =twoItemGARPTasks;
settings.twoItemGARPOrder = twoItemGARPOrder;
settings.item1 = item1;
settings.item2 = item2;
% if the records folder doesn't exist, create it.
mkdir(settings.recordfolder);
% creat the file name for this run of this subject
recordname = [settings.recordfolder '/' num2str(subjID) '_' datestr(now,'yyyymmddTHHMMSS') '.mat'];
% Save the settings (the results are saved later)
save (recordname, 'settings')
% Restrict the keys that can be used for the Kb commands
if (ismac)
RestrictKeysForKbCheck([f, j, ESCAPE])
escKey = KbName('ESCAPE');
else
RestrictKeysForKbCheck([f, j, Esc])
escKey = KbName('Esc');
end
% Display "READY"
% wait for the go signal (5's) from the MRI
%% during the experiment
% Be mindfull that only the "behavioral." data structure will be saved.
% Set all of the indexs equal to 1
i = 1;
oneItemIndex = 1;
scaledChoiceIndex = 1;
limitGARPIndex = 1;
twoItemGARPIndex =1;
while i < long;
if trialOrder(i) == 1; %is for the one v. one choice
if oneItemOrder(oneItemIndex) == 1;
oneItemChoice(item1,item2);
else
oneItemChoice(item2,item1);
end
end
if trialOrder(i) == 2; %is for the one item (same item both sides) choice
scaledChoice(item1, ...
item1, ...
scaledChoiceTasks(scaledChoiceOrder(scaledChoiceIndex),1), ...
scaledChoiceTasks(scaledChoiceOrder(scaledChoiceIndex),2));
scaledChoiceIndex = scaledChoiceIndex + 1 ;
end
if trialOrder(i) == 3; %is for the one item (per side) (different items) GARP
scaledChoice(item1, ...
item2, ...
limitGARPTasks(limitGARPOrder(limitGARPIndex),1), ...
limitGARPTasks(limitGARPOrder(limitGARPIndex),2));
limitGARPIndex = limitGARPIndex + 1 ;
end
if trialOrder(i) == 4; %is for the two item (per side) GARP
twoItemGARPChoice(item1, ...
item2, ...
item1, ...
item2, ...
twoItemGARPTasks(1,1,twoItemGARPOrder(twoItemGARPIndex)), ...
twoItemGARPTasks(1,2,twoItemGARPOrder(twoItemGARPIndex)), ...
twoItemGARPTasks(2,1,twoItemGARPOrder(twoItemGARPIndex)), ...
twoItemGARPTasks(2,2,twoItemGARPOrder(twoItemGARPIndex)));
twoItemGARPIndex = twoItemGARPIndex + 1;
end
if trialOrder(i) == 5; %is for the three item (per side) GARP
end
% call the right function that Niree is writing
% flip
% Key response
[behavioural.secs(i,1), keyCode, behavioral.deltaSecs] = KbWait;
behavioural.key(i,1) = KbName(keyCode);
i = i + 1 ;
end
%% at the end
% up at the end of setings we created a file to hold all of our important data
% Now we will save all of the behavioural data in the same -.mat file
save (recordname, behavioural, -append)