@@ -29,7 +29,7 @@ def populate_bids_templates(path, defaults={}):
29
29
30
30
lgr .info ("Populating template files under %s" , path )
31
31
descriptor = op .join (path , 'dataset_description.json' )
32
- if not op .exists (descriptor ):
32
+ if not op .lexists (descriptor ):
33
33
save_json (descriptor ,
34
34
OrderedDict ([
35
35
('Name' , "TODO: name of the dataset" ),
@@ -51,7 +51,7 @@ def populate_bids_templates(path, defaults={}):
51
51
('DatasetDOI' , 'TODO: eventually a DOI for the dataset' )
52
52
]))
53
53
sourcedata_README = op .join (path , 'sourcedata' , 'README' )
54
- if op .exists (op .dirname (sourcedata_README )):
54
+ if not op .lexists (op .dirname (sourcedata_README )):
55
55
create_file_if_missing (sourcedata_README ,
56
56
("TODO: Provide description about source data, e.g. \n "
57
57
"Directory below contains DICOMS compressed into tarballs per "
@@ -89,18 +89,22 @@ def populate_bids_templates(path, defaults={}):
89
89
suf = '_bold.json'
90
90
assert fpath .endswith (suf )
91
91
events_file = fpath [:- len (suf )] + '_events.tsv'
92
- lgr .debug ("Generating %s" , events_file )
93
- with open (events_file , 'w' ) as f :
94
- f .write ("onset\t duration\t trial_type\t response_time\t stim_file\t TODO -- fill in rows and add more tab-separated columns if desired" )
92
+ # do not touch any existing thing, it may be precious
93
+ if not op .lexists (events_file ):
94
+ lgr .debug ("Generating %s" , events_file )
95
+ with open (events_file , 'w' ) as f :
96
+ f .write ("onset\t duration\t trial_type\t response_time\t stim_file\t TODO -- fill in rows and add more tab-separated columns if desired" )
95
97
# extract tasks files stubs
96
98
for task_acq , fields in tasks .items ():
97
99
task_file = op .join (path , task_acq + '_bold.json' )
98
- lgr .debug ("Generating %s" , task_file )
99
- fields ["TaskName" ] = ("TODO: full task name for %s" %
100
- task_acq .split ('_' )[0 ].split ('-' )[1 ])
101
- fields ["CogAtlasID" ] = "TODO"
102
- with open (task_file , 'w' ) as f :
103
- f .write (json_dumps_pretty (fields , indent = 2 , sort_keys = True ))
100
+ # do not touch any existing thing, it may be precious
101
+ if not op .lexists (task_file ):
102
+ lgr .debug ("Generating %s" , task_file )
103
+ fields ["TaskName" ] = ("TODO: full task name for %s" %
104
+ task_acq .split ('_' )[0 ].split ('-' )[1 ])
105
+ fields ["CogAtlasID" ] = "TODO"
106
+ with open (task_file , 'w' ) as f :
107
+ f .write (json_dumps_pretty (fields , indent = 2 , sort_keys = True ))
104
108
105
109
106
110
def tuneup_bids_json_files (json_files ):
0 commit comments