Skip to content

Output warp fields and jacobian correction files in TOPUP. #1976

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 4 commits into from
Apr 27, 2017
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
24 changes: 22 additions & 2 deletions nipype/interfaces/fsl/epi.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

from ..base import (traits, TraitedSpec, InputMultiPath, File,
isdefined)
from .base import FSLCommand, FSLCommandInputSpec
from .base import FSLCommand, FSLCommandInputSpec, Info


class PrepareFieldmapInputSpec(FSLCommandInputSpec):
Expand Down Expand Up @@ -140,6 +140,13 @@ class TOPUPInputSpec(FSLCommandInputSpec):
out_field = File(argstr='--fout=%s', hash_files=False,
name_source=['in_file'], name_template='%s_field',
desc='name of image file with field (Hz)')
out_warp_prefix = traits.Str("warpfield", argstr='--dfout=%s', hash_files=False,
desc='prefix for the warpfield images (in mm)',
usedefault=True)
out_jac_prefix = traits.Str("jac", argstr='--jacout=%s',
hash_files=False,
desc='prefix for the warpfield images',
usedefault=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does making these required outputs have the potential to produce large amounts of data?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't thinks so. Those files will also be automatically deleted if no used.

out_corrected = File(argstr='--iout=%s', hash_files=False,
name_source=['in_file'], name_template='%s_corrected',
desc='name of 4D image file with unwarped images')
Expand Down Expand Up @@ -212,6 +219,8 @@ class TOPUPOutputSpec(TraitedSpec):
out_movpar = File(exists=True, desc='movpar.txt output file')
out_enc_file = File(desc='encoding directions file output for applytopup')
out_field = File(desc='name of image file with field (Hz)')
out_warps = traits.List(File(exists=True), desc='warpfield images')
out_jacs = traits.List(File(exists=True), desc='Jacobian images')
out_corrected = File(desc='name of 4D image file with unwarped images')
out_logfile = File(desc='name of log-file')

Expand All @@ -237,7 +246,8 @@ class TOPUP(FSLCommand):
>>> topup.cmdline # doctest: +ELLIPSIS +ALLOW_UNICODE
'topup --config=b02b0.cnf --datain=topup_encoding.txt \
--imain=b0_b0rev.nii --out=b0_b0rev_base --iout=b0_b0rev_corrected.nii.gz \
--fout=b0_b0rev_field.nii.gz --logout=b0_b0rev_topup.log'
--fout=b0_b0rev_field.nii.gz --jacout=jac --logout=b0_b0rev_topup.log \
--dfout=warpfield'
>>> res = topup.run() # doctest: +SKIP

"""
Expand Down Expand Up @@ -270,6 +280,16 @@ def _list_outputs(self):
outputs['out_movpar'] = self._gen_fname(base, suffix='_movpar',
ext='.txt', cwd=base_path)

n_vols = nb.load(self.inputs.in_file).shape[-1]
ext = Info.output_type_to_ext(self.inputs.output_type)
fmt = os.path.abspath('{prefix}_{i:02d}{ext}').format
outputs['out_warps'] = [
fmt(prefix=self.inputs.out_warp_prefix, i=i, ext=ext)
for i in range(1, n_vols + 1)]
outputs['out_jacs'] = [
fmt(prefix=self.inputs.out_jac_prefix, i=i, ext=ext)
for i in range(1, n_vols + 1)]

if isdefined(self.inputs.encoding_direction):
outputs['out_enc_file'] = self._get_encfilename()
return outputs
Expand Down
10 changes: 10 additions & 0 deletions nipype/interfaces/fsl/tests/test_auto_TOPUP.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ def test_TOPUP_inputs():
name_source=['in_file'],
name_template='%s_field',
),
out_warp_prefix=dict(argstr='--dfout=%s',
hash_files=False,
usedefault=True,
),
out_jac_prefix=dict(argstr='--jacout=%s',
hash_files=False,
usedefault=True,
),
out_logfile=dict(argstr='--logout=%s',
hash_files=False,
keep_extension=True,
Expand Down Expand Up @@ -98,6 +106,8 @@ def test_TOPUP_outputs():
out_fieldcoef=dict(),
out_logfile=dict(),
out_movpar=dict(),
out_warps=dict(),
out_jacs=dict(),
)
outputs = TOPUP.output_spec()

Expand Down