📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP
Socket
Sign inDemoInstall
Socket

brats

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

brats

BraTS algorithms

0.0.6
PyPI
Maintainers
2

BraTS

Python Versions Stable Version Documentation Status tests codecov License

Providing the top-performing algorithms from the Brain Tumor Segmentation (BraTS) challenges, through an easy-to-use Python API powered by Docker.

Features

  • Access to top-performing algorithms from recent BraTS challenges
  • Easy-to-use minimal API
  • Extensive documentation and examples

Installation

With a Python 3.8+ environment, you can install brats directly from PyPI:

pip install brats

[!IMPORTANT]
To run brats, you require a Docker installation.
Many algorithms also require GPU support (NVIDIA Docker).
In case you do not have access to a CUDA-capable GPU, the overview tables in the Available Algorithms and Usage section indicate which algorithms are CPU compatible.

Docker and NVIDIA Container Toolkit Setup

Available Algorithms and Usage

Segmentation Challenges

Adult Glioma Segmentation (Pre-Treatment)

Adult Glioma Segmentation on pre-treatment brain MRI exams.

Usage example (code) and top 3 participants
from brats import AdultGliomaPreTreatmentSegmenter
from brats.constants import AdultGliomaPreTreatmentAlgorithms

segmenter = AdultGliomaPreTreatmentSegmenter(algorithm=AdultGliomaPreTreatmentAlgorithms.BraTS23_1, cuda_devices="0")
# these parameters are optional, by default the winning algorithm of 2023 will be used on cuda:0
segmenter.infer_single(
    t1c="path/to/t1c.nii.gz",
    t1n="path/to/t1n.nii.gz",
    t2f="path/to/t2f.nii.gz",
    t2w="path/to/t2w.nii.gz",
    output_file="segmentation.nii.gz",
)

Note: If you're interested in Adult Glioma Segmentation, the BrainLes GlioMODA package may also be of interest.


Class: brats.AdultGliomaPreTreatmentSegmenter (Docs)
Challenge Paper 2023: Link

YearRankAuthorPaperCPU SupportKey Enum
20231stAndré Ferreira, et al.LinkBraTS23_1
20232ndAndriy Myronenko, et al.N/ABraTS23_2
20233rdFadillah Adamsyah Maani, et al.LinkBraTS23_3

Adult Glioma Segmentation (Post-Treatment)

Adult Glioma Segmentation on post-Treatment brain MRI exams.

Usage example (code) and top 3 participants
from brats import AdultGliomaPostTreatmentSegmenter
from brats.constants import AdultGliomaPostTreatmentAlgorithms

segmenter = AdultGliomaPostTreatmentSegmenter(algorithm=AdultGliomaPostTreatmentAlgorithms.BraTS23_1, cuda_devices="0")
# these parameters are optional, by default the winning algorithm of 2024 will be used on cuda:0
segmenter.infer_single(
    t1c="path/to/t1c.nii.gz",
    t1n="path/to/t1n.nii.gz",
    t2f="path/to/t2f.nii.gz",
    t2w="path/to/t2w.nii.gz",
    output_file="segmentation.nii.gz",
)

Class: brats.AdultGliomaPostTreatmentSegmenter (Docs)
Challenge Paper 2024: Link

YearRankAuthorPaperCPU SupportKey Enum
20241stAndré Ferreira, et al.N/ABraTS24_1
20242ndHeejong Kim, et al.LinkBraTS24_2
20243rdAdrian CelayaN/ABraTS24_3

BraTS-Africa Segmentation

Adult Glioma Segmentation on brain MRI exams in Sub-Sahara-Africa patient population.

Usage example (code) and top 3 participants
from brats import AfricaSegmenter
from brats.constants import AfricaAlgorithms

segmenter = AfricaSegmenter(algorithm=AfricaAlgorithms.BraTS23_1, cuda_devices="0")
# these parameters are optional, by default the winning algorithm will be used on cuda:0
segmenter.infer_single(
    t1c="path/to/t1c.nii.gz",
    t1n="path/to/t1n.nii.gz",
    t2f="path/to/t2f.nii.gz",
    t2w="path/to/t2w.nii.gz",
    output_file="segmentation.nii.gz",
)

Class: brats.AfricaSegmenter (Docs)
Challenge Paper 2023 Link
Challenge Paper 2024: N/A

