niworkflows.interfaces.norm module

A robust ANTs T1-to-MNI registration workflow with fallback retry.

class niworkflows.interfaces.norm.SpatialNormalization(**inputs)[source]

Bases: BaseInterface

An interface to robustly run T1-to-MNI spatial normalization.

Several settings are sequentially tried until some work.

Mandatory Inputs:
  • moving (‘T1w’ or ‘boldref’) – Registration type. (Nipype default value: T1w)

  • moving_image (a pathlike object or string representing an existing file) – Image to apply transformation to.

  • orientation (‘RAS’ or ‘LAS’) – Modify template orientation (should match input image). (Nipype default value: RAS)

  • reference (‘T1w’ or ‘T2w’ or ‘boldref’ or ‘PDw’) – Set the reference modality for registration. (Nipype default value: T1w)

Optional Inputs:
  • explicit_masking (a boolean) – Set voxels outside the masks to zero thus creating an artificial border that can drive the registration. Requires reliable and accurate masks. See https://sourceforge.net/p/advants/discussion/840261/thread/27216e69/#c7ba. (Nipype default value: True)

  • flavor (‘precise’ or ‘testing’ or ‘fast’) – Registration settings parameter set. (Nipype default value: precise)

  • float (a boolean) – Use single precision calculations. (Nipype default value: False)

  • initial_moving_transform (a pathlike object or string representing an existing file) – Transform for initialization.

  • lesion_mask (a pathlike object or string representing an existing file) – Lesion mask image.

  • moving_mask (a pathlike object or string representing an existing file) – Moving image mask.

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

  • reference_image (a pathlike object or string representing an existing file) – Override the reference image.

  • reference_mask (a pathlike object or string representing an existing file) – Reference image mask.

  • settings (a list of items which are a pathlike object or string representing an existing file) – Pass on the list of settings files.

  • template (a string) – Define the template to be used. (Nipype default value: MNI152NLin2009cAsym)

  • template_resolution (1 or 2 or None) – (DEPRECATED) template resolution.

  • template_spec (a dictionary with keys which are a value of class ‘str’ and with values which are any value) – Template specifications.

Outputs:
  • composite_transform (a pathlike object or string representing an existing file) – Composite transform file.

  • elapsed_time (a float) – The total elapsed time as reported by ANTs.

  • forward_invert_flags (a list of items which are a boolean) – List of flags corresponding to the forward transforms.

  • forward_transforms (a list of items which are a pathlike object or string representing an existing file) – List of output transforms for forward registration.

  • inverse_composite_transform (a pathlike object or string representing a file) – Inverse composite transform file.

  • inverse_warped_image (a pathlike object or string representing a file) – Outputs the inverse of the warped image.

  • metric_value (a float) – The final value of metric.

  • reference_image (a pathlike object or string representing an existing file) – Reference image used for registration target.

  • reverse_forward_invert_flags (a list of items which are a boolean) – List of flags corresponding to the forward transforms reversed for antsApplyTransform.

  • reverse_forward_transforms (a list of items which are a pathlike object or string representing an existing file) – List of output transforms for forward registration reversed for antsApplyTransform.

  • reverse_invert_flags (a list of items which are a boolean) – List of flags corresponding to the reverse transforms.

  • reverse_transforms (a list of items which are a pathlike object or string representing an existing file) – List of output transforms for reverse registration.

  • save_state (a pathlike object or string representing a file) – The saved registration state to be restored.

  • warped_image (a pathlike object or string representing a file) – Outputs warped image.

niworkflows.interfaces.norm.create_cfm(in_file, lesion_mask=None, global_mask=True, out_path=None)[source]

Create a mask to constrain registration.

Parameters:
  • in_file (str) – Path to an existing image (usually a mask). If global_mask = True, this is used as a size/dimension reference.

  • out_path (str) – Path/filename for the new cost function mask.

  • lesion_mask (str, optional) – Path to an existing binary lesion mask.

  • global_mask (bool) – Create a whole-image mask (True) or limit to reference mask (False) A whole image-mask is 1 everywhere

Returns:

Absolute path of the new cost function mask.

Return type:

str

Notes

in_file and lesion_mask must be in the same image space and have the same dimensions

niworkflows.interfaces.norm.mask(in_file, mask_file, new_name)[source]

Apply a binary mask to an image.

Parameters:
  • in_file (str) – Path to a NIfTI file to mask

  • mask_file (str) – Path to a binary mask

  • new_name (str) – Path/filename for the masked output image.

Returns:

Absolute path of the masked output image.

Return type:

str

Notes

in_file and mask_file must be in the same image space and have the same dimensions.