wsireg.reg_transforms package
Submodules
wsireg.reg_transforms.reg_transform module
- class wsireg.reg_transforms.reg_transform.RegTransform(elastix_transform)[source]
Bases:
object
Container for elastix transform that manages inversion and other metadata. Converts elastix transformation dict to it’s SimpleITK representation
- elastix_transform
elastix transform stored in a python dict
- Type:
dict
- itk_transform
elastix transform in SimpleITK container
- Type:
sitk.Transform
- output_spacing
Spacing of the targeted image during registration
- Type:
list of float
- output_size
Size of the targeted image during registration
- Type:
list of int
- output_direction
Direction of the targeted image during registration (not relevant for 2D applications)
- Type:
list of float
- output_origin
Origin of the targeted image during registration
- Type:
list of float
- resampler_interpolator
elastix interpolator setting for resampling the image
- Type:
str
- is_linear
Whether the given transform is linear or non-linear (non-rigid)
- Type:
bool
- inverse_transform
Inverse of the itk transform used for transforming from moving to fixed space Only calculated for non-rigid transforms when called by compute_inverse_nonlinear as the process is quite memory and computationally intensive
- Type:
sitk.Transform or None
- as_np_matrix(use_np_ordering: bool = False, n_dim: int = 3, use_inverse: bool = False, to_px_idx: bool = False) ndarray | None [source]
Creates a affine transform matrix as np.ndarray whether the center of rotation is 0,0. Optionally in physical or pixel coordinates. :param use_np_ordering: Use numpy ordering of yx (napari-compatible) :type use_np_ordering: bool :param n_dim: Number of dimensions in the affine matrix, using 3 creates a 3x3 array :type n_dim: int :param use_inverse: return the inverse affine transformation :type use_inverse: bool :param to_px_idx: return the transformation matrix specified in pixels or physical (microns) :type to_px_idx: bool
- Returns:
full_matrix – Affine transformation matrix
- Return type:
np.ndarray
wsireg.reg_transforms.reg_transform_seq module
- class wsireg.reg_transforms.reg_transform_seq.RegTransformSeq(reg_transforms: str | Path | Dict[str, List[str]] | None = None, transform_seq_idx: List[int] | None = None)[source]
Bases:
object
Class to concatenate and compose sequences of transformations
- add_transforms(transforms: str | Path | dict | List[RegTransform] | RegTransform, transform_seq_idx: List[int] | None = None) None [source]
Add transforms to sequence.
- Parameters:
transforms (path to wsireg transforms .json, elastix transform dict,RegTransform ot List of RegTransform) –
transform_seq_idx (list of int) – Order in sequence of the transform. If a pre-reg transform, it will not be reversed like a sequence of elastix transforms would to make the composite ITK transform
- append(other) None [source]
Concatenate transformation sequences.
- Parameters:
other (RegTransformSeq) – Append a RegTransformSeq to another
- composed_linear_mats: Dict[str, ndarray] | None = None
- property composite_transform: CompositeTransform
Composite ITK transform from transformation sequence
- property n_transforms: int
Number of transformations in sequence.
- property output_size: Tuple[int, int]
Output size of image resampled by transform, initially determined from the last transformation in the chain
- property output_spacing: Tuple[float, float] | Tuple[int, int]
Output spacing of image resampled by transform, initially determined from the last transformation in the chain
- reg_transforms: List[RegTransform] = []
- reg_transforms_itk_order: List[RegTransform] = []
- resampler: ResampleImageFilter | None = None
- set_output_spacing(spacing: Tuple[float, float] | Tuple[int, int]) None [source]
Method that allows setting the output spacing of the resampler to resampled to any pixel spacing desired. This will also change the output_size to match.
- Parameters:
spacing (tuple of float) – Spacing to set the new image. Will also change the output size to match.
- transform_points(pt_data: ndarray, px_idx=True, source_res=1, output_idx=True) ndarray [source]
Transform point sets using the transformation chain :param pt_data: Point data in xy order :type pt_data: np.ndarray :param px_idx: Whether point data is in pixel or physical coordinate sapce :type px_idx: bool :param source_res: spacing of the pixels associated with pt_data if they are not in physical coordinate space :type source_res: float :param output_idx: return transformed points to pixel indices in the output_spacing’s reference space :type output_idx: bool
- Returns:
tformed_pts – Transformed points
- Return type:
np.ndarray
- property transform_seq_idx: List[int]
Transformation sequence for all combined transformations.