@@ -42,12 +42,15 @@ def sanitize_path_comp(path_comp):
42
42
result .append (char )
43
43
return '' .join (result )
44
44
45
+
45
46
class NiftiGeneratorBaseInputSpec (TraitedSpec ):
46
47
out_format = traits .Str (desc = "String which can be formatted with "
47
48
"meta data to create the output filename(s)" )
48
- out_ext = traits .Str ('.nii.gz' ,
49
- usedefault = True ,
49
+ out_ext = traits .Str ('.nii.gz' , usedefault = True ,
50
50
desc = "Determines output file type" )
51
+ use_cwd = traits .Bool (True , usedefault = True ,
52
+ desc = 'use interface\' s current working directory' )
53
+
51
54
52
55
class NiftiGeneratorBase (BaseInterface ):
53
56
'''Base class for interfaces that produce Nifti files, potentially with
@@ -73,7 +76,12 @@ def _get_out_path(self, meta, idx=None):
73
76
out_fmt = '-' .join (out_fmt )
74
77
out_fn = (out_fmt % meta ) + self .inputs .out_ext
75
78
out_fn = sanitize_path_comp (out_fn )
76
- return path .join (os .getcwd (), out_fn )
79
+
80
+ if self .inputs .use_cwd :
81
+ return path .join (os .getcwd (), out_fn )
82
+ else :
83
+ return path .abspath (out_fn )
84
+
77
85
78
86
class DcmStackInputSpec (NiftiGeneratorBaseInputSpec ):
79
87
dicom_files = traits .Either (InputMultiPath (File (exists = True )),
0 commit comments