aslprep.niworkflows.interfaces.ants module

Nipype interfaces for ANTs’ commands.

class AI(**inputs)[source]

Bases: ANTSCommand

Wrapped executable: antsAI.

Replaces AffineInitializer.

Mandatory Inputs:
  • fixed_image (a string or os.PathLike object referring to an existing file) – Image to which the moving_image should be transformed.

  • metric (a tuple of the form: (‘Mattes’ or ‘GC’ or ‘MI’, an integer, ‘Regular’ or ‘Random’ or ‘None’, 0.0 <= a floating point number <= 1.0)) – The metric(s) to use. Maps to a command-line argument: -m %s.

  • moving_image (a string or os.PathLike object referring to an existing file) – Image that will be transformed to fixed_image.

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

  • convergence (a tuple of the form: (1 <= an integer <= 10000, a float, 1 <= an integer <= 100)) – Convergence. Maps to a command-line argument: -c [%d,%f,%d]. (Nipype default value: (10, 1e-06, 10))

  • dimension (an integer) – Dimension of output image. Maps to a command-line argument: -d %d. (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: {})

  • fixed_image_mask (a string or os.PathLike object referring to an existing file) – Fixed mage mask. Maps to a command-line argument: -x %s.

  • moving_image_mask (a string or os.PathLike object referring to an existing file) – Moving mage mask. Requires inputs: fixed_image_mask.

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

  • output_transform (a string or os.PathLike object) – Output file name. Maps to a command-line argument: -o %s. (Nipype default value: initialization.mat)

  • principal_axes (a boolean) – Align using principal axes. Maps to a command-line argument: -p %d. Mutually exclusive with inputs: blobs. (Nipype default value: False)

  • search_factor (a tuple of the form: (a float, 0.0 <= a floating point number <= 1.0)) – Search factor. Maps to a command-line argument: -s [%f,%f]. (Nipype default value: (20, 0.12))

  • search_grid (a tuple of the form: (a float, a tuple of the form: (a float, a float, a float)) or a tuple of the form: (a float, a tuple of the form: (a float, a float))) – Translation search grid in mm. Maps to a command-line argument: -g %s.

  • transform (a tuple of the form: (‘Affine’ or ‘Rigid’ or ‘Similarity’, a floating point number > 0.0)) – Several transform options are available. Maps to a command-line argument: -t %s[%f]. (Nipype default value: ('Affine', 0.1))

  • verbose (a boolean) – Enable verbosity. Maps to a command-line argument: -v %d. (Nipype default value: False)

Outputs:

output_transform (a string or os.PathLike object referring to an existing file) – Output file name.

class AntsJointFusion(**inputs)[source]

Bases: ANTSCommand

Wrapped executable: antsJointFusion.

Run antsJoinFusion (finds the consensus segmentation).

Mandatory Inputs:
  • atlas_image (a list of items which are a list of items which are a pathlike object or string representing an existing file) – The atlas image (or multimodal atlas images) assumed to be aligned to a common image domain. Maps to a command-line argument: -g %s....

  • atlas_segmentation_image (a list of items which are a pathlike object or string representing an existing file) – The atlas segmentation images. For performing label fusion the number of specified segmentations should be identical to the number of atlas image sets. Maps to a command-line argument: -l %s....

  • target_image (a list of items which are a list of items which are a pathlike object or string representing an existing file) – The target image (or multimodal target images) assumed to be aligned to a common image domain. Maps to a command-line argument: -t %s.

