3
3
from pydra .engine .specs import ShellSpec , ShellOutSpec , File , Directory , SpecInfo
4
4
5
5
6
- def dcm2niix_out_file (out_dir , filename , echo , compress ):
6
+ def dcm2niix_out_file (out_dir , filename , echo , suffix , compress ):
7
7
# 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 } "
10
12
else :
11
- echo_suffix = ""
13
+ file_suffix = ""
12
14
13
- out_file = f"{ out_dir } /{ filename } { echo_suffix } .nii"
15
+ out_file = f"{ out_dir } /{ filename } { file_suffix } .nii"
14
16
15
17
# If compressed, append the zip extension
16
18
if compress in ("y" , "o" , "i" ):
@@ -20,16 +22,17 @@ def dcm2niix_out_file(out_dir, filename, echo, compress):
20
22
21
23
# Check to see if multiple echos exist in the DICOM dataset
22
24
if not out_file .exists ():
23
- if echos := [
25
+ if echoes := [
24
26
str (p )
25
27
for p in out_file .parent .iterdir ()
26
- if p .stem .startswith (out_file . stem + "_e" )
28
+ if p .stem .startswith (filename + "_e" )
27
29
]:
28
30
raise ValueError (
29
31
"DICOM dataset contains multiple echos, please specify which "
30
32
"echo you want via the 'echo' input:\n "
31
- "\n " .join (echos )
33
+ "\n " .join (echoes )
32
34
)
35
+
33
36
return out_file
34
37
35
38
@@ -79,6 +82,22 @@ def dcm2niix_out_json(out_dir, filename, echo):
79
82
"echoes are discovered in the dataset then dcm2niix will create "
80
83
"separate files for each echo with the suffix '_e<echo-number>.nii'"
81
84
),
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" ],
82
101
},
83
102
),
84
103
(
0 commit comments