Filtering and manipulation (mialab.filtering package)#

This package contains various image filters and image manipulation functions.

Pre-processing (mialab.filtering.preprocessing module)#

The pre-processing module contains classes for image pre-processing.

Image pre-processing aims to improve the image quality (image intensities) for subsequent pipeline steps.

class mialab.filtering.preprocessing.ImageNormalization(*args: Any, **kwargs: Any)[source]#

Represents a normalization filter.

__init__()[source]#

Initializes a new instance of the ImageNormalization class.

execute(image: SimpleITK.Image, params: pymia.filtering.filter.FilterParams | None = None) SimpleITK.Image[source]#

Executes a normalization on an image.

Parameters:
  • image (sitk.Image) – The image.

  • params (FilterParams) – The parameters (unused).

Returns:

The normalized image.

Return type:

sitk.Image

class mialab.filtering.preprocessing.ImageRegistration(*args: Any, **kwargs: Any)[source]#

Represents a registration filter.

__init__()[source]#

Initializes a new instance of the ImageRegistration class.

execute(image: SimpleITK.Image, params: ImageRegistrationParameters | None = None) SimpleITK.Image[source]#

Registers an image.

Parameters:
Returns:

The registered image.

Return type:

sitk.Image

class mialab.filtering.preprocessing.ImageRegistrationParameters(*args: Any, **kwargs: Any)[source]#

Image registration parameters.

__init__(atlas: SimpleITK.Image, transformation: SimpleITK.Transform, is_ground_truth: bool = False)[source]#

Initializes a new instance of the ImageRegistrationParameters

Parameters:
  • atlas (sitk.Image) – The atlas image.

  • transformation (sitk.Transform) – The transformation for registration.

  • is_ground_truth (bool) – Indicates weather the registration is performed on the ground truth or not.

class mialab.filtering.preprocessing.SkullStripping(*args: Any, **kwargs: Any)[source]#

Represents a skull-stripping filter.

__init__()[source]#

Initializes a new instance of the SkullStripping class.

execute(image: SimpleITK.Image, params: SkullStrippingParameters | None = None) SimpleITK.Image[source]#

Executes a skull stripping on an image.

Parameters:
Returns:

The normalized image.

Return type:

sitk.Image

class mialab.filtering.preprocessing.SkullStrippingParameters(*args: Any, **kwargs: Any)[source]#

Skull-stripping parameters.

__init__(img_mask: SimpleITK.Image)[source]#

Initializes a new instance of the SkullStrippingParameters

Parameters:

img_mask (sitk.Image) – The brain mask image.

Feature extraction (mialab.filtering.feature_extraction module)#

The feature extraction module contains classes for feature extraction.

class mialab.filtering.feature_extraction.AtlasCoordinates(*args: Any, **kwargs: Any)[source]#

Represents an atlas coordinates feature extractor.

__init__()[source]#

Initializes a new instance of the AtlasCoordinates class.

execute(image: SimpleITK.Image, params: pymia.filtering.filter.FilterParams | None = None) SimpleITK.Image[source]#

Executes a atlas coordinates feature extractor on an image.

Parameters:
  • image (sitk.Image) – The image.

  • params (fltr.FilterParams) – The parameters (unused).

Returns:

The atlas coordinates image (a vector image with 3 components, which represent the physical x, y, z coordinates in mm).

Return type:

sitk.Image

Raises:

ValueError – If image is not 3-D.

class mialab.filtering.feature_extraction.NeighborhoodFeatureExtractor(*args: Any, **kwargs: Any)[source]#

Represents a feature extractor filter, which works on a neighborhood.

__init__(kernel=(3, 3, 3), function_=<function first_order_texture_features_function>)[source]#

Initializes a new instance of the NeighborhoodFeatureExtractor class.

execute(image: SimpleITK.Image, params: pymia.filtering.filter.FilterParams | None = None) SimpleITK.Image[source]#

Executes a neighborhood feature extractor on an image.

Parameters:
  • image (sitk.Image) – The image.

  • params (fltr.FilterParams) – The parameters (unused).

Returns:

The normalized image.

Return type:

sitk.Image

Raises:

ValueError – If image is not 3-D.

class mialab.filtering.feature_extraction.RandomizedTrainingMaskGenerator[source]#

Represents a training mask generator.

A training mask is an image with intensity values 0 and 1, where 1 represents masked. Such a mask can be used to sample voxels for training.

static get_mask(ground_truth: SimpleITK.Image, ground_truth_labels: list, label_percentages: list, background_mask: SimpleITK.Image | None = None) SimpleITK.Image[source]#

Gets a training mask.

Parameters:
  • ground_truth (sitk.Image) – The ground truth image.

  • ground_truth_labels (list of int) – The ground truth labels, where 0=background, 1=label1, 2=label2, …, e.g. [0, 1]

  • label_percentages (list of float) – The percentage of voxels of a corresponding label to extract as mask, e.g. [0.2, 0.2].

  • background_mask (sitk.Image) – A mask, where intensity 0 indicates voxels to exclude independent of the

  • label.

Returns:

The training mask.

Return type:

sitk.Image

mialab.filtering.feature_extraction.first_order_texture_features_function(values)[source]#

Calculates first-order texture features.

Parameters:

values (np.array) – The values to calculate the first-order texture features from.

Returns:

A vector containing the first-order texture features:

  • mean

  • variance

  • sigma

  • skewness

  • kurtosis

  • entropy

  • energy

  • snr

  • min

  • max

  • range

  • percentile10th

  • percentile25th

  • percentile50th

  • percentile75th

  • percentile90th

Return type:

np.array

Post-processing (mialab.filtering.postprocessing module)#

The post-processing module contains classes for image filtering mostly applied after a classification.

Image post-processing aims to alter images such that they depict a desired representation.

class mialab.filtering.postprocessing.ImagePostProcessing(*args: Any, **kwargs: Any)[source]#

Represents a post-processing filter.

__init__()[source]#

Initializes a new instance of the ImagePostProcessing class.

execute(image: SimpleITK.Image, params: pymia.filtering.filter.FilterParams | None = None) SimpleITK.Image[source]#

Registers an image.

Parameters:
  • image (sitk.Image) – The image.

  • params (FilterParams) – The parameters.

Returns:

The post-processed image.

Return type:

sitk.Image