@@ -332,7 +332,8 @@ def save_scans_key(item, bids_files):
332
332
333
333
def add_rows_to_scans_keys_file (fn , newrows ):
334
334
"""
335
- Add new rows to file fn for scans key filename
335
+ Add new rows to file fn for scans key filename and generate accompanying json
336
+ descriptor to make BIDS validator happy.
336
337
337
338
Parameters
338
339
----------
@@ -355,6 +356,25 @@ def add_rows_to_scans_keys_file(fn, newrows):
355
356
os .unlink (fn )
356
357
else :
357
358
fnames2info = newrows
359
+ # Populate _scans.json (an optional file to describe column names in
360
+ # _scans.tsv). This auto generation will make BIDS-validator happy.
361
+ scans_json = '.' .join (fn .split ('.' )[:- 1 ] + ['json' ])
362
+ if not op .lexists (scans_json ):
363
+ save_json (scans_json ,
364
+ OrderedDict ([
365
+ ("filename" , OrderedDict ([
366
+ ("Description" , "Name of the nifti file" )])),
367
+ ("acq_time" , OrderedDict ([
368
+ ("LongName" , "Acquisition time" ),
369
+ ("Description" , "Acquisition time of the particular scan" )])),
370
+ ("operator" , OrderedDict ([
371
+ ("Description" , "Name of the operator" )])),
372
+ ("randstr" , OrderedDict ([
373
+ ("LongName" , "Random string" ),
374
+ ("Description" , "md5 hash of UIDs" )])),
375
+ ]),
376
+ sort_keys = False ,
377
+ indent = 2 )
358
378
359
379
header = ['filename' , 'acq_time' , 'operator' , 'randstr' ]
360
380
# prepare all the data rows
0 commit comments