-
Notifications
You must be signed in to change notification settings - Fork 2
/
at_generateMatrixAV.m
48 lines (37 loc) · 2.03 KB
/
at_generateMatrixAV.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
function [data_output] = at_generateMatrixAV(catchtrials, congruent_mstrials, incongruent_mstrials, audInfo, visInfo, right_var, left_var, catch_var)
% Adam J. Tiesman - 7/17/23
% New, improved version of generated trial matrix.
% Catch trials
catchs = [catch_var, catch_var, catch_var, catch_var];
catchmat = repmat(catchs, catchtrials, 1);
% Prepare congruent and incongruent stimulus trials
AV_r_cong_trials = zeros(congruent_mstrials * length(audInfo.cohSet), 4);
AV_l_cong_trials = zeros(congruent_mstrials * length(audInfo.cohSet), 4);
AV_rA_incong_trials = zeros(incongruent_mstrials * length(audInfo.cohSet), 4);
AV_lA_incong_trials = zeros(incongruent_mstrials * length(audInfo.cohSet), 4);
% Populate congruent and incongruent trials
for i = 1:length(stimInfo.cohSet)
cohAud = audInfo.cohSet(i);
cohVis = visInfo.cohSet(i);
% Congruent trials
AV_r_cong_trials((i-1)*congruent_mstrials+1:i*congruent_mstrials, :) = [repmat([right_var, cohAud, right_var, cohVis], congruent_mstrials, 1)];
AV_l_cong_trials((i-1)*congruent_mstrials+1:i*congruent_mstrials, :) = [repmat([left_var, cohAud, left_var, cohVis], congruent_mstrials, 1)];
% Incongruent trials
AV_rA_incong_trials((i-1)*incongruent_mstrials+1:i*incongruent_mstrials, :) = [repmat([right_var, cohAud, left_var, cohVis], incongruent_mstrials, 1)];
AV_lA_incong_trials((i-1)*incongruent_mstrials+1:i*incongruent_mstrials, :) = [repmat([left_var, cohAud, right_var, cohVis], incongruent_mstrials, 1)];
end
% Combine all trial types
all_trials = [catchmat; AV_l_cong_trials; AV_r_cong_trials; AV_rA_incong_trials; AV_lA_incong_trials];
% Randomize trials
rng('shuffle');
nbtrials = size(all_trials, 1);
order = randperm(nbtrials);
trialOrder = all_trials(order, :);
% Prepare additional columns
resp = zeros(nbtrials, 1); % Response left or right
rt = zeros(nbtrials, 1); % Reaction time
keys = zeros(nbtrials, 1); % Keypress value
trial_status = zeros(nbtrials, 1); % Trial correctness
% Create final output matrix
data_output = [trialOrder, resp, rt, keys, trial_status];
end