2727 targetPerCondition = repmat(RANGE_TARGETS , 1 , NB_REPETITIONS / MAX_TARGET_PER_BLOCK );
2828
2929 numTargetsForEachBlock = zeros(1 , NB_BLOCKS );
30- numTargetsForEachBlock(CONDITON1_INDEX ) = shuffle(targetPerCondition );
31- numTargetsForEachBlock(CONDITON2_INDEX ) = shuffle(targetPerCondition );
30+
31+ if strcmpi(cfg .design .localizer , ' MT_MST' ) && length(cfg .design .names ) == 2
32+ numTargetsForEachBlock(CONDITON1_INDEX ) = shuffle(targetPerCondition );
33+ end
34+
35+ numTargetsForEachBlock(CONDITON2_INDEX ) = shuffle(targetPerCondition );
36+
37+ %% Give the blocks the names with condition and design the task in each event
38+ while 1
39+
40+ fixationTargets = zeros(NB_BLOCKS , NB_EVENTS_PER_BLOCK );
41+
42+ for iBlock = 1 : NB_BLOCKS
43+
44+ % Set target
45+ % - if there are 2 targets per block we make sure that they are at least
46+ % 2 events apart
47+ % - targets cannot be on the first or last event of a block
48+ % - no more than 2 target in the same event order
49+
50+ nbTarget = numTargetsForEachBlock(iBlock );
51+
52+ chosenPosition = setTargetPositionInSequence( ...
53+ NB_EVENTS_PER_BLOCK , ...
54+ nbTarget , ...
55+ [1 NB_EVENTS_PER_BLOCK ]);
56+
57+ fixationTargets(iBlock , chosenPosition ) = 1 ;
58+
59+ end
60+
61+ % Check rule 3
62+ if max(sum(fixationTargets )) < NB_REPETITIONS - 1
63+ break
64+ end
65+
66+ end
67+
68+ %% Now we do the easy stuff
69+ cfg.design.blockNames = assignConditions(cfg );
70+
71+ if strcmpi(cfg .design .localizer , ' MT_MST' )
72+
73+ if length(cfg .design .names ) == 1
74+
75+ nbBlocksPerHemifield = (NB_REPETITIONS / 4 ) * ...
76+ length(cfg .design .fixationPosition );
77+
78+ else
79+
80+ nbBlocksPerHemifield = (NB_REPETITIONS / 2 ) * ...
81+ length(cfg .design .fixationPosition );
82+
83+ end
84+
85+
86+
87+ cfg.design.blockFixationPosition = repmat(cfg .design .fixationPosition(1 ), ...
88+ nbBlocksPerHemifield , ...
89+ 1 );
90+
91+ if length(cfg .design .fixationPosition ) == 2
92+
93+ cfg.design.blockFixationPosition = [ cfg .design .blockFixationPosition ; ...
94+ repmat(cfg .design .fixationPosition(2 ), ...
95+ nbBlocksPerHemifield , ...
96+ 1 ) ];
97+
98+ end
99+
100+ end
101+
102+ cfg.design.nbBlocks = NB_BLOCKS ;
103+
104+ cfg = setDirections(cfg );
105+
106+ speeds = ones(NB_BLOCKS , NB_EVENTS_PER_BLOCK ) * cfg .dot .speedPixPerFrame ;
107+ cfg.design.speeds = speeds ;
108+
109+ cfg.design.fixationTargets = fixationTargets ;
110+
111+
0 commit comments