Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,10 @@ dist: bionic
cache:
apt: true # only works with Pro version

env:
global:
- OCTFLAGS="--no-gui --no-window-system --silent"

before_install:
- travis_retry sudo apt-get -y -qq update
- travis_retry sudo apt-get -y install octave
- travis_retry sudo apt-get -y install liboctave-dev
- cd .. && git clone https://github.com/florianschanda/miss_hit.git && export PATH=$PATH:`pwd`/miss_hit && cd CPP_PTB

install:
- octave $OCTFLAGS --eval "addpath (pwd); savepath ();"

before_script:
# Change current directory
- cd tests

jobs:
include:
- stage: "Tests and linter"
name: "Unit Tests" # names the first job
script: octave $OCTFLAGS --eval "results = runTests; assert(all(~[results.Failed]))"
- script: cd .. && mh_style `pwd`
- script: mh_style `pwd`
name: "miss_hit linter" # names the second job
59 changes: 0 additions & 59 deletions apertureTexture.m

This file was deleted.

69 changes: 61 additions & 8 deletions drawFixation.m
Original file line number Diff line number Diff line change
@@ -1,16 +1,69 @@
function drawFixation(cfg)
% Define the parameters of the fixation cross in `cfg` and `expParameters`

if strcmp(cfg.fixation.type, 'cross')
switch cfg.fixation.type
case 'cross'

smooth = 1;
smooth = 1;

Screen('DrawLines', ...
cfg.screen.win, ...
cfg.fixation.allCoords, ...
cfg.fixation.lineWidthPix, ...
cfg.fixation.color, ...
[cfg.screen.center(1) cfg.screen.center(2)], smooth);

case 'dot'

% Draw gap around fixation of 20% the size
Screen('FillOval', ...
cfg.screen.win, ...
cfg.color.background, ...
CenterRect( ...
[0 0 repmat(1.2 * cfg.fixation.widthPix, 1, 2)], ...
cfg.screen.winRect));

% Draw fixation
Screen('FillOval', ...
cfg.screen.win, ...
cfg.color.foreground, ...
CenterRect( ...
[0 0 repmat(cfg.fixation.widthPix, 1, 2)], ...
cfg.screen.winRect));

case 'bestFixation'

% Code adapted from:
% What is the best fixation target?
% DOI 10.1016/j.visres.2012.10.012

% Draw gap around fixation of 20% the size
Screen('FillOval', ...
cfg.screen.win, ...
cfg.color.background, ...
CenterRect( ...
[0 0 repmat(1.5 * cfg.fixation.widthPix, 1, 2)], ...
cfg.screen.winRect));

Screen('FillOval', ...
cfg.screen.win, ...
cfg.color.black, ...
cfg.fixation.outerOval, ...
cfg.fixation.widthPix);

Screen('DrawLines', ...
cfg.screen.win, ...
cfg.fixation.allCoords, ...
cfg.fixation.widthPix / 3, ...
cfg.color.white, ...
[cfg.screen.center(1) cfg.screen.center(2)]);

Screen('FillOval', ...
cfg.screen.win, ...
cfg.color.black, ...
cfg.fixation.innerOval, ...
cfg.fixation.widthPix / 3);

Screen('DrawLines', ...
cfg.screen.win, ...
cfg.fixation.allCoords, ...
cfg.fixation.lineWidthPix, ...
cfg.fixation.color, ...
[cfg.screen.center(1) cfg.screen.center(2)], smooth);
end

end
46 changes: 33 additions & 13 deletions initFixation.m
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
function cfg = initFixation(cfg)

if strcmp(cfg.fixation.type, 'cross')

% Convert some values from degrees to pixels
cfg.fixation = degToPix('width', cfg.fixation, cfg);
cfg.fixation = degToPix('xDisplacement', cfg.fixation, cfg);
cfg.fixation = degToPix('yDisplacement', cfg.fixation, cfg);

% Prepare fixation cross
cfg.fixation.xCoords = [-cfg.fixation.widthPix cfg.fixation.widthPix 0 0] / 2 + ...
cfg.fixation.xDisplacementPix;
cfg.fixation.yCoords = [0 0 -cfg.fixation.widthPix cfg.fixation.widthPix] / 2 + ...
cfg.fixation.yDisplacementPix;
cfg.fixation.allCoords = [cfg.fixation.xCoords; cfg.fixation.yCoords];
% Convert some values from degrees to pixels
cfg.fixation = degToPix('width', cfg.fixation, cfg);
cfg.fixation = degToPix('xDisplacement', cfg.fixation, cfg);
cfg.fixation = degToPix('yDisplacement', cfg.fixation, cfg);

% Prepare fixation cross
xLine = [-cfg.fixation.widthPix cfg.fixation.widthPix 0 0] / 2;
yLine = [0 0 -cfg.fixation.widthPix cfg.fixation.widthPix] / 2;

cfg.fixation.xCoords = xLine + cfg.fixation.xDisplacementPix;
cfg.fixation.yCoords = yLine + cfg.fixation.yDisplacementPix;

cfg.fixation.allCoords = [cfg.fixation.xCoords; cfg.fixation.yCoords];

switch cfg.fixation.type

case 'bestFixation'

% Code adapted from:
% What is the best fixation target?
% DOI 10.1016/j.visres.2012.10.012

