Skip to content

Commit 7ffda68

Browse files
committed
removed "echo" input in favour of "suffix"
1 parent 5841a7f commit 7ffda68

File tree

1 file changed

+14
-28
lines changed

1 file changed

+14
-28
lines changed

pydra/tasks/dcm2niix/utils.py

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,42 @@
44
from pydra.engine.specs import ShellSpec, ShellOutSpec, File, Directory, SpecInfo
55

66

7-
def out_file_path(out_dir, filename, echo, suffix, ext):
8-
# Append echo number of NIfTI echo to select is provided
9-
if suffix:
10-
file_suffix = "_" + suffix
11-
elif echo:
12-
file_suffix = f"_e{echo}"
13-
else:
14-
file_suffix = ""
7+
def out_file_path(out_dir, filename, suffix, ext):
8+
"""Attempting to handle the different suffixes that are appended to filenames
9+
created by Dcm2niix (see https://github.com/rordenlab/dcm2niix/blob/master/FILENAMING.md)
10+
"""
1511

16-
fpath = Path(f"{out_dir}/{filename}{file_suffix}{ext}").absolute()
12+
fpath = Path(f"{out_dir}/{filename}{suffix}{ext}").absolute()
1713

1814
# Check to see if multiple echos exist in the DICOM dataset
1915
if not fpath.exists():
2016
neighbours = [str(p) for p in fpath.parent.iterdir() if p.name.endswith(ext)]
2117
raise ValueError(
22-
f"\nDid not find expected file '{fpath}' after DICOM -> NIfTI "
23-
"conversion, instead found (check provided echo and suffix):\n"
18+
f"\nDid not find expected file '{fpath}' (suffix={suffix}) "
19+
"after DICOM -> NIfTI conversion, please see "
20+
"https://github.com/rordenlab/dcm2niix/blob/master/FILENAMING.md for the "
21+
"list of suffixes that dcm2niix produces and provide an appropriate "
22+
"suffix. Found the following files with matching extensions:\n"
2423
+ "\n".join(neighbours)
2524
)
2625

2726
return fpath
2827

2928

30-
def dcm2niix_out_file(out_dir, filename, echo, suffix, compress):
29+
def dcm2niix_out_file(out_dir, filename, suffix, compress):
3130

3231
ext = ".nii"
3332
# If compressed, append the zip extension
3433
if compress in ("y", "o", "i"):
3534
ext += ".gz"
3635

37-
return out_file_path(out_dir, filename, echo, suffix, ext)
36+
return out_file_path(out_dir, filename, suffix, ext)
3837

3938

40-
def dcm2niix_out_json(out_dir, filename, echo, suffix, bids):
39+
def dcm2niix_out_json(out_dir, filename, suffix, bids):
4140
# Append echo number of NIfTI echo to select is provided
4241
if bids in ("y", "o"):
43-
fpath = out_file_path(out_dir, filename, echo, suffix, ".json")
42+
fpath = out_file_path(out_dir, filename, suffix, ".json")
4443
else:
4544
fpath = attrs.NOTHING
4645
return fpath
@@ -72,19 +71,6 @@ def dcm2niix_out_json(out_dir, filename, echo, suffix, bids):
7271
"out_file",
7372
{"argstr": "-f '{filename}'", "help_string": "The output name for the file"},
7473
),
75-
(
76-
"echo",
77-
int,
78-
{
79-
"argstr": "",
80-
"help_string": (
81-
"The echo number to extract from the DICOM dataset. When multiple "
82-
"echoes are discovered in the dataset then dcm2niix will create "
83-
"separate files for each echo with the suffix '_e<echo-number>.nii'"
84-
),
85-
"xor": ["suffix"],
86-
},
87-
),
8874
(
8975
"suffix",
9076
str,

0 commit comments

Comments
 (0)