Sisyphe.core.sisypheTransform
External packages/modules
ANTs, image registration, http://stnava.github.io/ANTs/
DIPY, MR diffusion image processing, https://www.dipy.org/
NiBabel, Euler angle conversions, https://nipy.org/nibabel
Numpy, scientific computing, https://numpy.org/
PyQt5, Qt GUI, https://www.riverbankcomputing.com/software/pyqt/
Scipy, scientific computing, https://docs.scipy.org/doc/scipy/index.html
SimpleITK, medical image processing, https://simpleitk.org/
vtk, visualization engine/3D rendering, https://vtk.org/
- class Sisyphe.core.sisypheTransform.SisypheApplyTransform
Description
SisypheVolume resampling class.
Applies SisypheTransform geometric transformation to resample a moving image, ROI, mesh or streamlines into the space of a fixed image. Affine geometric transformation is in forward convention (apply inverse transformation to resample). Displacement field geometric transformation is in backward convention.
This class automatically updates the SisypheTransforms instances associated to the fixed, moving and resliced volumes.
Inheritance
object -> SisypheApplyTransform
Creation: 05/10/2021 Last revision: 11/02/2025
- clearMesh() None
Clear the moving mesh attribute of the current SisypheApplyTransform instance (set to none)
- clearMoving() None
Clear the moving volume attribute of the current SisypheApplyTransform instance (set to none)
- clearMovingROI() None
Clear the moving ROI attribute of the current SisypheApplyTransform instance (set to none)
- clearMovingStreamlines() None
Clear the moving streamlines attribute of the current SisypheApplyTransform instance (set to none)
- execute(fixed: SisypheVolume | None = None, save: bool = True, dialog: bool = False, prefix: str | None = None, suffix: str | None = None, wait: DialogWait | None = None) SisypheVolume | SisypheROI | SisypheMesh | SisypheStreamlines | None
Reslice the moving volume, ROI, mesh and streamlines attributes ith the geometric transformation attribute of the current SisypheApplyTransform instance.
Parameters
- fixedSisyphe.core.sisypheVolume.SisypheVolume | None
fixed volume (default None)
- savebool
save resliced moving volume if True (default)
- dialogbool
dialog to choice the resliced moving volume file name, if True
addBundle suffix/prefix to the moving volume file name, if False (default)
- prefixstr | None
file name prefix of the resliced moving volume (default None)
- suffixstr | None
file name suffix of the resliced moving volume (default None)
- waitSisyphe.gui.dialogWait.DialogWait | None
progress bar dialog (optional)
Returns
- Sisyphe.core.sisypheVolume.SisypheVolume | Sisyphe.core.sisypheROI.SisypheROI | Sisyphe.core.sisypheMesh.SisypheMesh | Sisyphe.core.sisypheTracts.SisypheStreamlines
resliced moving attributes
- getInterpolator() str
Get the interpolator attribute of the current SisypheApplyTransform instance. This attribute defines the method of interpolation used to reslice the “moving” volume.
Returns
- str
interpolation name. Methods of interpolation are : ‘nearest’, ‘linear’, ‘bspline’, ‘gaussian’, ‘hammingsinc’, ‘cosinesinc’, ‘welchsinc’, ‘lanczossinc’, ‘blackmansinc’
- classmethod getInterpolatorCodeFromName(name: str) int
Get SimpleITK’s interpolation int code from a name.
Parameters
- namestr
interpolation name. Methods of interpolation are: ‘nearest’, ‘linear’, ‘bspline’, ‘gaussian’, ‘hammingsinc’, ‘cosinesinc’, ‘welchsinc’, ‘lanczossinc’, ‘blackmansinc’
Returns
- int
SimpleITK’s interpolation int code
- classmethod getInterpolatorNameFromCode(code: int) str
Get interpolation name from a SimpleITK’s int code.
Parameters
- codeint
SimpleITK’s interpolation int code
Returns
- str
interpolation name. Methods of interpolation are : ‘nearest’, ‘linear’, ‘bspline’, ‘gaussian’, ‘hammingsinc’, ‘cosinesinc’, ‘welchsinc’, ‘lanczossinc’, ‘blackmansinc’
- getInterpolatorSITKCode() int
Get the interpolator attribute of the current SisypheApplyTransform instance. This attribute defines the method of interpolation used to reslice the “moving” volume.
Returns
- int
SimpleITK’s interpolation int code
- getMoving() SisypheVolume
Get the moving volume attribute of the current SisypheApplyTransform instance.
Returns
- Sisyphe.core.sisypheVolume.SisypheVolume
moving volume
- getMovingMesh() SisypheMesh
Get the moving mesh attribute of the current SisypheApplyTransform instance.
Returns
- Sisyphe.core.sisypheMesh.SisypheMesh
moving mesh
- getMovingROI() SisypheROI
Get the moving ROI attribute of the current SisypheApplyTransform instance.
Returns
- Sisyphe.core.sisypheROI.SisypheROI
moving roi
- getMovingStreamlines() SisypheStreamlines
Get the moving streamlines attribute of the current SisypheApplyTransform instance.
Returns
- Sisyphe.core.sisypheTracts.SisypheStreamlines
moving streamlines
- getResampleTransform() SisypheTransform
Get the backward transform attribute of the current SisypheApplyTransform instance.
Returns
- SisypheTransform
backward transform copy
- getSITKResampleTransform() Transform
Get backward transform attribute of the current SisypheApplyTransform instance as SimpleITK.Transform.
Returns
- SimpleITK.Transform
SimpleITK backward transform copy
- getSITKTransform() AffineTransform | DisplacementFieldTransform
Get forward transform attribute of the current SisypheApplyTransform instance as SimpleITK.Transform.
Returns
- SimpleITK.AffineTransform | SimpleITK.DisplacementFieldTransform
SimpleITK forward transform copy
- getTransform() SisypheTransform
Get the forward transform attribute of the current SisypheApplyTransform instance.
Returns
- SisypheTransform
forward transfrom copy
- hasAffineTransform() bool
Check whether the transform attribute of the current SisypheApplyTransform instance is an affine geometric transformation.
Returns
- bool
True if geometric transform is defined and is an affine transformation
- hasDisplacementFieldTransform() bool
Check whether the transform attribute of the current SisypheApplyTransform instance is a displacement field transformation.
Returns
- bool
True if geometric transform is defined and is a displacement field transform
- hasMoving() bool
Check whether the moving volume attribute of the current SisypheApplyTransform instance is defined (not None).
Returns
- bool
True if moving volume is defined
- hasMovingMesh() bool
Check whether the moving mesh attribute of the current SisypheApplyTransform instance is defined (not None).
Returns
- bool
True if moving mes his defined
- hasMovingROI() bool
Check whether the moving ROI attribute of the current SisypheApplyTransform instance is defined (not None).
Returns
- bool
True if moving roi is defined
- hasMovingStreamlines() bool
Check whether the moving streamlines attribute of the current SisypheApplyTransform instance is defined (not None).
Returns
- bool
True if moving streamlines are defined
- hasTransform() bool
Check whether the transform attribute of the current SisypheApplyTransform instance is defined (not None).
Returns
- bool
True if geometric transform is defined
- resampleMesh(save: bool = True, dialog: bool = False, prefix: str | None = None, suffix: str | None = None, wait: DialogWait | None = None) SisypheMesh | None
Reslice the moving mesh attribute with the geometric transformation attribute of the current SisypheApplyTransform instance.
Parameters
- savebool
save resliced moving mesh if True (default)
- dialogbool
dialog to choice the resliced moving mesh file name, if True
addBundle suffix/prefix to the moving mesh file name, if False (default)
- prefixstr | None
file name prefix of the resliced moving mesh (default None)
- suffixstr | None
file name suffix of the resliced moving mesh (default None)
- waitSisyphe.gui.dialogWait.DialogWait | None
progress bar dialog (optional)
Returns
- Sisyphe.core.sisypheMesh.SisypheMesh
resliced moving mesh
- resampleMoving(fixed: SisypheVolume | None = None, save: bool = True, dialog: bool = False, prefix: str | None = None, suffix: str | None = None, wait: DialogWait | None = None) SisypheVolume | None
Reslice the moving volume attribute with the geometric transformation attribute of the current SisypheApplyTransform instance.
Origin is not used during registration, origin must therefore be ignored at the resampling stage
Origin management:
moving volume origin is stored before resampling
set moving volume origin to (0.0, 0.0, 0.0)
moving volume resampling
moving volume origin is restored
copy moving volume attributes to resampled volume (identity, display, acquisition, acpc)
copy fixed volume ID to resampled volume (same brain space)
copy fixed volume origin to resampled volume
Parameters
- fixedSisyphe.core.sisypheVolume.SisypheVolume | None
fixed volume (default None)
- savebool
save resliced moving volume if True (default)
- dialogbool
dialog to choice the resliced moving volume file name, if True
addBundle suffix/prefix to the moving volume file name, if False (default)
- prefixstr | None
file name prefix of the resliced moving volume (default None)
- suffixstr | None
file name suffix of the resliced moving volume (default None)
- waitSisyphe.gui.dialogWait.DialogWait | None
progress bar dialog (optional)
Returns
- Sisyphe.core.sisypheVolume.SisypheVolume
resliced moving volume
- resampleROI(save: bool = True, dialog: bool = False, prefix: str | None = None, suffix: str | None = None, wait: DialogWait | None = None) SisypheROI | None
Reslice the moving ROI attribute with the geometric transformation attribute of the current SisypheApplyTransform instance.
Parameters
- savebool
save resliced moving ROI if True (default)
- dialogbool
dialog to choice the resliced moving ROI file name, if True
addBundle suffix/prefix to the moving ROI file name, if False (default)
- prefixstr | None
file name prefix of the resliced moving ROI (default None)
- suffixstr | None
file name suffix of the resliced moving ROI (default None)
- waitSisyphe.gui.dialogWait.DialogWait | None
progress bar dialog (optional)
Returns
- Sisyphe.core.sisypheROI.SisypheROI
resliced moving ROI
- resampleStreamlines(save: bool = True, dialog: bool = False, prefix: str | None = None, suffix: str | None = None, wait: DialogWait | None = None) SisypheStreamlines | None
Reslice the moving streamlines attribute with the geometric transformation attribute of the current SisypheApplyTransform instance.
Parameters
- savebool
save resliced moving streamlines if True (default)
- dialogbool
dialog to choice the resliced moving streamlines file name, if True
addBundle suffix/prefix to the moving streamlines file name, if False (default)
- prefixstr | None
file name prefix of the resliced moving streamlines (default None)
- suffixstr | None
file name suffix of the resliced moving streamlines (default None)
- waitSisyphe.gui.dialogWait.DialogWait | None
progress bar dialog (default None)
Returns
- Sisyphe.core.sisypheTracts.SisypheStreamlines
resliced moving streamlines
- setFromTransforms(trfs: SisypheTransforms, ID: str | SisypheVolume) None
Set the transform attribute of the current SisypheApplyTransform instance from a SisypheTransforms instance and an ID key.
Parameters
- trfsSisypheTransforms
trasnform to copy
- IDstr | Sisyphe.core.sisypheVolume.SisypheVolume
ID key of the SisypheTransforms container, SisypheTransform = SisypheTransforms[ID] or
ID key is the ID attribute of the SisypheVolume
- setFromVolumes(fixed: SisypheVolume, moving: SisypheVolume) None
Set attributes (size, spacing, moving volume and transform) of the current SisypheApplyTransform instance from fixed and moving SisypheVolume instances.
size and spacing: size and spacing attributes of the fixed SisypheVolume instance. transform: SisypheTransforms instance associated to the moving volume with ID attribute of the fixed volume as key.
Parameters
- fixedSisyphe.core.sisypheVolume.SisypheVolume
fixed volume
- movingSisyphe.core.sisypheVolume.SisypheVolume
moving volume
- setInterpolator(v: int | str) None
Set the interpolator attribute of the current SisypheApplyTransform instance. This attribute defines the method of interpolation used to reslice the “moving” volume.
Parameters
- vint | str
SimpleITK’s interpolation int code or interpolation name. Methods of interpolation are : ‘nearest’, ‘linear’, ‘bspline’, ‘gaussian’,’hammingsinc’, ‘cosinesinc’, ‘welchsinc’, ‘lanczossinc’, ‘blackmansinc’
- setMoving(img: SisypheVolume) None
Set the moving volume attribute of the current SisypheApplyTransform instance.
Parameters
- imgSisyphe.core.sisypheVolume.SisypheVolume
moving volume
- setMovingMesh(mesh: SisypheMesh) None
Set the moving mesh attribute of the current SisypheApplyTransform instance.
Parameters
- meshSisyphe.core.sisypheMesh.SisypheMesh
moving mesh
- setMovingROI(roi: SisypheROI) None
Set the moving ROI attribute of the current SisypheApplyTransform instance.
Parameters
- roiSisyphe.core.sisypheROI.SisypheROI
moving roi
- setMovingStreamlines(sl: SisypheStreamlines) None
Set the moving streamlines attribute of the current SisypheApplyTransform instance.
Parameters
- slSisyphe.core.sisypheTracts.SisypheStreamlines
moving streamlines
- setTransform(trf: SisypheTransform, center: bool = True) None
Set the transform attribute of the current SisypheApplyTransform instance. This attribute defines the geometric transformation used to reslice the “moving” volume.
Parameters
- trfSisypheTransform
transform to copy
- centerbool
set center to 0.0, 0.0, 0.0 if False (default True)
- updateTransforms(resampled: SisypheVolume, fixed: SisypheVolume | None) None
Update the SisypheTransforms instance associated to fixed, moving and resliced volumes. Do not call this method, called by resampleMoving() method.
Add forward transform (moving -> fixed/resampled) to moving volume SisypheTransforms (mtrfs)
Add backward transform (resampled -> moving) to resampled volume SisypheTransforms (rtrfs)
Add backward transform (fixed -> moving) to fixed volume SisypheTransforms (ftrfs)
Update moving volume SisypheTransforms
Copy transforms from fixed volume to moving volume (mtrfs)
forward transform (moving -> fixed) pre multiplied by each fixed transforms
Update fixed volume SisypheTransforms
Copy transforms from moving volume to fixed volume (ftrfs)
backward transform (fixed -> moving) pre multiplied by each moving transforms
Update resampled volume SisypheTransforms
Copy transforms from fixed volume to resampled volume (rtrfs)
simple copy (fixed and resampled are registered and share same space)
Parameters
- resampledSisyphe.core.sisypheVolume.SisypheVolume
resampled volume
- fixedSisyphe.core.sisypheVolume.SisypheVolume | None
fixed volume (optional)
- updateVolumeTransformsFromMoving(vol: SisypheVolume) None
Copy the SisypheTransforms instance associated to the SisypheVolume moving volume to another SisypheVolume instance with the same ID (same space as moving volume)
Parameters
- volSisyphe.core.sisypheVolume.SisypheVolume
volume SisypheTransforms is to be updated.
- class Sisyphe.core.sisypheTransform.SisypheTransform(parent: SisypheVolume | None = None)
Description
PySisyphe geometric centered transformation class.
Uses forward convention, i.e. transformation of fixed to floating volume coordinates. To resample floating volume, apply the inverse i.e. backward transformation. Private attributes ID, spacing and size are those of the fixed image (resampling space)
Fixed and floating volumes are associated with instance attributes:
Parent attribute = fixed volume.
ID attribute = ID of the floating volume
Methods to copy to/from ANTs, SimpleITK and VTK geometric transformation classes. IO methods for common neuroimaging geometric transformation file formats.
Inheritance
object -> SisypheTransform
Creation: 05/10/2021 Last revision: 19/03/2025
- addTranslations(t: list[float] | tuple[float, float, float]) None
Add translations to the current SisypheTransform instance.
Parameters
- ttuple[float, float, float] | list[float]
x-axis, y-axis and z-axis translations in mm
- affineToDisplacementField(inverse: bool = True) None
Convert the affine geometric transformation of the current SisypheTransform instance to a displacement field.
Parameters
- inversebool
inverse affine geometric transformation if True (default)
- applyInverseToPoint(coor: list[float] | tuple[float, float, float]) list[float] | tuple[float, float, float]
Apply the inverse geometric transformation of the current SisypheTransform instance to a point.
Parameters
- coortuple[float, float, float] | list[float]
x-axis, y-axis and z-axis point coordinates
Returns
- tuple[float, float, float] | list[float]
x-axis, y-axis and z-axis point coordinates
- applyToPoint(coor: list[float] | tuple[float, float, float]) list[float] | tuple[float, float, float]
Apply the geometric transformation of the current SisypheTransform instance to a point.
Parameters
- coortuple[float, float, float] | list[float]
x-axis, y-axis and z-axis point coordinates
Returns
- tuple[float, float, float] | list[float]
x-axis, y-axis and z-axis point coordinates
- composeRotations(r: list[float] | tuple[float, float, float], deg: bool = False) None
Compose rotations to the current SisypheTransform instance.
Parameters
- rtuple[float, float, float] | list[float]
rotations around x-axis, y-axis and z-axis
- degbool
rotations in degrees if True, in radians otherwise (default False)
- composeTransform(trf: SisypheTransform) None
Compose a geometric transformation (SisypheTransform) to the current SisypheTransform instance.
Parameters
- trfSisypheTransform
geometric transformation to compose
- copy() SisypheTransform
Copy the current SisypheTransform instance.
Returns
- SisypheTransform
transform copy
- copyAttributesFrom(t: SisypheTransform) None
Copy attributes of a SisypheTransform instance to the current SisypheTransform instance.
Parameters
- tSisypheTransform
copy attributes from this transform
- copyAttributesTo(t: SisypheTransform) None
Copy attributes of the current SisypheTransform instance to a SisypheTransform instance.
Parameters
- tSisypheTransform
copy attributes to this transform
- copyFrom(t: SisypheTransform) None
Copy a SisypheTransform instance to the current SisypheTransform instance.
Parameters
- tSisypheTransform
geometric transform
- copyFromDisplacementFieldImage(img: SisypheImage | Image) None
Copy a displacement field as SimpleITK.Image or Sisyphe.core.sisypheImage.SisypheImage instance to the current SisypheTransform instance.
Parameters
- imgSisyphe.core.sisypheImage.SisypheImage | SimpleITK.Image
displacement field image
- copyTo(t: SisypheTransform) None
Copy the current SisypheTransform instance to a SisypheTransform instance.
Parameters
- tSisypheTransform
transform copy
- createXML(doc: Document, currentnode: Element) None
Write the current SisypheTransform instance attributes to xml document instance. Use of this method is not recommended (called internally by saveAs method).
Parameters
- docminidom.Document
xml document
- currentnodeminidom.Element
xml root node
- getANTSTransform() ANTsTransform
Get an ants.core.ants_transform.ANTsTransform instance from the current SisypheTransform instance.
Returns
- ants.core.ants_transform.ANTsTransform
ANTs transform copy
- getAffineParametersFromMatrix(deg: bool = False) tuple[list[float], list[float], list[float], list[float]]
Get affine parameters from the affine matrix attribute of the current SisypheTransform instance.
Parameters
- degbool
rotations in degrees if True, in radians otherwise (default False)
Returns
- tuple[list[float], list[float], list[float], list[float]]
translations in x-axis, y-axis and z-axis
rotations around x-axis, y-axis and z-axis
zoom factors applied to x-axis, y-axis and z-axis
shear factors for x-y, x-z, y-z axes
- getAngleVector(deg: bool = False) tuple[float, list[float]]
Get angle and vector of rotation axis from the rotations of the current SisypheTransform instance.
Parameters
- degbool
angle in radians if False, in degrees otherwise
Returns
- float, tuple[float, float, float] | list[float]
angle of rotation and vector of rotation axis
- getCenter() list[float]
Get the center of rotation of the current SisypheTransform instance.
Returns
- list[float]
center of rotation coordinates
- getDisplacementField() SisypheVolume
Get the displacement field of the current SisypheTransform instance as SisypheVolume.
Returns
- Sisyphe.core.sisypheVolume.SisypheVolume
displacement field image
- getEquivalentTransformWithNewCenterOfRotation(c: list[float] | tuple[float, float, float]) SisypheTransform
Calculate a geometric transformation equivalent to the current SisypheTransform instance, with a new center of rotation
Apply forward translation, old center to new center (translation = volume center - old center)
Apply rotation, after forward translation, center of rotation is new center
Apply backward translation, new center to old center
Parameters
- ctuple[float, float, float] | list[float]
new center of rotation coordinates
Returns
SisypheTransform
- classmethod getFilterExt() str
Get SisypheTransform filter used by QFileDialog.getOpenFileName() and QFileDialog.getSaveFileName().
Returns
- str
‘PySisyphe Geometric transformation (.xtrf)’
- getFlattenMatrix(homogeneous: bool = False) list[float]
Get the affine matrix of the current SisypheTransform instance as a list.
Parameters
- homogeneousbool
homogeneous 4x4 affine matrix if True, 3x3 affine matrix otherwise
Returns
- list[float]
16 elements (4x4 matrix) if homogeneous is True, 9 elements (3x3 matrix) otherwise
- getID() str
Get the ID attribute of the current SisypheTransform instance.
Returns
- str
transform ID
- getInverseSITKTransform() AffineTransform
Get inverse of the current SisypheTransform instance as a SimpleITK.Transform instance.
Returns
- SimpleITK.AffineTransform
inverse transform
- getInverseTransform() SisypheTransform
Get the inverse geometric transformation of the current SisypheTransform instance.
Returns
- SisypheTransform
inverse geometric transformation
- getInverseVTKTransform(center_correction: bool = False) vtkTransform
Get the inverse affine matrix as vtk.vtkMatrix3x3 instance of the current SisypheTransform instance.
Parameters
- center_correctionbool
if True, take into account center of rotation and replace translations by offset if center of rotation is not default (0.0,0.0,0.0),
Returns
- vtk.vtkMatrix4x4
inverse transform as VTK homogeneous affine matrix
- getMatrixColumn(c: int) list[float] | tuple[float, float, float]
Get a column from the affine matrix of the current SisypheTransform instance.
Parameters
- cint
column number (0 <= c < 3)
Returns
- list[float]
column vector of affine matrix
- getMatrixDiagonal() list[float] | tuple[float, float, float]
Get the diagonal of the affine matrix of the current SisypheTransform instance.
Returns
- list[float]
diagonal vector of affine matrix
- getName() str
Get the name attribute of the current SisypheTransform instance.
Returns
- str
transform name
- getNumpyArray(homogeneous: bool = False) ndarray
Get the affine matrix as numpy.ndarray instance of the current SisypheTransform instance.
Parameters
- homogeneousboolean
homogeneous 4x4 affine matrix if True, 3x3 affine matrix otherwise
Returns
- numpy.ndarray
homogeneous affine matrix as numpy ndarray
- getOffsets() list[float]
Get offsets of the current SisypheTransform instance. if center of rotation is default (0.0, 0.0, 0.0), offsets are equal to translations. However, if center of rotation is not default, offsets are translations of an equivalent geometric transformation with a default center of rotation.
Returns
- tuple[float, float, float] | list[float]
x-axis, y-axis and z-axis translations in mm
- getParent() SisypheVolume | None
Get the parent attribute of the current SisypheTransform instance.
Returns
- Sisyphe.core.sisypheVolume.SisypheVolume
parent
- getRotations(deg: bool = False) list[float] | None
Get rotation attributes of the current SisypheTransform instance.
Parameters
deg : bool, rotations in degrees if True, in radians otherwise (default False)
Returns
- list[float]
rotations around x-axis, y-axis and z-axis
- getRotationsFromMatrix(deg: bool = False) list[float]
Get rotations from the affine matrix attribute of the current SisypheTransform instance.
Parameters
- degbool
rotations in degrees if True, in radians otherwise (default False)
Returns
- list[float]
rotations around x-axis, y-axis and z-axis
- getSITKDisplacementFieldSITKImage() Image
Get a SimpleITK.Image instance from the displacement field of the current SisypheTransform instance.
Returns
- SimpleITK.Image
displacement field image
- getSITKDisplacementFieldTransform() DisplacementFieldTransform
Get a SimpleITK.DisplacementFieldTransform instance from the current SisypheTransform instance.
Returns
- SimpleITK.DisplacementFieldTransform
displacement field transform copy
- getSITKTransform() AffineTransform | DisplacementFieldTransform
Get a SimpleITK.Transform instance from the current SisypheTransform instance.
Returns
- SimpleITK.AffineTransform | SimpleITK.DisplacementFieldTransform
transform copy
- classmethod getSITKtoNumpy(trf: AffineTransform | Euler3DTransform) ndarray
Convert SimpleITK.AffineTransform or SimpleITK.Euler3DTransform o a numpy.ndarray.
Parameters
trf : SimpleITK.AffineTransform | SimpleITK.Euler3DTransform
Returns
- numpy.ndarray
homogeneous affine matrix
- getSize() list[int] | tuple[int, int, int]
Get the size attribute of the current SisypheTransform instance. Image size in the x, y and z axes of the floating volume (in voxels).
Returns
- list[int]
image size in the x, y and z axes of the floating volume (in voxels)
- getSpacing() list[float] | tuple[float, float, float]
Get the spacing attribute of the current SisypheTransform instance. Voxel size in the x, y and z axes of the floating volume in mm.
Returns
- list[float]
Voxel size in the x, y and z axes of the floating volume in mm
- getTranslations() list[float]
Get translation attributes of the current SisypheTransform instance.
Returns
- tuple[float, float, float] | list[float]
x-axis, y-axis and z-axis translations in mm
- getVTKMatrix3x3() vtkMatrix3x3
Get the affine matrix as vtk.vtkMatrix3x3 instance of the current SisypheTransform instance.
Returns
- vtk.vtkMatrix4x4
VTK affine matrix copy
- getVTKMatrix4x4(center_correction: bool = False) vtkMatrix4x4
Get the affine matrix as vtk.vtkMatrix4x4 instance of the current SisypheTransform instance.
Parameters
- center_correctionbool
if True, replace translations by offset if center of rotation is not default (0.0,0.0,0.0),
Returns
- vtk.vtkMatrix4x4
VTK homogeneous affine matrix copy
- getVTKTransform(center_correction: bool = False) vtkTransform
Get a vtk.vtkTransform instance from the current SisypheTransform instance.
Parameters
- center_correctionbool
if True, replace translations by offset if center of rotation is not default (0.0,0.0,0.0),
Returns
- vtk.vtkTransform
VTK transform copy
- classmethod getVTKtoNumpy(trf: vtkMatrix4x4) ndarray
Convert a vtk.vtkMatrix4x4 to a numpy.ndarray.
Parameters
trf : vtk.vtkMatrix4x4
Returns
- numpy.ndarray
homogeneous affine matrix
- getVersor() list[float]
Get versor i.e. quaternion in w, x, y, z (real, then unit vector in 3D) from the rotation attributes of the current SisypheTransform instance.
Returns
- tuple[float, float, float, float] | list[float]
versor
- hasCenter() bool
Check whether the center of rotation of the current SisypheTransform instance is defined (not 0.0, 0.0, 0.0).
Returns
- bool
True if center is defined (not 0.0, 0.0, 0.0)
- hasFixedVolumeAttributes() bool
Check whether the attributes relating to fixed volume (size, spacing) of the current SisypheTransform instance are defined.
Returns
- bool
True if ID, size and spacing attributes are defined
- hasID() bool
Check whether the ID attribute of the current SisypheTransform instance is defined (not ‘’)
Returns
- bool
True if ID is defined
- hasName() bool
Check if the name attribute of the current SisypheTransform instance is defined (not ‘’).
Returns
- bool
True if name attribute is defined
- hasParent() bool
Check if the parent attribute of the current SisypheTransform instance is defined (not None).
Returns
- bool
True if parent attribute is defined
- hasSameFixedVolumeAttributes(vol: SisypheVolume) bool
Check whether the attributes of the current SisypheTransform instance relating to fixed volume (size, spacing) are those of a SisypheVolume instance.
Parameters
- volSisyphe.core.sisypheVolume.SisypheVolume
volume attributes to test
Returns
- bool
True if the parameter volume has the same size and spacing attributes
- hasSize() bool
Check whether the size attribute of the current SisypheTransform instance is defined (not 0, 0, 0)
Returns
- bool
True if size is defined
- hasSpacing() bool
Check whether the spacing attribute of the current SisypheTransform instance is defined (not 0.0, 0.0, 0.0)
Returns
- bool
True if spacing is defined
- isAffine() bool
Check whether the current SisypheTransform instance is an affine geometric transformation.
Returns
- bool
True if affine transform
- isCenteredFromParent() bool
Check whether the center of rotation of the current SisypheTransform instance is the center of the SisypheVolume parent attribute.
Returns
- bool
True if center of rotation = parent volume center
- isCenteredToSisypheVolume(vol: SisypheVolume) bool
Check whether the center of rotation of the current SisypheTransform instance is the center of a SisypheVolume image.
Parameters
- volSisyphe.core.sisypheVolume.SisypheVolume
volume center used as center of rotation
Returns
- bool
True if center of rotation = volume center
- isDisplacementField() bool
Check whether the current SisypheTransform instance is a displacement field geometric transformation.
Returns
- bool
True if displacement field transform
- isIdentity() bool
Check if the current SisypheTransform instance is an identity geometric transformation.
Returns
- bool
True if identity geometric transformation
- isRigid() bool
Check whether the current SisypheTransform instance is rigid geometric transformation. True if matrix is orthogonal i.e. M-1 Mt = I
Returns
- bool
True if rigid transform
- load(filename: str) None
Load the current SisypheTransform instance from PySisyphe Transform (.xtrf) file.
Parameters
- filenamestr
PySisyphe Transform file name
- loadFromANTSTransform(filename: str) None
Load the current SisypheTransform instance from a ANTs transform (.mat) file.
Parameters
- filenamestr
ANTs transform file name
- loadFromBrainVoyagerTransform(filename: str) None
Load the current SisypheTransform instance from a BrainVoyager transform (.trf) file.
Parameters
- filenamestr
BrainVoyager transform file name
- loadFromMatfileTransform(filename: str) None
Load the current SisypheTransform instance from a Matlab (.mat) file.
Parameters
- filenamestr
Matlab file name
- loadFromTfmTransform(filename: str) None
Load the current SisypheTransform instance from a TFM (.tfm) file.
Parameters
- filenamestr
TFM file name
- loadFromTxtTransform(filename: str) None
Load the current SisypheTransform instance from a text (.txt) file.
Parameters
- filenamestr
text file name
- loadFromXfmTransform(filename: str) None
Load the current SisypheTransform instance from a XFM (.xfm) file.
Parameters
- filenamestr
XFM file name
- classmethod openTransform(filename: str) SisypheTransform
create a SisypheTransform instance from PySisyphe geometric transformation file (.xtrf).
Parameters
- filenamestr
geometric transformation file name
Returns
- SisypheTransform
loaded geometric transform
- parseXML(doc: Document) None
Read the current SisypheTransform instance attributes from xml document instance. The use of this method is not recommended (called internally by load method).
Parameters
- docminidom.Document
xml document
- parseXMLNode(currentnode: Element) None
Read the current SisypheTransform instance attributes from xml document instance. The use of this method is not recommended (called internally by parseXML method).
Parameters
- currentnodeminidom.Element
xml document
- postMultiply(trf: vtkTransform | vtkMatrix4x4 | SisypheTransform | AffineTransform | Euler3DTransform | ndarray, homogeneous: bool = False) None
Compose a geometric transformation with the geometric transformation of the current SisypheTransform instance. Order of transformations 1. parameter 2. current (Post-multiply current by parameter)
Parameters
- trfvtk.vtkTransform | vtk.vtkMatrix4x4 | SimpleITK.AffineTransform | SimpleITK.Euler3DTransform | ndarray | SisypheTransform
affine transform used to post-multiply
- homogeneousbool
used for ndarray trf, 4x4 affine matrix if True, 3x3 affine matrix otherwise
- preMultiply(trf: vtkTransform | vtkMatrix4x4 | SisypheTransform | AffineTransform | Euler3DTransform | ndarray, homogeneous: bool = False) None
Compose a geometric transformation with the geometric transformation of the current SisypheTransform instance. Order of transformations 1. current 2. parameter (Pre-multiply current by parameter)
Parameters
- trfvtk.vtkTransform | vtk.vtkMatrix4x4 | SimpleITK.AffineTransform | SimpleITK.Euler3DTransform | ndarray | SisypheTransform
affine transform used to pre-multiply
- homogeneousbool
used for ndarray trf, 4x4 affine matrix if True, 3x3 affine matrix otherwise
- removeCenter() None
Set the center of rotation of the current SisypheTransform instance to [0.0, 0.0, 0.0]
- removeDisplacementField() None
Remove the displacement field of the current SisypheTransform instance.
- saveAs(filename: str) None
Save the current SisypheTransform instance to a PySisyphe Transform (.xtrf) file.
Parameters
- filenamestr
PySisyphe Transform file name
- saveDisplacementField(filename: str) None
Save the displacement field of the current SisypheTransform instance as SisypheVolume. Adds ‘field_’ prefix to the filename parameter.
Parameters
- filenamestr
displacement field file name
- saveToANTSTransform(filename: str) None
Save the current SisypheTransform instance to a ANTs transform (.mat) file.
Parameters
- filenamestr
ANTs transform file name
- saveToMatfileTransform(filename: str) None
Save the current SisypheTransform instance to a Matlab (.mat) file.
Parameters
- filenamestr
Matlab file name
- saveToTfmTransform(filename: str) None
Save the current SisypheTransform instance to a TFM (.tfm) file.
Parameters
- filenamestr
TFM file name
- saveToTxtTransform(filename: str) None
Save the current SisypheTransform instance to a text (.txt) file.
Parameters
- filenamestr
text file name
- saveToXfmTransform(filename: str) None
Save the current SisypheTransform instance to a XFM (.xfm) file.
Parameters
- filenamestr
XFM file name
- setANTSTransform(trf: ANTsTransform) None
Copy an ants.core.ants_transform.ANTsTransform instance to the current SisypheTransform instance. The only ANTsTransform supported type is AffineTransform.
Parameters
- trfants.core.ants_transform.ANTsTransform
ANTs transform to copy
- setAffineParameters(t: list[float] | tuple[float, float, float] | None = None, r: list[float] | tuple[float, float, float] | None = None, z: list[float] | tuple[float, float, float] | None = None, s: list[float] | tuple[float, float, float] | None = None, deg: bool = False) None
Set affine parameters i.e. translations, rotations, zooms and shears of the current SisypheTransform instance.
Parameters
- ttuple[float, float, float] | list[float]
translations in x-axis, y-axis and z-axis
- rtuple[float, float, float] | list[float]
rotations around x-axis, y-axis and z-axis
- ztuple[float, float, float] | list[float]
zoom factors applied to x-axis, y-axis and z-axis
- stuple[float, float, float] | list[float]
shear factors for x-y, x-z, y-z axes
- degbool
angle in radians if False, in degrees otherwise
- setAngleVector(a: float, v: list[float] | tuple[float, float, float], deg: bool = False) None
Set rotation attributes of the current SisypheTransform instance from a vector of rotation axis and an angle. Rotation matrix is processed from the Rodrigues’ formula.
Parameters
- afloat
angle of rotation
- vtuple[float, float, float] | list[float]
vector of rotation axis
- degbool
angle in radians if False, in degrees otherwise
- setAttributesFromFixedVolume(vol: SisypheVolume) None
Set the attributes relating to fixed volume (ID, size, spacing) of the current SisypheTransform instance from a SisypheVolume instance.
Parameters
- volSisyphe.core.sisypheVolume.SisypheVolume
copy ID, size and spacing attributes from this volume
- setCenter(c: list[float] | tuple[float, float, float]) None
Set the center of rotation of the current SisypheTransform instance.
Parameters
- ctuple[float, float, float] | list[float]
center of rotation coordinates
- setCenterFromParent() None
Set the center of rotation of the current SisypheTransform instance to the center of the SisypheVolume parent attribute.
- setCenterFromSisypheVolume(vol: SisypheVolume) None
Set the center of rotation of the current SisypheTransform instance to the center of a SisypheVolume image.
Parameters
- volSisyphe.core.sisypheVolume.SisypheVolume
center of rotation = volume center
- setFlattenMatrix(m: list[float], bycolumn: bool = False) None
Set the affine matrix of the current SisypheTransform instance from a list.
Parameters
- mlist[float]
9 (3x3 affine matrix) or 16 elements (4x4 homogeneous affine matrix)
- bycolumnbool
elements in column order if True, row order otherwise
- setID(ID: str | SisypheVolume) None
Set the ID attribute of the current SisypheTransform instance.
Parameters
- IDstr | Sisyphe.core.sisypheVolume.SisypheVolume
transform ID
- setIdentity() None
Clear the current SisypheTransform instance (set geometric transformation to identity).
- setName(name: str) None
Set the name attribute of the current SisypheTransform instance.
Parameters
- namestr
transform name
- setNumpyArray(np: ndarray) None
Copy an affine matrix as numpy.ndarray instance to the current SisypheTransform instance.
Parameters
- npnumpy.ndarray
homogeneous affine matrix
- setParent(parent: SisypheVolume) None
Set the parent attribute of the current SisypheTransform instance.
Parameters
- parentSisyphe.core.sisypheVolume.SisypheVolume
parent volume
- setRotations(r: list[float] | tuple[float, float, float], deg: bool = False) None
Set rotation attributes of the current SisypheTransform instance. The order in which rotations are applied is x-axis, then y-axis and finally z-axis.
Parameters
- rtuple[float, float, float] | list[float]
rotations around x-axis, y-axis and z-axis
- degbool
rotations in degrees if True, in radians otherwise (default False)
- setSITKDisplacementFieldImage(img: SisypheImage | Image) None
Set a displacement field as SimpleITK.Image or Sisyphe.core.sisypheImage.SisypheImage instance to the current SisypheTransform instance.
Parameters
- imgSisyphe.core.sisypheImage.SisypheImage | SimpleITK.Image
displacement field image
- setSITKDisplacementFieldTransform(trf: DisplacementFieldTransform) None
Set a SimpleITK.DisplacementFieldTransform instance to the current SisypheTransform instance.
Parameters
- trfSimpleITK.DisplacementFieldTransform
displacement field transform
- setSITKTransform(trf)
Copy a SimpleITK.Transform instance to the current SisypheTransform instance.
Parameters
- trfSimpleITK.TranslationTransform | SimpleITK.VersorTransform | SimpleITK.ScaleTransform | SimpleITK.VersorRigid3DTransform | SimpleITK.Euler3DTransform | SimpleITK.Similarity3DTransform | SimpleITK.ScaleVersor3DTransform | SimpleITK.ScaleSkewVersor3DTransform | SimpleITK.AffineTransform | SimpleITK.DisplacementFieldTransform
SimpleITK geometric transform
- setSize(size: list[int] | tuple[int, int, int])
Set the size attribute of the current SisypheTransform instance. Image size in the x, y and z axes of the floating volume (in voxels).
Parameters
- sizelist[int]
image size in the x, y and z axes of the floating volume (in voxels)
- setSpacing(spacing: list[float] | tuple[float, float, float]) None
Set the spacing attribute of the current SisypheTransform instance. Voxel size in the x, y and z axes of the floating volume in mm.
Parameters
- spacinglist[float]
Voxel size in the x, y and z axes of the floating volume in mm
- setTranslations(t: list[float] | tuple[float, float, float]) None
Set translation attributes of the current SisypheTransform instance.
Parameters
- ttuple[float, float, float] | list[float]
x-axis, y-axis and z-axis translations in mm
- setVTKMatrix3x3(mat: vtkMatrix3x3, center_reset: bool = False) None
Copy an affine matrix as vtk.vtkMatrix3x3 instance to the current SisypheTransform instance.
Parameters
- matvtk.vtkMatrix3x3
VTK affine matrix to copy
- center_resetbool
set center of rotation to default (0.0, 0.0, 0.0) if True
- setVTKMatrix4x4(mat: vtkMatrix4x4, center_reset: bool = False) None
Copy an affine matrix as vtk.vtkMatrix4x4 instance to the current SisypheTransform instance. The center of rotation of the current SisypheTransform instance is set to default (0.0, 0.0, 0.0).
Parameters
- matvtk.vtkMatrix4x4
VTK affine homogeneous affine matrix to copy
- center_resetbool
set center of rotation to default (0.0, 0.0, 0.0) if True
- setVTKTransform(trf: vtkTransform, center_reset: bool = False) None
Copy a vtk.vtkTransform instance to the current SisypheTransform instance. The center of rotation of the current SisypheTransform instance is set to default (0.0, 0.0, 0.0).
Parameters
- trfvtk.vtkTransform
VTK transform to copy
- center_resetbool
set center of rotation to default (0.0, 0.0, 0.0) if True
- class Sisyphe.core.sisypheTransform.SisypheTransformCollection
Description
Named list container of SisypheTransform instances. Container key to address elements can be an int index, a transform ID str, a SisypheTransform instance (its ID attribute is used as str key) or a SisypheVolume instance (its ID attribute is used as str key).
Getter methods of the SisypheTransform class are added to the SisypheTransformCollection class, returning a list of values returned by each SisypheTransform element in the container.
Inheritance
object -> SisypheTransformCollection
Creation: 05/10/2021 Last revision: 18/04/05/2025
- append(value: SisypheTransform, replace: bool = True) None
Append a SisypheTransform element in the current SisypheTransformCollection instance container.
Parameters
- valueSisypheTransform
geometric transformation to append
- replace: bool
if value is already in the current container, replace it (default True)
- clear() None
Remove all elements from the current SisypheTransformCollection instance container (empty).
- copy() SisypheTransformCollection
Copy the current SisypheTransformCollection instance container (Shallow copy of elements).
Returns
- SisypheTransformCollection
Shallow copy of container
- copyToList() list[SisypheTransform]
Copy the current SisypheTransformCollection instance container to a list (Shallow copy of elements).
Returns
- list[SisypheTransform]
shallow copy to list of container elements
- count() int
Get the number of SisypheTransform elements in the current SisypheTransformCollection instance container.
Returns
- int
number of SisypheTransform elements
- getList() list[SisypheTransform]
Get the list attribute of the current SisypheTransformCollection instance container (Shallow copy)
Returns
- list[SisypheTransform]
shallow copy of container list
- index(value: str | SisypheVolume | SisypheTransform) int
Index of a SisypheTransform element in the current SisypheTransformCollection instance container.
Parameters
- valuestr | SisypheTransform | Sisyphe.core.sisypheVolume.SisypheVolume
ID, SisypheTransform ID attribute or SisypheVolume ID attribute
Returns
- int
index
- insert(key: int | str | SisypheTransform | SisypheVolume, value: SisypheTransform) None
Insert a SisypheTransform element at the position given by the key in the current SisypheTransformCollection instance container.
Parameters
- keyint | str | SisypheTransform | Sisyphe.core.sisypheVolume.SisypheVolume | None
index, ID, SisypheTransform ID attribute or SisypheVolume ID attribute
- valueSisypheTransform
geometric transformation to insert
- isEmpty() bool
Checks if SisypheTransformCollection instance container is empty.
Returns
- bool
True if container is empty
- keys() list[str]
Get the list of keys in the current SisypheTransformCollection instance container.
Returns
- list[str]
list of keys in the container
- pop(key: int | str | SisypheTransform | SisypheVolume | None = None) SisypheTransform
Remove a SisypheTransform element from the current SisypheTransformCollection instance container and return it. If key is None, removes and returns the last element.
Parameters
- keyint | str | SisypheTransform | Sisyphe.core.sisypheVolume.SisypheVolume | None
index, ID, SisypheTransform ID attribute or SisypheVolume ID attribute
if None, remove the last element
Returns
- SisypheTransform
element removed from the container
- remove(value: int | str | SisypheTransform | SisypheVolume) None
Remove a SisypheTransform element from the current SisypheTransformCollection instance container.
Parameters
- valueint | str | SisypheTransform | Sisyphe.core.sisypheVolume.SisypheVolume
index, ID, SisypheTransform ID attribute or SisypheVolume ID attribute
- reverse() None
Reverses the order of the elements in the current SisypheTransformCollection instance container.
- class Sisyphe.core.sisypheTransform.SisypheTransforms(parent: SisypheVolume | None = None)
Description
Each SisypheVolume is associated with a SisypheTransforms instance, which stores all the geometric transformations calculated from co-registrations with other SisypheVolume instances.
This class works as a named list (key/value) container of SisypheTransform instances.
Key: ID attribute of a SisypheVolume that is co-registered with the reference SisypheVolume.
Value: the geometric transformation (SisypheTransform instance) used to co-register the SisypheVolume with the
reference SisypheVolume.
Inherits from SisypheTransformCollection class and adds
ID attribute of the associated (or reference) SisypheVolume instance,
IO methods.
Geometric transformations are in forward convention (apply inverse transformation to resample)
Inheritance
object -> SisypheTransformCollection -> SisypheTransforms
Creation: 05/10/2021 Last revision: 23/05/2024
- appendIdentityTransformWithVolume(vol: SisypheVolume) None
Add an identity geometric transformation with a SisypheVolume (parameter) in the current SisypheTransforms instance.
Parameters
- volSisyphe.core.sisypheVolume.SisypheVolume
volume (volume ID key) to associate with an identity tranform
- copy() SisypheTransforms
Copy the current SisypheTransforms instance container (Shallow copy of elements).
Returns
- SisypheTransforms
container shallow copy
- createXML(doc: Document) None
Write the current SisypheTransforms instance attributes to xml document instance.
Parameters
- docminidom.Document
xml document
- getFilename() str
Get the file name attribute of the current SisypheTransforms instance is defined.
Returns
- str
file name attribute
- classmethod getFilterExt() str
Get SisypheTransforms filter used by QFileDialog.getOpenFileName() and QFileDialog.getSaveFileName().
Returns
- str
‘PySisyphe Geometric transformation collection (.xtrfs)’
- getReferenceID() str
Get reference ID attribute of the current SisypheTransforms instance. The reference ID is the ID of the associated SisypheVolume.
Returns
- str
reference ID
- hasFilename() bool
Check whether the file name attribute of the current SisypheTransforms instance is defined.
Returns
- bool
True if file name attribute is defined
- hasReferenceID() bool
Check if the reference ID of the current SisypheTransforms instance is defined (not ‘’). The reference ID is the ID of the associated SisypheVolume.
Returns
- bool
True if reference ID is defined
- load(filename: str = '') None
Load the current SisypheTransforms instance from a PySisyphe geometric transformation collection file (.xtrfs).
Parameters
- filenamestr
PySisyphe geometric transformation collection file name (optional)
if filename is empty (‘’, default), the file name attribute of the current SisypheTransforms instance is used
- classmethod openTransforms(filename) SisypheTransforms
create a SisypheTransforms instance from PySisyphe geometric transformation collection file (.xtrfs).
Parameters
- filenamestr
geometric transformation collection file name
Returns
- SisypheTransforms
loaded geometric transformation collection
- parseXML(doc: Document) None
Read the current SisypheTransforms instance attributes from xml document instance.
Parameters
- docminidom.Document
xml document
- save(filename: str = '') None
Save the current SisypheTransforms instance to a PySisyphe geometric transformation collection file (.xtrfs).
Parameters
- filenamestr
PySisyphe geometric transformation collection file name (optional) if filename is empty (‘’, default), the file name attribute of the current SisypheTransforms instance is used
- saveAs(filename: str) None
Save the current SisypheTransforms instance to a PySisyphe geometric transformation collection file (.xtrfs).
Parameters
- filenamestr
PySisyphe geometric transformation collection file name
The file name attribute of the current SisypheTransforms instance is replaced by this parameter
- setFilenameFromVolume(img: SisypheVolume) None
Copy the file name attribute of the current SisypheTransforms instance from the file name attribute of a SisypheVolume instance.
Parameters
- imgSisyphe.core.sisypheVolume.SisypheVolume
volume filename to copy
- setReferenceID(ID: str | SisypheVolume) None
Set the reference ID attribute of the current SisypheTransforms instance. The reference ID is the ID of the associated SisypheVolume.
Parameters
- IDstr | Sisyphe.core.sisypheVolume.SisypheVolume
ID or SisypheVolume’s ID attribute