Skip to content

Fix DCMStack output #1089

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Next release
============

* FIX: Enable absolute path definitions in DCMStack (https://github.com/nipy/nipype/pull/1089)
* ENH: New algorithm: mesh.WarpPoints applies displacements fields to point sets.
* ENH: Improved FieldMap-Based (FMB) workflow for correction of susceptibility distortions
in EPI seqs. (https://github.com/nipy/nipype/pull/1019)
* ENH: Added interface to simulate DWIs using the multi-tensor model
(https://github.com/nipy/nipype/pull/1085)
* ENH: New mesh.MeshWarpMaths to operate on surface-defined warpings
(https://github.com/nipy/nipype/pull/1016)
* FIX: Refactor P2PDistance, change name to ComputeMeshWarp, add regression tests,
Expand Down
14 changes: 11 additions & 3 deletions nipype/interfaces/dcmstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,15 @@ def sanitize_path_comp(path_comp):
result.append(char)
return ''.join(result)


class NiftiGeneratorBaseInputSpec(TraitedSpec):
out_format = traits.Str(desc="String which can be formatted with "
"meta data to create the output filename(s)")
out_ext = traits.Str('.nii.gz',
usedefault=True,
out_ext = traits.Str('.nii.gz', usedefault=True,
desc="Determines output file type")
use_cwd = traits.Bool(True, usedefault=True,
desc='use interface\'s current working directory')


class NiftiGeneratorBase(BaseInterface):
'''Base class for interfaces that produce Nifti files, potentially with
Expand All @@ -73,7 +76,12 @@ def _get_out_path(self, meta, idx=None):
out_fmt = '-'.join(out_fmt)
out_fn = (out_fmt % meta) + self.inputs.out_ext
out_fn = sanitize_path_comp(out_fn)
return path.join(os.getcwd(), out_fn)

if self.inputs.use_cwd:
return path.join(os.getcwd(), out_fn)
else:
return path.abspath(out_fn)


class DcmStackInputSpec(NiftiGeneratorBaseInputSpec):
dicom_files = traits.Either(InputMultiPath(File(exists=True)),
Expand Down
2 changes: 2 additions & 0 deletions nipype/interfaces/tests/test_auto_DcmStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def test_DcmStack_inputs():
out_ext=dict(usedefault=True,
),
out_format=dict(),
use_cwd=dict(usedefault=True,
),
)
inputs = DcmStack.input_spec()

Expand Down
2 changes: 2 additions & 0 deletions nipype/interfaces/tests/test_auto_GroupAndStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def test_GroupAndStack_inputs():
out_ext=dict(usedefault=True,
),
out_format=dict(),
use_cwd=dict(usedefault=True,
),
)
inputs = GroupAndStack.input_spec()

Expand Down
2 changes: 2 additions & 0 deletions nipype/interfaces/tests/test_auto_MergeNifti.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ def test_MergeNifti_inputs():
),
out_format=dict(),
sort_order=dict(),
use_cwd=dict(usedefault=True,
),
)
inputs = MergeNifti.input_spec()

Expand Down
2 changes: 2 additions & 0 deletions nipype/interfaces/tests/test_auto_SplitNifti.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ def test_SplitNifti_inputs():
),
out_format=dict(),
split_dim=dict(),
use_cwd=dict(usedefault=True,
),
)
inputs = SplitNifti.input_spec()

Expand Down