Skip to main content

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

License

MIT License

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

brainchop-0.2.1.tar.gz (35.6 kB view details)

Uploaded Source

Built Distribution

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

brainchop-0.2.1-py3-none-any.whl (32.7 kB view details)

Uploaded Python 3

File details

Details for the file brainchop-0.2.1.tar.gz.

File metadata

  • Download URL: brainchop-0.2.1.tar.gz
  • Upload date:
  • Size: 35.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for brainchop-0.2.1.tar.gz
Algorithm Hash digest
SHA256 a01c548128496be95ad025559fedf23a89a60ed96862f984af6e2699a48ca900
MD5 11e7d999e5a79e3dca3ee0a55b85d5d4
BLAKE2b-256 bb9ecb6a0f8c77460abe8bfdeb7604f7663b4c978e75f463f0989e98ecfa8e0e

See more details on using hashes here.

File details

Details for the file brainchop-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: brainchop-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 32.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for brainchop-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5da0c1986edead7c7a07c383e941cccdc3aa9cf22665ddf274dfcd855b77a4ea
MD5 e751fb790c89625be3aacc3e1e459490
BLAKE2b-256 38017bfb285040ce6c58b198aefdb2e7ac84be544aa0ab21b6596085272fef3e

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