Skip to content

Commit 398494e

Browse files
committed
refactor saveToLog
1 parent 9bbec27 commit 398494e

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/saveEventsFile.m

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ function printHeaderExtraColumns(logFile)
382382

383383
onset = logFile(iEvent).onset;
384384
duration = logFile(iEvent).duration;
385-
trial_type = logFile(iEvent).trial_type;
386385

387386
if any(cell2mat(cellfun(@isnan, {onset duration}, 'UniformOutput', false))) || ...
388387
any(cellfun(@ischar, {onset duration})) || ...
@@ -429,25 +428,28 @@ function printHeaderExtraColumns(logFile)
429428
% now save the event to log file (if not skipping)
430429
warningSaveEventsFile(cfg, warningMessageID, warningMessage);
431430

432-
if ~skipEvent
431+
printToFile(cfg, logFile, skipEvent, iEvent);
433432

434-
if ~logFile(1).isStim
435-
436-
printData(logFile(1).fileID, onset, cfg);
437-
printData(logFile(1).fileID, duration, cfg);
438-
printData(logFile(1).fileID, trial_type, cfg);
433+
end
439434

440-
end
435+
end
441436

442-
printExtraColumns(logFile, iEvent, cfg);
437+
function printToFile(cfg, logFile, skipEvent, iEvent)
443438

444-
fprintf(logFile(1).fileID, '\n');
445-
fprintf(1, '\n');
439+
if ~skipEvent
446440

441+
if ~logFile(1).isStim
442+
printData(logFile(1).fileID, logFile(iEvent).onset, cfg);
443+
printData(logFile(1).fileID, logFile(iEvent).duration, cfg);
444+
printData(logFile(1).fileID, logFile(iEvent).trial_type, cfg);
447445
end
448446

449-
end
447+
printExtraColumns(logFile, iEvent, cfg);
450448

449+
fprintf(logFile(1).fileID, '\n');
450+
fprintf(1, '\n');
451+
452+
end
451453
end
452454

453455
function printExtraColumns(logFile, iEvent, cfg)

0 commit comments

Comments
 (0)