35
35
36
36
37
37
def copy2subjdir (cls , in_file , folder = None , basename = None , subject_id = None ):
38
+ """Method to copy an input to the subjects directory"""
39
+ # check that the input is defined
40
+ if not isdefined (in_file ):
41
+ return in_file
42
+ # check that subjects_dir is defined
38
43
if isdefined (cls .inputs .subjects_dir ):
39
44
subjects_dir = cls .inputs .subjects_dir
40
45
else :
41
- subjects_dir = os .getcwd ()
46
+ subjects_dir = os .getcwd () #if not use cwd
47
+ # check for subject_id
42
48
if not subject_id :
43
49
if isdefined (cls .inputs .subject_id ):
44
50
subject_id = cls .inputs .subject_id
45
51
else :
46
- subject_id = 'subject_id'
52
+ subject_id = 'subject_id' #default
53
+ # check for basename
47
54
if basename == None :
48
55
basename = os .path .basename (in_file )
56
+ # check which folder to put the file in
49
57
if folder != None :
50
58
out_dir = os .path .join (subjects_dir , subject_id , folder )
51
59
else :
52
60
out_dir = os .path .join (subjects_dir , subject_id )
61
+ # make the output folder if it does not exist
53
62
if not os .path .isdir (out_dir ):
54
63
os .makedirs (out_dir )
55
64
out_file = os .path .join (out_dir , basename )
@@ -58,7 +67,7 @@ def copy2subjdir(cls, in_file, folder=None, basename=None, subject_id=None):
58
67
return out_file
59
68
60
69
def createoutputdirs (outputs ):
61
- """create an output directories. If not created, some freesurfer interfaces fail"""
70
+ """create all output directories. If not created, some freesurfer interfaces fail"""
62
71
for output in outputs .itervalues ():
63
72
dirname = os .path .dirname (output )
64
73
if not os .path .isdir (dirname ):
@@ -2301,11 +2310,16 @@ class VolumeMaskInputSpec(FSTraitedSpec):
2301
2310
desc = "Implicit input left white matter surface" )
2302
2311
rh_white = File (mandatory = True , exists = True ,
2303
2312
desc = "Implicit input right white matter surface" )
2313
+ aseg = File (mandatory = True , exists = True ,
2314
+ xor = ['in_aseg' ],
2315
+ desc = "Implicit aseg.mgz segmentation. " +
2316
+ "Specify a different aseg by using the 'in_aseg' input." )
2304
2317
subject_id = traits .String ('subject_id' , usedefault = True ,
2305
2318
position = - 1 , argstr = "%s" , mandatory = True ,
2306
2319
desc = "Subject being processed" )
2307
2320
# optional
2308
- in_aseg = File (argstr = "--aseg_name %s" , mandatory = False , exists = True ,
2321
+ in_aseg = File (argstr = "--aseg_name %s" , mandatory = False ,
2322
+ exists = True , xor = ['aseg' ],
2309
2323
desc = "Input aseg file for VolumeMask" )
2310
2324
save_ribbon = traits .Bool (argstr = "--save_ribbon" , mandatory = False ,
2311
2325
desc = "option to save just the ribbon for the " +
@@ -2363,8 +2377,9 @@ def run(self, **inputs):
2363
2377
copy2subjdir (self , self .inputs .rh_pial , 'surf' , 'rh.pial' )
2364
2378
copy2subjdir (self , self .inputs .lh_white , 'surf' , 'lh.white' )
2365
2379
copy2subjdir (self , self .inputs .rh_white , 'surf' , 'rh.white' )
2366
- if isdefined (self .inputs .in_aseg ):
2367
- copy2subjdir (self , self .inputs .in_aseg , 'mri' )
2380
+ copy2subjdir (self , self .inputs .in_aseg , 'mri' )
2381
+ copy2subjdir (self , self .inputs .aseg , 'mri' , 'aseg.mgz' )
2382
+
2368
2383
return super (VolumeMask , self ).run (** inputs )
2369
2384
2370
2385
def _format_arg (self , name , spec , value ):
0 commit comments