@@ -378,9 +378,9 @@ function printToFile(cfg, logFile, skipEvent, iEvent)
378378 if ~skipEvent
379379
380380 if ~logFile(1 ).isStim
381- printData(logFile(1 ).fileID, logFile(iEvent ).onset, cfg );
382- printData(logFile(1 ).fileID, logFile(iEvent ).duration, cfg );
383- printData(logFile(1 ).fileID, logFile(iEvent ).trial_type, cfg );
381+ printData(logFile(1 ).fileID, logFile(iEvent ).onset, cfg , true );
382+ printData(logFile(1 ).fileID, logFile(iEvent ).duration, cfg , true );
383+ printData(logFile(1 ).fileID, logFile(iEvent ).trial_type, cfg , false );
384384 end
385385
386386 printExtraColumns(logFile , iEvent , cfg );
@@ -394,26 +394,41 @@ function printToFile(cfg, logFile, skipEvent, iEvent)
394394function printExtraColumns(logFile , iEvent , cfg )
395395 % loops through the extra columns and print them
396396 namesExtraColumns = returnNamesExtraColumns(logFile );
397+ if ~logFile(1 ).isStim && numel(namesExtraColumns ) > 0
398+ fprintf(logFile(1 ).fileID, ' \t ' );
399+ talkToMe(cfg , ' \t ' );
400+ end
401+ addTab = true ;
397402 for iExtraColumn = 1 : numel(namesExtraColumns )
398403 data = logFile(iEvent ).(namesExtraColumns{iExtraColumn });
399- printData(logFile(1 ).fileID, data , cfg );
404+ if iExtraColumn == numel(namesExtraColumns )
405+ addTab = false ;
406+ end
407+ printData(logFile(1 ).fileID, data , cfg , addTab );
400408 end
401409end
402410
403- function printData(output , data , cfg )
411+ function printData(output , data , cfg , addTab )
404412 % write char
405413 % for numeric data we replace any nan by n/a
414+
415+ if addTab
416+ separator = ' \t ' ;
417+ else
418+ separator = ' ' ;
419+ end
420+
406421 if ischar(data )
407- content = sprintf(' %s\t ' , data );
422+ content = sprintf(' %s%s ' , data , separator );
408423 fprintf(output , content );
409424 talkToMe(cfg , content );
410425
411426 else
412427 for i = 1 : numel(data )
413428 if isnan(data(i ))
414- content = sprintf(' %s\t ' , ' n/a' );
429+ content = sprintf(' %s%s ' , ' n/a' , separator );
415430 else
416- content = sprintf(' %f\t ' , data(i ));
431+ content = sprintf(' %f%s ' , data(i ), separator );
417432 end
418433 fprintf(output , content );
419434 talkToMe(cfg , content );
0 commit comments