YearRankAuthorPaperCPU SupportKey Enum
20241stZhifan Jiang et al.N/ABraTS24_1
20242ndLong Bai, et al.N/ABraTS24_2
20243rdSarim Hashmi, et al.LinkBraTS24_3
20231stAndriy Myronenko, et al.TODOBraTS23_1
20232ndAlyssa R Amod, et al.LinkBraTS23_2
20233rdZiyan Huang, et al.LinkBraTS23_3

Meningioma Segmentation

Segmentation of Meningioma on brain MRI exams.

Usage example (code) and top 3 participants

Unlike other segmentation challenges, the expected inputs for the Meningioma Segmentation Algorithms differ between years.

  • 2023: All 4 modalities are used (t1c, t1n, t2f, t2w)
  • 2024: Only t1c is used

Therefore, the usage differs slightly, depending on which algorithm is used. To understand why, please refer to the 2024 challenge manuscript.

from brats import MeningiomaSegmenter
from brats.constants import MeningiomaAlgorithms

### Example for 2023 algorithms
segmenter = MeningiomaSegmenter(algorithm=MeningiomaAlgorithms.BraTS23_1, cuda_devices="0")
# these parameters are optional, by default the winning algorithm will be used on cuda:0
segmenter.infer_single(
    t1c="path/to/t1c.nii.gz",
    t1n="path/to/t1n.nii.gz",
    t2f="path/to/t2f.nii.gz",
    t2w="path/to/t2w.nii.gz",
    output_file="segmentation_23.nii.gz",
)

### Example for 2024 algorithms
segmenter = MeningiomaSegmenter(algorithm=MeningiomaAlgorithms.BraTS24_1, cuda_devices="0")
segmenter.infer_single(
    t1c="path/to/t1c.nii.gz",
    output_file="segmentation_24.nii.gz",
)

Class: brats.MeningiomaSegmenter (Docs)
Challenge Paper 2024 Link
Challenge Paper 2023 Link

YearRankAuthorPaperCPU SupportKey Enum
20241stValeria AbramovaN/ABraTS24_1
20242ndMehdi AstarakiN/ABraTS24_2
20243rdAndre Ferreira, et al.LinkBraTS24_3
20231stAndriy Myronenko, et al.N/ABraTS23_1
20232ndZiyan Huang, et al.LinkBraTS23_2
20233rdDaniel Capell'an-Mart'in et al.LinkBraTS23_3

Brain Metastases Segmentation

Segmentation on brain metastases on MRI exams for pre- and post-treatment cases.

Usage example (code) and top 3 participants
from brats import MetastasesSegmenter
from brats.constants import MetastasesAlgorithms

segmenter = MetastasesSegmenter(algorithm=MetastasesAlgorithms.BraTS23_1, cuda_devices="0")
# these parameters are optional, by default the winning algorithm will be used on cuda:0
segmenter.infer_single(
    t1c="path/to/t1c.nii.gz",
    t1n="path/to/t1n.nii.gz",
    t2f="path/to/t2f.nii.gz",
    t2w="path/to/t2w.nii.gz",
    output_file="segmentation.nii.gz",
)

Note: If you're interested in Brain Metastases Segmentation, the BrainLes AURORA package may also be of interest.


Class: brats.MetastasesSegmenter (Docs)
Challenge Paper 2023 Link

YearRankAuthorPaperCPU SupportKey Enum
20231stAndriy Myronenko, et al.N/ABraTS23_1
20232ndSiwei Yang, et al.LinkBraTS23_2
20233rdZiyan Huang, et al.LinkBraTS23_3

Pediatric Segmentation

Segmentation of pediatric brain tumors on MRI exams.

Usage example (code) and top 3 participants
from brats import PediatricSegmenter
from brats.constants import PediatricAlgorithms

segmenter = PediatricSegmenter(algorithm=PediatricAlgorithms.BraTS23_1, cuda_devices="0")
# these parameters are optional, by default the winning algorithm will be used on cuda:0
segmenter.infer_single(
    t1c="path/to/t1c.nii.gz",
    t1n="path/to/t1n.nii.gz",
    t2f="path/to/t2f.nii.gz",
    t2w="path/to/t2w.nii.gz",
    output_file="segmentation.nii.gz",
)

