|
1 | 1 | function [cfg, thisEvent] = apertureTexture(action, cfg, thisEvent) |
2 | | - |
| 2 | + |
3 | 3 | transparent = [0 0 0 0]; |
4 | | - |
| 4 | + |
5 | 5 | switch action |
6 | | - |
| 6 | + |
7 | 7 | case 'init' |
8 | | - |
| 8 | + |
9 | 9 | switch cfg.aperture.type |
10 | | - |
| 10 | + |
11 | 11 | case 'circle' |
12 | 12 | % we take the screen height as maximum aperture width if not |
13 | 13 | % specified. |
14 | 14 | if ~isfield(cfg.aperture, 'width') || isempty(cfg.aperture.width) |
15 | 15 | cfg.aperture.width = cfg.screen.winRect(4) / cfg.screen.ppd; |
16 | 16 | end |
17 | 17 | cfg.aperture = degToPix('width', cfg.aperture, cfg); |
18 | | - |
| 18 | + |
19 | 19 | case 'ring' |
20 | | - |
| 20 | + |
21 | 21 | % Set parameters for rings |
22 | | - if strcmp(cfg.aperture.type ,'ring') |
| 22 | + if strcmp(cfg.aperture.type, 'ring') |
23 | 23 | % scale of outer ring (exceeding screen until |
24 | 24 | % inner ring reaches window boarder) |
25 | 25 | cfg.ring.maxEcc = ... |
|
35 | 35 | (cfg.ring.maxEcc + exp(1))) ; |
36 | 36 | end |
37 | 37 | end |
38 | | - |
| 38 | + |
39 | 39 | cfg.aperture.texture = Screen('MakeTexture', cfg.screen.win, ... |
40 | 40 | cfg.color.background(1) * ones(cfg.screen.winRect([4 3]))); |
41 | | - |
| 41 | + |
42 | 42 | case 'make' |
43 | | - |
| 43 | + |
44 | 44 | xCenter = cfg.screen.center(1); |
45 | 45 | yCenter = cfg.screen.center(2); |
46 | | - |
| 46 | + |
47 | 47 | switch cfg.aperture.type |
48 | | - |
| 48 | + |
49 | 49 | case 'none' |
50 | | - |
| 50 | + |
51 | 51 | Screen('Fillrect', cfg.aperture.texture, transparent); |
52 | | - |
| 52 | + |
53 | 53 | case 'circle' |
54 | | - |
| 54 | + |
55 | 55 | diameter = cfg.aperture.widthPix; |
56 | | - |
| 56 | + |
57 | 57 | if isfield(cfg.aperture, 'xPosPix') |
58 | 58 | xCenter = cfg.screen.center(1) + cfg.aperture.xPosPix; |
59 | 59 | end |
60 | 60 | if isfield(cfg.aperture, 'yPosPix') |
61 | 61 | yCenter = cfg.screen.center(2) + cfg.aperture.yPosPix; |
62 | 62 | end |
63 | | - |
| 63 | + |
64 | 64 | Screen('FillOval', cfg.aperture.texture, transparent, ... |
65 | 65 | CenterRectOnPoint([0 0 repmat(diameter, 1, 2)], ... |
66 | 66 | xCenter, yCenter)); |
67 | | - |
| 67 | + |
68 | 68 | case 'ring' |
69 | | - |
| 69 | + |
70 | 70 | % expansion speed is log over eccentricity |
71 | 71 | [cfg] = eccenLogSpeed(cfg, thisEvent.time); |
72 | | - |
| 72 | + |
73 | 73 | Screen('Fillrect', cfg.aperture.texture, cfg.color.background); |
74 | | - |
| 74 | + |
75 | 75 | Screen('FillOval', cfg.aperture.texture, transparent, ... |
76 | 76 | CenterRectOnPoint( ... |
77 | 77 | [0 0 repmat(cfg.ring.outerRimPix, 1, 2)], ... |
78 | 78 | xCenter, yCenter)); |
79 | | - |
| 79 | + |
80 | 80 | Screen('FillOval', cfg.aperture.texture, [cfg.color.background 255], ... |
81 | 81 | CenterRectOnPoint( ... |
82 | 82 | [0 0 repmat(cfg.ring.innerRimPix, 1, 2)], ... |
83 | 83 | xCenter, yCenter)); |
84 | | - |
| 84 | + |
85 | 85 | case 'wedge' |
86 | | - |
| 86 | + |
87 | 87 | cycleDuration = cfg.mri.repetitionTime * cfg.volsPerCycle; |
88 | | - |
| 88 | + |
89 | 89 | % Update angle for rotation of background and for apperture for wedge |
90 | 90 | switch cfg.direction |
91 | | - |
| 91 | + |
92 | 92 | case '+' |
93 | 93 | thisEvent.angle = 90 - ... |
94 | 94 | cfg.aperture.width / 2 + ... |
|
97 | 97 | thisEvent.angle = 90 - ... |
98 | 98 | cfg.aperture.width / 2 - ... |
99 | 99 | (thisEvent.time / cycleDuration) * 360; |
100 | | - |
| 100 | + |
101 | 101 | end |
102 | | - |
| 102 | + |
103 | 103 | Screen('Fillrect', cfg.aperture.texture, cfg.color.background); |
104 | | - |
| 104 | + |
105 | 105 | Screen('FillArc', cfg.aperture.texture, transparent, ... |
106 | 106 | CenterRect( ... |
107 | 107 | [0 0 repmat(cfg.stimRect(4), 1, 2)], ... |
108 | 108 | cfg.screen.winRect), ... |
109 | 109 | thisEvent.angle, ... % start angle |
110 | 110 | cfg.aperture.width); % arc angle |
111 | | - |
112 | | - |
| 111 | + |
113 | 112 | otherwise |
114 | | - |
| 113 | + |
115 | 114 | error('unknown aperture type: %s.', cfg.aperture.type); |
116 | | - |
| 115 | + |
117 | 116 | end |
118 | | - |
| 117 | + |
119 | 118 | case 'draw' |
120 | | - |
| 119 | + |
121 | 120 | Screen('DrawTexture', cfg.screen.win, cfg.aperture.texture); |
122 | | - |
| 121 | + |
123 | 122 | % Screen('DrawTexture', cfg.screen.win, apertureTexture, ... |
124 | 123 | % cfg.screen.winRect, cfg.screen.winRect, current.apertureAngle - 90); |
125 | | - |
| 124 | + |
126 | 125 | end |
127 | | - |
| 126 | + |
128 | 127 | end |
0 commit comments