|
1 | 1 | function [cfg] = expDesign(cfg, displayFigs) |
2 | 2 | % Creates the sequence of blocks and the events in them |
3 | 3 | % |
4 | | - % The conditions are consecutive static and motion blocks (Gives better results than randomised). |
| 4 | + % The conditions are consecutive static and motion blocks (Gives better results |
| 5 | + % than randomised). |
5 | 6 | % |
6 | 7 | % It can be run as a stand alone without inputs to display a visual example of possible design. |
7 | 8 | % |
|
24 | 25 | % - ExpParameters.designBlockNames = cell array (nr_blocks, 1) with the |
25 | 26 | % name for each block |
26 | 27 | % |
27 | | - % - ExpParameters.designDirections = array (nr_blocks, numEventsPerBlock) |
| 28 | + % - ExpParameters.designDirections = array (nr_blocks, nbEventsPerBlock) |
28 | 29 | % with the direction to present in a given block |
29 | 30 | % - 0 90 180 270 indicate the angle |
30 | 31 | % - -1 indicates static |
31 | 32 | % |
32 | | - % - ExpParameters.designSpeeds = array (nr_blocks, numEventsPerBlock) * speedEvent |
33 | 33 | % |
34 | | - % - ExpParameters.designFixationTargets = array (nr_blocks, numEventsPerBlock) |
| 34 | + % - ExpParameters.designFixationTargets = array (nr_blocks, nbEventsPerBlock) |
35 | 35 | % showing for each event if it should be accompanied by a target |
36 | 36 | % |
37 | 37 |
|
|
48 | 48 |
|
49 | 49 | % Set variables here for a dummy test of this function |
50 | 50 | if nargin < 1 || isempty(cfg) |
51 | | - cfg.names = {'static', 'motion'}; |
52 | | - cfg.numRepetitions = 4; |
53 | | - cfg.speedEvent = 4; |
54 | | - cfg.numEventsPerBlock = 12; |
55 | | - cfg.maxNumFixationTargetPerBlock = 2; |
| 51 | + cfg.design.names = {'static', 'motion'}; |
| 52 | + cfg.design.nbRepetitions = 4; |
| 53 | + cfg.design.nbEventsPerBlock = 12; |
| 54 | + cfg.target.maxNbPerBlock = 2; |
56 | 55 | end |
57 | 56 |
|
58 | 57 | % Set to 1 for a visualtion of the trials design order |
|
61 | 60 | end |
62 | 61 |
|
63 | 62 | % Get the parameters |
64 | | - names = cfg.names; |
65 | | - numRepetitions = cfg.numRepetitions; |
66 | | - speedEvent = cfg.speedEvent; |
67 | | - numEventsPerBlock = cfg.numEventsPerBlock; |
68 | | - maxNumFixTargPerBlock = cfg.target.maxNbPerBlock; |
69 | | - |
70 | | - if mod(numEventsPerBlock, length(motionDirections)) ~= 0 |
71 | | - warning('the number of events per block is not a multiple of the number of motion/static diection'); |
| 63 | + names = cfg.design.names; |
| 64 | + nbRepetitions = cfg.design.nbRepetitions; |
| 65 | + nbEventsPerBlock = cfg.design.nbEventsPerBlock; |
| 66 | + maxNbFixTargPerBlock = cfg.target.maxNbPerBlock; |
| 67 | + |
| 68 | + if mod(nbEventsPerBlock, length(motionDirections)) ~= 0 |
| 69 | + warning('the n. of events per block is not a multiple of experimental conditions'); |
72 | 70 | end |
73 | 71 |
|
74 | 72 | %% Adapt some variables according to input |
75 | 73 |
|
76 | 74 | % Set directions for static and motion condition |
77 | | - motionDirections = repmat(motionDirections, 1, numEventsPerBlock / length(motionDirections)); |
78 | | - staticDirections = repmat(staticDirections, 1, numEventsPerBlock / length(staticDirections)); |
| 75 | + motionDirections = repmat(motionDirections, 1, nbEventsPerBlock / length(motionDirections)); |
| 76 | + staticDirections = repmat(staticDirections, 1, nbEventsPerBlock / length(staticDirections)); |
79 | 77 |
|
80 | 78 | % Assign the conditions |
81 | | - condition = repmat(names, 1, numRepetitions); |
| 79 | + condition = repmat(names, 1, nbRepetitions); |
82 | 80 | nrBlocks = length(condition); |
83 | 81 | % Get the index of each condition |
84 | 82 | staticIndex = find(strcmp(condition, 'static')); |
85 | 83 | motionIndex = find(strcmp(condition, 'motion')); |
86 | 84 |
|
87 | 85 | % Assign the targets for each condition |
88 | | - rangeTargets = [1 maxNumFixTargPerBlock]; |
| 86 | + rangeTargets = [1 maxnbFixTargPerBlock]; |
89 | 87 | % Get random number of targets for one condition |
90 | | - targetPerCondition = randi(rangeTargets, 1, numRepetitions); |
| 88 | + targetPerCondition = randi(rangeTargets, 1, nbRepetitions); |
91 | 89 | % Assign the number of targets for each condition after shuffling |
92 | | - numTargets = zeros(1, nrBlocks); |
93 | | - numTargets(staticIndex) = Shuffle(targetPerCondition); |
94 | | - numTargets(motionIndex) = Shuffle(targetPerCondition); |
| 90 | + nbTargets = zeros(1, nrBlocks); |
| 91 | + nbTargets(staticIndex) = Shuffle(targetPerCondition); |
| 92 | + nbTargets(motionIndex) = Shuffle(targetPerCondition); |
95 | 93 |
|
96 | 94 | %% Give the blocks the names with condition |
97 | 95 |
|
98 | 96 | cfg.designBlockNames = cell(nrBlocks, 1); |
99 | | - cfg.designDirections = zeros(nrBlocks, numEventsPerBlock); |
100 | | - cfg.designSpeeds = ones(nrBlocks, numEventsPerBlock) * speedEvent; |
101 | | - cfg.designFixationTargets = zeros(nrBlocks, numEventsPerBlock); |
| 97 | + cfg.designDirections = zeros(nrBlocks, nbEventsPerBlock); |
| 98 | + cfg.designFixationTargets = zeros(nrBlocks, nbEventsPerBlock); |
102 | 99 |
|
103 | | - for iMotionBlock = 1:numRepetitions |
| 100 | + for iMotionBlock = 1:nbRepetitions |
104 | 101 |
|
105 | 102 | cfg.designDirections(motionIndex(iMotionBlock), :) = Shuffle(motionDirections); |
106 | 103 | cfg.designDirections(staticIndex(iMotionBlock), :) = Shuffle(staticDirections); |
|
125 | 122 |
|
126 | 123 | chosenTarget = []; |
127 | 124 |
|
128 | | - tmpTarget = numTargets(iBlock); |
| 125 | + tmpTarget = nbTargets(iBlock); |
129 | 126 |
|
130 | 127 | switch tmpTarget |
131 | 128 |
|
132 | 129 | case 1 |
133 | 130 |
|
134 | | - chosenTarget = randsample(2:numEventsPerBlock - 1, tmpTarget, false); |
| 131 | + chosenTarget = randsample(2:nbEventsPerBlock - 1, tmpTarget, false); |
135 | 132 |
|
136 | 133 | case 2 |
137 | 134 |
|
138 | 135 | targetDifference = 0; |
139 | 136 |
|
140 | 137 | while targetDifference <= 2 |
141 | | - chosenTarget = randsample(2:numEventsPerBlock - 1, tmpTarget, false); |
| 138 | + chosenTarget = randsample(2:nbEventsPerBlock - 1, tmpTarget, false); |
142 | 139 | targetDifference = (max(chosenTarget) - min(chosenTarget)); |
143 | 140 | end |
144 | 141 |
|
|
0 commit comments