Skip to content

Commit 84a1f8e

Browse files
committed
mh autofix
1 parent 1d889f5 commit 84a1f8e

File tree

2 files changed

+86
-87
lines changed

2 files changed

+86
-87
lines changed

setParameters.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
'output');
1212

1313
%% Debug mode settings
14-
14+
1515
cfg.debug.do = true; % To test the script out of the scanner, skip PTB sync
1616
cfg.debug.smallWin = false; % To test on a part of the screen, change to 1
1717
cfg.debug.transpWin = true; % To test with trasparent full size screen
@@ -39,7 +39,7 @@
3939
cfg.design.nbEventsPerBlock = 12; % DO NOT CHANGE
4040

4141
%% Timing
42-
42+
4343
% Time between blocs in secs
4444
cfg.IBI = .5; % 8;
4545
% Time between events in secs
@@ -50,7 +50,7 @@
5050
cfg.endDelay = .1;
5151

5252
cfg.eventDuration = 1; % second
53-
53+
5454
%% Visual Stimulation
5555

5656
% Speed in visual angles / second
@@ -92,7 +92,7 @@
9292
cfg.target.duration = 0.05; % In secs
9393

9494
cfg.extraColumns = {'direction', 'speed', 'target', 'event', 'block'};
95-
95+
9696
end
9797

9898
function cfg = setKeyboards(cfg)

subfun/expDesign.m

Lines changed: 82 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
function [cfg] = expDesign(cfg, displayFigs)
22
% Creates the sequence of blocks and the events in them
33
%
4-
% The conditions are consecutive static and motion blocks (Gives better results than randomised).
4+
% The conditions are consecutive static and motion blocks
5+
% (Gives better results than randomised).
56
%
67
% EVENTS
78
% The numEventsPerBlock should be a multiple of the number of "base"
8-
% listed in the motionDirections and staticDirections (4 at the moment).
9+
% listed in the MOTION_DIRECTIONS and STATIC_DIRECTIONS (4 at the moment).
10+
% MOTION_DIRECTIONS = [0 90 180 270];
11+
% STATIC_DIRECTIONS = [-1 -1 -1 -1];
912
%
1013
% Pseudorandomization rules:
1114
% (1) Directions are all present in random orders in `numEventsPerBlock/nDirections`
@@ -42,15 +45,14 @@
4245
% - cfg.designFixationTargets = array (nr_blocks, numEventsPerBlock)
4346
% showing for each event if it should be accompanied by a target
4447
%
45-
46-
48+
4749
%% Check inputs
48-
50+
4951
% Set to 1 for a visualtion of the trials design order
5052
if nargin < 2 || isempty(displayFigs)
5153
displayFigs = 0;
5254
end
53-
55+
5456
% Set variables here for a dummy test of this function
5557
if nargin < 1 || isempty(cfg)
5658
cfg.design.names = {'static'; 'motion'};
@@ -60,125 +62,124 @@
6062
cfg.target.maxNbPerBlock = 2;
6163
displayFigs = 1;
6264
end
63-
65+
6466
[NB_BLOCKS, NB_REPETITIONS, NB_EVENTS_PER_BLOCK, MAX_TARGET_PER_BLOCK] = getInput(cfg);
65-
[~, staticIndex, motionIndex] = assignConditions(cfg);
66-
67+
[~, STATIC_INDEX, motionIndex] = assignConditions(cfg);
68+
6769
RANGE_TARGETS = [1 MAX_TARGET_PER_BLOCK];
68-
targetPerCondition = repmat(RANGE_TARGETS, 1, NB_REPETITIONS/2);
69-
70+
targetPerCondition = repmat(RANGE_TARGETS, 1, NB_REPETITIONS / 2);
71+
7072
numTargetsForEachBlock = zeros(1, NB_BLOCKS);
71-
numTargetsForEachBlock(staticIndex) = shuffle(targetPerCondition);
72-
numTargetsForEachBlock(motionIndex) = shuffle(targetPerCondition);
73-
73+
numTargetsForEachBlock(STATIC_INDEX) = shuffle(targetPerCondition);
74+
numTargetsForEachBlock(MOTION_INDEX) = shuffle(targetPerCondition);
75+
7476
%% Give the blocks the names with condition and design the task in each event
7577
while 1
76-
78+
7779
fixationTargets = zeros(NB_BLOCKS, NB_EVENTS_PER_BLOCK);
78-
80+
7981
for iBlock = 1:NB_BLOCKS
80-
82+
8183
% Set target
8284
% - if there are 2 targets per block we make sure that they are at least
8385
% 2 events apart
8486
% - targets cannot be on the first or last event of a block
8587
% - no more than 2 target in the same event order
86-
88+
8789
chosenTarget = [];
88-
90+
8991
tmpTarget = numTargetsForEachBlock(iBlock);
90-
92+
9193
switch tmpTarget
92-
94+
9395
case 1
94-
96+
9597
chosenTarget = randsample(2:NB_EVENTS_PER_BLOCK - 1, tmpTarget, false);
96-
98+
9799
case 2
98-
100+
99101
targetDifference = 0;
100-
102+
101103
while any(targetDifference <= 2)
102104
chosenTarget = randsample(2:NB_EVENTS_PER_BLOCK - 1, tmpTarget, false);
103105
targetDifference = diff(chosenTarget);
104106
end
105-
107+
106108
end
107-
109+
108110
fixationTargets(iBlock, chosenTarget) = 1;
109-
111+
110112
end
111-
113+
112114
% Check rule 3
113115
if max(sum(fixationTargets)) < 3
114116
break
115117
end
116-
118+
117119
end
118-
120+
119121
%% Now we do the easy stuff
120122
cfg.design.blockNames = assignConditions(cfg);
121-
123+
122124
cfg.design.nbBlocks = NB_BLOCKS;
123-
125+
124126
cfg = setDirections(cfg);
125-
127+
126128
speeds = ones(NB_BLOCKS, NB_EVENTS_PER_BLOCK) * cfg.dot.speedPixPerFrame;
127129
cfg.design.speeds = speeds;
128-
130+
129131
cfg.design.fixationTargets = fixationTargets;
130132

