Skip to content

Commit 26bf518

Browse files
committed
refactor preTrialSetup
1 parent c854e6f commit 26bf518

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

subfun/doDotMo.m

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [onset, duration] = doDotMo(cfg, thisEvent)
1+
function [onset, duration] = doDotMo(cfg, thisEvent, thisFixation)
22
% Draws the stimulation of static/moving in 4 directions dots or static
33
%
44
% DIRECTIONS
@@ -46,9 +46,6 @@
4646

4747
apertureTexture('draw', cfg, thisEvent);
4848

49-
% If this frame shows a target we change the color of the cross
50-
thisFixation.fixation = cfg.fixation;
51-
thisFixation.screen = cfg.screen;
5249
if thisEvent.target(1) && GetSecs < (onset + cfg.target.duration)
5350
thisFixation.fixation.color = cfg.fixation.colorTarget;
5451
end

subfun/preTrialSetup.m

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
function varargout = preTrialSetup(varargin)
2+
% varargout = postInitializatinSetup(varargin)
3+
4+
% generic function to finalize some set up after psychtoolbox has been
5+
% initialized
6+
7+
[cfg, iBlock, iEvent] = deal(varargin{:});
8+
9+
% set direction, speed of that event and if it is a target
10+
thisEvent.trial_type = cfg.design.blockNames{iBlock};
11+
thisEvent.direction = cfg.design.directions(iBlock, iEvent);
12+
thisEvent.speed = cfg.design.speeds(iBlock, iEvent);
13+
thisEvent.target = cfg.design.fixationTargets(iBlock, iEvent);
14+
15+
% If this frame shows a target we change the color of the cross
16+
thisFixation.fixation = cfg.fixation;
17+
thisFixation.screen = cfg.screen;
18+
19+
varargout = {thisEvent, thisFixation};
20+
21+
end

visualLocTranslational.m

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,7 @@
7979
% Check for experiment abortion from operator
8080
checkAbort(cfg, cfg.keyboard.keyboard);
8181

82-
% set direction, speed of that event and if it is a target
83-
thisEvent.trial_type = cfg.design.blockNames{iBlock};
84-
thisEvent.direction = cfg.design.directions(iBlock, iEvent);
85-
thisEvent.speed = cfg.design.speeds(iBlock, iEvent);
86-
thisEvent.target = cfg.design.fixationTargets(iBlock, iEvent);
82+
[thisEvent, thisFixation] = preTrialSetup(cfg, iBlock, iEvent);
8783

8884
% we wait for a trigger every 2 events
8985
if cfg.pacedByTriggers.do && mod(iEvent, 2) == 1
@@ -95,7 +91,7 @@
9591
end
9692

9793
% play the dots and collect onset and duraton of the event
98-
[onset, duration] = doDotMo(cfg, thisEvent);
94+
[onset, duration] = doDotMo(cfg, thisEvent, thisFixation);
9995

10096
thisEvent.event = iEvent;
10197
thisEvent.block = iBlock;

0 commit comments

Comments
 (0)