Portable and lightweight brain segmentation using tinygrad
Project description
BrainChop
BrainChop is a lightweight tool for brain segmentation that runs on pretty much everything.
Installation
pip install brainchop
For development (includes docs, testing):
pip install -e ".[all]"
CLI Usage
# Segment a brain MRI
brainchop input.nii.gz -o output.nii.gz
# List available models
brainchop --list
# Use a specific model
brainchop input.nii.gz -m subcortical -o output.nii.gz
# Skull stripping
brainchop input.nii.gz --skull-strip -o brain.nii.gz
# With BEAM optimization
brainchop input.nii.gz -m tissue_fast --beam 2 -o output.nii.gz
Python API
import brainchop as bc
# List available models
print(bc.list_models())
# Load, segment, save
vol = bc.load("input.nii.gz")
result = bc.segment(vol, "subcortical")
bc.save(result, "output.nii.gz")
# With BEAM optimization
bc.optimize("tissue_fast", beam=2)
result = bc.segment(vol, "tissue_fast")
# Export to WebGPU
bc.export("tissue_fast", "/tmp/export")
Documentation
Serve docs locally:
mkdocs serve -w brainchop/
Docker
git clone git@github.com:neuroneural/brainchop-cli.git
cd brainchop-cli
docker build -t brainchop .
Then to run:
docker run --rm -it --device=nvidia.com/gpu=all -v [[output directory]]:/app brainchop [[input nifti file]] -o [[output nifti file]]
Requirements
- Python 3.10+
- tinygrad
- numpy
- requests
to use the WEBGPU export backend, also install dawn
brew tap wpmed92/dawn
brew install dawn
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
brainchop-0.2.3.tar.gz
(38.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
brainchop-0.2.3-py3-none-any.whl
(35.1 kB
view details)
File details
Details for the file brainchop-0.2.3.tar.gz.
File metadata
- Download URL: brainchop-0.2.3.tar.gz
- Upload date:
- Size: 38.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60faf4a4ef9795c2efd9e14fd724d0771677065c0d7d5769b690c1538ac41dd9
|
|
| MD5 |
8415a4d254b3598543403cd4f5e98365
|
|
| BLAKE2b-256 |
023b1088e059e111a52a91caa1544a4fd38f583aaeafddccb8e0342c205f2099
|
File details
Details for the file brainchop-0.2.3-py3-none-any.whl.
File metadata
- Download URL: brainchop-0.2.3-py3-none-any.whl
- Upload date:
- Size: 35.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e5199f1621ec8df19aef28b7a6d33970d5631cabcf31616d97a9bd4a4a4acf3
|
|
| MD5 |
367c6dceae5479d3108f0542a000013a
|
|
| BLAKE2b-256 |
7dbdc79f977db61f512d1369f643df4a0b7c38e70b08fa8da103896223e7946a
|