131-
132133
%% Plot
133-
diplayDesign(cfg, displayFigs)
134-
134+
diplayDesign(cfg, displayFigs);
135+
135136
end
136137

137138
function cfg = setDirections(cfg)
138-
139+
139140
% CONSTANTS
140141
% Set directions for static and motion condition
141142
MOTION_DIRECTIONS = [0 90 180 270];
142143
STATIC_DIRECTIONS = [-1 -1 -1 -1];
143-
144+
144145
[NB_BLOCKS, NB_REPETITIONS, NB_EVENTS_PER_BLOCK] = getInput(cfg);
145-
146-
[~, staticIndex, motionIndex] = assignConditions(cfg);
147-
146+
147+
[~, STATIC_INDEX, MOTION_INDEX] = assignConditions(cfg);
148+
148149
if mod(NB_EVENTS_PER_BLOCK, length(MOTION_DIRECTIONS)) ~= 0
149150
error('Number of events/block not a multiple of number of motion/static direction');
150151
end
151-
152+
152153
% initialize
153154
directions = zeros(NB_BLOCKS, NB_EVENTS_PER_BLOCK);
154-
155+
155156
% Create a vector for the static condition
156157
static_directions = repmat( ...
157158
STATIC_DIRECTIONS, ...
158159
1, NB_EVENTS_PER_BLOCK / length(STATIC_DIRECTIONS));
159-
160+
160161
for iMotionBlock = 1:NB_REPETITIONS
161-
162+
162163
% Check that we never have twice the same direction
163164
while 1
164165
tmp = [ ...
165166
shuffle(MOTION_DIRECTIONS), ...
166167
shuffle(MOTION_DIRECTIONS), ...
167168
shuffle(MOTION_DIRECTIONS)];
168-
169-
if ~any(diff(tmp,[],2)==0)
169+
170+
if ~any(diff(tmp, [], 2) == 0)
170171
break
171172
end
172173
end
173-
174+
174175
% Set motion direction and static order
175-
directions(motionIndex(iMotionBlock), :) = tmp;
176-
directions(staticIndex(iMotionBlock), :) = static_directions;
177-
176+
directions(MOTION_INDEX(iMotionBlock), :) = tmp;
177+
directions(STATIC_INDEX(iMotionBlock), :) = static_directions;
178+
178179
end
179-
180+
180181
cfg.design.directions = directions;
181-
182+
182183
end
183184

