Skip to content

Commit

Permalink
Merge pull request #1 from satra/antsct
Browse files Browse the repository at this point in the history
Antsct
  • Loading branch information
armaneshaghi committed Sep 2, 2014
2 parents 3c7fe61 + ed15c70 commit d409f1c
Show file tree
Hide file tree
Showing 29 changed files with 918 additions and 366 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -4,7 +4,7 @@ python:
- 2.7
# Setup anaconda
before_install:
- if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then wget http://repo.continuum.io/miniconda/Miniconda-3.0.0-Linux-x86_64.sh -O miniconda.sh; else wget http://repo.continuum.io/miniconda/Miniconda3-3.0.0-Linux-x86_64.sh -O miniconda.sh; fi
- if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh; else wget http://repo.continuum.io/miniconda/Miniconda3-3.6.0-Linux-x86_64.sh -O miniconda.sh; fi
- chmod +x miniconda.sh
- ./miniconda.sh -b
- export PATH=/home/travis/miniconda/bin:$PATH
Expand Down
1 change: 1 addition & 0 deletions CHANGES
@@ -1,6 +1,7 @@
Next Release
============

* ENH: New FSL interfaces: WarpPoints, WarpPointsToStd.
* ENH: New Freesurfer interface: MRIPretess
* ENH: New miscelaneous interface: AddCSVRow
* ENH: FUGUE interface has been refactored to use the name_template system, 3 examples
Expand Down
6 changes: 6 additions & 0 deletions nipype/interfaces/afni/tests/test_auto_Volreg.py
Expand Up @@ -32,6 +32,11 @@ def test_Volreg_inputs():
name_source='in_file',
name_template='%s.1D',
),
oned_matrix_save=dict(argstr='-1Dmatrix_save %s',
keep_extension=True,
name_source='in_file',
name_template='%s.aff12.1D',
),
out_file=dict(argstr='-prefix %s',
name_source='in_file',
name_template='%s_volreg',
Expand All @@ -57,6 +62,7 @@ def test_Volreg_inputs():
def test_Volreg_outputs():
output_map = dict(md1d_file=dict(),
oned_file=dict(),
oned_matrix_save=dict(),
out_file=dict(),
)
outputs = Volreg.output_spec()
Expand Down
54 changes: 26 additions & 28 deletions nipype/interfaces/ants/segmentation.py
Expand Up @@ -319,8 +319,7 @@ class antsCorticalThicknessInputSpec(ANTSCommandInputSpec):
desc=('Prefix that is prepended to all output'
' files (default = antsCT_)'))
image_suffix=traits.Str('nii.gz', desc=('any of standard ITK formats,'
' nii.gz is default'), mandatory = False, argstr='-s %s',
usedefault=True)
' nii.gz is default'), argstr='-s %s', usedefault=True)
t1_registration_template = File(exists=True,
desc = ('Anatomical *intensity* template'
'(assumed to be skull-stripped). A common'
Expand All @@ -330,56 +329,54 @@ class antsCorticalThicknessInputSpec(ANTSCommandInputSpec):
argstr='-t %s',
mandatory=True)
extraction_registration_mask=File(exists=True, argstr='-f %s',
mandatory=False, desc='Mask (defined in the template'
'space) used during registration for brain extraction.')
keep_temporary_files=traits.Int(argstrr='-k %d',
desc='Keep brain extraction/segmentation'
'warps, etc (default = 0).', mandatory=False)
desc=('Mask (defined in the template space) used during'
' registration for brain extraction.'))
keep_temporary_files=traits.Int(argstr='-k %d',
desc='Keep brain extraction/segmentation warps, etc (default = 0).')
max_iterations=traits.Int(argstr='-i %d',
desc='ANTS registration max iterations'
'(default = 100x100x70x20)', mandatory=False)
prior_segmentation_weight=traits.Float(mandatory=False, argstr='-w %f',
'(default = 100x100x70x20)')
prior_segmentation_weight=traits.Float(argstr='-w %f',
desc='Atropos spatial prior *probability* weight for'
'the segmentation')
segmentation_iterations=traits.Int(argstr='-n %d', mandatory=False,
segmentation_iterations=traits.Int(argstr='-n %d',
desc='N4 -> Atropos -> N4 iterations during segmentation'
'(default = 3)')
posterior_formulation=traits.Str(argstr='-b %s', mandatory=False,
posterior_formulation=traits.Str(argstr='-b %s',
desc=('Atropos posterior formulation and whether or not'
'to use mixture model proportions.'
'''e.g 'Socrates[1]' (default) or 'Aristotle[1]'.'''
'Choose the latter if you'
'want use the distance priors (see also the -l option'
'for label propagation control).'))
use_floatingpoint_precision=traits.Enum(0, 1, argstr='-j %d',
mandatory=False,
desc='Use floating point precision in registrations (default = 0)')
use_random_seeding=traits.Enum(0, 1, argstr='-u %d', mandatory=False,
desc='Use random number generated from system clock in Atropos'
'(default = 1)')
b_spline_smoothing=traits.Bool(argst='-v', mandatory=False,
desc='Use B-spline SyN for registrations and B-spline'
'exponential mapping in DiReCT.')
cortical_label_image=File(exists=True, mandatory=False,
use_random_seeding=traits.Enum(0, 1, argstr='-u %d',
desc=('Use random number generated from system clock in Atropos'
'(default = 1)'))
b_spline_smoothing=traits.Bool(argstr='-v',
desc=('Use B-spline SyN for registrations and B-spline'
'exponential mapping in DiReCT.'))
cortical_label_image=File(exists=True,
desc='Cortical ROI labels to use as a prior for ATITH.')
label_propagation=traits.Str(argstr='-l %s', mandatory=False,
desc='Incorporate a distance prior one the posterior formulation. Should be'
label_propagation=traits.Str(argstr='-l %s',
desc=('Incorporate a distance prior one the posterior formulation. Should be'
'''of the form 'label[lambda,boundaryProbability]' where label'''
'is a value of 1,2,3,... denoting label ID. The label'
'probability for anything outside the current label'
' = boundaryProbability * exp( -lambda * distanceFromBoundary )'
'Intuitively, smaller lambda values will increase the spatial capture'
'range of the distance prior. To apply to all label values, simply omit'
'specifying the label, i.e. -l [lambda,boundaryProbability].')
quick_registration=traits.Bool(argstr='-q 1', mandatory=False,
desc='If = 1, use antsRegistrationSyNQuick.sh as the basis for registration'
'specifying the label, i.e. -l [lambda,boundaryProbability].'))
quick_registration=traits.Bool(argstr='-q 1',
desc=('If = 1, use antsRegistrationSyNQuick.sh as the basis for registration'
'during brain extraction, brain segmentation, and'
'(optional) normalization to a template.'
'Otherwise use antsRegistrationSyN.sh (default = 0).')
debug=traits.Bool(argstr='-z 1', mandatory=False,
desc='If > 0, runs a faster version of the script.'
'Otherwise use antsRegistrationSyN.sh (default = 0).'))
debug=traits.Bool(argstr='-z 1',
desc=('If > 0, runs a faster version of the script.'
'Only for testing. Implies -u 0.'
'Requires single thread computation for complete reproducibility.')
'Requires single thread computation for complete reproducibility.'))

class antsCorticalThicknessoutputSpec(TraitedSpec):
BrainExtractionMask=File(exists=True,
Expand Down Expand Up @@ -450,6 +447,7 @@ def _format_arg(self, opt, spec, val):
retval += ext
return retval
return super(ANTSCommand, self)._format_arg(opt, spec, val)

def _run_interface(self, runtime):
priors_directory = os.path.join(os.getcwd(), "priors")
if not os.path.exists(priors_directory):
Expand Down
7 changes: 6 additions & 1 deletion nipype/interfaces/camino/tests/test_auto_ProcStreamlines.py
Expand Up @@ -56,14 +56,18 @@ def test_ProcStreamlines_inputs():
position=-1,
),
outputacm=dict(argstr='-outputacm',
requires=['outputroot', 'seedfile'],
),
outputcbs=dict(argstr='-outputcbs',
requires=['outputroot', 'targetfile', 'seedfile'],
),
outputcp=dict(argstr='-outputcp',
requires=['outputroot', 'seedfile'],
),
outputroot=dict(argstr='-outputroot %s',
),
outputsc=dict(argstr='-outputsc',
requires=['outputroot', 'seedfile'],
),
outputtracts=dict(argstr='-outputtracts',
),
Expand Down Expand Up @@ -103,7 +107,8 @@ def test_ProcStreamlines_inputs():
yield assert_equal, getattr(inputs.traits()[key], metakey), value

def test_ProcStreamlines_outputs():
output_map = dict(proc=dict(),
output_map = dict(outputroot_files=dict(),
proc=dict(),
)
outputs = ProcStreamlines.output_spec()

Expand Down
40 changes: 25 additions & 15 deletions nipype/interfaces/elastix/registration.py
Expand Up @@ -6,7 +6,7 @@
# @Author: oesteban - code@oscaresteban.es
# @Date: 2014-06-02 12:06:50
# @Last Modified by: oesteban
# @Last Modified time: 2014-06-17 10:19:23
# @Last Modified time: 2014-09-01 21:03:57
"""
Interfaces to perform image registrations and to apply the resulting
displacement maps to images and points.
Expand All @@ -18,8 +18,6 @@

from ..base import (CommandLine, CommandLineInputSpec, isdefined,
TraitedSpec, File, traits, InputMultiPath)


from base import ElastixBaseInputSpec

from ... import logging
Expand All @@ -31,10 +29,8 @@ class RegistrationInputSpec(ElastixBaseInputSpec):
desc='fixed image')
moving_image = File(exists=True, mandatory=True, argstr='-m %s',
desc='moving image')

parameters = InputMultiPath(File(exists=True), mandatory=True, argstr='-p %s...',
desc='parameter file, elastix handles 1 or more -p')

fixed_mask = File(exists=True, argstr='-fMask %s', desc='mask for fixed image')
moving_mask = File(exists=True, argstr='-mMask %s', desc='mask for moving image')
initial_transform = File(exists=True, argstr='-t0 %s',
Expand All @@ -51,7 +47,8 @@ class RegistrationOutputSpec(TraitedSpec):


class Registration(CommandLine):
"""Elastix nonlinear registration interface
"""
Elastix nonlinear registration interface
Example
-------
Expand All @@ -63,6 +60,8 @@ class Registration(CommandLine):
>>> reg.inputs.parameters = ['elastix.txt']
>>> reg.cmdline
'elastix -f fixed1.nii -m moving1.nii -out ./ -p elastix.txt'
"""

_cmd = 'elastix'
Expand Down Expand Up @@ -140,17 +139,21 @@ class ApplyWarpOutputSpec(TraitedSpec):
warped_file = File(desc='input moving image warped to fixed image')

class ApplyWarp(CommandLine):
"""Use `transformix` to apply a transform on an input image.
"""
Use ``transformix`` to apply a transform on an input image.
The transform is specified in the transform-parameter file.
Example::
Example
-------
>>> from nipype.interfaces.elastix import ApplyWarp
>>> reg = ApplyWarp()
>>> reg.inputs.moving_image = 'moving1.nii'
>>> reg.inputs.transform_file = 'TransformParameters.0.txt'
>>> reg.cmdline
'transformix -in moving1.nii -out ./ -tp TransformParameters.0.txt'
"""

_cmd = 'transformix'
Expand All @@ -170,22 +173,26 @@ class AnalyzeWarpInputSpec(ElastixBaseInputSpec):


class AnalyzeWarpOutputSpec(TraitedSpec):
disp_field = File(exists=True, desc='displacements field')
jacdet_map = File(exists=True, desc='det(Jacobian) map')
jacmat_map = File(exists=True, desc='Jacobian matrix map')
disp_field = File(desc='displacements field')
jacdet_map = File(desc='det(Jacobian) map')
jacmat_map = File(desc='Jacobian matrix map')

class AnalyzeWarp(CommandLine):
"""Use `transformix` to get details from the input transform (generate
"""
Use transformix to get details from the input transform (generate
the corresponding deformation field, generate the determinant of the
Jacobian map or the Jacobian map itself)
Example::
Example
-------
>>> from nipype.interfaces.elastix import AnalyzeWarp
>>> reg = AnalyzeWarp()
>>> reg.inputs.transform_file = 'TransformParameters.0.txt'
>>> reg.cmdline
'transformix -def all -jac all -jacmat all -out ./ -tp TransformParameters.0.txt'
"""

_cmd = 'transformix -def all -jac all -jacmat all'
Expand Down Expand Up @@ -213,17 +220,20 @@ class PointsWarpOutputSpec(TraitedSpec):
warped_file = File(desc='input points displaced in fixed image domain')

class PointsWarp(CommandLine):
"""Use `transformix` to apply a transform on an input point set.
"""Use ``transformix`` to apply a transform on an input point set.
The transform is specified in the transform-parameter file.
Example::
Example
-------
>>> from nipype.interfaces.elastix import PointsWarp
>>> reg = PointsWarp()
>>> reg.inputs.points_file = 'surf1.vtk'
>>> reg.inputs.transform_file = 'TransformParameters.0.txt'
>>> reg.cmdline
'transformix -out ./ -def surf1.vtk -tp TransformParameters.0.txt'
"""

_cmd = 'transformix'
Expand Down
7 changes: 5 additions & 2 deletions nipype/interfaces/elastix/utils.py
Expand Up @@ -6,7 +6,7 @@
# @Author: oesteban - code@oscaresteban.es
# @Date: 2014-06-17 10:17:07
# @Last Modified by: oesteban
# @Last Modified time: 2014-06-27 10:25:36
# @Last Modified time: 2014-09-01 21:05:33
"""
Generic interfaces to manipulate registration parameters files, including
transform files (to configure warpings)
Expand Down Expand Up @@ -51,14 +51,17 @@ class EditTransform(BaseInterface):
"""
Manipulates an existing transform file generated with elastix
Example::
Example
-------
>>> from nipype.interfaces.elastix import EditTransform
>>> tfm = EditTransform()
>>> tfm.inputs.transform_file = 'TransformParameters.0.txt'
>>> tfm.inputs.reference_image = 'fixed1.nii'
>>> tfm.inputs.output_type = 'unsigned char'
>>> tfm.run() # doctest: +SKIP
"""

input_spec = EditTransformInputSpec
Expand Down
2 changes: 1 addition & 1 deletion nipype/interfaces/fsl/__init__.py
Expand Up @@ -16,7 +16,7 @@
ImageStats, FilterRegressor, Overlay, Slicer,
PlotTimeSeries, PlotMotionParams, ConvertXFM,
SwapDimensions, PowerSpectrum, Reorient2Std,
Complex, InvWarp, WarpUtils, ConvertWarp)
Complex, InvWarp, WarpUtils, ConvertWarp, WarpPoints, WarpPointsToStd)

from .epi import (PrepareFieldmap, TOPUP, ApplyTOPUP, Eddy, EPIDeWarp,
SigLoss, EddyCorrect)
Expand Down

0 comments on commit d409f1c

Please sign in to comment.