Segmentation Algorithms

The following classes provide algorithms from several BraTS segmentation challenges.

class brats.core.segmentation_algorithms.AdultGliomaPreAndPostTreatmentSegmenter(algorithm: AdultGliomaPreAndPostTreatmentAlgorithms = AdultGliomaPreAndPostTreatmentAlgorithms.BraTS25_1, cuda_devices: str = '0', force_cpu: bool = False)

Bases: SegmentationAlgorithmWith4Modalities

Provides algorithms to perform tumor segmentation on adult glioma pre and post treatment MRI data.

Parameters:
  • algorithm (AdultGliomaPreAndPostTreatmentAlgorithms, optional) – Select an algorithm. Defaults to AdultGliomaPreAndPostTreatmentAlgorithms.BraTS25_1.

  • cuda_devices (Optional[str], optional) – Which cuda devices to use. Defaults to “0”.

  • force_cpu (bool, optional) – Execution will default to GPU, this flag allows forced CPU execution if the algorithm is compatible. Defaults to False.

class brats.core.segmentation_algorithms.AdultGliomaPreTreatmentSegmenter(algorithm: AdultGliomaPreTreatmentAlgorithms = AdultGliomaPreTreatmentAlgorithms.BraTS23_1, cuda_devices: str = '0', force_cpu: bool = False)

Bases: SegmentationAlgorithmWith4Modalities

Provides algorithms to perform tumor segmentation on adult glioma pre treatment MRI data.

Parameters:
  • algorithm (AdultGliomaPreTreatmentAlgorithms, optional) – Select an algorithm. Defaults to AdultGliomaPreTreatmentAlgorithms.BraTS23_1.

  • cuda_devices (Optional[str], optional) – Which cuda devices to use. Defaults to “0”.

  • force_cpu (bool, optional) – Execution will default to GPU, this flag allows forced CPU execution if the algorithm is compatible. Defaults to False.

class brats.core.segmentation_algorithms.AfricaSegmenter(algorithm: AfricaAlgorithms = AfricaAlgorithms.BraTS25_1, cuda_devices: str = '0', force_cpu: bool = False)

Bases: SegmentationAlgorithmWith4Modalities

Provides algorithms from the BraTSAfrica challenge

Parameters:
  • algorithm (AfricaAlgorithms, optional) – Select an algorithm. Defaults to AfricaAlgorithms.BraTS23_1.

  • cuda_devices (Optional[str], optional) – Which cuda devices to use. Defaults to “0”.

  • force_cpu (bool, optional) – Execution will default to GPU, this flag allows forced CPU execution if the algorithm is compatible. Defaults to False.

class brats.core.segmentation_algorithms.GoATSegmenter(algorithm: GoATAlgorithms = GoATAlgorithms.BraTS25_1A, cuda_devices: str = '0', force_cpu: bool = False)

Bases: SegmentationAlgorithmWith4Modalities

Provides algorithms from the BraTS Generalizability Across Tumors (BraTS-GoAT)

Parameters:
  • algorithm (GoATAlgorithms, optional) – Select an algorithm. Defaults to GoATAlgorithms.BraTS23_1.

  • cuda_devices (Optional[str], optional) – Which cuda devices to use. Defaults to “0”.

  • force_cpu (bool, optional) – Execution will default to GPU, this flag allows forced CPU execution if the algorithm is compatible. Defaults to False.

class brats.core.segmentation_algorithms.MeningiomaRTSegmenter(algorithm: MeningiomaRTAlgorithms = MeningiomaRTAlgorithms.BraTS25_1, cuda_devices: str = '0', force_cpu: bool = False)

Bases: SegmentationAlgorithm

Provides algorithms to perform tumor segmentation on adult meningioma Radio Therapy MRI data.

Parameters:
  • algorithm (MeningiomaAlgorithms, optional) – Select an algorithm. Defaults to MeningiomaAlgorithms.BraTS23_1.

  • cuda_devices (Optional[str], optional) – Which cuda devices to use. Defaults to “0”.

  • force_cpu (bool, optional) – Execution will default to GPU, this flag allows forced CPU execution if the algorithm is compatible. Defaults to False.

infer_batch(data_folder: Path | str, output_folder: Path | str, log_file: Path | str | None = None, backend: Backends | None = Backends.DOCKER) None

Perform segmentation on a batch of subjects with the provided T1C images and save the results to the output folder.

Requires the following structure:

data_folder

┣ A

┃ ┗ A-t1c.nii.gz

┣ B

┃ ┗ B-t1c.nii.gz

┃ …

Parameters:
  • data_folder (Path | str) – Folder containing the subjects with required structure

  • output_folder (Path | str) – Output folder to save the segmentations

  • log_file (Path | str, optional) – Save logs to this file

  • backend (Backends, optional) – Backend to use for inference. Defaults to Backends.DOCKER.

infer_single(t1c: Path | str, output_file: Path | str, log_file: Path | str | None = None, backend: Backends | None = Backends.DOCKER) None

