2222%
2323%
2424% action:
25- % - 'open': will create the file ID and return it in logFile.eventLogFile using the information in
25+ % - 'open': will create the file ID and return it in logFile.fileID using the information in
2626% the expParameters structure. This file ID is then reused when calling that function to save data
2727% into this file.
2828% This creates the header with the obligatory 'onset', 'trial_type', 'duration' required bt BIDS and other
2929% coluns can be specified in varargin.
3030% example : logFile = saveEventsFile('open', expParameters, [], 'direction', 'speed', 'target');
3131%
32- % - 'save': will save the data contained in logfile by using the file ID logFile.eventLogFile ;
32+ % - 'save': will save the data contained in logfile by using the file ID logFile.fileID ;
3333% logfile must then contain:
3434% - logFile.onset
3535% - logFile.trial_type
3636% - logFile.duration
3737% The name of any extra column whose content must be saved should be listed in varargin.
3838%
39- % - 'close': closes the file with file ID logFile.eventLogFile . If expParameters.verbose is set to true
39+ % - 'close': closes the file with file ID logFile.fileID . If expParameters.verbose is set to true
4040% then this will tell you where the file is located.
4141%
4242% See test_saveEventsFile in the test folder for more details on how to use it.
5353
5454 % Initialize txt logfiles and empty fields for the standard BIDS
5555 % event file
56- logFile.eventLogFile = fopen(...
56+ logFile.fileID = fopen(...
5757 fullfile(...
5858 expParameters .outputDir , ...
5959 expParameters .modality , ...
6868
6969 % Initialize txt logfiles and empty fields for the standard BIDS
7070 % event file
71- logFile.eventLogFile = fopen(...
71+ logFile.fileID = fopen(...
7272 fullfile(...
7373 expParameters .outputDir , ...
7474 expParameters .modality , ...
8787 % first with the standard BIDS data and then any extra things
8888 for iEvent = 1 : size(logFile ,1 )
8989
90- fprintf(logFile(1 ).eventLogFile ,' %f\t%s\t%f\t ' ,...
90+ fprintf(logFile(1 ).fileID ,' %f\t%s\t%f\t ' ,...
9191 logFile(iEvent ).onset, ...
9292 logFile(iEvent ).trial_type, ...
9393 logFile(iEvent ).duration);
109109 end
110110
111111 if ischar(data )
112- fprintf(logFile(1 ).eventLogFile , ' %s\t ' , data );
112+ fprintf(logFile(1 ).fileID , ' %s\t ' , data );
113113 else
114- fprintf(logFile(1 ).eventLogFile , ' %f\t ' , data );
114+ fprintf(logFile(1 ).fileID , ' %f\t ' , data );
115115 end
116116
117117 end
118118
119- fprintf(logFile(1 ).eventLogFile , ' \n ' );
119+ fprintf(logFile(1 ).fileID , ' \n ' );
120120 end
121121
122122 case ' close'
123123
124124 % close txt log file
125- fclose(logFile(1 ).eventLogFile );
125+ fclose(logFile(1 ).fileID );
126126
127127 if expParameters .verbose
128128 fprintf(1 ,' \n Data were saved in this file:\n\n%s\n\n ' , ...
140140function initializeHeader(logFile , varargin )
141141
142142% print the basic BIDS columns
143- fprintf(logFile .eventLogFile , ' %s\t%s\t%s\t ' , ' onset' , ' trial_type' , ' duration' );
143+ fprintf(logFile .fileID , ' %s\t%s\t%s\t ' , ' onset' , ' trial_type' , ' duration' );
144144
145145% print any extra column specified by the user
146146% also prepare an empty field in the structure to collect data
147147% for those
148148for iExtraColumn = 1 : numel(varargin{1 })
149- fprintf(logFile .eventLogFile ,' %s\t ' , lower(varargin{1 }{iExtraColumn }));
149+ fprintf(logFile .fileID ,' %s\t ' , lower(varargin{1 }{iExtraColumn }));
150150end
151151
152152% next line so we start printing at the right place
153- fprintf(logFile .eventLogFile , ' \n ' );
153+ fprintf(logFile .fileID , ' \n ' );
154154
155155end
0 commit comments