Skip to content

Commit 89d79d6

Browse files
authored
Merge pull request #99 from cpp-lln-lab/remi-update_from_retinotopy
fix from retintotopy and allow to tweak skisynchtest
2 parents c33ae7f + 47fd27f commit 89d79d6

File tree

4 files changed

+129
-114
lines changed

4 files changed

+129
-114
lines changed

src/aperture/apertureTexture.m

Lines changed: 120 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -10,128 +10,29 @@
1010
cfg = apertureInit(cfg);
1111

1212
cfg.aperture.texture = Screen('MakeTexture', cfg.screen.win, ...
13-
cfg.color.background(1) * ones(cfg.screen.winRect([4 3])));
13+
cfg.color.background(1) * ones(cfg.screen.winRect([3 3])));
1414

1515
case 'make'
1616

17-
TRANSPARENT = [0, 0, 0, 0];
17+
cfg = apertureTextureMake(cfg, thisEvent);
1818

19-
xCenter = cfg.screen.center(1);
20-
yCenter = cfg.screen.center(2);
21-
22-
switch cfg.aperture.type
23-
24-
case 'none'
25-
26-
Screen('Fillrect', cfg.aperture.texture, TRANSPARENT);
27-
28-
case 'circle'
29-
30-
diameter = cfg.aperture.widthPix;
31-
32-
if isfield(cfg.aperture, 'xPosPix')
33-
xCenter = cfg.screen.center(1) + cfg.aperture.xPosPix;
34-
end
35-
if isfield(cfg.aperture, 'yPosPix')
36-
yCenter = cfg.screen.center(2) + cfg.aperture.yPosPix;
37-
end
38-
39-
Screen('FillOval', cfg.aperture.texture, TRANSPARENT, ...
40-
CenterRectOnPoint([0, 0, repmat(diameter, 1, 2)], ...
41-
xCenter, yCenter));
42-
43-
case 'ring'
44-
45-
% expansion speed is log over eccentricity
46-
[cfg] = eccenLogSpeed(cfg, thisEvent.time);
47-
48-
Screen('Fillrect', cfg.aperture.texture, cfg.color.background);
49-
50-
Screen('FillOval', cfg.aperture.texture, TRANSPARENT, ...
51-
CenterRectOnPoint( ...
52-
[0, 0, repmat(cfg.ring.outerRimPix, 1, 2)], ...
53-
xCenter, yCenter));
54-
55-
Screen('FillOval', cfg.aperture.texture, [cfg.color.background 255], ...
56-
CenterRectOnPoint( ...
57-
[0, 0, repmat(cfg.ring.innerRimPix, 1, 2)], ...
58-
xCenter, yCenter));
59-
60-
case 'wedge'
61-
62-
cycleDuration = cfg.mri.repetitionTime * cfg.volsPerCycle;
63-
64-
% Update angle for rotation of background and for apperture for wedge
65-
switch cfg.direction
66-
67-
case '+'
68-
thisEvent.angle = 90 - ...
69-
cfg.aperture.width / 2 + ...
70-
(thisEvent.time / cycleDuration) * 360;
71-
case '-'
72-
thisEvent.angle = 90 - ...
73-
cfg.aperture.width / 2 - ...
74-
(thisEvent.time / cycleDuration) * 360;
75-
76-
end
77-
78-
Screen('Fillrect', cfg.aperture.texture, cfg.color.background);
79-
80-
Screen('FillArc', cfg.aperture.texture, TRANSPARENT, ...
81-
CenterRect( ...
82-
[0, 0, repmat(cfg.stimRect(4), 1, 2)], ...
83-
cfg.screen.winRect), ...
84-
thisEvent.angle, ... % start angle
85-
cfg.aperture.width); % arc angle
86-
87-
case 'bar'
88-
89-
% aperture is the color of the background
90-
Screen('FillRect', cfg.aperture.texture, cfg.color.background);
91-
92-
% We let the stimulus through
93-
Screen('FillOval', cfg.aperture.texture, TRANSPARENT, ...
94-
CenterRect([0, 0, repmat(cfg.stimRect(3), 1, 2)], cfg.screen.winRect));
95-
96-
% Then we add the position of the bar aperture
97-
98-
% which one is the right and which one is the left??
99-
100-
Screen('FillRect', cfg.aperture.texture, cfg.color.background, ...
101-
[0, ...
102-
0, ...
103-
thisEvent.barPosPix - cfg.aperture.barWidthPix / 2, ...
104-
cfg.screen.winRect(4)]);
105-
106-
Screen('FillRect', cfg.aperture.texture, cfg.color.background, ...
107-
[thisEvent.barPosPix + cfg.aperture.barWidthPix / 2, ...
108-
0, ...
109-
cfg.screen.winRect(3), ...
110-
cfg.screen.winRect(4)]);
111-
112-
otherwise
113-
114-
error('unknown aperture type: %s.', cfg.aperture.type);
19+
case 'draw'
11520

