Skip to content

Commit 698708e

Browse files
committed
factor out preSaveSetup
1 parent 26bf518 commit 698708e

File tree

2 files changed

+29
-20
lines changed

2 files changed

+29
-20
lines changed

subfun/preSaveSetup.m

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
function varargout = preSaveSetup(varargin)
2+
% varargout = postInitializatinSetup(varargin)
3+
4+
% generic function to prepare structures before saving
5+
6+
[thisEvent, iBlock, iEvent, duration, onset, cfg, logFile] = deal(varargin{:});
7+
8+
thisEvent.event = iEvent;
9+
thisEvent.block = iBlock;
10+
thisEvent.keyName = 'n/a';
11+
thisEvent.duration = duration;
12+
thisEvent.onset = onset - cfg.experimentStart;
13+
14+
% % this value should be in degrees / second in the log file
15+
% % highlights that the way speed is passed around could be
16+
% % simplified.
17+
% %
18+
% thisEvent.speed
19+
% %
20+
21+
% Save the events txt logfile
22+
% we save event by event so we clear this variable every loop
23+
thisEvent.fileID = logFile.fileID;
24+
thisEvent.extraColumns = logFile.extraColumns;
25+
26+
varargout = thisEvent;
27+
28+
end

visualLocTranslational.m

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -93,28 +93,9 @@
9393
% play the dots and collect onset and duraton of the event
9494
[onset, duration] = doDotMo(cfg, thisEvent, thisFixation);
9595

96-
thisEvent.event = iEvent;
97-
thisEvent.block = iBlock;
98-
thisEvent.keyName = 'n/a';
99-
thisEvent.duration = duration;
100-
thisEvent.onset = onset - cfg.experimentStart;
101-
102-
% % this value should be in degrees / second in the log file
103-
% % highlights that the way speed is passed around could be
104-
% % simplified.
105-
% %
106-
% thisEvent.speed
107-
% %
108-
109-
% Save the events txt logfile
110-
% we save event by event so we clear this variable every loop
111-
thisEvent.fileID = logFile.fileID;
112-
thisEvent.extraColumns = logFile.extraColumns;
113-
96+
thisEvent = preSaveSetup(thisEvent, iBlock, iEvent, duration, onset, cfg, logFile);
11497
saveEventsFile('save', cfg, thisEvent);
11598

116-
clear thisEvent;
117-
11899
% collect the responses and appends to the event structure for
119100
% saving in the tsv file
120101
responseEvents = getResponse('check', cfg.keyboard.responseBox, cfg, ...

0 commit comments

Comments
 (0)