Skip to content

Commit cb32a6f

Browse files
committed
update files from retinotopy aperture refactoring
1 parent 089abb1 commit cb32a6f

File tree

2 files changed

+100
-1
lines changed

2 files changed

+100
-1
lines changed

apertureTexture.m renamed to src/aperture/apertureTexture.m

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function cfg = apertureTexture(action, cfg, thisEvent)
1+
function [cfg, thisEvent] = apertureTexture(action, cfg, thisEvent)
22

33
transparent = [0 0 0 0];
44

@@ -15,6 +15,25 @@
1515
cfg.aperture.width = cfg.screen.winRect(4) / cfg.screen.ppd;
1616
end
1717
cfg.aperture = degToPix('width', cfg.aperture, cfg);
18+
19+
case 'ring'
20+
21+
% Set parameters for rings
22+
if strcmp(cfg.aperture.type ,'ring')
23+
% scale of outer ring (exceeding screen until
24+
% inner ring reaches window boarder)
25+
cfg.ring.maxEcc = ...
26+
cfg.screen.FOV / 2 + ...
27+
cfg.aperture.width + ...
28+
log(cfg.screen.FOV / 2 + 1) ;
29+
% ring.CsFuncFact is used to expand with log increasing speed so
30+
% that ring is at ring.maxEcc at end of cycle
31+
cfg.ring.csFuncFact = ...
32+
1 / ...
33+
((cfg.ring.maxEcc + exp(1)) * ...
34+
log(cfg.ring.maxEcc + exp(1)) - ...
35+
(cfg.ring.maxEcc + exp(1))) ;
36+
end
1837
end
1938

2039
cfg.aperture.texture = Screen('MakeTexture', cfg.screen.win, ...
@@ -48,6 +67,9 @@
4867

4968
case 'ring'
5069

70+
% expansion speed is log over eccentricity
71+
[cfg] = eccenLogSpeed(cfg, thisEvent.time);
72+
5173
Screen('Fillrect', cfg.aperture.texture, cfg.color.background);
5274

5375
Screen('FillOval', cfg.aperture.texture, transparent, ...
@@ -62,6 +84,22 @@
6284

6385
case 'wedge'
6486

87+
cycleDuration = cfg.mri.repetitionTime * cfg.volsPerCycle;
88+
89+
% Update angle for rotation of background and for apperture for wedge
90+
switch cfg.direction
91+
92+
case '+'
93+
thisEvent.angle = 90 - ...
94+
cfg.aperture.width / 2 + ...
95+
(thisEvent.time / cycleDuration) * 360;
96+
case '-'
97+
thisEvent.angle = 90 - ...
98+
cfg.aperture.width / 2 - ...
99+
(thisEvent.time / cycleDuration) * 360;
100+
101+
end
102+
65103
Screen('Fillrect', cfg.aperture.texture, cfg.color.background);
66104

67105
Screen('FillArc', cfg.aperture.texture, transparent, ...

src/aperture/eccenLogSpeed.m

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
function [cfg] = eccenLogSpeed(cfg, time)
2+
% vary CurrScale so that expansion speed is log over eccentricity
3+
% cf. Tootell 1997; Swisher 2007; Warnking 2002 etc
4+
5+
TR = cfg.mri.repetitionTime;
6+
cycleDuration = TR * cfg.volsPerCycle;
7+
8+
% CurrScale only influences ring
9+
if strcmp(cfg.aperture.type, 'ring')
10+
11+
csFuncFact = cfg.ring.csFuncFact;
12+
ringWidthVA = cfg.ring.ringWidthVA;
13+
maxEcc = cfg.ring.maxEcc;
14+
15+
switch cfg.direction
16+
case '+'
17+
% current visual angle linear in time
18+
outerRimVA = 0 + mod(time, cycleDuration) / cycleDuration * maxEcc;
19+
% ensure some foveal stimulation at beginning (which is hidden by
20+
% fixation cross otherwise)
21+
if outerRimVA < cfg.fixation.size
22+
outerRimVA = cfg.fixation.size + .1;
23+
end
24+
case '-'
25+
outerRimVA = maxEcc - mod(time, cycleDuration) / cycleDuration * maxEcc;
26+
if outerRimVA > maxEcc
27+
outerRimVA = maxEcc;
28+
end
29+
end
30+
31+
% near-exp visual angle
32+
newOuterRimVA = ((outerRimVA + exp(1)) * log(outerRimVA + exp(1)) - ...
33+
(outerRimVA + exp(1))) * maxEcc * csFuncFact;
34+
outerRimPix = newOuterRimVA * cfg.screen.ppd; % in pixel
35+
36+
% width of apperture changes logarithmically with eccentricity of inner ring
37+
oldScaleInnerVA = outerRimVA - ringWidthVA;
38+
if oldScaleInnerVA < 0
39+
oldScaleInnerVA = 0;
40+
end
41+
42+
% growing with inner ring ecc
43+
ringWidthVA = cfg.aperture.width + log(oldScaleInnerVA + 1);
44+
innerRimVA = newOuterRimVA - ringWidthVA;
45+
46+
if innerRimVA < 0
47+
innerRimVA = 0;
48+
end
49+
50+
% in pixel
51+
innerRimPix = innerRimVA * cfg.screen.ppd;
52+
53+
% update cfg that we are about to return
54+
cfg.ring.outerRimPix = outerRimPix;
55+
cfg.ring.innerRimPix = innerRimPix;
56+
cfg.ring.ring_outer_rim = newOuterRimVA;
57+
cfg.ring.ring_inner_rim = innerRimVA;
58+
59+
end
60+
61+
end

0 commit comments

Comments
 (0)