@@ -42,12 +42,15 @@ def sanitize_path_comp(path_comp):
4242 result .append (char )
4343 return '' .join (result )
4444
45+
4546class NiftiGeneratorBaseInputSpec (TraitedSpec ):
4647 out_format = traits .Str (desc = "String which can be formatted with "
4748 "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 ,
5050 desc = "Determines output file type" )
51+ use_cwd = traits .Bool (True , usedefault = True ,
52+ desc = 'use interface\' s current working directory' )
53+
5154
5255class NiftiGeneratorBase (BaseInterface ):
5356 '''Base class for interfaces that produce Nifti files, potentially with
@@ -73,7 +76,12 @@ def _get_out_path(self, meta, idx=None):
7376 out_fmt = '-' .join (out_fmt )
7477 out_fn = (out_fmt % meta ) + self .inputs .out_ext
7578 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+
7785
7886class DcmStackInputSpec (NiftiGeneratorBaseInputSpec ):
7987 dicom_files = traits .Either (InputMultiPath (File (exists = True )),
0 commit comments