-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathseq_pruned_mseq.m
35 lines (31 loc) · 1.09 KB
/
seq_pruned_mseq.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
function [ms]=seq_pruned_mseq(ttrial,rr,or)
%[ms]=seq_pruned_mseq(ttrial,rr,or)
%
% Generates a pseudo-maximum length sequence, pruned for UCS and oddball
% conditions.
%randomly create an mseq with 11^2 using random taps
ms0 = [];
for r = randsample(1:18,18);
[ms0]=[ms0 ; mseq2(11,2,[],r)];
end
OK = 1;
%ttrial is the target trials, however we have to cut it a bit longer so
%that when pruned target trial is reached.
ttrial2 = ttrial;
while OK
ms = ms0(1:ttrial2);
%prune
conds = unique(ms);%all conditions
o_i = ms == max(conds);%oddball index
o_trial_current = sum(o_i);%number of current oddbalss
o_trial_target = round(ttrial*or);%number of oddballs to have
ms( randsample(find(ms == max(conds)), o_trial_current - o_trial_target) ) = [];
nucs = round(sum(ms == 4)*(rr./(1-rr)));%how many do we need to have?
tucs = sum(ms == (max(conds)-1));
ms(randsample(find(ms == (max(conds)-1)),tucs-nucs)) = [];
if length(ms) == ttrial
OK = 0;
else
ttrial2 = ttrial2 + 1;
end
end