-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMBcourse_GenerateTaskDesign.m
More file actions
33 lines (27 loc) · 1008 Bytes
/
Copy pathMBcourse_GenerateTaskDesign.m
File metadata and controls
33 lines (27 loc) · 1008 Bytes
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
function out = MBcourse_GenerateTaskDesign( nTrialsPerBlocks, pReward )
% Get the total number of trials
nTrials = sum(nTrialsPerBlocks);
nBlocks = numel(nTrialsPerBlocks);
% Get reward probability for one of the stimuli in each block
probTrial = repmat([pReward, 1-pReward], 1, floor(nBlocks/2));
if mod(nBlocks/2, 1) ~= 0
probTrial = [probTrial, repmat(pReward, 1, nTrialsPerBlocks(end))];
end
% Prepare outputs
feedbackprob = NaN(nTrials, 1);
feedback = NaN(nTrials, 2);
% Generate the feedback sequence
t = 1;
for b = 1:nBlocks
for x = 1:nTrialsPerBlocks(b)
feedbackprob(t) = probTrial(b);
feedback(t,1) = double(rand(1) <= feedbackprob(t));
feedback(t,2) = 1 - feedback(t,1);
t = t+1;
end
end
% Export all that information
out = struct('nTrialsPerBlocks', nTrialsPerBlocks, 'pReward', pReward, ...
'nTrials', nTrials, 'nBlocks', nBlocks, 'probTrial', probTrial, ...
'feedbackprob', feedbackprob, 'feedback', feedback);
end