Skip to content

Commit 51a11e0

Browse files
committed
mh autofix
1 parent 71f5f77 commit 51a11e0

File tree

12 files changed

+113
-120
lines changed

12 files changed

+113
-120
lines changed

drawFixation.m

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,38 @@
11
function drawFixation(cfg)
22
% Define the parameters of the fixation cross in `cfg` and `expParameters`
3-
3+
44
switch cfg.fixation.type
55
case 'cross'
6-
6+
77
smooth = 1;
8-
8+
99
Screen('DrawLines', ...
1010
cfg.screen.win, ...
1111
cfg.fixation.allCoords, ...
1212
cfg.fixation.lineWidthPix, ...
1313
cfg.fixation.color, ...
1414
[cfg.screen.center(1) cfg.screen.center(2)], smooth);
15-
15+
1616
case 'dot'
17-
17+
1818
% Draw gap around fixation of 20% the size
1919
Screen('FillOval', ...
2020
cfg.screen.win, ...
2121
cfg.color.background, ...
2222
CenterRect( ...
2323
[0 0 repmat(1.2 * cfg.fixation.widthPix, 1, 2)], ...
2424
cfg.screen.winRect));
25-
25+
2626
% Draw fixation
2727
Screen('FillOval', ...
2828
cfg.screen.win, ...
2929
cfg.color.foreground, ...
3030
CenterRect( ...
3131
[0 0 repmat(cfg.fixation.widthPix, 1, 2)], ...
3232
cfg.screen.winRect));
33-
34-
33+
3534
case 'bestFixation'
36-
35+
3736
% Code adapted from:
3837
% What is the best fixation target?
3938
% DOI 10.1016/j.visres.2012.10.012
@@ -45,26 +44,26 @@ function drawFixation(cfg)
4544
CenterRect( ...
4645
[0 0 repmat(1.5 * cfg.fixation.widthPix, 1, 2)], ...
4746
cfg.screen.winRect));
48-
47+
4948
Screen('FillOval', ...
5049
cfg.screen.win, ...
5150
cfg.color.black, ...
5251
cfg.fixation.outerOval, ...
5352
cfg.fixation.widthPix);
54-
53+
5554
Screen('DrawLines', ...
5655
cfg.screen.win, ...
5756
cfg.fixation.allCoords, ...
5857
cfg.fixation.widthPix / 3, ...
5958
cfg.color.white, ...
6059
[cfg.screen.center(1) cfg.screen.center(2)]);
61-
60+
6261
Screen('FillOval', ...
6362
cfg.screen.win, ...
6463
cfg.color.black, ...
6564
cfg.fixation.innerOval, ...
6665
cfg.fixation.widthPix / 3);
6766

6867
end
69-
68+
7069
end

initFixation.m

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
function cfg = initFixation(cfg)
2-
2+
33
% Convert some values from degrees to pixels
44
cfg.fixation = degToPix('width', cfg.fixation, cfg);
55
cfg.fixation = degToPix('xDisplacement', cfg.fixation, cfg);
66
cfg.fixation = degToPix('yDisplacement', cfg.fixation, cfg);
7-
7+
88
% Prepare fixation cross
99
xLine = [-cfg.fixation.widthPix cfg.fixation.widthPix 0 0] / 2;
1010
yLine = [0 0 -cfg.fixation.widthPix cfg.fixation.widthPix] / 2;
11-
11+
1212
cfg.fixation.xCoords = xLine + cfg.fixation.xDisplacementPix;
1313
cfg.fixation.yCoords = yLine + cfg.fixation.yDisplacementPix;
14-
14+
1515
cfg.fixation.allCoords = [cfg.fixation.xCoords; cfg.fixation.yCoords];
16-
16+
1717
switch cfg.fixation.type
18-
18+
1919
case 'bestFixation'
20-
20+
2121
% Code adapted from:
2222
% What is the best fixation target?
2323
% DOI 10.1016/j.visres.2012.10.012
24-
25-
cfg.fixation.outerOval = [...
26-
cfg.screen.center(1)-cfg.fixation.widthPix/2, ...
27-
cfg.screen.center(2)-cfg.fixation.widthPix/2, ...
28-
cfg.screen.center(1)+cfg.fixation.widthPix/2, ...
29-
cfg.screen.center(2)+cfg.fixation.widthPix/2];
30-
31-
cfg.fixation.innerOval = [...
32-
cfg.screen.center(1)-cfg.fixation.widthPix/6, ...
33-
cfg.screen.center(2)-cfg.fixation.widthPix/6, ...
34-
cfg.screen.center(1)+cfg.fixation.widthPix/6, ...
35-
cfg.screen.center(2)+cfg.fixation.widthPix/6];
36-
24+
25+
cfg.fixation.outerOval = [ ...
26+
cfg.screen.center(1) - cfg.fixation.widthPix / 2, ...
27+
cfg.screen.center(2) - cfg.fixation.widthPix / 2, ...
28+
cfg.screen.center(1) + cfg.fixation.widthPix / 2, ...
29+
cfg.screen.center(2) + cfg.fixation.widthPix / 2];
30+
31+
cfg.fixation.innerOval = [ ...
32+
cfg.screen.center(1) - cfg.fixation.widthPix / 6, ...
33+
cfg.screen.center(2) - cfg.fixation.widthPix / 6, ...
34+
cfg.screen.center(1) + cfg.fixation.widthPix / 6, ...
35+
cfg.screen.center(2) + cfg.fixation.widthPix / 6];
36+
3737
end
38-
38+
3939
end