Optional Inputs:
  • alpha (a float) – Regularization term added to matrix Mx for calculating the inverse. Default = 0.1. Maps to a command-line argument: -a %s. (Nipype default value: 0.1)

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

  • beta (a float) – Exponent for mapping intensity difference to the joint error. Default = 2.0. Maps to a command-line argument: -b %s. (Nipype default value: 2.0)

  • constrain_nonnegative (a boolean) – Constrain solution to non-negative weights. Maps to a command-line argument: -c. (Nipype default value: False)

  • dimension (3 or 2 or 4) – This option forces the image to be treated as a specified-dimensional image. If not specified, the program tries to infer the dimensionality from the input image. Maps to a command-line argument: -d %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: {})

  • exclusion_image (a list of items which are a pathlike object or string representing an existing file) – Specify an exclusion region for the given label.

  • exclusion_image_label (a list of items which are a string) – Specify a label for the exclusion region. Maps to a command-line argument: -e %s. Requires inputs: exclusion_image.

  • mask_image (a pathlike object or string representing an existing file) – If a mask image is specified, fusion is only performed in the mask region. Maps to a command-line argument: -x %s.

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

  • out_atlas_voting_weight_name_format (a string) – Optional atlas voting weight image file name format. Requires inputs: out_label_fusion, out_intensity_fusion_name_format, out_label_post_prob_name_format.

  • out_intensity_fusion_name_format (a string) – Optional intensity fusion image file name format. (e.g. “antsJointFusionIntensity_%d.nii.gz”).

  • out_label_fusion (a pathlike object or string representing a file) – The output label fusion image. Maps to a command-line argument: %s.

  • out_label_post_prob_name_format (a string) – Optional label posterior probability image file name format. Requires inputs: out_label_fusion, out_intensity_fusion_name_format.

  • patch_metric (‘PC’ or ‘MSQ’) – Metric to be used in determining the most similar neighborhood patch. Options include Pearson’s correlation (PC) and mean squares (MSQ). Default = PC (Pearson correlation). Maps to a command-line argument: -m %s.

  • patch_radius (a list of items which are a value of class ‘int’) – Patch radius for similarity measures.Default: 2x2x2. Maps to a command-line argument: -p %s.

  • retain_atlas_voting_images (a boolean) – Retain atlas voting images. Default = false. Maps to a command-line argument: -f. (Nipype default value: False)

  • retain_label_posterior_images (a boolean) – Retain label posterior probability images. Requires atlas segmentations to be specified. Default = false. Maps to a command-line argument: -r. Requires inputs: atlas_segmentation_image. (Nipype default value: False)

  • search_radius (a list of from 1 to 3 items which are any value) – Search radius for similarity measures. Default = 3x3x3. One can also specify an image where the value at the voxel specifies the isotropic search radius at that voxel. Maps to a command-line argument: -s %s. (Nipype default value: [3, 3, 3])

  • verbose (a boolean) – Verbose output. Maps to a command-line argument: -v.

Outputs:
  • out_atlas_voting_weight (a list of items which are a pathlike object or string representing an existing file)

  • out_intensity_fusion (a list of items which are a pathlike object or string representing an existing file)

  • out_label_fusion (a pathlike object or string representing an existing file)

  • out_label_post_prob (a list of items which are a pathlike object or string representing an existing file)

class ImageMath(**inputs)[source]

Bases: ANTSCommand

Wrapped executable: ImageMath.

Operations over images.

Example

>>> maths = ImageMath(dimension=3, op1=nifti_fname, operation='+', op2='2')
>>> result = maths.run()
>>> np.all(nb.load(result.outputs.output_image).get_sform() ==
...        nb.load(nifti_fname).get_sform())
True
Mandatory Inputs:
  • op1 (a pathlike object or string representing an existing file) – First operator. Maps to a command-line argument: %s (position: -2).

  • operation (a string) – Operations and intputs. 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.

  • copy_header (a boolean) – Copy headers of the original image into the output (corrected) file. (Nipype default value: True)

  • dimension (an integer) – Dimension of output image. Maps to a command-line argument: %d (position: 1). (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: {})

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

  • op2 (a pathlike object or string representing an existing file or a string) – Second operator. Maps to a command-line argument: %s (position: -1).

  • output_image (a pathlike object or string representing a file) – Output image file. Maps to a command-line argument: %s (position: 2).

Outputs:

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

class ResampleImageBySpacing(**inputs)[source]

Bases: ANTSCommand

Wrapped executable: ResampleImageBySpacing.

Resample an image with a given spacing.

Examples

