xcp_d.interfaces.ants module

ANTS interfaces.

class xcp_d.interfaces.ants.ApplyTransforms(**inputs)[source]

Bases: FixHeaderApplyTransforms

Wrapped executable: antsApplyTransforms.

A modified version of FixHeaderApplyTransforms from niworkflows.

The niworkflows version of ApplyTransforms “fixes the resampled image header to match the xform of the reference image”. This modification overrides the allowed interpolation values, since FixHeaderApplyTransforms doesn’t support GenericLabel, which is preferred over MultiLabel.

Mandatory Inputs:
  • input_image (a pathlike object or string representing an existing file) – Image to apply transformation to (generally a coregistered functional). Maps to a command-line argument: --input %s.

  • reference_image (a pathlike object or string representing an existing file) – Reference image space that you wish to warp INTO. Maps to a command-line argument: --reference-image %s.

  • transforms (a list of items which are a pathlike object or string representing an existing file or ‘identity’) – Transform files: will be applied in reverse order. For example, the last specified transform will be applied first. Maps to a command-line argument: %s.

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • default_value (a float) – Maps to a command-line argument: --default-value %g. (Nipype default value: 0.0)

  • dimension (2 or 3 or 4) – This option forces the image to be treated as a specified-dimensional image. If not specified, antsWarp tries to infer the dimensionality from the input image. Maps to a command-line argument: --dimensionality %d.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • float (a boolean) – Use float instead of double for computations. Maps to a command-line argument: --float %d. (Nipype default value: False)

  • input_image_type (0 or 1 or 2 or 3) – Option specifying the input image type of scalar (default), vector, tensor, or time series. Maps to a command-line argument: --input-image-type %d.

  • interpolation (‘Linear’ or ‘NearestNeighbor’ or ‘CosineWindowedSinc’ or ‘WelchWindowedSinc’ or ‘HammingWindowedSinc’ or ‘LanczosWindowedSinc’ or ‘MultiLabel’ or ‘Gaussian’ or ‘BSpline’ or ‘GenericLabel’) – Maps to a command-line argument: %s. (Nipype default value: Linear)

  • interpolation_parameters (a tuple of the form: (an integer) or a tuple of the form: (a float, a float))

  • invert_transform_flags (a list of items which are a boolean)

  • num_threads (an integer) – Number of ITK threads to use. (Nipype default value: 1)

  • out_postfix (a string) – Postfix that is appended to all output files (default = _trans). (Nipype default value: _trans)

  • output_image (a string) – Output file name. Maps to a command-line argument: --output %s.

  • print_out_composite_warp_file (a boolean) – Output a composite warp file instead of a transformed image. Requires inputs: output_image.

Outputs:

output_image (a pathlike object or string representing an existing file) – Warped image.

class xcp_d.interfaces.ants.CompositeInvTransformUtil(**inputs)[source]

Bases: ANTSCommand

Wrapped executable: CompositeTransformUtil.

Wrapper for the ANTS CompositeTransformUtil command.

ANTs utility which can combine or break apart transform files into their individual constituent components.

Examples

>>> from nipype.interfaces.ants import CompositeInvTransformUtil
>>> tran = CompositeInvTransformUtil()
>>> tran.inputs.process = 'disassemble'
>>> tran.inputs.in_file = 'output_Composite.h5'
>>> tran.cmdline
'CompositeTransformUtil --disassemble output_Composite.h5 transform'
>>> tran.run()  
example for assembling transformation files
>>> from nipype.interfaces.ants import CompositeInvTransformUtil
>>> tran = CompositeInvTransformUtil()
>>> tran.inputs.process = 'assemble'
>>> tran.inputs.out_file = 'my.h5'
>>> tran.inputs.in_file = ['AffineTransform.mat', 'DisplacementFieldTransform.nii.gz']
>>> tran.cmdline
'CompositeTransformUtil --assemble my.h5 AffineTransform.mat
 DisplacementFieldTransform.nii.gz '
>>> tran.run()  
Mandatory Inputs:

in_file (a list of items which are a pathlike object or string representing an existing file) – Input transform file(s). Maps to a command-line argument: %s... (position: 3).

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • num_threads (an integer) – Number of ITK threads to use. (Nipype default value: 1)

  • out_file (a pathlike object or string representing a file) – Output file path (only used for disassembly). Maps to a command-line argument: %s (position: 2).

  • output_prefix (a string) – A prefix that is prepended to all output files (only used for assembly). Maps to a command-line argument: %s (position: 4). (Nipype default value: transform)

  • process (‘assemble’ or ‘disassemble’) – What to do with the transform inputs (assemble or disassemble). Maps to a command-line argument: --%s (position: 1). (Nipype default value: assemble)

Outputs:
  • affine_transform (a pathlike object or string representing a file) – Affine transform component.

  • displacement_field (a pathlike object or string representing a file) – Displacement field component.

  • out_file (a pathlike object or string representing a file) – Compound transformation file.

class xcp_d.interfaces.ants.ConvertTransformFile(command=None, terminal_output=None, write_cmdline=False, **inputs)[source]

Bases: CommandLine

Wrapped executable: ConvertTransformFile.

Wrapper for the ANTS ConvertTransformFile command.

Utility to read in a transform file (presumed to be in binary format) and output it in various formats. Default output is legacy human-readable text format. Without any options, the output filename extension must be .txt or .tfm to signify a text-formatted transform file.

Mandatory Inputs:

in_transform (a string or os.PathLike object referring to an existing file) – Maps to a command-line argument: %s (position: 1).

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • dimension (3 or 2) – Maps to a command-line argument: %d (position: 0). (Nipype default value: 3)

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • out_transform (a string or os.PathLike object) – Maps to a command-line argument: %s (position: 2).

Outputs:

out_transform (a string or os.PathLike object referring to an existing file)