Skip to content

Intensity transforms

intensity_transforms #

ClipIntensity dataclass #

ClipIntensity(lower: float, upper: float)

Bases: imgtools.transforms.intensity_transforms.IntensityTransform

ClipIntensity operation class.

A callable class that clips image grey level intensities to specified range.

Parameters:

Name Type Description Default

lower #

float

The lower bound on grey level intensity. Voxels with lower intensity will be set to this value.

required

upper #

float

The upper bound on grey level intensity. Voxels with higer intensity will be set to this value.

required

Methods:

Name Description
supports_reference

Return whether this transform supports reference images.

name property #

name: str

Return the name of the transform class for logging and debugging.

Returns:

Type Description
str

The name of the transform class.

supports_reference #

supports_reference() -> bool

Return whether this transform supports reference images.

Returns:

Type Description
bool

Always False for intensity transforms.

Source code in src/imgtools/transforms/intensity_transforms.py
def supports_reference(self) -> bool:
    """Return whether this transform supports reference images.

    Returns
    -------
    bool
        Always False for intensity transforms.
    """
    return False

IntensityTransform #

Bases: imgtools.transforms.base_transform.BaseTransform

Base class for intensity transforms.

Intensity transforms modify the pixel/voxel intensity values of an image without changing its spatial properties.

All intensity transforms operate on individual pixel/voxel values independently, leaving the image dimensions, spacing, and orientation unchanged.

Examples:

>>> # This is an abstract base class and cannot be instantiated directly.
>>> # Use one of its subclasses like ClipIntensity or WindowIntensity.

Methods:

Name Description
supports_reference

Return whether this transform supports reference images.

name property #

name: str

Return the name of the transform class for logging and debugging.

Returns:

Type Description
str

The name of the transform class.

supports_reference #

supports_reference() -> bool

Return whether this transform supports reference images.

Returns:

Type Description
bool

Always False for intensity transforms.

Source code in src/imgtools/transforms/intensity_transforms.py
def supports_reference(self) -> bool:
    """Return whether this transform supports reference images.

    Returns
    -------
    bool
        Always False for intensity transforms.
    """
    return False

N4BiasFieldCorrection dataclass #

N4BiasFieldCorrection()

Bases: imgtools.transforms.intensity_transforms.IntensityTransform

N4BiasFieldCorrection operation class.

A callable class that applies N4 bias field correction to reduce smooth intensity inhomogeneities (bias fields) commonly found in MR imaging. This transform corrects voxel intensities while preserving image geometry (spacing, orientation, and dimensions).

The correction uses SimpleITK's N4BiasFieldCorrectionImageFilter, which implements the N4 algorithm (Tustison et al., 2010).

Notes
  • This transform is computationally intensive and may take several seconds to minutes depending on image size.
  • Best suited for MR images; application to other modalities is typically not meaningful.
  • No rotation, translation, or scaling is applied.

Methods:

Name Description
supports_reference

Return whether this transform supports reference images.

name property #

name: str

Return the name of the transform class for logging and debugging.

Returns:

Type Description
str

The name of the transform class.

supports_reference #

supports_reference() -> bool

Return whether this transform supports reference images.

Returns:

Type Description
bool

Always False for intensity transforms.

Source code in src/imgtools/transforms/intensity_transforms.py
def supports_reference(self) -> bool:
    """Return whether this transform supports reference images.

    Returns
    -------
    bool
        Always False for intensity transforms.
    """
    return False

WindowIntensity dataclass #

WindowIntensity(window: float, level: float)

Bases: imgtools.transforms.intensity_transforms.IntensityTransform

WindowIntensity operation class.

A callable class that restricts image grey level intensities to a given window and level. This is commonly used in medical imaging to enhance visibility of specific tissue types (e.g., bone window, lung window in CT).

The window/level parameters define a range centered at the 'level' value with a width of 'window'. All intensities outside this range are clipped.

Parameters:

Name Type Description Default

window #

float

The width of the intensity window. Must be positive.

required

level #

float

The mid-point of the intensity window.

required

Methods:

Name Description
supports_reference

Return whether this transform supports reference images.

name property #

name: str

Return the name of the transform class for logging and debugging.

Returns:

Type Description
str

The name of the transform class.

supports_reference #

supports_reference() -> bool

Return whether this transform supports reference images.

Returns:

Type Description
bool

Always False for intensity transforms.

Source code in src/imgtools/transforms/intensity_transforms.py
def supports_reference(self) -> bool:
    """Return whether this transform supports reference images.

    Returns
    -------
    bool
        Always False for intensity transforms.
    """
    return False