11function test_saveEventsFileOpen()
22
3- %% check header writing with extra columns
3+ %% Initialize file
44 fprintf(' \n\n --------------------------------------------------------------------\n\n ' );
55
66 clear ;
@@ -16,15 +16,12 @@ function test_saveEventsFileOpen()
1616
1717 cfg.testingDevice = ' mri' ;
1818
19- % define the extra columns: they will be added to the tsv files in the order the user input them
20- logFile.extraColumns = {' Speed' , ' is_Fixation' };
21-
2219 % %% do stuff
2320
2421 [cfg , expParameters ] = createFilename(cfg , expParameters );
2522
2623 % create the events file and header
27- logFile = saveEventsFile(' open' , expParameters , logFile );
24+ logFile = saveEventsFile(' open' , expParameters );
2825
2926 % close the file
3027 saveEventsFile(' close' , expParameters , logFile );
@@ -37,9 +34,8 @@ function test_saveEventsFileOpen()
3734 expParameters .date ' .tsv' ];
3835
3936 % open the file
40- nbExtraCol = 2 ;
4137 FID = fopen(fullfile(funcDir , eventFilename ), ' r' );
42- C = textscan(FID , repmat(' %s ' , 1 , nbExtraCol + 3 ), ' Delimiter' , ' \t ' , ' EndOfLine' , ' \n ' );
38+ C = textscan(FID , repmat(' %s ' , 1 , 3 ), ' Delimiter' , ' \t ' , ' EndOfLine' , ' \n ' );
4339
4440 % check that the file has the right path and name
4541 assert(exist(fullfile(funcDir , eventFilename ), ' file' ) == 2 );
@@ -48,6 +44,53 @@ function test_saveEventsFileOpen()
4844 assert(isequal(C{1 }{1 }, ' onset' ));
4945 assert(isequal(C{2 }{1 }, ' trial_type' ));
5046 assert(isequal(C{3 }{1 }, ' duration' ));
47+
48+
49+
50+ %% check header writing with extra columns
51+ fprintf(' \n\n --------------------------------------------------------------------\n\n ' );
52+
53+ clear ;
54+
55+ outputDir = fullfile(fileparts(mfilename(' fullpath' )), ' ..' , ' output' );
56+
57+ % %% set up
58+
59+ expParameters.subjectNb = 1 ;
60+ expParameters.runNb = 1 ;
61+ expParameters.task = ' testtask' ;
62+ expParameters.outputDir = outputDir ;
63+
64+ cfg.testingDevice = ' mri' ;
65+
66+ % define the extra columns: they will be added to the tsv files in the order the user input them
67+ logFile.extraColumns = {' Speed' , ' is_Fixation' };
68+
69+ % %% do stuff
70+
71+ [cfg , expParameters ] = createFilename(cfg , expParameters );
72+
73+ % create the events file and header
74+ logFile = saveEventsFile(' open' , expParameters , logFile );
75+
76+ % close the file
77+ saveEventsFile(' close' , expParameters , logFile );
78+
79+ % %% test section
80+
81+ % open the file
82+ nbExtraCol = 2 ;
83+ FID = fopen(fullfile( ...
84+ expParameters .subjectOutputDir , ...
85+ expParameters .modality , ...
86+ expParameters .fileName .events ), ...
87+ ' r' );
88+ C = textscan(FID , repmat(' %s ' , 1 , nbExtraCol + 3 ), ' Delimiter' , ' \t ' , ' EndOfLine' , ' \n ' );
89+
90+ % check the extra columns of the header
91+ assert(isequal(C{1 }{1 }, ' onset' ));
92+ assert(isequal(C{2 }{1 }, ' trial_type' ));
93+ assert(isequal(C{3 }{1 }, ' duration' ));
5194 assert(isequal(C{4 }{1 }, ' Speed' ));
5295 assert(isequal(C{5 }{1 }, ' is_Fixation' ));
5396
0 commit comments