>>> res = ResampleImageBySpacing(dimension=3)
>>> res.inputs.input_image = nifti_fname
>>> res.inputs.output_image = 'output.nii.gz'
>>> res.inputs.out_spacing = (4, 4, 4)
>>> res.cmdline  
'ResampleImageBySpacing 3 .../test.nii.gz output.nii.gz 4 4 4'
>>> res = ResampleImageBySpacing(dimension=3)
>>> res.inputs.input_image = nifti_fname
>>> res.inputs.output_image = 'output.nii.gz'
>>> res.inputs.out_spacing = (4, 4, 4)
>>> res.inputs.apply_smoothing = True
>>> res.cmdline  
'ResampleImageBySpacing 3 .../test.nii.gz output.nii.gz 4 4 4 1'
>>> res = ResampleImageBySpacing(dimension=3)
>>> res.inputs.input_image = nifti_fname
>>> res.inputs.output_image = 'output.nii.gz'
>>> res.inputs.out_spacing = (0.4, 0.4, 0.4)
>>> res.inputs.apply_smoothing = True
>>> res.inputs.addvox = 2
>>> res.inputs.nn_interp = False
>>> res.cmdline  
'ResampleImageBySpacing 3 .../test.nii.gz output.nii.gz 0.4 0.4 0.4 1 2 0'
Mandatory Inputs:
  • input_image (a pathlike object or string representing an existing file) – Input image file. Maps to a command-line argument: %s (position: 2).

  • out_spacing (a list of from 2 to 3 items which are a float or a tuple of the form: (a float, a float, a float) or a tuple of the form: (a float, a float)) – Output spacing. Maps to a command-line argument: %s (position: 4).

Optional Inputs:
  • addvox (an integer) – Addvox pads each dimension by addvox. Maps to a command-line argument: %d (position: 6). Requires inputs: apply_smoothing.

  • apply_smoothing (a boolean) – Smooth before resampling. Maps to a command-line argument: %d (position: 5).

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

  • dimension (an integer) – Dimension of output image. Maps to a command-line argument: %d (position: 1). (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: {})

  • nn_interp (a boolean) – Nn interpolation. Maps to a command-line argument: %d (position: -1). Requires inputs: addvox.

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

  • output_image (a pathlike object or string representing a file) – Output image file. Maps to a command-line argument: %s (position: 3).

Outputs:

output_image (a string or os.PathLike object referring to an existing file) – Resampled file.

class ThresholdImage(**inputs)[source]

Bases: ANTSCommand

Wrapped executable: ThresholdImage.

Apply thresholds on images.

Examples

>>> thres = ThresholdImage(dimension=3)
>>> thres.inputs.input_image = nifti_fname
>>> thres.inputs.output_image = 'output.nii.gz'
>>> thres.inputs.th_low = 0.5
>>> thres.inputs.th_high = 1.0
>>> thres.inputs.inside_value = 1.0
>>> thres.inputs.outside_value = 0.0
>>> thres.cmdline  
'ThresholdImage 3 .../test.nii.gz output.nii.gz 0.500000 1.000000 1.000000 0.000000'
>>> result = thres.run()
>>> os.path.exists(result.outputs.output_image)
True
>>> thres = ThresholdImage(dimension=3)
>>> thres.inputs.input_image = nifti_fname
>>> thres.inputs.output_image = 'output.nii.gz'
>>> thres.inputs.mode = 'Kmeans'
>>> thres.inputs.num_thresholds = 4
>>> thres.cmdline  
'ThresholdImage 3 .../test.nii.gz output.nii.gz Kmeans 4'
Mandatory Inputs:
  • copy_header (a boolean) – Copy headers of the original image into the output (corrected) file. (Nipype default value: True)

  • input_image (a pathlike object or string representing an existing file) – Input image file. Maps to a command-line argument: %s (position: 2).

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

  • dimension (an integer) – Dimension of output image. Maps to a command-line argument: %d (position: 1). (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: {})

  • input_mask (a pathlike object or string representing an existing file) – Input mask for Otsu, Kmeans. Maps to a command-line argument: %s. Requires inputs: num_thresholds.

  • inside_value (a float) – Inside value. Maps to a command-line argument: %f (position: 6). Requires inputs: th_low.

  • mode (‘Otsu’ or ‘Kmeans’) – Whether to run Otsu / Kmeans thresholding. Maps to a command-line argument: %s (position: 4). Mutually exclusive with inputs: th_low, th_high. Requires inputs: num_thresholds.

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

  • num_thresholds (an integer) – Number of thresholds. Maps to a command-line argument: %d (position: 5).

  • output_image (a pathlike object or string representing a file) – Output image file. Maps to a command-line argument: %s (position: 3).

  • outside_value (a float) – Outside value. Maps to a command-line argument: %f (position: 7). Requires inputs: th_low.

  • th_high (a float) – Upper threshold. Maps to a command-line argument: %f (position: 5). Mutually exclusive with inputs: mode.

  • th_low (a float) – Lower threshold. Maps to a command-line argument: %f (position: 4). Mutually exclusive with inputs: mode.

Outputs:

output_image (a string or os.PathLike object referring to an existing file) – Resampled file.