Skip to content

Commit 9da0729

Browse files
authored
Merge pull request #61 from cpp-lln-lab/remi-update_from_retinotopy
Updates from retinotopy
2 parents fce7479 + 0fed4ce commit 9da0729

15 files changed

+324
-144
lines changed

.travis.yml

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,10 @@ dist: bionic
55
cache:
66
apt: true # only works with Pro version
77

8-
env:
9-
global:
10-
- OCTFLAGS="--no-gui --no-window-system --silent"
11-
128
before_install:
13-
- travis_retry sudo apt-get -y -qq update
14-
- travis_retry sudo apt-get -y install octave
15-
- travis_retry sudo apt-get -y install liboctave-dev
169
- cd .. && git clone https://github.com/florianschanda/miss_hit.git && export PATH=$PATH:`pwd`/miss_hit && cd CPP_PTB
1710

18-
install:
19-
- octave $OCTFLAGS --eval "addpath (pwd); savepath ();"
20-
21-
before_script:
22-
# Change current directory
23-
- cd tests
24-
2511
jobs:
2612
include:
27-
- stage: "Tests and linter"
28-
name: "Unit Tests" # names the first job
29-
script: octave $OCTFLAGS --eval "results = runTests; assert(all(~[results.Failed]))"
30-
- script: cd .. && mh_style `pwd`
13+
- script: mh_style `pwd`
3114
name: "miss_hit linter" # names the second job

apertureTexture.m

Lines changed: 0 additions & 59 deletions
This file was deleted.

drawFixation.m

Lines changed: 61 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,69 @@
11
function drawFixation(cfg)
22
% Define the parameters of the fixation cross in `cfg` and `expParameters`
33

4-
if strcmp(cfg.fixation.type, 'cross')
4+
switch cfg.fixation.type
5+
case 'cross'
56

6-
smooth = 1;
7+
smooth = 1;
8+
9+
Screen('DrawLines', ...
10+
cfg.screen.win, ...
11+
cfg.fixation.allCoords, ...
12+
cfg.fixation.lineWidthPix, ...
13+
cfg.fixation.color, ...
14+
[cfg.screen.center(1) cfg.screen.center(2)], smooth);
15+
16+
case 'dot'
17+
18+
% Draw gap around fixation of 20% the size
19+
Screen('FillOval', ...
20+
cfg.screen.win, ...
21+
cfg.color.background, ...
22+
CenterRect( ...
23+
[0 0 repmat(1.2 * cfg.fixation.widthPix, 1, 2)], ...
24+
cfg.screen.winRect));
25+
26+
% Draw fixation
27+
Screen('FillOval', ...
28+
cfg.screen.win, ...
29+
cfg.color.foreground, ...
30+
CenterRect( ...
31+
[0 0 repmat(cfg.fixation.widthPix, 1, 2)], ...
32+
cfg.screen.winRect));
33+
34+
case 'bestFixation'
35+
36+
% Code adapted from:
37+
% What is the best fixation target?
38+
% DOI 10.1016/j.visres.2012.10.012
39+
40+
% Draw gap around fixation of 20% the size
41+
Screen('FillOval', ...
42+
cfg.screen.win, ...
43+
cfg.color.background, ...
44+
CenterRect( ...
45+
[0 0 repmat(1.5 * cfg.fixation.widthPix, 1, 2)], ...
46+
cfg.screen.winRect));
47+
48+
Screen('FillOval', ...
49+
cfg.screen.win, ...
50+
cfg.color.black, ...
51+
cfg.fixation.outerOval, ...
52+
cfg.fixation.widthPix);
53+
54+
Screen('DrawLines', ...
55+
cfg.screen.win, ...
56+
cfg.fixation.allCoords, ...
57+
cfg.fixation.widthPix / 3, ...
58+
cfg.color.white, ...
59+
[cfg.screen.center(1) cfg.screen.center(2)]);
60+
61+
Screen('FillOval', ...
62+
cfg.screen.win, ...
63+
cfg.color.black, ...
64+
cfg.fixation.innerOval, ...
65+
cfg.fixation.widthPix / 3);
766

8-
Screen('DrawLines', ...
9-
cfg.screen.win, ...
10-
cfg.fixation.allCoords, ...
11-
cfg.fixation.lineWidthPix, ...
12-
cfg.fixation.color, ...
13-
[cfg.screen.center(1) cfg.screen.center(2)], smooth);
1467
end
1568

1669
end

initFixation.m

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,38 @@
11
function cfg = initFixation(cfg)
22