src/aperture/apertureTexture.m

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
function [cfg, thisEvent] = apertureTexture(action, cfg, thisEvent)
2-
2+
33
transparent = [0 0 0 0];
4-
4+
55
switch action
6-
6+
77
case 'init'
8-
8+
99
switch cfg.aperture.type
10-
10+
1111
case 'circle'
1212
% we take the screen height as maximum aperture width if not
1313
% specified.
1414
if ~isfield(cfg.aperture, 'width') || isempty(cfg.aperture.width)
1515
cfg.aperture.width = cfg.screen.winRect(4) / cfg.screen.ppd;
1616
end
1717
cfg.aperture = degToPix('width', cfg.aperture, cfg);
18-
18+
1919
case 'ring'
20-
20+
2121
% Set parameters for rings
22-
if strcmp(cfg.aperture.type ,'ring')
22+
if strcmp(cfg.aperture.type, 'ring')
2323
% scale of outer ring (exceeding screen until
2424
% inner ring reaches window boarder)
2525
cfg.ring.maxEcc = ...
@@ -35,60 +35,60 @@
3535
(cfg.ring.maxEcc + exp(1))) ;
3636
end
3737
end
38-
38+
3939
cfg.aperture.texture = Screen('MakeTexture', cfg.screen.win, ...
4040
cfg.color.background(1) * ones(cfg.screen.winRect([4 3])));
41-
41+
4242
case 'make'
43-
43+
4444
xCenter = cfg.screen.center(1);
4545
yCenter = cfg.screen.center(2);
46-
46+
4747
switch cfg.aperture.type
48-
48+
4949
case 'none'
50-
50+
5151
Screen('Fillrect', cfg.aperture.texture, transparent);
52-
52+
5353
case 'circle'
54-
54+
5555
diameter = cfg.aperture.widthPix;
56-
56+
5757
if isfield(cfg.aperture, 'xPosPix')
5858
xCenter = cfg.screen.center(1) + cfg.aperture.xPosPix;
5959
end
6060
if isfield(cfg.aperture, 'yPosPix')
6161
yCenter = cfg.screen.center(2) + cfg.aperture.yPosPix;
6262
end
63-
63+
6464
Screen('FillOval', cfg.aperture.texture, transparent, ...
6565
CenterRectOnPoint([0 0 repmat(diameter, 1, 2)], ...
6666
xCenter, yCenter));
67-
67+
6868
case 'ring'
69-
69+
7070
% expansion speed is log over eccentricity
7171
[cfg] = eccenLogSpeed(cfg, thisEvent.time);
72-
72+
7373
Screen('Fillrect', cfg.aperture.texture, cfg.color.background);
74-
74+
7575
Screen('FillOval', cfg.aperture.texture, transparent, ...
7676
CenterRectOnPoint( ...
7777
[0 0 repmat(cfg.ring.outerRimPix, 1, 2)], ...
7878
xCenter, yCenter));
79-
79+
8080
Screen('FillOval', cfg.aperture.texture, [cfg.color.background 255], ...
8181
CenterRectOnPoint( ...
8282
[0 0 repmat(cfg.ring.innerRimPix, 1, 2)], ...
8383
xCenter, yCenter));
84-
84+
8585
case 'wedge'
86-
86+
8787
cycleDuration = cfg.mri.repetitionTime * cfg.volsPerCycle;
88-
88+
8989
% Update angle for rotation of background and for apperture for wedge
9090
switch cfg.direction
91-
91+
9292
case '+'
9393
thisEvent.angle = 90 - ...
9494
cfg.aperture.width / 2 + ...
@@ -97,32 +97,31 @@
9797
thisEvent.angle = 90 - ...
9898
cfg.aperture.width / 2 - ...
9999
(thisEvent.time / cycleDuration) * 360;
100-
100+
101101
end
102-
102+
103103
Screen('Fillrect', cfg.aperture.texture, cfg.color.background);
104-
104+
105105
Screen('FillArc', cfg.aperture.texture, transparent, ...
106106
CenterRect( ...
107107
[0 0 repmat(cfg.stimRect(4), 1, 2)], ...
108108
cfg.screen.winRect), ...
109109
thisEvent.angle, ... % start angle
110110
cfg.aperture.width); % arc angle
111-
112-
111+
113112
otherwise
114-
113+
115114
error('unknown aperture type: %s.', cfg.aperture.type);
116-
115+
117116
end
118-
117+
119118
case 'draw'
120-
119+
121120
Screen('DrawTexture', cfg.screen.win, cfg.aperture.texture);
122-
121+
123122
% Screen('DrawTexture', cfg.screen.win, apertureTexture, ...
124123
% cfg.screen.winRect, cfg.screen.winRect, current.apertureAngle - 90);
125-
124+
126125
end
127-
126+
128127
end

