44 %
55
66 switch action
7-
7+
88 case ' init'
9-
9+
1010 cfg = apertureInit(cfg );
11-
11+
1212 cfg.aperture.texture = Screen(' MakeTexture' , cfg .screen .win , ...
1313 cfg .color .background(1 ) * ones(cfg .screen .winRect([4 3 ])));
14-
14+
1515 case ' make'
16-
16+
1717 transparent = [0 , 0 , 0 , 0 ];
18-
18+
1919 xCenter = cfg .screen .center(1 );
2020 yCenter = cfg .screen .center(2 );
21-
21+
2222 switch cfg .aperture .type
23-
23+
2424 case ' none'
25-
25+
2626 Screen(' Fillrect' , cfg .aperture .texture , transparent );
27-
27+
2828 case ' circle'
29-
29+
3030 diameter = cfg .aperture .widthPix ;
31-
31+
3232 if isfield(cfg .aperture , ' xPosPix' )
3333 xCenter = cfg .screen .center(1 ) + cfg .aperture .xPosPix ;
3434 end
3535 if isfield(cfg .aperture , ' yPosPix' )
3636 yCenter = cfg .screen .center(2 ) + cfg .aperture .yPosPix ;
3737 end
38-
38+
3939 Screen(' FillOval' , cfg .aperture .texture , transparent , ...
4040 CenterRectOnPoint([0 , 0 , repmat(diameter , 1 , 2 )], ...
4141 xCenter , yCenter ));
42-
42+
4343 case ' ring'
44-
44+
4545 % expansion speed is log over eccentricity
4646 [cfg ] = eccenLogSpeed(cfg , thisEvent .time );
47-
47+
4848 Screen(' Fillrect' , cfg .aperture .texture , cfg .color .background );
49-
49+
5050 Screen(' FillOval' , cfg .aperture .texture , transparent , ...
5151 CenterRectOnPoint( ...
5252 [0 , 0 , repmat(cfg .ring .outerRimPix , 1 , 2 )], ...
5353 xCenter , yCenter ));
54-
54+
5555 Screen(' FillOval' , cfg .aperture .texture , [cfg .color .background 255 ], ...
5656 CenterRectOnPoint( ...
5757 [0 , 0 , repmat(cfg .ring .innerRimPix , 1 , 2 )], ...
5858 xCenter , yCenter ));
59-
59+
6060 case ' wedge'
61-
61+
6262 cycleDuration = cfg .mri .repetitionTime * cfg .volsPerCycle ;
63-
63+
6464 % Update angle for rotation of background and for apperture for wedge
6565 switch cfg .direction
66-
66+
6767 case ' +'
6868 thisEvent.angle = 90 - ...
6969 cfg .aperture .width / 2 + ...
7272 thisEvent.angle = 90 - ...
7373 cfg .aperture .width / 2 - ...
7474 (thisEvent .time / cycleDuration ) * 360 ;
75-
75+
7676 end
77-
77+
7878 Screen(' Fillrect' , cfg .aperture .texture , cfg .color .background );
79-
79+
8080 Screen(' FillArc' , cfg .aperture .texture , transparent , ...
8181 CenterRect( ...
8282 [0 , 0 , repmat(cfg .stimRect(4 ), 1 , 2 )], ...
8383 cfg .screen .winRect ), ...
8484 thisEvent .angle , ... % start angle
8585 cfg .aperture .width ); % arc angle
86-
86+
8787 case ' bar'
88-
88+
8989 % aperture is the color of the background
9090 Screen(' FillRect' , cfg .aperture .texture , cfg .color .background );
91-
91+
9292 % We let the stimulus through
9393 Screen(' FillOval' , cfg .aperture .texture , transparent , ...
9494 CenterRect([0 , 0 , repmat(cfg .stimRect(3 ), 1 , 2 )], cfg .screen .winRect ));
95-
95+
9696 % Then we add the position of the bar aperture
9797 Screen(' FillRect' , cfg .aperture .texture , cfg .color .background , ...
9898 [0 , ...
9999 0 , ...
100100 thisEvent .barPosPix - cfg .aperture .barWidthPix / 2 , ...
101101 cfg .screen .winRect(4 )]);
102-
102+
103103 Screen(' FillRect' , cfg .aperture .texture , cfg .color .background , ...
104104 [thisEvent .barPosPix + cfg .aperture .barWidthPix / 2 , ...
105105 0 , ...
106106 cfg .screen .winRect(3 ), ...
107107 cfg .screen .winRect(4 )]);
108108
109109 otherwise
110-
110+
111111 error(' unknown aperture type: %s .' , cfg .aperture .type );
112-
112+
113113 end
114-
114+
115115 case ' draw'
116-
116+
117117 if strcmp(cfg .aperture .type , ' bar' )
118-
118+
119119 % Draw aperture and we rotate to match the required condition
120120 Screen(' DrawTexture' , cfg .screen .win , cfg .aperture .texture , ...
121121 cfg .screen .winRect , ...
122122 cfg .screen .winRect , ...
123123 thisEvent .condition - 90 );
124124 else
125-
125+
126126 Screen(' DrawTexture' , cfg .screen .win , cfg .aperture .texture );
127-
128- end
129127
130-
128+ end
131129
132-
133130 end
134-
135- end
136131
132+ end
137133
138134function cfg = apertureInit(cfg )
139-
135+
140136 switch cfg .aperture .type
141-
137+
142138 case ' circle'
143139 % we take the screen height as maximum aperture width if not
144140 % specified.
145141 if ~isfield(cfg .aperture , ' width' ) || isempty(cfg .aperture .width )
146142 cfg.aperture.width = cfg .screen .winRect(4 ) / cfg .screen .ppd ;
147143 end
148144 cfg.aperture = degToPix(' width' , cfg .aperture , cfg );
149-
145+
150146 case ' ring'
151-
147+
152148 % Set parameters for rings
153149 if strcmp(cfg .aperture .type , ' ring' )
154150 % scale of outer ring (exceeding screen until
165161 log(cfg .ring .maxEcc + exp(1 )) - ...
166162 (cfg .ring .maxEcc + exp(1 ))) ;
167163 end
168-
164+
169165 case ' bar'
170-
166+
171167 % Set parameters drifting bars
172168 cfg.aperture.barWidthPix = cfg .stimRect(3 ) / cfg .volsPerCycle ;
173169 cfg.aperture.barPosPix = ...
174- [ 0 : cfg .aperture .barWidthPix : cfg .stimRect(3 ) - cfg .aperture .barWidthPix ] + ...
170+ [0 : cfg .aperture .barWidthPix : cfg .stimRect(3 ) - cfg .aperture .barWidthPix ] + ...
175171 (cfg .screen .winRect(3 ) / 2 - cfg .stimRect(3 ) / 2 ) + ...
176172 cfg .aperture .barWidthPix / 2 ; % #ok<NBRAK>
177-
173+
178174 % Width of bar in degrees of VA (needed for saving)
179175 cfg.aperture.width = cfg .aperture .barWidthPix / cfg .screen .ppd ;
180176 cfg.aperture.barPos = ...
181177 (cfg .aperture .barPosPix - cfg .screen .center(1 )) / ...
182178 cfg .screen .ppd ;
183-
179+
184180 end
185-
186- end
181+
182+ end
0 commit comments