Note: If you're interested in Pediatric Segmentation, the BrainLes PeTu package may also be of interest.


Class: brats.PediatricSegmenter (Docs)
Challenge Paper 2024 Link
Challenge Paper 2023 Link

YearRankAuthorPaperCPU SupportKey Enum
20241stTim Mulvany, et al.LinkBraTS24_1
20242ndMehdi AstarakiN/ABraTS24_2
20243rdSarim Hashmi, et al.LinkBraTS24_3
20231stZhifan Jiang et al.LinkBraTS23_1
20232ndAndriy Myronenko, et al.N/ABraTS23_2
20233rdYubo ZhouLinkBraTS23_3

Generalizability Across Tumors (BraTS-GoAT) Segmentation

Segmentation algorithm, adapting and generalizing to different brain tumors with segmentation labels of different tumor sub-regions.

Usage example (code) and top 3 participants
from brats import GoATSegmenter
from brats.constants import GoATAlgorithms

segmenter = GoATSegmenter(algorithm=GoATAlgorithms.BraTS24_1, cuda_devices="0")
# these parameters are optional, by default the winning algorithm will be used on cuda:0
segmenter.infer_single(
    t1c="path/to/t1c.nii.gz",
    t1n="path/to/t1n.nii.gz",
    t2f="path/to/t2f.nii.gz",
    t2w="path/to/t2w.nii.gz",
    output_file="segmentation.nii.gz",
)

Class: brats.PediatricSegmenter (Docs)
Challenge Paper 2024: N/A

YearRankAuthorPaperCPU SupportKey Enum
20241stFrank Miao, Shengjie NiuN/ABraTS24_1

Inpainting Challenge

Algorithm to realistically synthesize and fill 3D healthy brain tissue in a region affected by glioma in brain MRI exams.

Usage example (code) and top 3 participants
from brats import Inpainter
from brats.constants import InpaintingAlgorithms

inpainter = Inpainter(algorithm=InpaintingAlgorithms.BraTS24_1, cuda_devices="0")
inpainter.infer_single(
    t1n="path/to/voided_t1n.nii.gz",
    mask="path/to/mask.nii.gz",
    output_file="inpainting.nii.gz",
)

Class: brats.Inpainter (Docs)
Challenge Paper 2023 and 2024 Link

YearRankAuthorPaperCPU SupportKey Enum
20241stKe Chen, Juexin Zhang, Ying WengN/ABraTS24_1
20242ndAndré Ferreira, et al.N/ABraTS24_2
20243rdAlicia Durrer, et al.N/ABraTS24_3
20231stJuexin Zhang, et al.LinkBraTS23_1
20232ndAlicia Durrer, et al.LinkBraTS23_2
20233rdJiayu Huo, et al.LinkBraTS23_3

Missing MRI Challenge

Algorithm to realistically synthesize missing MRI modalities from available sequences to enhance brain tumor segmentation.

Usage example (code) and top 3 participants
from brats import MissingMRI
from brats.constants import MissingMRIAlgorithms

missing_mri = MissingMRI(algorithm=MissingMRIAlgorithms.BraTS24_1, cuda_devices="0")
# Example to synthesize t2f modality (whichever modality is missing will be inferred)
missing_mri.infer_single(
    t1c="path/to/t1c.nii.gz",
    t1n="path/to/t1n.nii.gz",
    # t2f="path/to/t2f.nii.gz",
    t2w="path/to/t2w.nii.gz",
    output_file="inferred_t2f.nii.gz",
)

Class: brats.MissingMRI (Docs)
Challenge Paper 2024: N/A

YearRankAuthorPaperCPU SupportKey Enum
20241stJihoon Cho, Seunghyuck Park, Jinah ParkN/ABraTS24_1
20242ndHaowen PangN/ABraTS24_2
20243rdMinjoo Lim, Bogyeong KangN/ABraTS24_3

[!TIP] For a full notebook example with more details, please check here:
nbviewer

Citation

If you use BraTS in your research, please cite it to support the development!

TODO: citation will be added asap

Contributing

We welcome all kinds of contributions from the community!

Reporting Bugs, Feature Requests, and Questions

Please open a new issue here.

Code contributions

Nice to have you on board! Please have a look at our CONTRIBUTING.md file.

Keywords

brain tumor

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts