Sisyphe.core.sisypheVolume
External packages/modules
Cython, static compiler, https://cython.org/
ANTs, image registration, http://stnava.github.io/ANTs/
ITK, medical image processing, https://itk.org/
Numpy, scientific computing, https://numpy.org/
PyQt5, Qt GUI, https://www.riverbankcomputing.com/software/pyqt/
SimpleITK, medical image processing, https://simpleitk.org/
vtk, visualization engine/3D rendering, https://vtk.org/
- class Sisyphe.core.sisypheVolume.SisypheVolume(image: str | Image | ndarray | vtkImageData | ANTsImage | SisypheVolume | None = None, **kargs)
Description
PySisyphe volume class.
SisypheVolume is in RAS+ world coordinates convention (as MNI, Nibabel, NIFTI…) with origin to corner of the voxel
x, direction[1.0, 0.0, 0.0]: left(-) to right(+)
y, direction[0.0, 1.0, 0.0]: posterior(-) to anterior(+)
z: direction[0.0, 0.0, 1.0]: inferior(-) to superior(+)
SimpleITK, ITK, DICOM is in LPS+ world coordinates convention
x: right(-) to left(+) -> apply flipx for RAS+ conversion
y: anterior(-) to posterior(+) -> apply flipy for RAS+ conversion
z: inferior(-) to superior(+)
This class provides access to internal SimpleITK, ITK, VTK and numpy image classes, which share the same image buffer (behaviour inherited from the ancestor class SisypheImage).
Supported properties:
Array ID: ID number calculated from scalar values (md5 algorithm)
ID: space ID, can be shared between several volumes (i.e. image of the same subject with same field of view)
identity: lastname, firstname, birthdate, gender
acquisition: modality, sequence, date of scan, stereotactic frame, signal unit, labels for label map modality,
degrees of freedom and autocorrelations for statistical maps - display: look-up table colormap, range and window values, slope/intercept - acpc: AC coordinates, PC coordinates, geometric transformation to geometric reference with axes aligned on the AC-PC line with origin to the AC coordinates - transforms: list of geometric transformations to all co-registered volumes - dicom: access to Dicom fields of the related XmlDicom file (created during Dicom conversion)
Overloaded operators which work with int, float, SisypheVolume, SisypheImage, SimpleITK Image, and numpy array instances.
Arithmetic +, -, /, //, *
Logic & (and), | (or), ^ (xor), ~ (not)
Relational >, >=, <, <=, ==, !=
Getter and Setter access to scalar values with slicing ability.
Getter: v = instance_name[x, y, z]
Setter: instance_name[x, y, z] = v
x, y, z are int or pythonic slicing (i.e. python slice object, syntax first:last:step)
Deep copy methods to and from SimpleITK, ITK, VTK, ANTs, NiBabel and numpy image instances. IO methods for the most common neuroimaging file formats (BrainVoyager, FreeSurfer, Nifti, Nrrd, Minc, VTK).
Inheritance
object -> SisypheImage -> SisypheVolume
Creation: 04/02/2021 Last revisions: 18/04/2025
- property acpc: SisypheACPC
Set the acp instance of the current SisypheVolume instance. Sisyphe.core.sisypheImageAttributes.SisypheACPC attributes are: (AC) and posterior (PC) commissure coordinates, rigid geometric transformation i.e. geometric transformation to reference with axes aligned on the AC-PC line, with midACPC point as center of rotation.
Returns
- Sisyphe.core.sisypheImageAttributes.SisypheACPC
acpc attribute
- property acquisition: SisypheAcquisition
Get the acquisition instance of the current SisypheVolume instance. Sisyphe.core.sisypheImageAttributes.SisypheAcquisition attributes are: modality, sequence, date of scan, frame, units of scalar values, labels for LB modality, degrees of freedom and autocorrelation for statistical map sequences.
Returns
- Sisyphe.core.sisypheImageAttributes.SisypheAcquisition
acquisition attribute
- cast(datatype: str) SisypheVolume
SisypheVolume copy of the current SisypheVolume instance with a new datatype.
Parameters
- datatypestr
numpy datatype
Returns
- SisypheVolume
cast volume
- clearXmlDicom() None
Clear the XmlDicom instance of the current SisypheVolume instance (set to None).
- componentsToSisypheVolumeCollection() SisypheVolumeCollection
Copy each component of the current SisypheVolume instance to a SisypheVolumeCollection.
Returns
- SisypheVolumeCollection
collection of components
- copy() SisypheVolume
SisypheVolume copy of the current SisypheVolume instance.
Returns
- SisypheVolume
image copy
- copyAttributesFrom(img: SisypheVolume, id: bool = True, identity: bool = True, acquisition: bool = True, display: bool = True, acpc: bool = True, transform: bool = True, slope: bool = True) None
Copy the properties and attributes of a SisypheVolume instance to the current SisypheVolume instance.
Parameters
- imgSisypheVolume
copy from this instance
- idbool
copy ID attribute if True (default)
- identitybool
copy identity property if True (default)
- acquisitionbool
copy acquisition property if True (default)
- displaybool
copy display property if True (default)
- acpcbool
copy acpc property if True (default)
- transformbool
copy transform property if True (default)
- slopebool
copy slope/intercept attributes if True (default)
- copyAttributesTo(img: SisypheVolume, id: bool = True, identity: bool = True, acquisition: bool = True, display: bool = True, acpc: bool = True, transform: bool = True, slope: bool = True) None
Copy the properties and attributes of the current SisypheVolume instance to a SisypheVolume instance.
Parameters
- imgSisypheVolume
copy to this instance
- idbool
copy ID attribute if True (default)
- identitybool
copy identity property if True (default)
- acquisitionbool
copy acquisition property if True (default)
- displaybool
copy display property if True (default)
- acpcbool
copy acpc property if True (default)
- transformbool
copy transform property if True (default)
- slopebool
copy slope/intercept attributes if True (default)
- copyComponent(c: int = 0) SisypheVolume
Copy a component of the current SisypheVolume instance.
Parameters
- cint
component index (default 0)
Returns
- SisypheVolume
single-component volume
- copyFilenameFrom(vol: SisypheVolume) None
Copy the file name attribute of a SisypheVolume instance to the current SisypheVolume instance
Parameters
- volSisypheVolume
copy from this volume
- copyFilenameTo(vol: SisypheVolume) None
Copy the file name attribute of the current SisypheVolume instance to a SisypheVolume instance.
Parameters
- volSisypheVolume
copy to this volume
- copyFromANTSImage(img: ANTsImage) None
Copy an ANTsImage buffer to the current SisypheVolume instance. Image buffer is not shared between ANTsImage and SisypheVolume instances.
Parameters
- imgants.core.ANTsImage
image to copy
- copyFromITKImage(img: <itkTemplate itk::Image>) None
Copy an ITKImage buffer to the current SisypheVolume instance. Image buffer is not shared between ITKImage and SisypheVolume instances.
Parameters
- imgitk.Image
image to copy
- copyFromNumpyArray(img: ndarray, spacing: list[float] | tuple[float, float, float] = (1.0, 1.0, 1.0), origin: list[float] | tuple[float, float, float] = (0, 0, 0), direction: tuple | list = (1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0), defaultshape: bool = True) None
Copy a Numpy array buffer to the current SisypheVolume instance. Image buffer is not shared between numpy array and SisypheVolume instances.
Parameters
- imgnumpy.ndarray
image to copy
- spacinglist[float, float, float] | tuple[float, float, float]
voxel sizes in mm (default 1.0, 1.0, 1.0)
- originlist[float, float, float] | tuple[float, float, float]
origin coordinates (default 0.0, 0.0, 0.0)
- directionlist[float]
axes directions
- defaultshapebool
if True (default), numpy shape order is reversed (i.e. z, y, x)
- copyFromSITKImage(img: Image) None
Copy a SimpleITK image buffer to the current SisypheVolume instance. Image buffer is not shared between SimpleITK image and SisypheVolume instances.
Parameters
- imgSimpleITK.Image
image to copy
- copyFromVTKImage(img: vtkImageData) None
Copy a VTKImageData buffer to the current SisypheVolume instance. Image buffer is not shared between VTKImageData and SisypheVolume instances.
Parameters
- imgvtk.vtkImageData
image to copy
- copyPropertiesFrom(img: SisypheVolume, identity: bool = True, acquisition: bool = True, display: bool = True, acpc: bool = True, slope: bool = True) None
Copy the properties of a SisypheVolume instance to the current SisypheVolume instance.
Parameters
- imgSisypheVolume
copy from this instance
- identitybool
copy identity property if True (default)
- acquisitionbool
copy acquisition property if True (default)
- displaybool
copy display property if True (default)
- acpcbool
copy acpc property if True (default)
- slopebool
copy slope/intercept attributes if True (default)
- copyPropertiesTo(img: SisypheVolume, identity: bool = True, acquisition: bool = True, display: bool = True, acpc: bool = True, slope: bool = True) None
Copy the properties of the current SisypheVolume instance to a SisypheVolume instance.
Parameters
- imgSisypheVolume
copy to this instance
- identitybool
copy identity property if True (default)
- acquisitionbool
copy acquisition property if True (default)
- displaybool
copy display property if True (default)
- acpcbool
copy acpc property if True (default)
- slopebool
copy slope/intercept attributes if True (default)
- createXML(doc: Document, single: bool = True) None
Write the current SisypheVolume instance attributes to xml instance. This method is called by save() and saveAs() methods, it is not recommended for use.
Parameters
- docminidom.Document
xml document
- singlebool
if True, saved in a single file (xml part + binary part)
if False, The xml part is saved in .xvol file and the binary part in .raw file
- property dicom: XmlDicom | None
Get the XmlDicom instance of the current SisypheVolume instance. XmlDicom file stores DICOM fields in a key/value XML file. Each SisypheVolume converted from Dicom files is associated with an XmlDicom file (same file name with .xdcm extension).
Returns
- Sisyphe.core.sisypheDicom.XmlDicom
XmlDicom attribute
- property display: SisypheDisplay
Get the display instance of the current SisypheVolume instance.
Returns
- Sisyphe.core.sisypheImageAttributes.SisypheDisplay
display attribute
- getACPC() SisypheACPC
Set the acp instance of the current SisypheVolume instance. Sisyphe.core.sisypheImageAttributes.SisypheACPC attributes are: (AC) and posterior (PC) commissure coordinates, rigid geometric transformation i.e. geometric transformation to reference with axes aligned on the AC-PC line, with midACPC point as center of rotation.
Returns
- Sisyphe.core.sisypheImageAttributes.SisypheACPC
acpc attribute
- getAcquisition() SisypheAcquisition
Get the acquisition instance of the current SisypheVolume instance. Sisyphe.core.sisypheImageAttributes.SisypheAcquisition attributes are: modality, sequence, date of scan, frame, units of scalar values, labels for LB modality, degrees of freedom and autocorrelation for statistical map sequences.
Returns
- Sisyphe.core.sisypheImageAttributes.SisypheAcquisition
acquisition attribute
- getArrayID() str
Get the Array ID attribute of the current SisypheVolume instance.
There are two types of identifier (i.e. ID):
Array ID: unique, calculated from scalar values (md5 algorithm). This cannot be edited.
ID: this is a space ID, it is not unique, all volumes sharing a common space have the same ID. This
attribute is used as key in the Sisyphe.core.sisypheTransform.SisypheTransforms instances.
Returns
- str
Array ID
- getBasename() str
Get the base name attribute of the current SisypheVolume instance. The file name attribute is used to save the current SisypheVolume instance.
Returns
- str
base name (base part of the file name)
- getBitmapCapture(index: int, zoom: float = 1.0, orient: str = 'a') QImage
Get a bitmap capture of the current SisypheVolume instance.
Parameters
- indexint
slice index
- zoomfloat
zoom factor (default 1.0, no zoom)
- orientint
slice orientation (‘a’ axial, ‘c’ coronal or ‘s’ sagittal)
Returns
- PyQt5.QtGui.QImage
Bitmap Qt image
- getComponentAllZero(c: list[int] | tuple[int, ...] | slice | None = None) SisypheVolume
Get vectors whose values are all zero in a multicomponent image.
Parameters
- cint | list[int] | tuple[int, …] | slice | None
- component indices
list[int]: list of component indices
tuple[int, …]: tuple of component indices
slice: slice of component indices (start:end:step)
None: no selection, all components are processed (default)
Returns
- SisypheVolume
single-component volume
- getComponentArgmax() SisypheVolume
Get the index of the highest scalar value of each vector in a multicomponent image.
Returns
- SisypheVolume
single-component volume
- getComponentArgmin(nonzero: bool = False) SisypheVolume
Get the index of the lowest scalar value of each vector in a multicomponent image.
Parameters
- nonzerobool
exclude zero values if True
Returns
- SisypheVolume
single-component volume
- getComponentKurtosis(c: list[int] | tuple[int, ...] | slice | None = None) SisypheVolume
Get kurtosis of each vector in a multicomponent image.
Parameters
- cint | list[int] | tuple[int, …] | slice | None
- component indices
list[int]: list of component indices
tuple[int, …]: tuple of component indices
slice: slice of component indices (start:end:step)
None: no selection, all components are processed (default)
Returns
- SisypheVolume
component kurtosis volume
- getComponentMax(c: list[int] | tuple[int, ...] | slice | None = None) SisypheVolume
Get maximum of each vector in a multicomponent image.
Parameters
- cint | list[int] | tuple[int, …] | slice | None
- component indices
list[int]: list of component indices
tuple[int, …]: tuple of component indices
slice: slice of component indices (start:end:step)
None: no selection, all components are processed (default)
Returns
- SisypheVolume
component max volume
- getComponentMean(c: list[int] | tuple[int, ...] | slice | None = None) SisypheVolume
Get mean of each vector in a multicomponent image. Process all components or a subset selected by indices.
Parameters
- cint | list[int] | tuple[int, …] | slice | None
- component indices
list[int]: list of component indices
tuple[int, …]: tuple of component indices
slice: slice of component indices (start:end:step)
None: no selection, all components are processed
Returns
- SisypheVolume
component mean volume
- getComponentMedian(c: list[int] | tuple[int, ...] | slice | None = None) SisypheVolume
Get median of each vector in a multicomponent image.
Parameters
- cint | list[int] | tuple[int, …] | slice | None
- component indices
list[int]: list of component indices
tuple[int, …]: tuple of component indices
slice: slice of component indices (start:end:step)
None: no selection, all components are processed (default)
Returns
- SisypheVolume
component median volume
- getComponentMin(c: list[int] | tuple[int, ...] | slice | None = None) SisypheVolume
Get minimum of each vector in a multicomponent image.
Parameters
- cint | list[int] | tuple[int, …] | slice | None
- component indices
list[int]: list of component indices
tuple[int, …]: tuple of component indices
slice: slice of component indices (start:end:step)
None: no selection, all components are processed (default)
Returns
- SisypheVolume
component min volume
- getComponentNumberOfNonZero(c: list[int] | tuple[int, ...] | slice | None = None) SisypheVolume
Get the number of non-zero values for each vector in a multicomponent image.
Parameters
- cint | list[int] | tuple[int, …] | slice | None
- component indices
list[int]: list of component indices
tuple[int, …]: tuple of component indices
slice: slice of component indices (start:end:step)
None: no selection, all components are processed (default)
Returns
- SisypheVolume
single-component volume
- getComponentPercentile(perc: int = 25, c: list[int] | tuple[int, ...] | slice | None = None) SisypheVolume
Get percentile of each vector in a multicomponent image.
Parameters
- percint
percentile (default 25, first quartile)
- cint | list[int] | tuple[int, …] | slice | None
- component indices
list[int]: list of component indices
tuple[int, …]: tuple of component indices
slice: slice of component indices (start:end:step)
None: no selection, all components are processed (default)
Returns
- SisypheVolume
component percentile volume
- getComponentRange(c: list[int] | tuple[int, ...] | slice | None = None) SisypheVolume
Get range (max - min) of each vector in a multicomponent image.
Parameters
- cint | list[int] | tuple[int, …] | slice | None
- component indices
list[int]: list of component indices
tuple[int, …]: tuple of component indices
slice: slice of component indices (start:end:step)
None: no selection, all components are processed (default)
Returns
- SisypheVolume
component range volume
- getComponentSkewness(c: list[int] | tuple[int, ...] | slice | None = None) SisypheVolume
Get skewness of each vector in a multicomponent image.
Parameters
- cint | list[int] | tuple[int, …] | slice | None
- component indices
list[int]: list of component indices
tuple[int, …]: tuple of component indices
slice: slice of component indices (start:end:step)
None: no selection, all components are processed (default)
Returns
- SisypheVolume
component skewness volume
- getComponentStd(c: list[int] | tuple[int, ...] | slice | None = None) SisypheVolume
Get standard deviation of each vector in a multicomponent image.
Parameters
- cint | list[int] | tuple[int, …] | slice | None
- component indices
list[int]: list of component indices
tuple[int, …]: tuple of component indices
slice: slice of component indices (start:end:step)
None: no selection, all components are processed (default)
Returns
- SisypheVolume
component std volume
- getCompression() bool
Get the compression attribute of the current SisypheVolume instance. PySisyphe volume format (.xvol) can be optionally gzipped.
Returns
- bool
True, if compression is enabled
- getCrop(c: tuple | list | ndarray) SisypheVolume
Get a cropped volume of the current SisypheVolume instance.
Parameters
- ctuple | list
xmin, xmax, ymin, ymax, zmin, zmax
Returns
- SisypheVolume
cropped volume
- getCroppedProjection(slc: int, d: str = 'left', thickness: float = 0.0, func: str = 'max', output: str = 'native', emask: SisypheVolume | None = None) Image | ndarray | QImage | SisypheVolume
Get a 2D projection of the current SisypheVolume instance. The projection is processed to a depth expressed in mm from the head surface (default 0.0, whole brain, no thickness). Operators applied to voxels on a projection line: maximum, mean, median, standard deviation, sum. The volume can be cut out to a specified depth (slice index) in the direction of projection.
Parameters
- slcint
cutting plan (orientation is given by d parameter, see below)
- dstr
direction of the projection: ‘left’, ‘right’, ‘ant’, ‘post’, ‘top’, ‘bottom’
- thickness: float
projection by a given thickness in mm (default 0.0, whole brain, no thickness)
- funcstr
‘max’, ‘mean’, ‘median’, ‘std’, ‘sum’, ‘label’
if ‘label’: threshold > 0 instead of automatic to process mask, and then uses ‘max’ operator
- outputstr
output format: ‘numpy’ numpy.ndarray, ‘sitk’ SimpleITK.Image, ‘qimage’ PyQt5.gui.QImage, ‘native’ SisypheVolume
- emaskSisypheVolume
if mask is None (default), mask is processed from the current SisypheImage instance (automatic thresholding with Huang algorithm for grayscale images, or non-zero voxels for label images). If an explicit mask is given, array size must match the current SisypheImage instance.
Returns
- SimpleITK.Image | numpy.ndarray | PyQt5.QtGui.QPixmap | SisypheVolume
SimpleITK.Image if output = ‘sitk’,
numpy.ndarray if output = ‘numpy’,
PyQt5.QtGui.QImage if output = ‘qimage’,
SisypheVolume if output = ‘native’
- getDirname() str
Get the path name attribute of the current SisypheVolume instance. The file name attribute is used to save the current SisypheVolume instance.
Returns
- str
path name (path part of the file name)
- getDisplay() SisypheDisplay
Get the display instance of the current SisypheVolume instance.
Returns
- Sisyphe.core.sisypheImageAttributes.SisypheDisplay
display attribute
- getFilename() str
Get the file name attribute of the current SisypheVolume instance. The file name attribute is used to save the current SisypheVolume instance.
Returns
- str
file name
- getFilenamePrefix(sep: str = '_') str
Get prefix (if any) from the file name attribute of the current SisypheVolume instance. The file name attribute is used to save the current SisypheVolume instance.
Parameters
- sepstr
char between prefix and base name (default ‘_’)
Returns
- str
prefix
- getFilenameSuffix(sep: str = '_') str
Get suffix (if any) from the file name attribute of the current SisypheVolume instance. The file name attribute is used to save the current SisypheVolume instance.
Parameters
- sepstr
char between prefix and base name (default ‘_’)
Returns
- str
suffix
- classmethod getFilterExt() str
Get SisypheVolume filter used by QFileDialog.getOpenFileName() and QFileDialog.getSaveFileName().
Returns
- str
‘PySisyphe Volume (.xvol)’
- getFlip(axis: list[bool]) SisypheVolume
Get a flipped copy of the current SisypheVolume instance.
Parameters
- axislist[bool, bool, bool]
flip axis if True, axis order x, y, z.
Returns
- SisypheVolume
flipped volume
- getICBMTransform() SisypheTransform | None
Get the geometric transformation to the ICBM152 template space (if any) in the transforms attribute of the current SisypheVolume instance.
Returns
- Sisyphe.core.sisypheTransform.SisypheTransform | None
geometric transform to ICBM152 template space
- getICBMfromWorld(p: list[float] | tuple[float, float, float]) list[float] | tuple[float, float, float] | None
Convert world coordinates to ICBM coordinates. Returns None if the transforms attribute of the current SisypheVolume instance does not contain the ‘ICBM152’ ID.
Parameters
- plist[float, float, float] | tuple[float, float, float]
World coordinates
Returns
- tuple[float, float, float] | None
ICBM coordinates
- getID() str
Get the ID attribute of the current SisypheVolume instance.
There are two types of identifier (i.e. ID):
Array ID: unique, calculated from scalar values (md5 algorithm). This cannot be edited.
ID: this is a space ID, it is not unique, all volumes sharing a common space have the same ID. This
attribute is used as key in the Sisyphe.core.sisypheTransform.SisypheTransforms instances.
Returns
- str
ID
- getIdentity() SisypheIdentity
Get the identity instance of the current SisypheVolume instance. Sisyphe.core.sisypheImageAttributes.SisypheIdentity attributes are: lastname, firstname, gender, birthdate
Returns
- Sisyphe.core.sisypheImageAttributes.SisypheIdentity
identity attribute
- getIntercept() float
Set the intercept attribute of the current SisypheVolume instance. The slope and intercept attributes are used to apply a linear transformation of the scalar values: value = slope * scalar value + intercept.
Returns
- float
intercept value
- getLEKSELLTransform() SisypheTransform | None
Get the geometric transformation to the LEKSELL space (if any) in the transforms attribute of the current SisypheVolume instance.
Returns
- Sisyphe.core.sisypheTransform.SisypheTransform
geometric transform to LEKSELL space
- getLEKSELLfromWorld(p: list[float] | tuple[float, float, float]) list[float] | tuple[float, float, float] | None
Convert world coordinates to LEKSELL coordinates Returns None if the transforms attribute of the current SisypheVolume instance does not contain the ‘LEKSELL’ ID.
Parameters
- plist[float, float, float] | tuple[float, float, float]
World coordinates
Returns
- tuple[float, float, float] | None
LEKSELL coordinates
- getMask(algo: str = 'huang', morpho: str = '', niter: int = 1, kernel: int = 0, fill: str = '', c: int | None = 0) SisypheVolume
Calc SisypheVolume mask of the head.
Parameters
- algostr
Automatic thresholding algorithm used for background segmentation: ‘mean’, ‘otsu’, ‘huang’, ‘renyi’, ‘yen’, ‘li’, ‘shanbhag’, ‘triangle’, ‘intermodes’, ‘maximumentropy’, ‘kittler’, ‘isodata’ or ‘moments’
- morphostr
binary morphology operator, ‘dilate’, ‘erode’, ‘open’, ‘close’ or ‘’ (default, no morphology)
- niterint
number of binary morphology iterations (default 1)
- kernelint
structuring element size (default 0, no morphology)
- fillstr
‘2d’, fill holes slice by slice
‘3d’, fill holes in 3D
‘’, no filling (default)
- cint | None
parameter only used for multi-component image
int index of the component to process (default 0, first component)
None, processing is performed on the mean image
Returns
- SisypheVolume
mask
- getMask2(algo: str = 'huang', morphoiter: int = 1, kernel: int = 0, c: int | None = 0) SisypheVolume
Calc SisypheVolume mask of the head.
Parameters
- algostr
Automatic thresholding algorithm used for background segmentation: ‘mean’, ‘otsu’, ‘huang’, ‘renyi’, ‘yen’, ‘li’, ‘shanbhag’, ‘triangle’, ‘intermodes’, ‘maximumentropy’, ‘kittler’, ‘isodata’ or ‘moments’
- morphoiterint
number of binary morphology iterations (default 2)
- kernelint
structuring element size, 0 automatic value (kernel=2 if spacing < 1.5 mm, kernel=1 otherwise)
- cint | None
parameter only used for multi-component image
int index of the component to process (default 0, first component)
None, processing is performed on the mean image
Returns
- SisypheVolume
mask
- getMaskROI(name: str = 'Mask', algo: str = 'huang', morpho: str = '', niter: int = 1, kernel: int = 0, fill: str = '', c: int | None = 0) SisypheROI
Calc Sisyphe.core.sisypheROI.SisypheROI mask of the head.
Parameters
- namestr
roi name
- algostr
Automatic thresholding algorithm used for background segmentation: ‘mean’, ‘otsu’, ‘huang’, ‘renyi’, ‘yen’, ‘li’, ‘shanbhag’, ‘triangle’, ‘intermodes’, ‘maximumentropy’, ‘kittler’, ‘isodata’ or ‘moments’
- morphostr
binary morphology operator, ‘dilate’, ‘erode’, ‘open’, ‘close’ or ‘’ (default, no morphology)
- niterint
number of binary morphology iterations (default 1)
- kernelint
structuring element size (default 0, no morphology)
- fillstr
‘2d’, fill holes slice by slice
‘3d’, fill holes in 3D
‘’, no filling (default)
- cint | None
parameter only used for multi-component image
int index of the component to process (default 0, first component)
None, processing is performed on the mean image
Returns
- Sisyphe.core.sisypheROI.SisypheROI
mask roi
- getMaskROI2(name: str = 'Mask', algo: str = 'huang', morphoiter: int = 1, kernel: int = 0, c: int | None = 0) SisypheROI
Calc Sisyphe.core.sisypheROI.SisypheROI mask of the head.
Parameters
- namestr
roi name
- algostr
Automatic thresholding algorithm used for background segmentation: ‘mean’, ‘otsu’, ‘huang’, ‘renyi’, ‘yen’, ‘li’, ‘shanbhag’, ‘triangle’, ‘intermodes’, ‘maximumentropy’, ‘kittler’, ‘isodata’ or ‘moments’
- morphoiterint
number of binary morphology iterations (default 2)
- kernelint
structuring element size, 0 automatic value (kernel=2 if spacing < 1.5 mm, kernel=1 otherwise)
- cint | None
parameter only used for multi-component image
int index of the component to process (default 0, first component)
None, processing is performed on the mean image
Returns
- Sisyphe.core.sisypheROI.SisypheROI
mask roi
- getName() str
Get the name attribute of the current SisypheVolume instance. This is the base part of the file name, without extension.
Returns
- str
name (base part of the file name, without extension)
- getNonZeroMask(c: int | None = 0) SisypheVolume
Calc SisypheImage mask of non-zero voxels of the current SisypheImage instance.
Parameters
- cint | None
parameter only used for multi-component image
int index of the component to process (default 0, first component)
None, processing is performed on the mean image
Returns
- SisypheVolume
non-zero mask
- getOrientation() int
Get the orientation attribute of the current SisypheVolume instance as int code.
Returns
- int
1 ‘axial’, 2 ‘coronal’, 3 ‘sagittal’ or 0 ‘unspecified’
- getOrientationAsString() str
Get the orientation attribute of the current SisypheVolume instance as str.
Returns
- str
‘axial’, ‘coronal’, ‘sagittal’ or ‘unspecified’
- getProjection(d: str = 'left', thickness: float = 0.0, func: str = 'max', output: str = 'native', emask: SisypheVolume | None = None) Image | ndarray | QImage | SisypheVolume
Get a 2D projection of the current SisypheVolume instance. The projection is processed to a depth expressed in mm from the head surface (default 0.0, whole brain, no thickness). Operators applied to voxels on a projection line: maximum, mean, median, standard deviation, sum.
Parameters
- dstr
direction of the projection: ‘left’, ‘right’, ‘ant’, ‘post’, ‘top’, ‘bottom’
- thickness: float
projection by a given thickness in mm (default 0.0, whole brain, no thickness)
- funcstr
‘max’, ‘mean’, ‘median’, ‘std’, ‘sum’, ‘label’
if ‘label’: threshold > 0 instead of automatic to process mask, and then uses ‘max’ operator
- outputstr
output format: ‘numpy’ numpy.ndarray, ‘sitk’ SimpleITK.Image, ‘qimage’ PyQt5.gui.QImage, ‘native’ SisypheVolume
- emaskSisypheVolume
if mask is None (default), mask is processed from the current SisypheImage instance (automatic thresholding with Huang algorithm for grayscale images, or non-zero voxels for label images). If an explicit mask is given, array size must match the current SisypheImage instance.
Returns
- SimpleITK.Image | numpy.ndarray | PyQt5.QtGui.QPixmap | SisypheVolume
SimpleITK.Image if output = ‘sitk’,
numpy.ndarray if output = ‘numpy’,
PyQt5.QtGui.QImage if output = ‘qimage’,
SisypheVolume if output = ‘native’
- getROI(threshold: float = 0.5, op: str = '>', c: int | None = 0) SisypheROI
Converting current SisypheVolume instance to Sisyphe.core.sisypheROI.SisypheROI.
Parameters
- thresholdfloat
threshold for binarization (default 0.5)
- opstr
comparison operator: ‘>’ (default), ‘>=’, ‘<’, ‘<=’, ‘==’, ‘!=’
- cint | None
parameter only used for multi-component image - int index of the component to process (default 0, first component) - None, processing is performed on the mean image
Returns
Sisyphe.core.sisypheROI.SisypheROI
- getSlope() float
Get the slope attribute of the current SisypheVolume instance. The slope and intercept attributes are used to apply a linear transformation of the scalar values: value = slope * scalar value + intercept.
Returns
- float
slope value
- getStandardizeIntensity(method: str = 'norm') SisypheVolume
Get an intensity normalized copy of the current SisypheImage instance.
Parameters
- methodstr
‘norm’, standardize the intensity as zscore (i.e. zero mean, [-std, +std] mapped to [0, 1]
‘rescale’, standardize the intensity values to the range [0, 1]
Returns
- SisypheVolume
standardized volume
- getTransformFromID(ID: str | SisypheVolume) SisypheTransform | None
Get the geometric transformation corresponding to a given ID in the transforms attribute of the current SisypheVolume instance.
Parameters
- IDstr | SisypheVolume
ID or SisypheVolume ID attribute
Returns
- Sisyphe.core.sisypheTransform.SisypheTransform | None
geometric transform
- getTransformFromIndex(index: int) SisypheTransform
Get the geometric transformation corresponding to a given index in the transforms attribute of the current SisypheVolume instance.
Parameters
- indexint
index in geometric transform collection
Returns
- Sisyphe.core.sisypheTransform.SisypheTransform
geometric transform
- getTransforms() SisypheTransforms
Set the transforms attribute of the current SisypheVolume attribute. Each SisypheVolume is associated with a SisypheTransforms instance, which stores all the geometric transformations calculated from co-registrations with other SisypheVolume instances. This transforms attribute is saved the same file name with .xtrfs extension.
Returns
- SisypheTransforms
geometric transform collection
- getTruncateIntensity(centile: int = 1, outputrange: tuple[float, float] | None = None) SisypheVolume
Get intensity truncated copy of the current SisypheImage instance. Truncate threshold is expressed in percentile (min threshold = centile, max threshold = 100 - centile). The max and min values of the output image are given in the output range parameter. If output range is None, max and min values of the output image are the max and min truncate thresholds.
Parameters
- centileint
truncate threshold expressed in percentile
- outputrangetuple[float, float] | None
max and min values of the output image
Returns
- SisypheVolume
truncated volume
- classmethod getVolumeAttribute(filename: str, attr: str) str | int | float | tuple | list
Get an attribute of a PySisyphe Volume file (.xvol).
Parameters
- filenamestr
PySisyphe Volume file name
- attrstr
attribute name: ID, size, spacing, FOV, number of componentes, datatype, origin, directions, orientation, modality, sequence, date of scan, stereotactic frame, scalar unit, range, window, slope, intercept, lastname, firstname, gender, date of birthday
Returns
- str | int | float | tuple | list
attribute value
- classmethod getVolumeAttributes(filename: str) dict
Get attributes of a PySisyphe Volume file (.xvol).
Parameters
- filenamestr
PySisyphe Volume file name
Returns
- dict
attribute keys: ID, size, spacing, FOV, number of componentes, datatype, origin, directions, orientation, modality, sequence, date of scan, stereotactic frame, scalar unit, range, window, slope, intercept, lastname, firstname, gender, date of birthday
- getWorldfromICBM(p: list[float] | tuple[float, float, float]) list[float] | tuple[float, float, float] | None
Convert ICBM coordinates to world coordinates Returns None if the transforms attribute of the current SisypheVolume instance does not contain the ‘ICBM152’ ID.
Parameters
- plist[float, float, float] | tuple[float, float, float]
ICBM coordinates
Returns
- tuple[float, float, float] | None
world coordinates
- getWorldfromLEKSELL(p: list[float] | tuple[float, float, float]) list[float] | tuple[float, float, float] | None
Convert LEKSELL coordinates to world coordinates Returns None if the transforms attribute of the current SisypheVolume instance does not contain the ‘LEKSELL’ ID.
Parameters
- plist[float, float, float] | tuple[float, float, float]
LEKSELL coordinates
Returns
- tuple[float, float, float] | None
world coordinates
- getWorldfromTransform(ID: str | SisypheVolume, p: list[float] | tuple[float, float, float]) list[float] | tuple[float, float, float]
Extract the geometric transformation corresponding to an ID key from the SisypheTransforms attribute of the current SisypheVolume instance. Then apply this geometric transformation to a given point.
Parameters
- IDstr | SisypheVolume
ID or SisypheVolume ID attribute
- plist[float, float, float] | tuple[float, float, float]
point coordinates
Returns
- tuple[float, float, float]
point coordinates, returns the same point coordinates if the ID is not in the SisypheTransforms attribute
- getXmlDicom() XmlDicom | None
Get the XmlDicom instance of the current SisypheVolume instance. XmlDicom file stores DICOM fields in a key/value XML file. Each SisypheVolume converted from Dicom files is associated with an XmlDicom file (same file name with .xdcm extension).
Returns
- Sisyphe.core.sisypheDicom.XmlDicom
XmlDicom attribute
- classmethod getXmlVolume(filename: str) XmlVolume
Get a XmlVolume instance of a PySisyphe Volume file (.xvol).
Parameters
- filenamestr
PySisyphe Volume file name
Returns
- Sisyphe.core.sisypheXml.XmlVolume
XmlVolume
- hasFilename() bool
Check whether the filename attribute of the current SisypheVolume instance is defined (i.e. not ‘’)
Returns
- bool
True if filename attribute is defined
- hasICBMTransform() bool
Check whether the transforms attribute of the current SisypheVolume instance contains a geometric transformation to the ICBM152 template space (contains ID == ‘ICBM152’).
Returns
- bool
True if an ICBM152 transform is in collection
- hasLEKSELLTransform() bool
Check whether the transforms attribute of the current SisypheVolume instance contains a geometric transformation to the LEKSELL space (contains ID == ‘LEKSELL’).
Returns
- bool
True if a LEKSELL transform is in collection
- hasSameID(ID: str | SisypheVolume | SisypheROI | SisypheMesh) bool
Check if an ID is identical to the ID of the current SisypheVolume instance.
Parameters
- IDstr | SisypheVolume | Sisyphe.core.sisypheROI.SisypheROI | Sisyphe.core.sisypheMesh.SisypheMesh
ID, SisypheVolume ID attribute, SisypheROI ID attribute or SisypheMesh ID attribute
Returns
bool
- hasTransform(ID: str | SisypheVolume) bool
Check whether the transforms attribute of the current SisypheVolume attribute contains a given ID.
Parameters
- IDstr | SisypheVolume
ID or SisypheVolume ID attribute
Returns
- bool
True if geometric transform is in collection
- hasXmlDicom() bool
Check whether the XmlDicom instance of the current SisypheVolume instance is defined (not None). XmlDicom file stores DICOM fields in a key/value XML file. Each SisypheVolume converted from Dicom files is associated with an XmlDicom file (same file name with .xdcm extension).
Returns
- Sisyphe.core.sisypheDicom.XmlDicom
XmlDicom attribute
- property identity: SisypheIdentity
Get the identity instance of the current SisypheVolume instance. Sisyphe.core.sisypheImageAttributes.SisypheIdentity attributes are: lastname, firstname, gender, birthdate
Returns
- Sisyphe.core.sisypheImageAttributes.SisypheIdentity
identity attribute
- isAxial() bool
Check whether the orientation attribute of the current SisypheVolume instance is axial.
Returns
- bool
True if axial orientation
- isCoronal() bool
Check whether the orientation attribute of the current SisypheVolume instance is coronal.
Returns
- bool
True if coronal orientation
- isIdentityTransform(ID: str | SisypheVolume) bool
Check whether the geometric transformation corresponding to a given ID in the transforms attribute of the current SisypheVolume instance, is an identity transformation.
Parameters
- IDstr | SisypheVolume
ID or SisypheVolume ID attribute
Returns
- bool
True if identity geometric transform
- isSagittal() bool
Check whether the orientation attribute of the current SisypheVolume instance is sagittal.
Returns
- bool
True if sagittal orientation
- labelToROI(label: int = 0) SisypheROI
Converting a label of the current SisypheVolume instance to Sisyphe.core.sisypheROI.SisypheROI. The modality of the current SisypheVolume instance must be LB (Label).
Parameters
- labelint
label index (default 0)
Returns
- Sisyphe.core.sisypheROI.SisypheROI
roi converted from label volume
- load(filename: str = '', binary: bool = True) None
Load the current SisypheVolume instance from a PySisyphe Volume (.xvol) file.
Parameters
- filenamestr
PySisyphe Volume file name (optional). If filename is empty (‘’, default), the file name attribute of the current SisypheVolume instance is used
- binarybool
if False, load only xml part (attributes), not binary part (array), default is True (load xml and binary parts)
- loadFromBrainVoyagerVMR(filename: str) None
Load the current SisypheVolume instance from a BrainVoyager (.vmr) file.
Parameters
- filenamestr
BrainVoyager file name
- loadFromFreeSurferMGH(filename: str) None
Load the current SisypheVolume instance from a FreeSurfer (.mgh, .mgz) file.
Parameters
- filenamestr
FreeSurfer file name
- loadFromMINC(filename: str) None
Load the current SisypheVolume instance from a Minc (.minc) file.
Parameters
- filenamestr
Minc file name
- loadFromNIFTI(filename: str, reorient: bool = True) None
Load the current SisypheVolume instance from a Nifti (.nii) file.
Parameters
- filenamestr
Nifti file name
- reorientbool
conversion to RAS+ world coordinates convention if True (default)
- loadFromNRRD(filename: str) None
Load the current SisypheVolume instance from a Nrrd (.nrrd) file.
Parameters
- filenamestr
Nrrd file name
- loadFromNumpy(filename: str) None
Load the current SisypheVolume instance from a numpy (.npy) file.
Parameters
- filenamestr
numpy file name
- loadFromSisyphe(filename: str) None
Load the current SisypheVolume instance from an old Sisyphe Volume (.vol) file.
Parameters
- filenamestr
old Sisyphe Volume file name
- loadFromVTK(filename: str) None
Load the current SisypheVolume instance from a VTK (.vtk) file.
Parameters
- filenamestr
VTK file name
- loadTransforms() None
Load the transforms attribute of the current SisypheVolume instance. Each SisypheVolume is associated with a SisypheTransforms instance, which stores all the geometric transformations calculated from co-registrations with other SisypheVolume instances.
- loadXmlDicom() None
Load the XmlDicom instance associated to the current SisypheVolume instance. XmlDicom file stores DICOM fields in a key/value XML file. Each SisypheVolume converted from Dicom files is associated with an XmlDicom file (same file name with .xdcm extension).
- classmethod openVolume(filename: str) SisypheVolume | None
create a SisypheVolume instance from PySisyphe Volume file (.xvol).
Parameters
- filenamestr
volume file name
Returns
- SisypheVolume
loaded volume
- parseXML(doc: Document) dict
Read the current SisypheVolume instance attributes from xml instance. This method is called by load() method, it is not recommended for use.
Parameters
- docminidom.Document
xml document
Returns
- dict[str]
- Key / Value
‘size’: list[int, int, int], image size in each axis
‘components’: int, number of components
‘spacing’: list[float, float, float], voxel size in each axis
‘origin’: list[float, float, float], origin coordinates
‘datatype’: str, numpy datatype
‘directions’: list[float], direction vectors
‘array’: bytes, array image
- removeAllPrefixes(sep: str = '_') None
Remove all prefixes from the file name attribute of the current SisypheVolume instance.
Parameters
- sepstr
char between prefix(es) (default ‘_’)
- removeAllSuffixes(sep: str = '_') None
Remove all prefixes from the file name attribute of the current SisypheVolume instance.
Parameters
- sepstr
char between prefix(es) (default ‘_’)
- removeDisplay() None
Clear the display attribute of the current SisypheVolume instance. Default display values: gray level colormap, no windowing.
- removeNeckSlices(f: float = 1.8) SisypheVolume
Get a new SisypheVolume instance, cropped in z. Most sagittal MRI scans have extensive and useless inferior coverage. This function crop MR volume in z direction, removing empty slices and lower slices of neck below foramen magnum.
Parameters
- ffloat
multiplicative factor to adjust the neck slice. Lower values remove more slices, higher values keep more slices (between 1.5 and 2.0, default 1.8 close to the foramen magnum for most MR images)
Returns
- SisypheVolume
cropped volume
- removeSuffixNumber() None
Remove a suffix number (if any) from the file name attribute of the current SisypheVolume instance.
- save(filename: str = '', single: bool = True) None
Save the current SisypheVolume instance to a PySisyphe Volume (.xvol) file.
Parameters
- filenamestr
PySisyphe Volume file name (optional). if filename is empty (‘’, default), the file name attribute of the current SisypheVolume instance is used
- singlebool
if True, saved in a single file (xml part + binary part)
if False, The xml part is saved in .xvol file and the binary part in .raw file
- saveAs(filename: str, single: bool = True) None
Save the current SisypheVolume instance to a PySisyphe Volume (.xvol) file.
Parameters
- filenamestr
PySisyphe Volume file name
- singlebool
if True, saved in a single file (xml part + binary part)
if False, The xml part is saved in .xvol file and the binary part in .raw file
- saveBitmapCapture(filename: str, index: int, zoom: float = 1.0, orient: str = 'a') None
Save a bitmap capture of the current SisypheVolume instance.
Parameters
filename : str index : int
slice index
- zoomfloat
zoom factor (default 1.0, no zoom)
- orientint
slice orientation (‘a’ axial, ‘c’ coronal or ‘s’ sagittal)
Returns
- PyQt5.QtGui.QPixmap
Bitmap Qt pixmap
- saveToMINC(filename: str = '') None
Save the current SisypheVolume instance to a Minc (.minc) file.
Parameters
- filenamestr
Minc file name, if filename is empty (‘’, default), the file name attribute of the current SisypheVolume instance is used
- saveToNIFTI(filename: str = '', compress: bool = False) None
Save the current SisypheVolume instance to a Nifti (.nii) file.
Parameters
- filenamestr
Nifti file name, if filename is empty (‘’, default), the file name attribute of the current SisypheVolume instance is used
- compressbool
gzip compression if True (default False)
- saveToNRRD(filename: str = '') None
Save the current SisypheVolume instance to a Nrrd (.nrrd) file.
Parameters
- filenamestr
Nrrd file name, if filename is empty (‘’, default), the file name attribute of the current SisypheVolume instance is used
- saveToNumpy(filename: str = '') None
Save the current SisypheVolume instance to a numpy (.npy) file.
Parameters
- filenamestr
numpy file name, if filename is empty (‘’, default), the file name attribute of the current SisypheVolume instance is used
- saveToVTK(filename: str = '') None
Save the current SisypheVolume instance to a VTK (.vtk) file.
Parameters
- filenamestr
VTK file name, if filename is empty (‘’, default), the file name attribute of the current SisypheVolume instance is used
- saveTransforms() None
Save the transforms attribute of the current SisypheVolume instance. Each SisypheVolume is associated with a SisypheTransforms instance, which stores all the geometric transformations calculated from co-registrations with other SisypheVolume instances.
- setACPC(acpc: SisypheACPC) None
Set the acp instance of the current SisypheVolume instance. Sisyphe.core.sisypheImageAttributes.SisypheACPC attributes are: (AC) and posterior (PC) commissure coordinates, rigid geometric transformation i.e. geometric transformation to reference with axes aligned on the AC-PC line, with midACPC point as center of rotation.
Parameters
- acpcSisyphe.core.sisypheImageAttributes.SisypheACPC
acpc attribute
- setAcquisition(acquisition: SisypheAcquisition) None
Set the acquisition instance of the current SisypheVolume instance. Sisyphe.core.sisypheImageAttributes.SisypheAcquisition attributes are: modality, sequence, date of scan, frame, units of scalar values, labels for LB modality, degrees of freedom and autocorrelation for statistical map sequences.
Parameters
- acquisitionSisyphe.core.sisypheImageAttributes.SisypheAcquisition
acquisition attribute
- setCompression(v: bool) None
Set the compression attribute of the current SisypheVolume instance. ySisyphe volume format (.xvol) can be optionally gzipped.
Parameters
- vbool
compression is enabled if True
- setCompressionOff() None
Disables gzip file compression of the current SisypheVolume instance. PySisyphe volume format (.xroi) can be optionally gzipped.
- setCompressionOn() None
Enables gzip file compression of the current SisypheVolume instance. PySisyphe volume format (.xroi) can be optionally gzipped.
- setDefaultDirections() None
Set vectors of image axes to default in RAS+ coordinates system. PySisyphe uses RAS+ world coordinates system convention (as MNI, Nibabel, Dipy…) with origin to corner of the voxel
x, direction [1.0, 0.0, 0.0]: left(-) to right(+)
y, direction [0.0, 1.0, 0.0]: posterior(-) to anterior(+)
z, direction [0.0, 0.0, 1.0]: inferior(-) to superior(+)
Directions is a list of 9 float, 3 vectors of 3 floats
First vector, x image axis direction, [1.0, 0.0, 0.0] (RAS+ default)
Second vector, y image axis direction, [0.0, 1.0, 0.0] (RAS+ default)
Third vector, y image axis direction, [0.0, 0.0, 1.0] (RAS+ default)
- setDirections(direction: tuple = (1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)) None
Set vectors of image axes in RAS+ coordinates system. PySisyphe uses RAS+ world coordinates system convention (as MNI, Nibabel, Dipy…) with origin to corner of the voxel.
x, direction [1.0, 0.0, 0.0]: left(-) to right(+)
y, direction [0.0, 1.0, 0.0]: posterior(-) to anterior(+)
z, direction [0.0, 0.0, 1.0]: inferior(-) to superior(+)
Directions is a list of 9 float, 3 vectors of 3 floats
First vector, x image axis direction, [1.0, 0.0, 0.0] (RAS+ default)
Second vector, y image axis direction, [0.0, 1.0, 0.0] (RAS+ default)
Third vector, y image axis direction, [0.0, 0.0, 1.0] (RAS+ default)
Parameters
- directionlist[float]
vectors of image axes
- setDirname(path: str) None
Set the path name attribute of the current SisypheVolume instance. The file name attribute is used to save the current SisypheVolume instance.
Parameters
- pathstr
path name (path part of the file name)
- setDisplay(display: SisypheDisplay) None
Set the display instance of the current SisypheVolume instance.
Parameters
- displaySisyphe.core.sisypheImageAttributes.SisypheDisplay
display attribute
- setFilename(filename: str) None
Set the file name attribute of the current SisypheVolume instance. The file name attribute is used to save the current SisypheVolume instance.
Parameters
- filenamestr
file name
- setFilenamePrefix(prefix: str, sep: str = '_') None
Set a prefix to the file name attribute of the current SisypheVolume instance. The file name attribute is used to save the current SisypheVolume instance.
Parameters
- prefixstr
prefix to add
- sepstr
char between prefix and base name (default ‘_’)
- setFilenameSuffix(suffix: str, sep: str = '_') None
Set a suffix to the file name attribute of the current SisypheVolume instance. The file name attribute is used to save the current SisypheVolume instance.
Parameters
- suffixstr
suffix to add
- sepstr
char between base name and suffix (default ‘_’)
- setID(ID: str | SisypheVolume) None
Set the ID attribute of the current SisypheVolume instance.
There are two ID types:
ID is a space ID, it is not unique, all volumes sharing a common space have the same ID. This attribute is
used as key in the Sisyphe.core.sisypheTransform.SisypheTransforms instances - Array ID, unique, calculated from scalar values (md5 algorithm). This cannot be edited.
Parameters
- IDstr | SisypheVolume
ID or SisypheVolume ID attribute
- setIDtoATROPOS() None
Set the ID attribute of the current SisypheVolume instance to ATROPOS.
- setIDtoICBM152() None
Set the ID attribute of the current SisypheVolume instance to ICBM152.
- setIDtoICBM452() None
Set the ID attribute of the current SisypheVolume instance to ICBM452.
- setIDtoSRI24() None
Set the ID attribute of the current SisypheVolume instance to SRI24.
- setIdentity(identity: SisypheIdentity) None
Set the identity instance of the current SisypheVolume instance. Sisyphe.core.sisypheImageAttributes.SisypheIdentity attributes are: lastname, firstname, gender, birthdate
Parameters
- identitySisyphe.core.sisypheImageAttributes.SisypheIdentity
identity attribute
- setIntercept(intercept: float = 0.0) None
Set the intercept attribute of the current SisypheVolume instance. The slope and intercept attributes are used to apply a linear transformation of the scalar values: value = slope * scalar value + intercept.
Parameters
- interceptfloat
intercept value
- setOrientation(orient: str = 'axial') None
Set the orientation attribute of the current SisypheVolume instance.
Parameters
- orientstr
‘axial’, ‘coronal’, ‘sagittal’ or ‘unspecified’
- setOrientationToAxial() None
Set the orientation attribute of the current SisypheVolume instance to axial.
- setOrientationToCoronal() None
Set the orientation attribute of the current SisypheVolume instance to coronal.
- setOrientationToSagittal() None
Set the orientation attribute of the current SisypheVolume instance to sagittal.
- setSITKImage(img: Image) None
Shallow copy of a SimpleITK Image to the SimpleITK Image attribute of the current SisypheVolume instance. Image buffer is shared between SimpleITK image and current SisypheVolume instances.
Parameters
- imgSimpleITK.Image
image to copy
- setSlope(slope: float = 1.0) None
Set the slope attribute of the current SisypheVolume instance. The slope and intercept attributes are used to apply a linear transformation of the scalar values: value = slope * scalar value + intercept.
Parameters
- slopefloat
slope value
- setTransforms(transforms: SisypheTransforms, force: bool = False) None
Set the transforms attribute of the current SisypheVolume attribute. Each SisypheVolume is associated with a SisypheTransforms instance which stores all the geometric transformations calculated from co-registrations with other SisypheVolume instances. This transforms attribute is saved the same file name with .xtrfs extension.
Parameters
- transformsSisypheTransforms
geometric transform collection to copy
- forcebool
if True, ignores reference ID (default False)
- property transforms: SisypheTransforms
Set the transforms attribute of the current SisypheVolume attribute. Each SisypheVolume is associated with a SisypheTransforms instance, which stores all the geometric transformations calculated from co-registrations with other SisypheVolume instances. This transforms attribute is saved the same file name with .xtrfs extension.
Returns
- SisypheTransforms
geometric transform collection
- updateArrayID() None
Re-calculate the array ID attribute from the scalar values of the current SisypheVolume instance.
- class Sisyphe.core.sisypheVolume.SisypheVolumeCollection
Description
Named list container of SisypheVolume instances. Container key to address elements can be int index, ID str or SisypheVolume (uses ID attribute as str key).
Getter methods of the SisypheVolume class are added to the SisypheVolumeCollection class, returning a list of values sent by each SisypheVolume element in the container.
Inheritance
object -> SisypheVolumeCollection
Creation: 04/02/2021 Last revision: 20/12/2024
- append(value: SisypheVolume) None
Append a SisypheVolume element in the current SisypheVolumeCollection instance container.
Parameters
- valueSisypheVolume
volume to append
- clear() None
Remove all elements from the current SisypheVolumeCollection instance container (empty).
- copy() SisypheVolumeCollection
Copy the current SisypheVolumeCollection instance container (Shallow copy of elements).
Returns
- SisypheVolumeCollection
Shallow copy of collection elements
- copyFromList(vols: list[SisypheVolume]) None
Copy a list of SisypheVolume to the current SisypheVolumeCollection instance container (Shallow copy of image array)
Parameters
- volslist[SisypheVolume]
list of volumes to copy in collection
- copyToList() list[SisypheVolume]
Copy the current SisypheVolumeCollection instance container to a list. (Shallow copy of elements)
Returns
- list[SisypheVolume]
shallow copy of collection elements
- copyToMultiComponentSisypheVolume() SisypheVolume
Copy the current SisypheVolumeCollection instance to a multi-component SisypheVolume instance
Returns
- SisypheVolume
multi-component volume
- copyToNumpyArray(defaultshape: bool = True) ndarray
Copy the current SisypheVolumeCollection instance to a numpy.ndarray.
Returns
- numpy.ndarray
multi-component numpy array
- count() int
Get the number of SisypheVolume elements in the current SisypheVolumeCollection instance container.
Returns
- int
number of SisypheVolume elements
- getArgmaxVolume() SisypheVolume
Calculate argmax image of the SisypheVolume images in the current SisypheVolumeCollection instance. argmax returns the image index of the minimum value in the SisypheVolumeCollection instance.
Returns
- SisypheVolume
argmax volume
- getArgminVolume() SisypheVolume
Calculate argmin image of the SisypheVolume images in the current SisypheVolumeCollection instance. argmin returns the image index of the minimum value in the SisypheVolumeCollection instance.
Returns
- SisypheVolume
argmin volume
- getList() list[SisypheVolume]
Get the list attribute of the current SisypheVolumeCollection instance container (Shallow copy of the elements).
Returns
- list[SisypheVolume]
shallow copy of collection
- getMaxVolume(c: list[int] | tuple[int, ...] | slice | None = None) SisypheVolume
Calculate maximum image of the SisypheVolume images in the current SisypheVolumeCollection instance. Process all volumes or a subset selected by indices.
Parameters
- cint | list[int] | tuple[int, …] | slice | None
- volume indices
list[int]: list of indices
tuple[int, …]: tuple of indices
slice: slice of indices (start:end:step)
None: no selection, all volumes are processed
Returns
- SisypheVolume
max volume
- getMeanVolume(c: list[int] | tuple[int, ...] | slice | None = None) SisypheVolume
Calculate mean image of the SisypheVolume images in the current SisypheVolumeCollection instance. Process all volumes or a subset selected by indices.
Parameters
- cint | list[int] | tuple[int, …] | slice | None
- volume indices
list[int]: list of indices
tuple[int, …]: tuple of indices
slice: slice of indices (start:end:step)
None: no selection, all volumes are processed
Returns
- SisypheVolume
mean volume
- getMedianVolume(c: list[int] | tuple[int, ...] | slice | None = None) SisypheVolume
Calculate median image of the SisypheVolume images in the current SisypheVolumeCollection instance. Process all volumes or a subset selected by indices.
Parameters
- cint | list[int] | tuple[int, …] | slice | None
- volume indices
list[int]: list of indices
tuple[int, …]: tuple of indices
slice: slice of indices (start:end:step)
None: no selection, all volumes are processed
Returns
- SisypheVolume
median volume
- getMinVolume(c: list[int] | tuple[int, ...] | slice | None = None) SisypheVolume
Calculate minimum image of the SisypheVolume images in the current SisypheVolumeCollection instance. Process all volumes or a subset selected by indices.
Parameters
- cint | list[int] | tuple[int, …] | slice | None
- volume indices
list[int]: list of indices
tuple[int, …]: tuple of indices
slice: slice of indices (start:end:step)
None: no selection, all volumes are processed
Returns
- SisypheVolume
min volume
- getPercentileVolume(perc: int = 25, c: list[int] | tuple[int, ...] | slice | None = None) SisypheVolume
Calculate percentile image of the SisypheVolume images in the current SisypheVolumeCollection instance. Process all volumes or a subset selected by indices.
Parameters
- percint
percentile value (default 25, first quartile)
- cint | list[int] | tuple[int, …] | slice | None
- volume indices
list[int]: list of indices
tuple[int, …]: tuple of indices
slice: slice of indices (start:end:step)
None: no selection, all volumes are processed
Returns
- SisypheVolume
percentile volume
- getStdVolume(c: list[int] | tuple[int, ...] | slice | None = None) SisypheVolume
Calculate standard deviation image of the SisypheVolume images in the current SisypheVolumeCollection instance. Process all volumes or a subset selected by indices.
Parameters
- cint | list[int] | tuple[int, …] | slice | None
- volume indices
list[int]: list of indices
tuple[int, …]: tuple of indices
slice: slice of indices (start:end:step)
None: no selection, all volumes are processed
Returns
- SisypheVolume
std volume
- getValuesAt(x: int, y: int, z: int, asnumpy: bool = False) list[float] | ndarray
Get scalar values in a voxel of the SisypheVolume images in the current SisypheVolumeCollection instance. The current SisypheVolumeCollection instance must be homogeneous (see isHomogeneous() method)
Parameters
- xint
x-axis voxel coordinate
- yint
y-axis voxel coordinate
- zint
z-axis voxel coordinate
- asnumpybool
returns numpy.ndarray if True, list[float] otherwise (default False)
Returns
- numpy.ndarray | list[float]
volues at voxel (x, y, z)
- getValuesInsideMask(mask: SisypheImage) list[ndarray]
Get scalar values inside a mask of the SisypheVolume images in the current SisypheVolumeCollection instance. The current SisypheVolumeCollection instance must be homogeneous (see isHomogeneous() method)
Parameters
mask : Sisyphe.core.sisypheImage.SisypheImage
Returns
- numpy.ndarray | list[float]
values inside mask
- getVector(x: int, y: int, z: int, asnumpy: bool = False) list[float] | ndarray
Get scalar values in a voxel of the SisypheVolume images in the current SisypheVolumeCollection instance. The current SisypheVolumeCollection instance must be homogeneous (see isHomogeneous() method)
Parameters
- xint
x-axis voxel coordinate
- yint
y-axis voxel coordinate
- zint
z-axis voxel coordinate
- asnumpybool
returns numpy.ndarray if True, list[float] otherwise (default False)
Returns
- numpy.ndarray | list[float]
volues at voxel (x, y, z)
- index(value: str | SisypheVolume) int
Index of a SisypheVolume element in the current SisypheVolumeCollection instance container.
Parameters
- valuestr | SisypheVolume
ID, SisypheVolume ID attribute
Returns
- int
index
- insert(key: int | str | SisypheVolume, value: SisypheVolume) None
Insert a SisypheVolume element at the position given by the key in the current SisypheVolumeCollection instance container.
Parameters
- keyint | str | SisypheVolume
index, ID, SisypheVolume ID attribute
- valueSisypheVolume
volume to insert
- isEmpty() bool
Check if SisypheVolumeCollection instance container is empty.
Returns
- bool
True if container is empty
- isHomogeneous() bool
Check whether SisypheVolume instances is the current SisypheVolumeCollection are homogeneous (i.e. same field of view and datatype)
Returns
- bool
True if container is homogeneous
- keys() list[str]
Get the list of keys in the current SisypheVolumeCollection instance container.
Returns
- list[str]
list of keys in the container
- labelSTAPLECombination() SisypheVolume
Performs a pixelwise combination of Labels, where each of them represents a segmentation of the same image. The labelings are weighted relative to each other based on their “performance” as estimated by an expectation-maximization algorithm. In the process, a ground truth segmentation is estimated, and the estimated performances of the individual segmentations are relative to this estimated ground truth.
The algorithm is based on the binary STAPLE algorithm by Warfield et al. : S. Warfield, K. Zou, W. Wells, “Validation of image segmentation and expert quality with an expectation-maximization algorithm” in MICCAI 2002: Fifth International Conference on Medical Image Computing and Computer-Assisted Intervention, Springer-Verlag, Heidelberg, Germany, 2002, pp. 298-306
Returns
- SisypheVolume
combined volume
- labelVotingCombination() SisypheVolume
Performs a pixelwise combination of Labels, where each of them represents a segmentation of the same image. Label voting is a simple method of classifier combination applied to image segmentation. Typically, the accuracy of the combined segmentation exceeds the accuracy of the input segmentations. Voting is therefore commonly used as a way of boosting segmentation performance.
The use of label voting for combination of multiple segmentations is described in T. Rohlfing and C. R. Maurer, Jr., “Multi-classifier framework for atlas-based image segmentation,” Pattern Recognition Letters, 2005.
Returns
- SisypheVolume
combined volume
- load(filenames: str | list[str]) None
Load SisypheVolume elements in the current SisypheVolumeCollection instance container from a list of PySisyphe volume (.xvol) file names.
Parameters
- filenamesstr | list[str]
list of PySisyphe Volume (.xvol) file names
- loadFromMINC(filenames: str | list[str]) None
Load SisypheVolume elements in the current SisypheVolumeCollection instance container from a list of Minc file names.
Parameters
- filenamesstr | list[str]
list of Minc file names
- loadFromNIFTI(filenames: str | list[str]) None
Load SisypheVolume elements in the current SisypheVolumeCollection instance container from a list of Nifti file names.
Parameters
- filenamesstr | list[str]
list of Nifti file names
- loadFromNRRD(filenames: str | list[str]) None
Load SisypheVolume elements in the current SisypheVolumeCollection instance container from a list of Nrrd file names.
Parameters
- filenamesstr | list[str]
list of Nrrd file names
- loadFromSisyphe(filenames: str | list[str]) None
Load SisypheVolume elements in the current SisypheVolumeCollection instance container from a list of old Sisyphe volume (.vol) file names.
Parameters
- filenamesstr | list[str]
list of old Sisyphe Volume (.vol) file names
- loadFromVTK(filenames: str | list[str]) None
Load SisypheVolume elements in the current SisypheVolumeCollection instance container from a list of VTK file names.
Parameters
- filenamesstr | list[str]
list of VTK file names
- pop(key: int | str | SisypheVolume | None = None) SisypheVolume
Remove a SisypheVolume element from the current SisypheVolumeCollection instance container and return it. If key is None, removes and returns the last element.
Parameters
- keyint | str | SisypheVolume
index, ID, SisypheVolume ID attribute
if None, remove the last element
Returns
- SisypheVolume
element removed from the container
- remove(value: int | str | SisypheVolume) None
Remove a SisypheVolume element from the current SisypheVolumeCollection instance container.
Parameters
- valueint | str | SisypheVolume
index, ID, SisypheVolume ID attribute
- resample(trf: SisypheTransform, save: bool = True, dialog: bool = False, prefix: str | None = None, suffix: str | None = None, wait: DialogWait | None = None) SisypheVolumeCollection
Resample all the SisypheVolume images in the current SisypheVolumeCollection instance. The current SisypheVolumeCollection instance must be homogeneous (see isHomogeneous() method)
Parameters
- trfSisyphe.core.sisypheTransform.SisypheTransform
geometric transformation to apply
- savebool
save resampled images if True (default)
- dialogbool
dialog to choice the resampled image file names, if True
addBundle suffix/prefix to the image file names, if False (default)
- prefixstr | None
file name prefix of the resampled images (default None)
- suffixstr | None
file name suffix of the resampled images (default None)
- waitSisyphe.gui.dialogWait.DialogWait | None
progress bar dialog (optional)
Returns
- SisypheVolumeCollection
resampled images
- reverse() None
Reverses the order of the elements in the current SisypheVolumeCollection instance container.
- save() None
Iteratively save SisypheVolume elements in the current SisypheVolumeCollection instance container.
- saveToMulticomponentVolume(filename: str, copyattr: bool | dict[slice(<class 'str'>, <class 'bool'>, None)] = False) None
Save SisypheVolume elements of the current SisypheVolumeCollection instance container to a multi-component SisypheVolume.
Parameters
- filenamestr
file name
- copyattrbool | dict[str: bool]
bool: copy all attributes if True (default False)
- or dict, keys
‘ID’: bool, copy ID attribute if True
‘identity’: bool, copy identity attribute if True
‘acquisition’: bool, copy acquisition attribute if True
‘display’: bool, copy display attribute if True
‘acpc’: bool, copy acpc attribute if True
‘transform’: bool, copy transform attribute if True
‘slope’: bool, copy slope/intercept attributes if True
- setList(vols: list[SisypheVolume])
Copy a list of SisypheVolume to the current SisypheVolumeCollection instance container (Shallow copy of list).
Parameters
- volslist[SisypheVolume]
list of volumes to copy in collection
- sort(reverse: bool = False) None
Sort elements of the current SisypheVolumeCollection instance container. Sorting is based on the name attribute of the SisypheVolume elements, in the ascending order.
Parameters
- reversebool
sorting in reverse order
- toLabelVolume(threshold: float = 0.5) SisypheVolume
Copy the current SisypheVolumeCollection instance to a SisypheVolume label instance. Each image of the current SisypheVolumeCollection instance is thresholded to get a binary image, this image is multiplied by its index in the container to get a label image.
Parameters
- thresholdfloat
threshold applied to each image of the current SisypheVolumeCollection instance to get a binary image (default 0.5)
Returns
- SisypheVolume
label volume
- Sisyphe.core.sisypheVolume.multiComponentSisypheVolumeFromList(vols: list[SisypheVolume] | SisypheVolumeCollection) SisypheVolume
Create a multicomponent SisypheVolume from a list of single-component SisypheVolume or a SisypheVolumeCollection.
Parameters
- volslist[SisypheVolume] | SisypheVolumeCollection
list of single-component volumes
Returns
- SisypheVolume
multi-component volume