Skip to main content

Turn your brain MRI into a printable 3D model in seconds 🧠➡️🖨️

Project description

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 ✂️

gif

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. 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 create_gif.py to get a GIF of your model and share it on social media with the hashtag #brain-stl 🤗

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

brain_stl-0.0.1.tar.gz (117.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

brain_stl-0.0.1-py3-none-any.whl (115.4 kB view details)

Uploaded Python 3

File details

Details for the file brain_stl-0.0.1.tar.gz.

File metadata

  • Download URL: brain_stl-0.0.1.tar.gz
  • Upload date:
  • Size: 117.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.12.7 Linux/5.15.0-56-generic

File hashes

Hashes for brain_stl-0.0.1.tar.gz
Algorithm Hash digest
SHA256 c5d3c34eb32e79332a79f7ee4424cd4b60078eb8e9b9f5bb73c922e1d21957a9
MD5 9357de889af726cb28ff7ebad5998fc9
BLAKE2b-256 a6db6d6b484dc0ec711c0553a58672e4c0cf11ae1a738eb54e76055d179e7293

See more details on using hashes here.

File details

Details for the file brain_stl-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: brain_stl-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 115.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.12.7 Linux/5.15.0-56-generic

File hashes

Hashes for brain_stl-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 10da879a8c0e68ede3189ea5498f8ac03322e8187364130d90cf7cbdbab856ed
MD5 16602731e289bcff17584d1c7095b79e
BLAKE2b-256 9499427658270828e9936141443d031cdf6f1a45593ba3fa43172d9bef16565a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page