21+
scalingFactor = 1;
22+
if isfield(cfg, 'scalingFactor') && ~isempty(cfg.scalingFactor)
23+
scalingFactor = cfg.scalingFactor;
11624
end
11725

118-
case 'draw'
119-
26+
rotationAngle = [];
12027
if strcmp(cfg.aperture.type, 'bar')
121-
122-
% Draw aperture and we rotate to match the required condition
123-
Screen('DrawTexture', cfg.screen.win, cfg.aperture.texture, ...
124-
cfg.screen.winRect, ...
125-
CenterRect( ...
126-
cfg.screen.winRect, ...
127-
cfg.screen.winRect), ...
128-
thisEvent.condition - 90);
129-
else
130-
131-
Screen('DrawTexture', cfg.screen.win, cfg.aperture.texture);
132-
28+
rotationAngle = thisEvent.condition - 90;
13329
end
13430

31+
Screen('DrawTexture', cfg.screen.win, cfg.aperture.texture, ...
32+
cfg.screen.winRect, ...
33+
CenterRect(cfg.screen.winRect * scalingFactor, cfg.screen.winRect), ...
34+
rotationAngle);
35+
13536
end
13637

13738
end
@@ -188,3 +89,110 @@
18889
end
18990

19091
end
92+
93+
function cfg = apertureTextureMake(cfg, thisEvent)
94+
95+
TRANSPARENT = [0, 0, 0, 0];
96+
97+
xCenter = cfg.screen.center(1);
98+
yCenter = cfg.screen.center(2);
99+
100+
switch cfg.aperture.type
101+
102+
case 'none'
103+
104+
Screen('Fillrect', cfg.aperture.texture, TRANSPARENT);
105+
106+
case 'circle'
107+
108+
diameter = cfg.aperture.widthPix;
109+
110+
if isfield(cfg.aperture, 'xPosPix')
111+
xCenter = xCenter + cfg.aperture.xPosPix;
112+
end
113+
if isfield(cfg.aperture, 'yPosPix')
114+
yCenter = yCenter + cfg.aperture.yPosPix;
115+
end
116+
117+
Screen('FillOval', cfg.aperture.texture, TRANSPARENT, ...
118+
CenterRectOnPoint([0, 0, repmat(diameter, 1, 2)], ...
119+
xCenter, yCenter));
120+
121+
case 'ring'
122+
123+
% expansion speed is log over eccentricity
124+
[cfg] = eccenLogSpeed(cfg, thisEvent.time);
125+
126+
Screen('Fillrect', cfg.aperture.texture, cfg.color.background);
127+
128+
Screen('FillOval', cfg.aperture.texture, TRANSPARENT, ...
129+
CenterRectOnPoint( ...
130+
[0, 0, repmat(cfg.ring.outerRimPix, 1, 2)], ...
131+
xCenter, yCenter));
132+
133+
Screen('FillOval', cfg.aperture.texture, [cfg.color.background 255], ...
134+
CenterRectOnPoint( ...
135+
[0, 0, repmat(cfg.ring.innerRimPix, 1, 2)], ...
136+
xCenter, yCenter));
137+
138+
case 'wedge'
139+
140+
cycleDuration = cfg.mri.repetitionTime * cfg.volsPerCycle;
141+
142+
% Update angle for rotation of background and for apperture for wedge
143+
switch cfg.direction
144+
145+
case '+'
146+
thisEvent.angle = 90 - ...
147+
cfg.aperture.width / 2 + ...
148+
(thisEvent.time / cycleDuration) * 360;
149+
case '-'
150+
thisEvent.angle = 90 - ...
151+
cfg.aperture.width / 2 - ...
152+
(thisEvent.time / cycleDuration) * 360;
153+
154+
end
155+
156+
Screen('Fillrect', cfg.aperture.texture, cfg.color.background);
157+
158+
Screen('FillArc', cfg.aperture.texture, TRANSPARENT, ...
159+
CenterRect( ...
160+
cfg.destinationRect, ...
161+
cfg.screen.winRect), ...
162+
thisEvent.angle, ... % start angle
163+
cfg.aperture.width); % arc angle
164+
165+
case 'bar'
166+
167+
% aperture is the color of the background
168+
Screen('FillRect', cfg.aperture.texture, cfg.color.background);
169+
170+
% We let the stimulus through
171+
Screen('FillOval', cfg.aperture.texture, TRANSPARENT, ...
172+
CenterRect( ...
173+
[0, 0, repmat(cfg.screen.winRect(4), 1, 2)], ...
174+
cfg.screen.winRect));
175+
176+
% Then we add the position of the bar aperture
177+
178+
% which one is the right and which one is the left??
179+
180+
Screen('FillRect', cfg.aperture.texture, cfg.color.background, ...
181+
[0, ...
182+
0, ...
183+
thisEvent.barPosPix - cfg.aperture.barWidthPix / 2, ...
184+
cfg.screen.winRect(4)]);
185+
186+
Screen('FillRect', cfg.aperture.texture, cfg.color.background, ...
187+
[thisEvent.barPosPix + cfg.aperture.barWidthPix / 2, ...
188+
0, ...
189+
cfg.screen.winRect(3), ...
190+
cfg.screen.winRect(4)]);
191+
192+
otherwise
193+
194+
error('unknown aperture type: %s.', cfg.aperture.type);
195+
196+
end
197+
198+
end