Perform segmentation on a single subject with the provided T1C image and save the result to the output file.

Parameters:
  • t1c (Path | str) – Path to the T1c image

  • output_file (Path | str) – Output file to save the segmentation.

  • log_file (Optional[Path | str], optional) – Save logs to this file. Defaults to None.

  • backend (Backends, optional) – Backend to use for inference. Defaults to Backends.DOCKER.

class brats.core.segmentation_algorithms.MeningiomaSegmenter(algorithm: MeningiomaAlgorithms = MeningiomaAlgorithms.BraTS25_1, cuda_devices: str = '0', force_cpu: bool = False)

Bases: SegmentationAlgorithmWith4Modalities

Provides algorithms to perform tumor segmentation on adult meningioma MRI data.

Parameters:
  • algorithm (MeningiomaAlgorithms, optional) – Select an algorithm. Defaults to MeningiomaAlgorithms.BraTS23_1.

  • cuda_devices (Optional[str], optional) – Which cuda devices to use. Defaults to “0”.

  • force_cpu (bool, optional) – Execution will default to GPU, this flag allows forced CPU execution if the algorithm is compatible. Defaults to False.

class brats.core.segmentation_algorithms.MetastasesSegmenter(algorithm: MetastasesAlgorithms = MetastasesAlgorithms.BraTS25_1, cuda_devices: str = '0', force_cpu: bool = False)

Bases: SegmentationAlgorithmWith4Modalities

Provides algorithms from the Brain Metastases Segmentation challenge

Parameters:
  • algorithm (MetastasesAlgorithms, optional) – Select an algorithm. Defaults to MetastasesAlgorithms.BraTS23_1.

  • cuda_devices (Optional[str], optional) – Which cuda devices to use. Defaults to “0”.

  • force_cpu (bool, optional) – Execution will default to GPU, this flag allows forced CPU execution if the algorithm is compatible. Defaults to False.

class brats.core.segmentation_algorithms.PediatricSegmenter(algorithm: PediatricAlgorithms = PediatricAlgorithms.BraTS25_1, cuda_devices: str = '0', force_cpu: bool = False)

Bases: SegmentationAlgorithmWith4Modalities

Provides algorithms to perform tumor segmentation on pediatric MRI data

Parameters:
  • algorithm (PediatricAlgorithms, optional) – Select an algorithm. Defaults to PediatricAlgorithms.BraTS23_1.

  • cuda_devices (Optional[str], optional) – Which cuda devices to use. Defaults to “0”.

  • force_cpu (bool, optional) – Execution will default to GPU, this flag allows forced CPU execution if the algorithm is compatible. Defaults to False.

class brats.core.segmentation_algorithms.SegmentationAlgorithm(algorithm: Algorithms, algorithms_file_path: Path, cuda_devices: str = '0', force_cpu: bool = False)

Bases: BraTSAlgorithm

This class provides algorithms to perform tumor segmentation on MRI data. It is the base class for all segmentation algorithms and provides the common interface for single and batch inference.

abstract infer_batch(data_folder: Path | str, output_folder: Path | str, log_file: Path | str | None = None) None
abstract infer_single(*args, **kwargs) None
class brats.core.segmentation_algorithms.SegmentationAlgorithmWith4Modalities(algorithm: Algorithms, algorithms_file_path: Path, cuda_devices: str = '0', force_cpu: bool = False)

Bases: SegmentationAlgorithm

Segmentation algorithm that works with 4 modalities (T1c, T1n, T2f, T2w).

infer_batch(data_folder: Path | str, output_folder: Path | str, log_file: Path | str | None = None, backend: Backends | None = Backends.DOCKER) None

Perform segmentation on a batch of subjects with the provided images and save the results to the output folder.

Requires the following structure:

data_folder

┣ A

┃ ┣ A-t1c.nii.gz

┃ ┣ A-t1n.nii.gz

┃ ┣ A-t2f.nii.gz

┃ ┗ A-t2w.nii.gz

┣ B

┃ ┣ B-t1c.nii.gz

┃ ┣ …

Parameters:
  • data_folder (Path | str) – Folder containing the subjects with required structure

  • output_folder (Path | str) – Output folder to save the segmentations

  • log_file (Path | str, optional) – Save logs to this file

  • backend (Backends, optional) – Backend to use for inference. Defaults to Backends.DOCKER.

infer_single(t1c: Path | str, t1n: Path | str, t2f: Path | str, t2w: Path | str, output_file: Path | str, log_file: Path | str | None = None, backend: Backends | None = Backends.DOCKER) None

Perform segmentation on a single subject with the provided images and save the result to the output file.

Parameters:
  • t1c (Path | str) – Path to the T1c image

  • t1n (Path | str) – Path to the T1n image

  • t2f (Path | str) – Path to the T2f image

  • t2w (Path | str) – Path to the T2w image

  • output_file (Path | str) – Path to save the segmentation

  • log_file (Path | str, optional) – Save logs to this file

  • backend (Backends, optional) – Backend to use for inference. Defaults to Backends.DOCKER.