Skip to main content

Preprocessing Procedures

All preprocessing functions should conform to the very basic signature:

.. code-block:: python

def func(study: Study, **kwargs) -> Study: ...

Segmentation

The preprocessing.segmentation module contains two primary methods to calculate segmentation masks:

  1. segment_nnunet_pretrained.py allows for the usage of a pretrained nnUnet model to segment the prostate in T2 images.
  2. segment_slice.py is used on MRI acquisitions of MRI phantoms and only detects a circular mask in a single slice of the volumes.

Basic usage:

.. code-block:: python

from mismo.preprocessing.segmentation import segment_nnunet_pretrained, SegmentationModel, download_pretrained_nnunet

download the pretrained model - only needs to be performed once!

model files will be stored in environment-defined folder

download_pretrained_nnunet(SegmentationModel.T2_ONLY)

calculate mask for study

mask_volume = segment_nnunet_pretrained(study, return_only_mask=True)

alternatively, the function can return the entire study, with the mask

added to the study object

study = segment_nnunet_pretrained(study, return_only_mask=False)

.. note:: At the moment, only segmentation using the pretrained Task 24 prostate segmentation model is supported. The SegmentationModel enum however holds the structure for added support for different models in the future.

.. automodule:: mismo.preprocessing.segmentation :members: segment_nnunet_pretrained, segment_slice, download_pretrained_nnunet

Registration

Registration is implemented with SimpleITK-SimpleElastix. The function registers the DWI volumes onto the T2 volume. If no T2 volume is present in the study, an exception will be thrown.

.. code-block:: python

from mismo.preprocessing.registration import register_study

study = register_study(study, mode="affine")

Alternatively, mode="pyramid" can be used.

The returned study will contain the registered DWI volumes. However, neither the DWI volumes nor the T2 volumes will be resampled to another shape - everything will be left in its original shape.

The returned study object will have new identifiers and new study titles.

.. note:: TODO: add more configurability to registration

.. automodule:: mismo.preprocessing.registration :members: register_study

Normalization

Two normalization methods are implemented:

  • B0-Normalization: divides every DWI volume with a b-value greater than 0 by its respective b=0 acquisition.
  • Min-Max-Normalization: normalizes all study DWI volumes to the range [0, 1].

.. code-block:: python

from mismo.preprocessing.normalization import normalize_b0, normalize_minmax

study = normalize_b0(study) study = normalize_minmax(study)

.. automodule:: mismo.preprocessing.normalization :members: normalize_b0, normalize_minmax

Denoising

Marcenko-Pastur PCA-based denoising is implemented in the preprocessing.denoising module. We make use of the localpca function implemented in Dipy.

.. code-block:: python

from mismo.preprocessing.denoising import mppca_denoising study = mppca_denoising(study)

.. automodule:: mismo.preprocessing.denoising :members: mppca_denoising

Artifact Correction

Gibbs ringing artifact removal is implemented in the preprocessing.artifact_removal module. We simply call the corresponding module from Dipy.

.. automodule:: mismo.preprocessing.artifact_removal :members: gibbs_art_removal