src/aperture/eccenLogSpeed.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
case '+'
1717
% current visual angle linear in time
1818
outerRimVA = 0 + mod(time, cycleDuration) / cycleDuration * maxEcc;
19-
% ensure some foveal stimulation at beginning (which is hidden by
19+
% ensure some foveal stimulation at beginning (which is hidden by
2020
% fixation cross otherwise)
2121
if outerRimVA < cfg.fixation.size
2222
outerRimVA = cfg.fixation.size + .1;
@@ -47,7 +47,7 @@
4747
innerRimVA = 0;
4848
end
4949

50-
% in pixel
50+
% in pixel
5151
innerRimPix = innerRimVA * cfg.screen.ppd;
5252

5353
% update cfg that we are about to return

src/dot/computeCartCoord.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function cartesianCoordinates = computeCartCoord(positions, cfg)
22
cartesianCoordinates = ...
3-
[positions(:,1) + cfg.dot.matrixWidth, ... % x coordinate
4-
positions(:,2) + cfg.dot.matrixWidth]; % y coordinate
5-
6-
% cartesianCoordinates = positions;
7-
end
3+
[positions(:, 1) + cfg.dot.matrixWidth, ... % x coordinate
4+
positions(:, 2) + cfg.dot.matrixWidth]; % y coordinate
5+
6+
% cartesianCoordinates = positions;
7+
end
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
function angleMotion = computeRadialMotionDirection(cfg, dots)
2-
2+
33
cartesianCoordinates = computeCartCoord(dots.positions, cfg);
4-
4+
55
[angleMotion, ~] = cart2pol(cartesianCoordinates(:, 1), cartesianCoordinates(:, 2));
66
angleMotion = angleMotion / pi * 180;
7-
7+
88
if dots.direction == -666
99
angleMotion = angleMotion - 180;
1010
end
11-
12-
end
1311

12+
end

src/dot/generateNewDotPositions.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function newPositions = generateNewDotPositions(cfg, dotNumber)
2-
2+
33
newPositions = rand(dotNumber, 2) * cfg.dot.matrixWidth;
4-
5-
end
4+
5+
end

src/dot/initDots.m

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,3 @@
6464
dots.speedPixPerFrame = speedPixPerFrame;
6565

6666
end
67-
68-

0 commit comments

Comments
 (0)