Skip to content

Commit 01f3fb5

Browse files
committed
add more info and fix typos
1 parent 22e1735 commit 01f3fb5

File tree

3 files changed

+60
-58
lines changed

3 files changed

+60
-58
lines changed

Visual-loc_translational/subfun/doDotMo.m

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
% 0=Right; 90=Up; 180=Left; 270=down
66
%
77
% Input:
8-
% - Cfg: PTB/machine configurations returned by SetParameters and initPTB
9-
% - ExpParameters: parameters returned by SetParameters
10-
% - logFile: structur that stores the experiment logfile to be saved
8+
% - cfg: PTB/machine configurations returned by setParameters and initPTB
9+
% - expParameters: parameters returned by setParameters
10+
% - logFile: structure that stores the experiment logfile to be saved
1111
%
1212
% Output:
13-
% -
13+
% -
1414
%
1515
% The dots are drawn on a square that contains the round aperture, then any
1616
% dots outside of the aperture is turned into a NaN so effectively the
@@ -58,7 +58,7 @@
5858
% [1,1] is the bottom / right of the square that contains the square aperture
5959
xy = rand(ndots, 2);
6060

61-
% Set a N x 2 matrix that gives jump size in pixels
61+
% Set a N x 2 matrix that gives jump size in pixels
6262
% pix/sec * sec/frame = pix / frame
6363
dxdy = repmat(...
6464
speed * 10/(diamAperture*10) * (3/cfg.monRefresh) ...
@@ -84,69 +84,69 @@
8484
onset = vbl;
8585

8686
while continueShow
87-
87+
8888
% L are the dots that will be moved
8989
L = rand(ndots,1) < coh;
90-
90+
9191
% Move the selected dots
9292
xy(L,:) = xy(L,:) + dxdy(L,:);
93-
93+
9494
% If not 100% coherence, we get new random locations for the other dots
9595
if sum(~L) > 0
9696
xy(~L,:) = rand(sum(~L),2);
9797
end
98-
98+
9999
% Create a logical vector to detect any dot that has:
100100
% - an xy position inferior to 0
101101
% - an xy position superior to 1
102102
% - has exceeded its liftime
103103
N = any([xy > 1, xy < 0, dotTime > dotLifeTime], 2) ;
104-
104+
105105
% If there is any such dot we relocate it to a new random position
106106
% and change its lifetime to 1
107107
if any(N)
108108
xy(N,:) = rand(sum(N), 2);
109109
dotTime(N, 1) = 1;
110110
end
111-
111+
112112
% Convert the dot position to pixels
113113
xy_pix = floor( xy * diamAperturePix );
114-
114+
115115
% This assumes that zero is at the top left, but we want it to be
116116
% in the center, so shift the dots up and left, which just means
117117
% adding half of the aperture size to both the x and y direction.
118118
xy_pix = (xy_pix - diamAperturePix/2)';
119-
119+
120120
% NaN out-of-circle dots
121121
% We use Pythagore's theorem to figure out which dots are out of the
122122
% circle
123123
outCircle = sqrt(xy_pix(1,:).^2 + xy_pix(2,:).^2) + dotSizePix/2 > (diamAperturePix / 2);
124124
xy_pix(:, outCircle) = NaN;
125-
126-
125+
126+
127127
%% PTB draws the dots stimulation
128-
128+
129129
% Draw the fixation cross
130130
color = expParameters.fixationCrossColor;
131131
% If this frame shows a target we change the color
132132
if GetSecs < (onset+targetDuration) && isTarget==1
133133
color = expParameters.fixationCrossColorTarget;
134134
end
135135
drawFixationCross(cfg, expParameters, color)
136-
136+
137137
% Draw the dots
138138
Screen('DrawDots', cfg.win, xy_pix, dotSizePix, dotColor, cfg.center, 2);
139-
139+
140140
Screen('DrawingFinished', cfg.win, dontClear );
141-
141+
142142
vbl = Screen('Flip', cfg.win, vbl+cfg.ifi, dontClear );
143-
144-
143+
144+
145145
%% Update counters
146146

147147
% Check for end of loop
148148
continueShow = continueShow - 1;
149-
149+
150150
% Add one frame to the dot lifetime to each dot
151151
dotTime = dotTime + 1;
152152

Visual-loc_translational/subfun/expDesign.m

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
%
44
% The conditions are consecutive static and motion blocks (Gives better results than randomised).
55
%
6+
% It can be run as a stand alone without inputs to display a visual example of possible design.
7+
%
68
% EVENTS
79
% The numEventsPerBlock should be a multiple of the number of "base"
810
% listed in the motionDirections and staticDirections (4 at the moment).
@@ -22,12 +24,12 @@
2224
% - ExpParameters.designBlockNames = cell array (nr_blocks, 1) with the
2325
% name for each block
2426
%
25-
% - ExpParameters.designDirections = array (nr_blocks, numEventsPerBlock)
27+
% - ExpParameters.designDirections = array (nr_blocks, numEventsPerBlock)
2628
% with the direction to present in a given block
2729
% - 0 90 180 270 indicate the angle
2830
% - -1 indicates static
2931
%
30-
% - ExpParameters.designSpeeds = array (nr_blocks, numEventsPerBlock) * speedEvent;
32+
% - ExpParameters.designSpeeds = array (nr_blocks, numEventsPerBlock) * speedEvent
3133
%
3234
% - ExpParameters.designFixationTargets = array (nr_blocks, numEventsPerBlock)
3335
% showing for each event if it should be accompanied by a target
@@ -103,14 +105,14 @@
103105
expParameters.designFixationTargets = zeros(nrBlocks, numEventsPerBlock);
104106

105107
for iMotionBlock = 1:numRepetitions
106-
108+
107109
expParameters.designDirections( motionIndex(iMotionBlock), :) = Shuffle(motionDirections);
108110
expParameters.designDirections( staticIndex(iMotionBlock), :) = Shuffle(staticDirections);
109-
111+
110112
end
111113

112114
for iBlock = 1:nrBlocks
113-
115+
114116
% Set block name
115117
switch condition{iBlock}
116118
case 'static'
@@ -119,55 +121,55 @@
119121
thisBlockName = {'motion'};
120122
end
121123
expParameters.designBlockNames(iBlock) = thisBlockName;
122-
123-
124+
125+
124126
% set target
125127
% if there are 2 targets per block we make sure that they are at least
126128
% 2 events apart
127129
% targets cannot be on the first or last event of a block
128-
130+
129131
chosenTarget = [];
130-
132+
131133
tmpTarget = numTargets(iBlock);
132-
134+
133135
switch tmpTarget
134-
136+
135137
case 1
136-
138+
137139
chosenTarget = randsample(2:numEventsPerBlock-1, tmpTarget, false);
138-
140+
139141
case 2
140-
142+
141143
targetDifference = 0;
142-
144+
143145
while targetDifference <= 2
144146
chosenTarget = randsample(2:numEventsPerBlock-1, tmpTarget, false);
145147
targetDifference = (max(chosenTarget) - min(chosenTarget));
146-
end
147-
148+
end
149+
148150
end
149-
151+
150152
expParameters.designFixationTargets(iBlock, chosenTarget) = 1;
151-
153+
152154
end
153155

154156

155157
%% Visualize the design matrix
156158
if displayFigs
157-
159+
158160
uniqueNames = unique(expParameters.designBlockNames) ;
159-
161+
160162
Ind = zeros(length(expParameters.designBlockNames), length(uniqueNames)) ;
161-
163+
162164
for i = 1:length(uniqueNames)
163165
CondInd(:,i) = find(strcmp(expParameters.designBlockNames, uniqueNames{i})) ; %#ok<*AGROW>
164166
Ind(CondInd(:,i), i) = 1 ;
165167
end
166-
168+
167169
imagesc(Ind)
168-
170+
169171
set(gca, ...
170172
'XTick',1:length(uniqueNames),...
171173
'XTickLabel', uniqueNames)
172-
174+
173175
end
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
function wait4Trigger(Cfg)
22

33
if strcmp(Cfg.device,'Scanner')
4-
4+
55
fprintf('Waiting for trigger \n');
6-
6+
77
DrawFormattedText(Cfg.win,'Waiting For Trigger',...
88
'center', 'center', Cfg.textColor);
99
Screen('Flip', Cfg.win);
10-
10+
1111
triggerCounter=0;
12-
12+
1313
while triggerCounter < Cfg.numTriggers
1414

1515
[keyIsDown, ~, keyCode, ~] = KbCheck(-1);
16-
16+
1717
if strcmp(KbName(keyCode),Cfg.triggerKey)
18-
18+
1919
triggerCounter = triggerCounter+1 ;
20-
20+
2121
fprintf('Trigger %s \n', num2str(triggerCounter));
22-
22+
2323
DrawFormattedText(Cfg.win,['Trigger ',num2str(triggerCounter)],'center', 'center', Cfg.textColor);
2424
Screen('Flip', Cfg.win);
25-
25+
2626
while keyIsDown
2727
[keyIsDown, ~, ~, ~] = KbCheck(-1);
2828
end
29-
29+
3030
end
3131
end
3232
end
33-
end
33+
end

0 commit comments

Comments
 (0)