@@ -127,15 +127,25 @@ def run(command, env={}, ignore_errors=False):
127127
128128subject_dirs = glob (os .path .join (args .bids_dir , "sub-*" ))
129129
130- if args .acquisition_label :
131- acq_tpl = "*acq-%s*" % args .acquisition_label
130+ #Got to combine acq_tpl and rec_tpl
131+ if args .acquisition_label and not args .reconstruction_label :
132+ ar_tpl = "*acq-%s*" % args .acquisition_label
133+ elif args .reconstruction_label and not args .acquisition_label :
134+ ar_tpl = "*rec-%s*" % args .reconstruction_label
135+ elif args .reconstruction_label and args .acquisition_label :
136+ ar_tpl = "*acq-%s*_rec-%s*" % (args .acquisition_label , args .reconstruction_label )
132137else :
133- acq_tpl = "*"
134-
135- if args .reconstruction_label :
136- rec_tpl = "*rec-%s*" % args .reconstruction_label
138+ ar_tpl = "*"
139+
140+ #Got to combine acq_tpl and rec_tpl
141+ if args .refine_pial_acquisition_label and not args .refine_pial_reconstruction_label :
142+ ar_t2 = "*acq-%s*" % args .refine_pial_acquisition_label
143+ elif args .refine_pial_reconstruction_label and not args .refine_pial_acquisition_label :
144+ ar_t2 = "*rec-%s*" % args .refine_pial_reconstruction_label
145+ elif args .refine_pial_reconstruction_label and args .refine_pial_acquisition_label :
146+ ar_t2 = "*acq-%s*_rec-%s*" % (args .refine_pial_acquisition_label , args .refine_pial_reconstruction_label )
137147else :
138- rec_tpl = "*"
148+ ar_t2 = "*"
139149
140150# if there are session folders, check if study is truly longitudinal by
141151# searching for the first subject with more than one valid sessions
@@ -150,7 +160,7 @@ def run(command, env={}, ignore_errors=False):
150160 if glob (os .path .join (args .bids_dir , "sub-%s" % subject_label ,
151161 "ses-%s" % session_label ,
152162 "anat" ,
153- "%s_T1w.nii*" % acq_tpl )):
163+ "%s_T1w.nii*" % ar_tpl )):
154164 n_valid_sessions += 1
155165 if n_valid_sessions > 1 :
156166 multi_session_study = True
@@ -161,15 +171,6 @@ def run(command, env={}, ignore_errors=False):
161171else :
162172 longitudinal_study = False
163173
164- if args .refine_pial_acquisition_label :
165- acq_t2 = "*acq-%s*" % args .refine_pial_acquisition_label
166- else :
167- acq_t2 = "*"
168-
169- if args .refine_pial_reconstruction_label :
170- rec_t2 = "*rec-%s*" % args .refine_pial_reconstruction_label
171- else :
172- rec_t2 = "*"
173174
174175subjects_to_analyze = []
175176# only for a subset of subjects
@@ -208,7 +209,7 @@ def run(command, env={}, ignore_errors=False):
208209 "sub-%s" % subject_label ,
209210 "ses-*" ,
210211 "anat" ,
211- "%s_% s_T1w.nii*" % (acq_tpl , rec_tpl )))
212+ "%s_T1w.nii*" % (ar_tpl )))
212213 sessions = set ([os .path .normpath (t1 ).split (os .sep )[- 3 ].split ("-" )[- 1 ] for t1 in T1s ])
213214 if args .session_label :
214215 sessions = sessions .intersection (args .session_label )
@@ -222,7 +223,7 @@ def run(command, env={}, ignore_errors=False):
222223 "sub-%s" % subject_label ,
223224 "ses-%s" % session_label ,
224225 "anat" ,
225- "%s_% s_T1w.nii*" % (acq_tpl , rec_tpl )))
226+ "%s_T1w.nii*" % (ar_tpl )))
226227 input_args = ""
227228
228229 if three_T == 'true' :
@@ -238,10 +239,10 @@ def run(command, env={}, ignore_errors=False):
238239
239240 T2s = glob (os .path .join (args .bids_dir , "sub-%s" % subject_label ,
240241 "ses-%s" % session_label , "anat" ,
241- "%s_% s_T2w.nii*" % (acq_t2 , rec_t2 )))
242+ "%s_T2w.nii*" % (ar_t2 )))
242243 FLAIRs = glob (os .path .join (args .bids_dir , "sub-%s" % subject_label ,
243244 "ses-%s" % session_label , "anat" ,
244- "%s_% s_FLAIR.nii*" % (acq_t2 , rec_t2 )))
245+ "%s_FLAIR.nii*" % (ar_t2 )))
245246 if args .refine_pial == "T2" :
246247 for T2 in T2s :
247248 if (max (nibabel .load (T2 ).header .get_zooms ()) < 1.2 ) | args .allow_lowresT2 :
@@ -338,7 +339,7 @@ def run(command, env={}, ignore_errors=False):
338339 "sub-%s" % subject_label ,
339340 "ses-*" ,
340341 "anat" ,
341- "%s_% s_T1w.nii*" % (acq_tpl , rec_tpl )))
342+ "%s_T1w.nii*" % (ar_tpl )))
342343 input_args = ""
343344
344345 if three_T == 'true' :
@@ -356,12 +357,12 @@ def run(command, env={}, ignore_errors=False):
356357 "sub-%s" % subject_label ,
357358 "ses-*" ,
358359 "anat" ,
359- "%s_% s_T2w.nii*" % (acq_t2 , rec_t2 )))
360+ "%s_T2w.nii*" % (ar_t2 )))
360361 FLAIRs = glob (os .path .join (args .bids_dir ,
361362 "sub-%s" % subject_label ,
362363 "ses-*" ,
363364 "anat" ,
364- "%s_% s_FLAIR.nii*" % (acq_t2 , rec_t2 )))
365+ "%s_FLAIR.nii*" % (ar_t2 )))
365366 if args .refine_pial == "T2" :
366367 for T2 in T2s :
367368 if (max (nibabel .load (T2 ).header .get_zooms ()) < 1.2 ) | args .allow_lowresT2 :
@@ -408,7 +409,7 @@ def run(command, env={}, ignore_errors=False):
408409 T1s = glob (os .path .join (args .bids_dir ,
409410 "sub-%s" % subject_label ,
410411 "anat" ,
411- "%s_% s_T1w.nii*" % (acq_tpl , rec_tpl )))
412+ "%s_T1w.nii*" % (ar_tpl )))
412413 if not T1s :
413414 print ("No T1w nii files found for subject %s. Skipping subject." % subject_label )
414415 continue
@@ -426,9 +427,9 @@ def run(command, env={}, ignore_errors=False):
426427 input_args += " -hires"
427428 input_args += " -i %s" % T1
428429 T2s = glob (os .path .join (args .bids_dir , "sub-%s" % subject_label , "anat" ,
429- "%s_% s_T2w.nii*" % (acq_t2 , rec_t2 )))
430+ "%s_T2w.nii*" % (ar_t2 )))
430431 FLAIRs = glob (os .path .join (args .bids_dir , "sub-%s" % subject_label , "anat" ,
431- "%s_% s_FLAIR.nii*" % (acq_t2 , rec_t2 )))
432+ "%s_FLAIR.nii*" % (ar_t2 )))
432433 if args .refine_pial == "T2" :
433434 for T2 in T2s :
434435 if max (nibabel .load (T2 ).header .get_zooms ()) < 1.2 :
0 commit comments