ants.deeplearn.randomly_transform_image_data

randomly_transform_image_data(reference_image, input_image_list, segmentation_image_list=None, number_of_simulations=10, transform_type='affine', sd_affine=0.02, deformation_transform_type='bspline', number_of_random_points=1000, sd_noise=10.0, number_of_fitting_levels=4, mesh_size=1, sd_smoothing=4.0, input_image_interpolator='linear', segmentation_image_interpolator='nearestNeighbor')[source]

Randomly transform image data (optional: with corresponding segmentations).

Apply rigid, affine and/or deformable maps to an input set of training images. The reference image domain defines the space in which this happens.

Parameters:
  • reference_image (ants.core.ANTsImage) – Defines the spatial domain for all output images. If the input images do not match the spatial domain of the reference image, we internally resample the target to the reference image. This could have unexpected consequences. Resampling to the reference domain is performed by testing using ants.image_physical_space_consistency then calling ants.resample_image_to_target with failure.

  • input_image_list (list of lists of ANTsImages) – List of lists of input images to warp. The internal list sets contain one or more images (per subject) which are assumed to be mutually aligned. The outer list contains multiple subject lists which are randomly sampled to produce output image list.

  • segmentation_image_list (list of ANTsImages) – List of segmentation images corresponding to the input image list (optional).

  • number_of_simulations (int) – Number of simulated output image sets.

  • transform_type (str) – One of the following options: “translation”, “rotation”, “rigid”, “scaleShear”, “affine”, “deformation”, “affineAndDeformation”.

  • sd_affine (float) – Parameter dictating deviation amount from identity for random linear transformations.

  • deformation_transform_type (str) – “bspline” or “exponential”.

  • number_of_random_points (int) – Number of displacement points for the deformation field.

  • sd_noise (float) – Standard deviation of the displacement field.

  • number_of_fitting_levels (int) – Number of fitting levels (bspline deformation only).

  • mesh_size (int or typing.Tuple) – Determines fitting resolution (bspline deformation only).

  • sd_smoothing (float) – Standard deviation of the Gaussian smoothing in mm (exponential field only).

  • input_image_interpolator (str) – One of the following options: “nearestNeighbor”, “linear”, “gaussian”, “bSpline”.

  • segmentation_image_interpolator (str) – Only “nearestNeighbor” is currently available.

Return type:

list of lists of transformed images

Example

>>> import ants
>>> image1_list = list()
>>> image1_list.append(ants.image_read(ants.get_ants_data("r16")))
>>> image2_list = list()
>>> image2_list.append(ants.image_read(ants.get_ants_data("r64")))
>>> input_segmentations = list()
>>> input_segmentations.append(ants.threshold_image(image1, "Otsu", 3))
>>> input_segmentations.append(ants.threshold_image(image2, "Otsu", 3))
>>> input_images = list()
>>> input_images.append(image1_list)
>>> input_images.append(image2_list)
>>> data = antspynet.randomly_transform_image_data(image1,
>>>     input_images, input_segmentations, sd_affine=0.02,
>>>     transform_type = "affineAndDeformation" )