src/initPTB.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535

3636
cfg = setDefaultsPTB(cfg);
3737

38+
Screen('Preference', 'SkipSyncTests', cfg.skipSyncTests);
39+
3840
initKeyboard;
3941
initDebug(cfg);
4042

@@ -120,10 +122,11 @@
120122
function initDebug(cfg)
121123

122124
% init PTB with different options in concordance to the debug Parameters
123-
Screen('Preference', 'SkipSyncTests', 0);
125+
124126
if cfg.debug.do
125127

126-
Screen('Preference', 'SkipSyncTests', 2);
128+
cfg.skipSyncTests = 2;
129+
Screen('Preference', 'SkipSyncTests', cfg.skipSyncTests);
127130
Screen('Preference', 'Verbosity', 0);
128131
Screen('Preference', 'SuppressAllWarnings', 1);
129132

src/utils/setDefaultsPTB.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
%% list the default values
1111
fieldsToSet.testingDevice = 'pc';
1212

13+
fieldsToSet.skipSyncTests = 0;
14+
1315
% keyboard defaults
1416
fieldsToSet.keyboard.keyboard = [];
1517
fieldsToSet.keyboard.responseBox = [];

tests/test_setDefaultsPTB.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ function test_setDefaultsPtbAudio()
7070
expectedCFG.screen.monitorDistance = 134;
7171
expectedCFG.screen.resolution = {[], [], []};
7272

73+
expectedCFG.skipSyncTests = 0;
74+
7375
% fixation cross or dot
7476
expectedCFG.fixation.type = 'cross';
7577
expectedCFG.fixation.xDisplacement = 0;

0 commit comments

Comments
 (0)