class ardent.transform.Transform[source]

Transform stores the deformation that is output by a registration and provides methods for applying that transformation to various images.

Initialize Transform object. Sets attributes to None.

register(self, template: numpy.ndarray, target: numpy.ndarray, template_resolution=[1, 1, 1], target_resolution=[1, 1, 1], preset=None, sigmaR=None, eV=None, eL=None, eT=None, A=None, v=None, device=None, **kwargs) → None[source]

Perform a registration using transformer between template and target. Populates attributes for future calls to the apply_transform method.

  • template (np.ndarray) -- Image to target.
  • target (np.ndarray) -- Image to be registered to.
  • template_resolution (scalar, list, optional) -- Per-axis resolution of template. Defaults to: [1,1,1].
  • target_resolution (scalar, list, optional) -- Per-axis resolution of target. Defaults to: [1,1,1].
  • preset (string, NoneType, optional) --

    Preset of registration parameters. If any of those values are provided anyway, the provided values supersede the corresponding preset values. Supported options:

    'identity' 'clarity, mouse' 'nissl, mouse' 'mri, human'

    Defaults to: None.

  • sigmaR (float, optional) -- Deformation allowance. Defaults to: None.
  • eV (float, optional) -- Deformation step size. Defaults to: None.
  • eL (float, optional) -- Linear transformation step size. Defaults to: None.
  • eT (float, optional) -- Translation step size. Defaults to: None.
  • A (np.ndarray, NoneType, optional) -- Initial affine transformation. Defaults to: None.
  • v (np.ndarray, optional) -- Initial velocity field. Defaults to: None.
  • device (NoneType, str, optional) --

    The device to be used with pytorch. If None, will choose 'cuda:0' if cuda is available, else 'cpu'. Valid options:

    None 'cuda:0' 'cpu'

    Defaults to: None.


Sets internal attributes and returns None.

Return type:


apply_transform(self, subject: numpy.ndarray, deform_to='template', save_path=None) → numpy.ndarray[source]

Apply the transformation--computed by the last call to self.register--to subject, deforming it into the space of <deform_to>.

  • subject (np.ndarray) -- The image to deform.
  • deform_to (str, optional) -- Either 'template' or 'target' indicating which to deform <subject> to match. Defaults to: "template".
  • save_path (str, Path, optional) -- The full path to save the output to. Defaults to: None.

The result of deforming <subject> to match <deform_to>.

Return type:


save(self, file_path)[source]

Save the entire instance of this Transform object (self) to file.

Parameters:file_path (str, Path) -- The full path to save self to.
load(self, file_path)[source]

Load an entire instance of a Transform object from memory, as from a file created with the save method, and transplants all of its writeable attributes into self.

Parameters:file_path (str, Path) -- The full path that a Transform object was saved to.