|
2 | 2 | % [cfg, thisEvent] = apertureTexture(action, cfg, thisEvent) |
3 | 3 | % |
4 | 4 | % |
5 | | - |
| 5 | + |
6 | 6 | switch action |
7 | | - |
| 7 | + |
8 | 8 | case 'init' |
9 | | - |
| 9 | + |
10 | 10 | cfg = apertureInit(cfg); |
11 | | - |
| 11 | + |
12 | 12 | cfg.aperture.texture = Screen('MakeTexture', cfg.screen.win, ... |
13 | 13 | cfg.color.background(1) * ones(cfg.screen.winRect([3 3]))); |
14 | | - |
| 14 | + |
15 | 15 | case 'make' |
16 | | - |
| 16 | + |
17 | 17 | TRANSPARENT = [0, 0, 0, 0]; |
18 | | - |
| 18 | + |
19 | 19 | xCenter = cfg.screen.center(1); |
20 | 20 | yCenter = cfg.screen.center(2); |
21 | | - |
| 21 | + |
22 | 22 | switch cfg.aperture.type |
23 | | - |
| 23 | + |
24 | 24 | case 'none' |
25 | | - |
| 25 | + |
26 | 26 | Screen('Fillrect', cfg.aperture.texture, TRANSPARENT); |
27 | | - |
| 27 | + |
28 | 28 | case 'circle' |
29 | | - |
| 29 | + |
30 | 30 | diameter = cfg.aperture.widthPix; |
31 | | - |
| 31 | + |
32 | 32 | if isfield(cfg.aperture, 'xPosPix') |
33 | 33 | xCenter = cfg.screen.center(1) + cfg.aperture.xPosPix; |
34 | 34 | end |
35 | 35 | if isfield(cfg.aperture, 'yPosPix') |
36 | 36 | yCenter = cfg.screen.center(2) + cfg.aperture.yPosPix; |
37 | 37 | end |
38 | | - |
| 38 | + |
39 | 39 | Screen('FillOval', cfg.aperture.texture, TRANSPARENT, ... |
40 | 40 | CenterRectOnPoint([0, 0, repmat(diameter, 1, 2)], ... |
41 | 41 | xCenter, yCenter)); |
42 | | - |
| 42 | + |
43 | 43 | case 'ring' |
44 | | - |
| 44 | + |
45 | 45 | % expansion speed is log over eccentricity |
46 | 46 | [cfg] = eccenLogSpeed(cfg, thisEvent.time); |
47 | | - |
| 47 | + |
48 | 48 | Screen('Fillrect', cfg.aperture.texture, cfg.color.background); |
49 | | - |
| 49 | + |
50 | 50 | Screen('FillOval', cfg.aperture.texture, TRANSPARENT, ... |
51 | 51 | CenterRectOnPoint( ... |
52 | 52 | [0, 0, repmat(cfg.ring.outerRimPix, 1, 2)], ... |
53 | 53 | xCenter, yCenter)); |
54 | | - |
| 54 | + |
55 | 55 | Screen('FillOval', cfg.aperture.texture, [cfg.color.background 255], ... |
56 | 56 | CenterRectOnPoint( ... |
57 | 57 | [0, 0, repmat(cfg.ring.innerRimPix, 1, 2)], ... |
58 | 58 | xCenter, yCenter)); |
59 | | - |
| 59 | + |
60 | 60 | case 'wedge' |
61 | | - |
| 61 | + |
62 | 62 | cycleDuration = cfg.mri.repetitionTime * cfg.volsPerCycle; |
63 | | - |
| 63 | + |
64 | 64 | % Update angle for rotation of background and for apperture for wedge |
65 | 65 | switch cfg.direction |
66 | | - |
| 66 | + |
67 | 67 | case '+' |
68 | 68 | thisEvent.angle = 90 - ... |
69 | 69 | cfg.aperture.width / 2 + ... |
|
72 | 72 | thisEvent.angle = 90 - ... |
73 | 73 | cfg.aperture.width / 2 - ... |
74 | 74 | (thisEvent.time / cycleDuration) * 360; |
75 | | - |
| 75 | + |
76 | 76 | end |
77 | | - |
| 77 | + |
78 | 78 | Screen('Fillrect', cfg.aperture.texture, cfg.color.background); |
79 | | - |
| 79 | + |
80 | 80 | Screen('FillArc', cfg.aperture.texture, TRANSPARENT, ... |
81 | 81 | CenterRect( ... |
82 | 82 | cfg.destinationRect, ... |
83 | 83 | cfg.screen.winRect), ... |
84 | 84 | thisEvent.angle, ... % start angle |
85 | 85 | cfg.aperture.width); % arc angle |
86 | | - |
| 86 | + |
87 | 87 | case 'bar' |
88 | | - |
| 88 | + |
89 | 89 | % aperture is the color of the background |
90 | 90 | Screen('FillRect', cfg.aperture.texture, cfg.color.background); |
91 | | - |
| 91 | + |
92 | 92 | % We let the stimulus through |
93 | 93 | Screen('FillOval', cfg.aperture.texture, TRANSPARENT, ... |
94 | 94 | CenterRect( ... |
95 | 95 | [0, 0, repmat(cfg.screen.winRect(4), 1, 2)], ... |
96 | 96 | cfg.screen.winRect)); |
97 | | - |
| 97 | + |
98 | 98 | % Then we add the position of the bar aperture |
99 | | - |
| 99 | + |
100 | 100 | % which one is the right and which one is the left?? |
101 | | - |
| 101 | + |
102 | 102 | Screen('FillRect', cfg.aperture.texture, cfg.color.background, ... |
103 | 103 | [0, ... |
104 | 104 | 0, ... |
105 | 105 | thisEvent.barPosPix - cfg.aperture.barWidthPix / 2, ... |
106 | 106 | cfg.screen.winRect(4)]); |
107 | | - |
| 107 | + |
108 | 108 | Screen('FillRect', cfg.aperture.texture, cfg.color.background, ... |
109 | 109 | [thisEvent.barPosPix + cfg.aperture.barWidthPix / 2, ... |
110 | 110 | 0, ... |
111 | 111 | cfg.screen.winRect(3), ... |
112 | 112 | cfg.screen.winRect(4)]); |
113 | | - |
| 113 | + |
114 | 114 | otherwise |
115 | | - |
| 115 | + |
116 | 116 | error('unknown aperture type: %s.', cfg.aperture.type); |
117 | | - |
| 117 | + |
118 | 118 | end |
119 | | - |
| 119 | + |
120 | 120 | case 'draw' |
121 | | - |
| 121 | + |
122 | 122 | scalingFactor = 1; |
123 | 123 | if isfield(cfg, 'scalingFactor') && ~isempty(cfg.scalingFactor) |
124 | 124 | scalingFactor = cfg.scalingFactor; |
125 | 125 | end |
126 | | - |
| 126 | + |
127 | 127 | rotationAngle = []; |
128 | 128 | if strcmp(cfg.aperture.type, 'bar') |
129 | | - rotationAngle = thisEvent.condition - 90; |
| 129 | + rotationAngle = thisEvent.condition - 90; |
130 | 130 | end |
131 | | - |
| 131 | + |
132 | 132 | Screen('DrawTexture', cfg.screen.win, cfg.aperture.texture, ... |
133 | 133 | cfg.screen.winRect, ... |
134 | 134 | CenterRect(cfg.screen.winRect * scalingFactor, cfg.screen.winRect), ... |
135 | 135 | rotationAngle); |
136 | | - |
| 136 | + |
137 | 137 | end |
138 | | - |
| 138 | + |
139 | 139 | end |
140 | 140 |
|
141 | 141 | function cfg = apertureInit(cfg) |
142 | | - |
| 142 | + |
143 | 143 | switch cfg.aperture.type |
144 | | - |
| 144 | + |
145 | 145 | case 'circle' |
146 | 146 | % we take the screen height as maximum aperture width if not |
147 | 147 | % specified. |
148 | 148 | if ~isfield(cfg.aperture, 'width') || isempty(cfg.aperture.width) |
149 | 149 | cfg.aperture.width = cfg.screen.winRect(4) / cfg.screen.ppd; |
150 | 150 | end |
151 | 151 | cfg.aperture = degToPix('width', cfg.aperture, cfg); |
152 | | - |
| 152 | + |
153 | 153 | case 'ring' |
154 | | - |
| 154 | + |
155 | 155 | % Set parameters for rings |
156 | 156 | if strcmp(cfg.aperture.type, 'ring') |
157 | 157 | % scale of outer ring (exceeding screen until |
|
168 | 168 | log(cfg.ring.maxEcc + exp(1)) - ... |
169 | 169 | (cfg.ring.maxEcc + exp(1))); |
170 | 170 | end |
171 | | - |
| 171 | + |
172 | 172 | case 'bar' |
173 | | - |
| 173 | + |
174 | 174 | % Set parameters drifting bars |
175 | 175 | cfg.aperture.barWidthPix = cfg.stimRect(3) / cfg.volsPerCycle; |
176 | | - |
| 176 | + |
177 | 177 | barPosPix = ... |
178 | 178 | [0:cfg.aperture.barWidthPix:cfg.stimRect(3) - cfg.aperture.barWidthPix] + ... |
179 | 179 | (cfg.screen.winRect(3) / 2 - cfg.stimRect(3) / 2) + ... |
180 | 180 | cfg.aperture.barWidthPix / 2; %#ok<NBRAK> |
181 | | - |
| 181 | + |
182 | 182 | cfg.aperture.barPosPix = barPosPix; |
183 | | - |
| 183 | + |
184 | 184 | % Width of bar in degrees of VA (needed for saving) |
185 | 185 | cfg.aperture.width = cfg.aperture.barWidthPix / cfg.screen.ppd; |
186 | 186 | cfg.aperture.barPos = ... |
187 | 187 | (cfg.aperture.barPosPix - cfg.screen.center(1)) / ... |
188 | 188 | cfg.screen.ppd; |
189 | | - |
| 189 | + |
190 | 190 | end |
191 | | - |
| 191 | + |
192 | 192 | end |
0 commit comments