|
10 | 10 | cfg = apertureInit(cfg); |
11 | 11 |
|
12 | 12 | 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]))); |
14 | 14 |
|
15 | 15 | case 'make' |
16 | 16 |
|
17 | | - TRANSPARENT = [0, 0, 0, 0]; |
| 17 | + cfg = apertureTextureMake(cfg, thisEvent); |
18 | 18 |
|
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' |
115 | 20 |
|
| 21 | + scalingFactor = 1; |
| 22 | + if isfield(cfg, 'scalingFactor') && ~isempty(cfg.scalingFactor) |
| 23 | + scalingFactor = cfg.scalingFactor; |
116 | 24 | end |
117 | 25 |
|
118 | | - case 'draw' |
119 | | - |
| 26 | + rotationAngle = []; |
120 | 27 | 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; |
133 | 29 | end |
134 | 30 |
|
| 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 | + |
135 | 36 | end |
136 | 37 |
|
137 | 38 | end |
|
188 | 89 | end |
189 | 90 |
|
190 | 91 | 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 |
0 commit comments