184185
function [nbBlocks, nbRepet, nbEventsBlock, maxTargBlock] = getInput(cfg)
@@ -188,16 +189,16 @@
188189
nbBlocks = length(cfg.design.names) * nbRepet;
189190
end
190191

191-
function [condition, staticIndex, motionIndex] = assignConditions(cfg)
192-
192+
function [condition, STATIC_INDEX, MOTION_INDEX] = assignConditions(cfg)
193+
193194
[~, nbRepet] = getInput(cfg);
194-
195+
195196
condition = repmat(cfg.design.names, nbRepet, 1);
196-
197+
197198
% Get the index of each condition
198-
staticIndex = find(strcmp(condition, 'static'));
199-
motionIndex = find(strcmp(condition, 'motion'));
200-
199+
STATIC_INDEX = find(strcmp(condition, 'static'));
200+
MOTION_INDEX = find(strcmp(condition, 'motion'));
201+
201202
end
202203

203204
function shuffled = shuffle(unshuffled)
@@ -210,67 +211,65 @@
210211
end
211212

212213
function diplayDesign(cfg, displayFigs)
213-
214+
214215
%% Visualize the design matrix
215216
if displayFigs
216-
217-
close all
217+
218+
close all;
218219

219220
figure(1);
220-
221+
221222
% Shows blocks (static and motion) and events (motion direction) order
222223
directions = cfg.design.directions;
223224
directions(directions == -1) = -90;
224-
225+
225226
subplot(3, 1, 1);
226227
imagesc(directions);
227-
228+
228229
labelAxesBlock();
229-
230+
230231
caxis([-90 - 37, 270 + 37]);
231232
myColorMap = lines(5);
232233
colormap(myColorMap);
233-
234+
234235
title('Block (static and motion) & Events (motion direction)');
235-
236+
236237
% Shows the fixation targets design in each event (1 or 0)
237238
fixationTargets = cfg.design.fixationTargets;
238-
239+
239240
subplot(3, 1, 2);
240241
imagesc(fixationTargets);
241242
labelAxesBlock();
242243
title('Fixation Targets design');
243244
colormap(gray);
244-
245+
245246
% Shows the fixation targets position distribution in the block across
246247
% the experimet
247248
[~, itargetPosition] = find(fixationTargets == 1);
248-
249+
249250
subplot(3, 1, 3);
250251
hist(itargetPosition);
251252
labelAxesFreq();
252253
title('Fixation Targets position distribution');
253-
254-
254+
255255
figure(2);
256-
256+
257257
MOTION_DIRECTIONS = [0 90 180 270];
258-
258+
259259
for iMotion = 1:length(MOTION_DIRECTIONS)
260-
260+
261261
[~, position] = find(directions == MOTION_DIRECTIONS(iMotion));
262-
262+
263263
subplot(2, 2, iMotion);
264264
hist(position);
265265
scaleAxes();
266266
labelAxesFreq();
267267
title(num2str(MOTION_DIRECTIONS(iMotion)));
268-
268+
269269
end
270-
271270

272271
end
273-
272+
274273
end
275274

276275
function labelAxesBlock()

0 commit comments

Comments
 (0)