@@ -7,29 +7,43 @@ function createDataDictionary(cfg, logFile)
77 % will create empty field that you can then fill in manually in the JSON
88 % file
99
10+ fileName = strrep(logFile(1 ).filename, ' .tsv' , ' .json' );
11+ fullFilename = getFullFilename(fileName , cfg );
12+
13+ jsonContent = setJsonContent(fullFilename , logFile );
14+
1015 opts.Indent = ' ' ;
16+ bids .util .jsonencode(fullFilename , jsonContent , opts );
1117
12- fileName = strrep(logFile( 1 ).filename, ' .tsv ' , ' .json ' );
18+ end
1319
14- fileName = fullfile( ...
15- cfg .dir .outputSubject , ...
16- cfg .fileName .modality , ...
17- fileName );
20+ function jsonContent = setJsonContent(fullFilename , logFile )
1821
22+ % transfer content of extra fields to json content
23+ namesExtraColumns = returnNamesExtraColumns(logFile );
24+
25+ % default content for events file that will be overriddent if we are dealing
26+ % with a stim file
1927 jsonContent = struct( ...
2028 ' onset' , struct( ...
2129 ' Description' , ' time elapsed since experiment start' , ...
22- ' Unit ' , ' s' ), ...
30+ ' Units ' , ' s' ), ...
2331 ' trial_type' , struct( ...
2432 ' Description' , ' types of trial' , ...
2533 ' Levels' , ' ' ), ...
2634 ' duration' , struct( ...
2735 ' Description' , ' duration of the event or the block' , ...
28- ' Unit ' , ' s' ) ...
36+ ' Units ' , ' s' ) ...
2937 );
3038
31- % transfer content of extra fields to json content
32- namesExtraColumns = returnNamesExtraColumns(logFile );
39+ if contains(fullFilename , ' _stim' )
40+
41+ jsonContent = struct( ...
42+ ' SamplingFrequency' , nan , ...
43+ ' StartTime' , nan , ...
44+ ' Columns' , []);
45+
46+ end
3347
3448 for iExtraColumn = 1 : numel(namesExtraColumns )
3549
@@ -39,13 +53,17 @@ function createDataDictionary(cfg, logFile)
3953
4054 headerName = returnHeaderName(namesExtraColumns{iExtraColumn }, nbCol , iCol );
4155
56+ if contains(fullFilename , ' _stim' )
57+
58+ jsonContent.Columns{end + 1 } = headerName ;
59+
60+ end
61+
4262 jsonContent.(headerName ) = ...
4363 logFile(1 ).extraColumns.(namesExtraColumns{iExtraColumn }).bids;
4464
4565 end
4666
4767 end
4868
49- bids .util .jsonencode(fileName , jsonContent , opts );
50-
5169end
0 commit comments