Skip to main content

brain-stl 🧠

The easiest and fastest way to turn brain MRI scans into 3D printable models 🖨️ powered by deepmriprep ✨

Use the Colab demo or install it locally via pip install brain_stl 💨

By default, the model is saved as brain.stl, but you can customize the filename along with other options like

  • Threshold: Pick a value between 0 and 3 for different tissue types (see GIF left, 2.5: white matter only) 🧠
  • Hollowness: Adjust how hollow the brain is (enables faster printing) 💨
  • Text: Add personalized text that works as a support structure 🔤
  • Smoothing: Achieve a polished surface via iterative Laplacian smoothing ✨
  • Mesh Reduction: Simplify the mesh to reduce the size of brain.stl ✂️

brain

Usage 💻

To get your first brain.stl just run

from brain_stl import run_brain_stl

run_brain_stl()  # per default output_folder='.' (current folder)

and a publicly available brain MRI scan (from OpenNeuro) will be used 🌐

Scan files can be inputted in NifTi (.nii or .nii.gz) or DICOM (.dcm or folder) format

from brain_stl import run_brain_stl

run_brain_stl('/path/to/scan.nii.gz')  # or '/path/to/dicom_folder'

The main arguments of run_brain_stl are

  • scan_filepath: Path to the input scan (if None, use scan from url). Default: None
  • output_folder: Folder to save the .stl file and other outputs. Must already exist. Default: '.'
  • stl_name: Name of the example .stl file (without extension). Default: 'brain'
Click here, to see all remaining arguments 📑
  • nifti_name: If DICOM produces multiple NifTis, this NifTi filename is used to proceed. Default: None
  • url: URL to download a brain scan if no scan_filepath is provided. Default: OPENNEURO_URL
  • use_cache: If True, reuses intermediate outputs (e.g., tissue data). Default: False
  • threshold: Threshold tissue value (0.5: fluid, 1.5: gray matter, 2.5: white matter). Default: 1.5
  • hollow: How hollow the brain is (0 to 1). Default: 0
  • in_template_space: If True, the 3D model is in standardized (template) orientation. Default: False
  • mesh_reduction: Fraction of mesh reduction (0 to 1) for smaller .stl file size. Default: 0 (no reduction)
  • smooth_iter: Number of iterations for Laplacian smoothing. Default: 0 (none)
  • smooth_lamb: Strength of each Laplacian smoothing step. Default: 0.2
  • text: Custom text used as structural support. Default: None
    • text2: Second line of text. Default: None
    • textsize: Size (height) of the text. Default: 120
    • textback: Coronal (depth) position of the back of the text. Default: 300
    • textfront: Coronal (depth) position of the front of the text. Default: 330
    • textlinelength: Length of line below the text. Default: 10

Command-Line Interface 🖥️

Process your first brain scan from the terminal by just running

brain-stl

Without providing any arguments, it downloads a publicly available scan and creates a brain.stl of it 🧠

Run brain-stl --help (+copy&paste into ChatGPT) to understand the usage of custom settings 💡

Share Your Brains 🧠🌐

Use animate.py to get an animated AVIF of your model and share it on social media with the hashtag #brain-stl 🤗

Metadata

Release files for brain-stl 0.0.2

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

Source distribution (sdist)

Source distribution for brain-stl 0.0.2
File Size Uploaded Provenance Actions
brain_stl-0.0.2.tar.gz 117.3 kB Without provenance Details for brain_stl-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for brain-stl 0.0.2
File Interpreter ABI Platform Actions
brain_stl-0.0.2-py3-none-any.whl Python 3 none any Details for brain_stl-0.0.2-py3-none-any.whl

Total release size: 233.0 kB

Release files / brain_stl-0.0.2.tar.gz

Download URL brain_stl-0.0.2.tar.gz
Size 117.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2aa0cc26a3243cdfdecaf2cca13533d675ee104ca916b154b61b9e72844cdcf4
BLAKE2b-256 checksum
How to use checksums
b11245b9ad4d675a2a9deffef7f0dbfe0411c37c1395f7c23a32d8dd64d2f77e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","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 / brain_stl-0.0.2-py3-none-any.whl

Download URL brain_stl-0.0.2-py3-none-any.whl
Size 115.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8418e1b49857f3c5a9a0c2c6aaf8c3247f70b35daca174599835106055c521bc
BLAKE2b-256 checksum
How to use checksums
054dc2daa65ae3dff02008bb2faedbf65ce1a593101893949db4b503e0f70577
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","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}

Security for brain-stl 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

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