Skip to content

Commit 4bea9be

Browse files
committed
enh: update possible extensions
1 parent 407ea43 commit 4bea9be

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

nipype/interfaces/dcm2nii.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ class Dcm2niixInputSpec(CommandLineInputSpec):
330330
False,
331331
argstr='-t',
332332
usedefault=True,
333-
desc="Flag if text notes include private patient details")
333+
desc="Text notes including private patient details")
334334
compression = traits.Enum(
335335
1, 2, 3, 4, 5, 6, 7, 8, 9,
336336
argstr='-%d',
@@ -348,6 +348,9 @@ class Dcm2niixInputSpec(CommandLineInputSpec):
348348
philips_float = traits.Bool(
349349
argstr='-p',
350350
desc="Philips precise float (not display) scaling")
351+
to_nrrd = traits.Bool(
352+
argstr="-e",
353+
desc="Export as NRRD instead of NIfTI")
351354

352355

353356
class Dcm2niixOutputSpec(TraitedSpec):
@@ -395,8 +398,11 @@ def version(self):
395398
return Info.version()
396399

397400
def _format_arg(self, opt, spec, val):
398-
bools = ['bids_format', 'merge_imgs', 'single_file', 'verbose', 'crop',
399-
'has_private', 'anon_bids', 'ignore_deriv', 'philips_float']
401+
bools = [
402+
'bids_format', 'merge_imgs', 'single_file', 'verbose', 'crop',
403+
'has_private', 'anon_bids', 'ignore_deriv', 'philips_float',
404+
'to_nrrd',
405+
]
400406
if opt in bools:
401407
spec = deepcopy(spec)
402408
if val:
@@ -425,17 +431,27 @@ def _parse_stdout(self, stdout):
425431

426432
def _parse_files(self, filenames):
427433
outfiles, bvals, bvecs, bids = [], [], [], []
428-
outtypes = (".nii", ".nii.gz", ".bval", ".bvec", ".json")
434+
outtypes = [".gz", ".bval", ".bvec", ".json", ".txt"]
435+
if self.to_nrrd:
436+
outtypes += [".nrrd", ".nhdr"]
437+
else:
438+
outtypes += [".nii"]
439+
429440
for filename in filenames:
430441
# search for relevant files, and sort accordingly
431442
for fl in search_files(filename, outtypes):
432-
if fl.endswith(".nii") or fl.endswith(".gz"):
443+
if (
444+
fl.endswith(".nii") or
445+
fl.endswith(".gz") or
446+
fl.endswith(".nrrd") or
447+
fl.endswith(".nhdr")
448+
):
433449
outfiles.append(fl)
434450
elif fl.endswith(".bval"):
435451
bvals.append(fl)
436452
elif fl.endswith(".bvec"):
437453
bvecs.append(fl)
438-
elif fl.endswith(".json"):
454+
elif fl.endswith(".json") or fl.endswith(".txt"):
439455
bids.append(fl)
440456
self.output_files = outfiles
441457
self.bvecs = bvecs

nipype/interfaces/tests/test_auto_Dcm2niix.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def test_Dcm2niix_inputs():
6161
position=-1,
6262
xor=['source_dir'],
6363
),
64+
to_nrrd=dict(argstr='-e', ),
6465
verbose=dict(
6566
argstr='-v',
6667
usedefault=True,

0 commit comments

Comments
 (0)