16
16
import logging
17
17
lgr = logging .getLogger (__name__ )
18
18
19
- INIT_MSG = "Running {packname} version {version}" .format
19
+ INIT_MSG = "Running {packname} version {version} latest {latest} " .format
20
20
21
21
22
22
def is_interactive ():
@@ -112,6 +112,7 @@ def main(argv=None):
112
112
random .seed (args .random_seed )
113
113
import numpy
114
114
numpy .random .seed (args .random_seed )
115
+ # Ensure only supported bids options are passed
115
116
if args .debug :
116
117
lgr .setLevel (logging .DEBUG )
117
118
# Should be possible but only with a single subject -- will be used to
@@ -129,7 +130,7 @@ def main(argv=None):
129
130
130
131
def get_parser ():
131
132
docstr = ("""Example:
132
- heudiconv -d rawdata/{subject} -o . -f heuristic.py -s s1 s2 s3""" )
133
+ heudiconv -d ' rawdata/{subject}' -o . -f heuristic.py -s s1 s2 s3""" )
133
134
parser = ArgumentParser (description = docstr )
134
135
parser .add_argument ('--version' , action = 'version' , version = __version__ )
135
136
group = parser .add_mutually_exclusive_group ()
@@ -138,7 +139,12 @@ def get_parser():
138
139
'subject id {subject} and session {session}. Tarballs '
139
140
'(can be compressed) are supported in addition to '
140
141
'directory. All matching tarballs for a subject are '
141
- 'extracted and their content processed in a single pass' )
142
+ 'extracted and their content processed in a single '
143
+ 'pass. If multiple tarballs are found, each is '
144
+ 'assumed to be a separate session and the --ses '
145
+ 'argument is ignored. Note that you might need to '
146
+ 'surround the value with quotes to avoid {...} being '
147
+ 'considered by shell' )
142
148
group .add_argument ('--files' , nargs = '*' ,
143
149
help = 'Files (tarballs, dicoms) or directories '
144
150
'containing files to process. Cannot be provided if '
@@ -181,8 +187,16 @@ def get_parser():
181
187
parser .add_argument ('-ss' , '--ses' , dest = 'session' , default = None ,
182
188
help = 'session for longitudinal study_sessions, default '
183
189
'is none' )
184
- parser .add_argument ('-b' , '--bids' , action = 'store_true' ,
185
- help = 'flag for output into BIDS structure' )
190
+ parser .add_argument ('-b' , '--bids' , nargs = '*' ,
191
+ metavar = ('BIDSOPTION1' , 'BIDSOPTION2' ),
192
+ choices = ['notop' ],
193
+ dest = 'bids_options' ,
194
+ help = 'flag for output into BIDS structure. Can also '
195
+ 'take bids specific options, e.g., --bids notop.'
196
+ 'The only currently supported options is'
197
+ '"notop", which skips creation of top-level bids '
198
+ 'files. This is useful when running in batch mode to '
199
+ 'prevent possible race conditions.' )
186
200
parser .add_argument ('--overwrite' , action = 'store_true' , default = False ,
187
201
help = 'flag to allow overwriting existing converted files' )
188
202
parser .add_argument ('--datalad' , action = 'store_true' ,
@@ -234,8 +248,16 @@ def process_args(args):
234
248
235
249
outdir = op .abspath (args .outdir )
236
250
251
+ import etelemetry
252
+ try :
253
+ latest = etelemetry .get_project ("nipy/heudiconv" )
254
+ except Exception as e :
255
+ lgr .warning ("Could not check for version updates: " , e )
256
+ latest = {"version" : 'Unknown' }
257
+
237
258
lgr .info (INIT_MSG (packname = __packagename__ ,
238
- version = __version__ ))
259
+ version = __version__ ,
260
+ latest = latest ["version" ]))
239
261
240
262
if args .command :
241
263
process_extra_commands (outdir , args )
@@ -302,7 +324,8 @@ def process_args(args):
302
324
from ..external .dlad import prepare_datalad
303
325
dlad_sid = sid if not anon_sid else anon_sid
304
326
dl_msg = prepare_datalad (anon_study_outdir , anon_outdir , dlad_sid ,
305
- session , seqinfo , dicoms , args .bids )
327
+ session , seqinfo , dicoms ,
328
+ args .bids_options )
306
329
307
330
lgr .info ("PROCESSING STARTS: {0}" .format (
308
331
str (dict (subject = sid , outdir = study_outdir , session = session ))))
@@ -316,7 +339,7 @@ def process_args(args):
316
339
anon_outdir = anon_study_outdir ,
317
340
with_prov = args .with_prov ,
318
341
ses = session ,
319
- bids = args .bids ,
342
+ bids_options = args .bids_options ,
320
343
seqinfo = seqinfo ,
321
344
min_meta = args .minmeta ,
322
345
overwrite = args .overwrite ,
@@ -333,7 +356,7 @@ def process_args(args):
333
356
# also in batch mode might fail since we have no locking ATM
334
357
# and theoretically no need actually to save entire study
335
358
# we just need that
336
- add_to_datalad (outdir , study_outdir , msg , args .bids )
359
+ add_to_datalad (outdir , study_outdir , msg , args .bids_options )
337
360
338
361
# if args.bids:
339
362
# # Let's populate BIDS templates for folks to take care about
0 commit comments