@@ -46,6 +46,63 @@ function test_saveEventsFileSaveBasic()
4646
4747end
4848
49+ function test_saveEventsFileSaveStim()
50+
51+ %% set up
52+
53+ cfg.verbose = 2 ;
54+
55+ cfg.subject.subjectNb = 1 ;
56+ cfg.subject.runNb = 1 ;
57+
58+ cfg.task.name = ' testtask' ;
59+
60+ cfg.testingDevice = ' mri' ;
61+
62+ cfg = createFilename(cfg );
63+
64+ logFile.extraColumns = {' Speed' , ' LHL24' , ' is_Fixation' };
65+
66+ logFile = saveEventsFile(' init_stim' , cfg , logFile );
67+
68+ logFile.extraColumns.Speed.length = 1 ;
69+ logFile.extraColumns.LHL24.length = 3 ;
70+ logFile.extraColumns.is_Fixation.length = 1 ;
71+
72+ % create the events file and header
73+ logFile = saveEventsFile(' open' , cfg , logFile );
74+
75+ % ROW 2: normal events : all info is there
76+ logFile(1 , 1 ).onset = 2 ;
77+ logFile(end , 1 ).trial_type = ' motion_up' ;
78+ logFile(end , 1 ).duration = 3 ;
79+ logFile(end , 1 ).Speed = 2 ;
80+ logFile(end , 1 ).LHL24 = 1 : 3 ;
81+ logFile(end , 1 ).is_Fixation = true ;
82+
83+ logFile = saveEventsFile(' save' , cfg , logFile );
84+
85+ % close the file
86+ saveEventsFile(' close' , cfg , logFile );
87+
88+ % check the extra columns of the header and some of the content
89+ nbExtraCol = ...
90+ logFile(1 ).extraColumns.Speed.length + ...
91+ logFile(1 ).extraColumns.LHL24.length + ...
92+ logFile(1 ).extraColumns.is_Fixation.length;
93+
94+ funcDir = fullfile(cfg .dir .outputSubject , cfg .fileName .modality );
95+
96+ FID = fopen(fullfile(funcDir , logFile .filename ), ' r' );
97+ content = textscan(FID , repmat(' %s ' , 1 , nbExtraCol ), ' Delimiter' , ' \t ' , ' EndOfLine' , ' \n ' );
98+
99+ % event 1/ ROW 2: check that values are entered correctly
100+ assertEqual(content{1 }{1 }, sprintf(' %f ' , 2 ));
101+ assertEqual(content{4 }{1 }, sprintf(' %f ' , 3 ));
102+ assertEqual(content{5 }{1 }, ' true' );
103+
104+ end
105+
49106function test_saveEventsFileSaveSkipEmptyEvents()
50107
51108 %% set up
0 commit comments