3-
if strcmp(cfg.fixation.type, 'cross')
4-
5-
% Convert some values from degrees to pixels
6-
cfg.fixation = degToPix('width', cfg.fixation, cfg);
7-
cfg.fixation = degToPix('xDisplacement', cfg.fixation, cfg);
8-
cfg.fixation = degToPix('yDisplacement', cfg.fixation, cfg);
9-
10-
% Prepare fixation cross
11-
cfg.fixation.xCoords = [-cfg.fixation.widthPix cfg.fixation.widthPix 0 0] / 2 + ...
12-
cfg.fixation.xDisplacementPix;
13-
cfg.fixation.yCoords = [0 0 -cfg.fixation.widthPix cfg.fixation.widthPix] / 2 + ...
14-
cfg.fixation.yDisplacementPix;
15-
cfg.fixation.allCoords = [cfg.fixation.xCoords; cfg.fixation.yCoords];
3+
% Convert some values from degrees to pixels
4+
cfg.fixation = degToPix('width', cfg.fixation, cfg);
5+
cfg.fixation = degToPix('xDisplacement', cfg.fixation, cfg);
6+
cfg.fixation = degToPix('yDisplacement', cfg.fixation, cfg);
7+
8+
% Prepare fixation cross
9+
xLine = [-cfg.fixation.widthPix cfg.fixation.widthPix 0 0] / 2;
10+
yLine = [0 0 -cfg.fixation.widthPix cfg.fixation.widthPix] / 2;
11+
12+
cfg.fixation.xCoords = xLine + cfg.fixation.xDisplacementPix;
13+
cfg.fixation.yCoords = yLine + cfg.fixation.yDisplacementPix;
14+
15+
cfg.fixation.allCoords = [cfg.fixation.xCoords; cfg.fixation.yCoords];
16+
17+
switch cfg.fixation.type
18+
19+
case 'bestFixation'
20+
21+
% Code adapted from:
22+
% What is the best fixation target?
23+
% DOI 10.1016/j.visres.2012.10.012
24+
25+
cfg.fixation.outerOval = [ ...
26+
cfg.screen.center(1) - cfg.fixation.widthPix / 2, ...
27+
cfg.screen.center(2) - cfg.fixation.widthPix / 2, ...
28+
cfg.screen.center(1) + cfg.fixation.widthPix / 2, ...
29+
cfg.screen.center(2) + cfg.fixation.widthPix / 2];
30+
31+
cfg.fixation.innerOval = [ ...
32+
cfg.screen.center(1) - cfg.fixation.widthPix / 6, ...
33+
cfg.screen.center(2) - cfg.fixation.widthPix / 6, ...
34+
cfg.screen.center(1) + cfg.fixation.widthPix / 6, ...
35+
cfg.screen.center(2) + cfg.fixation.widthPix / 6];
1636

1737
end
1838

setDefaultsPTB.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
fieldsToSet.fixation.xDisplacement = 0;
3636
fieldsToSet.fixation.yDisplacement = 0;
3737
fieldsToSet.fixation.color = [255 255 255];
38-
fieldsToSet.fixation.width = 1;
38+
fieldsToSet.fixation.width = 1; % degrees of visual angle
3939
fieldsToSet.fixation.lineWidthPix = 5;
4040

4141
% define visual apperture field

src/aperture/apertureTexture.m

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
function [cfg, thisEvent] = apertureTexture(action, cfg, thisEvent)
2+
3+
transparent = [0 0 0 0];
4+
5+
switch action
6+
7+
case 'init'
8+
9+
switch cfg.aperture.type
10+
11+
case 'circle'
12+
% we take the screen height as maximum aperture width if not
13+
% specified.
14+
if ~isfield(cfg.aperture, 'width') || isempty(cfg.aperture.width)
15+
cfg.aperture.width = cfg.screen.winRect(4) / cfg.screen.ppd;
16+
end
17+
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
37+
end
38+
39+
cfg.aperture.texture = Screen('MakeTexture', cfg.screen.win, ...
40+
cfg.color.background(1) * ones(cfg.screen.winRect([4 3])));
41+
42+
case 'make'
43+
44+
xCenter = cfg.screen.center(1);
45+
yCenter = cfg.screen.center(2);
46+
47+
switch cfg.aperture.type
48+
49+
case 'none'
50+
51+
Screen('Fillrect', cfg.aperture.texture, transparent);
52+
53+
case 'circle'
54+
55+
diameter = cfg.aperture.widthPix;
56+
57+
if isfield(cfg.aperture, 'xPosPix')
58+
xCenter = cfg.screen.center(1) + cfg.aperture.xPosPix;
59+
end
60+
if isfield(cfg.aperture, 'yPosPix')
61+
yCenter = cfg.screen.center(2) + cfg.aperture.yPosPix;
62+
end
63+
64+
Screen('FillOval', cfg.aperture.texture, transparent, ...
65+
CenterRectOnPoint([0 0 repmat(diameter, 1, 2)], ...
66+
xCenter, yCenter));
67+
68+
case 'ring'
69+
70+
% expansion speed is log over eccentricity
71+
[cfg] = eccenLogSpeed(cfg, thisEvent.time);
72+
73+
Screen('Fillrect', cfg.aperture.texture, cfg.color.background);
74+
75+
Screen('FillOval', cfg.aperture.texture, transparent, ...
76+
CenterRectOnPoint( ...
77+
[0 0 repmat(cfg.ring.outerRimPix, 1, 2)], ...
78+
xCenter, yCenter));
79+
80+
Screen('FillOval', cfg.aperture.texture, [cfg.color.background 255], ...
81+
CenterRectOnPoint( ...
82+
[0 0 repmat(cfg.ring.innerRimPix, 1, 2)], ...
83+
xCenter, yCenter));
84+
85+
case 'wedge'
86+
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+
103+
Screen('Fillrect', cfg.aperture.texture, cfg.color.background);
104+
105+
Screen('FillArc', cfg.aperture.texture, transparent, ...
106+
CenterRect( ...
107+
[0 0 repmat(cfg.stimRect(4), 1, 2)], ...
108+
cfg.screen.winRect), ...
109+
thisEvent.angle, ... % start angle
110+
cfg.aperture.width); % arc angle
111+
112+
otherwise
113+
114+
error('unknown aperture type: %s.', cfg.aperture.type);
115+
116+
end
117+
118+
case 'draw'
119+
120+
Screen('DrawTexture', cfg.screen.win, cfg.aperture.texture);
121+
122+
% Screen('DrawTexture', cfg.screen.win, apertureTexture, ...
123+
% cfg.screen.winRect, cfg.screen.winRect, current.apertureAngle - 90);
124+
125+
end
126+
127+
end

0 commit comments

Comments
 (0)