33from pydra .engine .specs import ShellSpec , ShellOutSpec , File , Directory , SpecInfo
44
55
6- def dcm2niix_out_file (out_dir , filename , echo , compress ):
6+ def dcm2niix_out_file (out_dir , filename , echo , suffix , compress ):
77 # Append echo number of NIfTI echo to select is provided
8- if echo :
9- echo_suffix = f"_e{ echo } "
8+ if suffix :
9+ file_suffix = "_" + suffix
10+ elif echo :
11+ file_suffix = f"_e{ echo } "
1012 else :
11- echo_suffix = ""
13+ file_suffix = ""
1214
13- out_file = f"{ out_dir } /{ filename } { echo_suffix } .nii"
15+ out_file = f"{ out_dir } /{ filename } { file_suffix } .nii"
1416
1517 # If compressed, append the zip extension
1618 if compress in ("y" , "o" , "i" ):
@@ -20,16 +22,17 @@ def dcm2niix_out_file(out_dir, filename, echo, compress):
2022
2123 # Check to see if multiple echos exist in the DICOM dataset
2224 if not out_file .exists ():
23- if echos := [
25+ if echoes := [
2426 str (p )
2527 for p in out_file .parent .iterdir ()
26- if p .stem .startswith (out_file . stem + "_e" )
28+ if p .stem .startswith (filename + "_e" )
2729 ]:
2830 raise ValueError (
2931 "DICOM dataset contains multiple echos, please specify which "
3032 "echo you want via the 'echo' input:\n "
31- "\n " .join (echos )
33+ "\n " .join (echoes )
3234 )
35+
3336 return out_file
3437
3538
@@ -79,6 +82,22 @@ def dcm2niix_out_json(out_dir, filename, echo):
7982 "echoes are discovered in the dataset then dcm2niix will create "
8083 "separate files for each echo with the suffix '_e<echo-number>.nii'"
8184 ),
85+ "xor" : ["suffix" ],
86+ },
87+ ),
88+ (
89+ "suffix" ,
90+ str ,
91+ {
92+ "argstr" : "" ,
93+ "help_string" : (
94+ "A suffix to append to the out_file, used to select which "
95+ "of the disambiguated outputs to return (see https://github.com/"
96+ "rordenlab/dcm2niix/blob/master/FILENAMING.md"
97+ "#file-name-post-fixes-image-disambiguation) "
98+ ),
99+ "xor" : ["echo" ],
100+ "allowed_values" : ["Eq" , "ph" , "imaginary" , "MoCo" , "real" , "phMag" ],
82101 },
83102 ),
84103 (
0 commit comments