55from pydra .engine .specs import ShellSpec , ShellOutSpec , File , Directory , SpecInfo
66
77
8- def out_file_path (out_dir , filename , file_suffix , ext ):
8+ def out_file_path (out_dir , filename , file_postfix , ext ):
99 """Attempting to handle the different suffixes that are appended to filenames
1010 created by Dcm2niix (see https://github.com/rordenlab/dcm2niix/blob/master/FILENAMING.md)
1111 """
1212
13- fpath = Path (out_dir ) / filename
14- fpath = fpath .with_suffix (( file_suffix if file_suffix else "" ) + ext ). absolute ()
13+ fpath = Path (out_dir ) / ( filename + ( file_postfix if file_postfix else "" ) + ext )
14+ fpath = fpath .absolute ()
1515
1616 # Check to see if multiple echos exist in the DICOM dataset
1717 if not fpath .exists ():
18- if file_suffix is not None : # NB: doesn't match attrs.NOTHING
18+ if file_postfix is not None : # NB: doesn't match attrs.NOTHING
1919 neighbours = [
2020 str (p ) for p in fpath .parent .iterdir () if p .name .endswith (ext )
2121 ]
2222 raise ValueError (
23- f"\n Did not find expected file '{ fpath } ' (file_suffix= { file_suffix } ) "
23+ f"\n Did not find expected file '{ fpath } ' (file_postfix= { file_postfix } ) "
2424 "after DICOM -> NIfTI conversion, please see "
2525 "https://github.com/rordenlab/dcm2niix/blob/master/FILENAMING.md for the "
26- "list of suffixes that dcm2niix produces and provide an appropriate "
27- "suffix , or set suffix to None to ignore matching a single file and use "
26+ "list of postfixes that dcm2niix produces and provide an appropriate "
27+ "postfix , or set postfix to None to ignore matching a single file and use "
2828 "the list returned in 'out_files' instead. Found the following files "
2929 "with matching extensions:\n " + "\n " .join (neighbours )
3030 )
@@ -34,20 +34,20 @@ def out_file_path(out_dir, filename, file_suffix, ext):
3434 return fpath
3535
3636
37- def dcm2niix_out_file (out_dir , filename , suffix , compress ):
37+ def dcm2niix_out_file (out_dir , filename , file_postfix , compress ):
3838
3939 ext = ".nii"
4040 # If compressed, append the zip extension
4141 if compress in ("y" , "o" , "i" ):
4242 ext += ".gz"
4343
44- return out_file_path (out_dir , filename , suffix , ext )
44+ return out_file_path (out_dir , filename , file_postfix , ext )
4545
4646
47- def dcm2niix_out_json (out_dir , filename , suffix , bids ):
47+ def dcm2niix_out_json (out_dir , filename , file_postfix , bids ):
4848 # Append echo number of NIfTI echo to select is provided
49- if bids in ("y" , "o" ):
50- fpath = out_file_path (out_dir , filename , suffix , ".json" )
49+ if bids is attrs . NOTHING or bids in ("y" , "o" ):
50+ fpath = out_file_path (out_dir , filename , file_postfix , ".json" )
5151 else :
5252 fpath = attrs .NOTHING
5353 return fpath
@@ -88,21 +88,19 @@ def dcm2niix_out_files(out_dir, filename):
8888 {"argstr" : "-f '{filename}'" , "help_string" : "The output name for the file" },
8989 ),
9090 (
91- "file_suffix " ,
91+ "file_postfix " ,
9292 str ,
9393 {
9494 "help_string" : (
95- "The suffix appended to the output filename, used to select which "
95+ "The postfix appended to the output filename. Used to select which "
9696 "of the disambiguated nifti files created by dcm2niix to return "
9797 "in this field (see https://github.com/"
9898 "rordenlab/dcm2niix/blob/master/FILENAMING.md"
9999 "#file-name-post-fixes-image-disambiguation). Set to None to skip "
100100 "matching a single file (out_file will be set to attrs.NOTHING if the "
101- "base filepath without suffixes doesn't exist) and handle the list of "
101+ "base path without postfixes doesn't exist) and handle the list of "
102102 "output files returned in 'out_files' instead."
103103 ),
104- "xor" : ["echo" ],
105- "allowed_values" : ["Eq" , "ph" , "imaginary" , "MoCo" , "real" , "phMag" ],
106104 },
107105 ),
108106 (
@@ -355,8 +353,11 @@ def dcm2niix_out_files(out_dir, filename):
355353 File ,
356354 {
357355 "help_string" : (
358- "output NIfTI image. If multiple nifti files are created and 'suffix' "
359- "is provided then " ,
356+ "output NIfTI image. If multiple nifti files are created (e.g. for "
357+ "different echoes), then the 'file_postfix' input can be provided to "
358+ "select which of them is considered the 'out_file'. Otherwise it "
359+ "should be set to None and 'out_files' used instead (in which case "
360+ "'out_file' will be set to attrs.NOTHING)" ,
360361 ),
361362 "callable" : dcm2niix_out_file ,
362363 "mandatory" : True ,
@@ -389,7 +390,7 @@ def dcm2niix_out_files(out_dir, filename):
389390 ),
390391 (
391392 "out_files" ,
392- ty . List [ File ] ,
393+ list ,
393394 {
394395 "help_string" : (
395396 "all output files in a list, including files disambiguated "
0 commit comments