Skip to main content

Cere-MEG-Bellum (CMB)

PyPI License: MIT CI Documentation Status

CMB is a Python package for fitting a high-resolution cerebellar atlas to standard MRI (ARCUS) and MEG/EEG source space computation including the cerebellum.

Currently under active development: API changes are possible. Please report any issues or feature requests on the GitHub issue tracker.

For more information about the method, please see:

Samuelsson, J. G., J. D.Schmahmann, M. I.Sereno, B.Rosen, and M. S.Hämäläinen. 2026. “A Digital Anatomical Atlas of the Human Cerebellum at Subfolial Resolution.” Human Brain Mapping 47, no. 4: e70497. https://doi.org/10.1002/hbm.70497.

Features

  • Automatic segmentation of cerebellar lobules using a trained nnU-Net model
  • Diffeomorphic registration (ANTs SyNCC) of a high-resolution cerebellar template to subject anatomy
  • Construction of cerebellar cortical source spaces compatible with MNE-Python
  • Visualization of cerebellar data in normal, inflated, and flatmap views

Documentation

The full documentation, including the API reference, is available at ceremegbellum.readthedocs.io.

Requirements

  • Python >= 3.11
  • nnU-Net (v1) (installed automatically as a dependency)
  • FreeSurfer (not required to run the package, but recon-all outputs are required)

Installation

  1. Create a new virtual environment for Cere-MEG-Bellum and activate it. You can do this, for example, with uv (recommended!), venv or conda. uv and conda are good options because they can also manage the Python version without depending on system Python.

    # uv
    uv venv cmb-env --python 3.12 --seed
    source cmb-env/bin/activate
    # conda
    conda create -n cmb-env python=3.12 pip
    conda activate cmb-env
    # venv
    python -m venv cmb-env
    source cmb-env/bin/activate
    
  2. Install the correct PyTorch version for your hardware. Look up the exact installation command on the PyTorch website. Here is an example command for NVIDIA GPUs with CUDA 12.6 support.

    # NOTE: PyTorch website may use pip3.
    # Inside virtual environment pip and pip3 are the same.
    pip install torch torchvision --index-url https://download.pytorch.org/whl/cu126
    
    # Or use uv for faster installation!
    uv pip install torch torchvision --index-url https://download.pytorch.org/whl/cu126
    
  3. Install Cere-MEG-Bellum and rest of the dependencies from PyPI.

    pip install "cmb[viz]"
    
    # Or use uv for faster installation!
    uv pip install "cmb[viz]"
    

    This installs the core package plus PyVista for 3D visualization. If you don't need 3D views (normal/inflated) and only want flatmaps, you can use pip install cmb instead.

    To use the non-blocking Qt window (backend="pyvistaqt" in plot_normal / plot_inflated), install pip install "cmb[viz-qt]", which adds pyvistaqt and the PySide6 Qt binding. If you prefer another Qt binding (e.g. PyQt6), install pip install "cmb[viz]" pyvistaqt pyqt6 instead.

Quick start

See complete end-to-end example that uses the MNE sample dataset in the documentation or on GitHub.

The example works with both current MNE-Python releases and the upcoming release that adds mne.setup_subcortical_source_space, and picks the source space layout from the installed version:

  • Current MNE-Python: cmb.setup_full_source_space gives [cortex, cerebellum].
  • Upcoming MNE-Python: mne.setup_source_space(...) + mne.setup_subcortical_source_space(...) gives a mixed source space [lh, rh, cerebellum].

Both give the same forward solution. In either layout the cerebellum is the last source space, fwd["src"][-1]. To plot the cortex of a mixed source space with the CMB plotting functions, join the hemispheres with cmb.join_cortical_source_spaces(fwd["src"][:2]).

For developers

Installation for development

Follow steps 1 and 2 from regular installation, then install the package from source with all optional dependencies and developer tools:

git clone https://github.com/ceremegbellum/ceremegbellum.git
cd ceremegbellum

pip install -e ".[dev,docs,viz-qt]"
# or
uv pip install -e ".[dev,docs,viz-qt]"

-e flag stands for editable mode (changes to source code will be reflected immediately). The dev extra has the test, lint and type-checking tools, and docs has the tools for building the documentation.

Running tests

# Runs all the tests, including those that need data.
pytest tests/

# Runs only the tests that don't need data (and are faster).
pytest tests/ -m "not requires_data"

Building the documentation

The documentation is built with Sphinx and hosted on Read the Docs. The front page is generated from this README, and the API reference from the NumPy-style docstrings.

cd docs
make html  # on Windows use 'make.bat html'

Then view the built html documentation by opening file docs/build/html/index.html in a web browser.

Type checking, linting, and formatting

# Type checking
pyright

# Linting
ruff check .
# Fixing linting errors
ruff check --fix .

# Checking formatting
ruff format --check .
# Fixing formatting
ruff format .

License

CMB is licensed under the MIT License.

Copyright (c) 2021-2026, authors of CMB. All rights reserved.

Metadata

Release files for cmb 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cmb 0.1.3
File Size Uploaded
cmb-0.1.3.tar.gz 41.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cmb 0.1.3
File Interpreter ABI Platform
cmb-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 80.8 kB

Release files / cmb-0.1.3.tar.gz

Download URL cmb-0.1.3.tar.gz
Size 41.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9c1fec5f9e9fe4ace25d70bfd9a39e2eeb9ca992967a358e69af1d3b3fbe81d8
BLAKE2b-256 checksum
How to use checksums
b03f7ba2d9f95458e1240ffe0acfc00912a2f421b978f276cc328621776758f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / cmb-0.1.3-py3-none-any.whl

Download URL cmb-0.1.3-py3-none-any.whl
Size 39.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dd39188e9a8cb6a5666562a2e027893f3b8f163e61ffc18fbd37a3c36aced79a
BLAKE2b-256 checksum
How to use checksums
4f166fdbd45ad40621c892a026745aa29af5f7759b4ad1b3544af62d99d14325
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page