cfg.fixation.outerOval = [ ...
cfg.screen.center(1) - cfg.fixation.widthPix / 2, ...
cfg.screen.center(2) - cfg.fixation.widthPix / 2, ...
cfg.screen.center(1) + cfg.fixation.widthPix / 2, ...
cfg.screen.center(2) + cfg.fixation.widthPix / 2];

cfg.fixation.innerOval = [ ...
cfg.screen.center(1) - cfg.fixation.widthPix / 6, ...
cfg.screen.center(2) - cfg.fixation.widthPix / 6, ...
cfg.screen.center(1) + cfg.fixation.widthPix / 6, ...
cfg.screen.center(2) + cfg.fixation.widthPix / 6];

end

Expand Down
2 changes: 1 addition & 1 deletion setDefaultsPTB.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
fieldsToSet.fixation.xDisplacement = 0;
fieldsToSet.fixation.yDisplacement = 0;
fieldsToSet.fixation.color = [255 255 255];
fieldsToSet.fixation.width = 1;
fieldsToSet.fixation.width = 1; % degrees of visual angle
fieldsToSet.fixation.lineWidthPix = 5;

% define visual apperture field
Expand Down
127 changes: 127 additions & 0 deletions src/aperture/apertureTexture.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
function [cfg, thisEvent] = apertureTexture(action, cfg, thisEvent)

transparent = [0 0 0 0];

switch action

case 'init'

switch cfg.aperture.type

case 'circle'
% we take the screen height as maximum aperture width if not
% specified.
if ~isfield(cfg.aperture, 'width') || isempty(cfg.aperture.width)
cfg.aperture.width = cfg.screen.winRect(4) / cfg.screen.ppd;
end
cfg.aperture = degToPix('width', cfg.aperture, cfg);

case 'ring'

% Set parameters for rings
if strcmp(cfg.aperture.type, 'ring')
% scale of outer ring (exceeding screen until
% inner ring reaches window boarder)
cfg.ring.maxEcc = ...
cfg.screen.FOV / 2 + ...
cfg.aperture.width + ...
log(cfg.screen.FOV / 2 + 1) ;
% ring.CsFuncFact is used to expand with log increasing speed so
% that ring is at ring.maxEcc at end of cycle
cfg.ring.csFuncFact = ...
1 / ...
((cfg.ring.maxEcc + exp(1)) * ...
log(cfg.ring.maxEcc + exp(1)) - ...
(cfg.ring.maxEcc + exp(1))) ;
end
end

cfg.aperture.texture = Screen('MakeTexture', cfg.screen.win, ...
cfg.color.background(1) * ones(cfg.screen.winRect([4 3])));

case 'make'

xCenter = cfg.screen.center(1);
yCenter = cfg.screen.center(2);

switch cfg.aperture.type

case 'none'

Screen('Fillrect', cfg.aperture.texture, transparent);

case 'circle'

diameter = cfg.aperture.widthPix;

if isfield(cfg.aperture, 'xPosPix')
xCenter = cfg.screen.center(1) + cfg.aperture.xPosPix;
end
if isfield(cfg.aperture, 'yPosPix')
yCenter = cfg.screen.center(2) + cfg.aperture.yPosPix;
end

Screen('FillOval', cfg.aperture.texture, transparent, ...
CenterRectOnPoint([0 0 repmat(diameter, 1, 2)], ...
xCenter, yCenter));

case 'ring'

% expansion speed is log over eccentricity
[cfg] = eccenLogSpeed(cfg, thisEvent.time);

Screen('Fillrect', cfg.aperture.texture, cfg.color.background);

Screen('FillOval', cfg.aperture.texture, transparent, ...
CenterRectOnPoint( ...
[0 0 repmat(cfg.ring.outerRimPix, 1, 2)], ...
xCenter, yCenter));

Screen('FillOval', cfg.aperture.texture, [cfg.color.background 255], ...
CenterRectOnPoint( ...
[0 0 repmat(cfg.ring.innerRimPix, 1, 2)], ...
xCenter, yCenter));

case 'wedge'

cycleDuration = cfg.mri.repetitionTime * cfg.volsPerCycle;

% Update angle for rotation of background and for apperture for wedge
switch cfg.direction

case '+'
thisEvent.angle = 90 - ...
cfg.aperture.width / 2 + ...
(thisEvent.time / cycleDuration) * 360;
case '-'
thisEvent.angle = 90 - ...
cfg.aperture.width / 2 - ...
(thisEvent.time / cycleDuration) * 360;

end

Screen('Fillrect', cfg.aperture.texture, cfg.color.background);

Screen('FillArc', cfg.aperture.texture, transparent, ...
CenterRect( ...
[0 0 repmat(cfg.stimRect(4), 1, 2)], ...
cfg.screen.winRect), ...
thisEvent.angle, ... % start angle
cfg.aperture.width); % arc angle

otherwise

error('unknown aperture type: %s.', cfg.aperture.type);

end

case 'draw'

Screen('DrawTexture', cfg.screen.win, cfg.aperture.texture);

% Screen('DrawTexture', cfg.screen.win, apertureTexture, ...
% cfg.screen.winRect, cfg.screen.winRect, current.apertureAngle - 90);

end

end
Loading