Portable and lightweight brain segmentation using tinygrad
Project description
BrainChop
BrainChop is a lightweight tool for brain segmentation that runs on pretty much everything.
(NEW) No install single command use
Using uv, brainchop can be ran without needing an enviroment
uvx brainchop --help
## Installation
```bash
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
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
File details
Details for the file brainchop-0.2.4.tar.gz.
File metadata
- Download URL: brainchop-0.2.4.tar.gz
- Upload date:
- Size: 39.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0628d07d92116e9f2ace2752322fe3090a2b218feae3f96cb5e8a4eddb8939b7
|
|
| MD5 |
887a60dec462df0d6b8c5c481a4d2620
|
|
| BLAKE2b-256 |
37482ed84d187dfb3e901579c9827fa173a4cc386b4113dcaf9ed2932c7db568
|
File details
Details for the file brainchop-0.2.4-py3-none-any.whl.
File metadata
- Download URL: brainchop-0.2.4-py3-none-any.whl
- Upload date:
- Size: 36.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7b9ad4a68e82e80adcdf6ae14039e073b5bac66de167862bd4d02145bc1b48f
|
|
| MD5 |
3be92c15b4407fb14b3452bd9e1a5ee1
|
|
| BLAKE2b-256 |
b35603208128b04ba63b6d97d30269814675d3b29127bdb529dd2bf6e51e4b2b
|