dartbrains-tools
Helper library and interactive anywidgets for the DartBrains fMRI course. Extracted from the book repo so the widgets and helpers can be installed standalone — including in molab and pyodide/WASM marimo notebooks.
Install
pip install dartbrains-tools
# Optional: include marimo for notebook_utils.youtube()
pip install "dartbrains-tools[notebook]"
Modules
dartbrains_tools.data.localizer— load the Pinel Localizer dataset from the Hugging Face Hub. The same API is re-exported atdartbrains_tools.datafor back-compat.dartbrains_tools.data.sherlock— load the Sherlock naturalistic-fMRI dataset (Chen et al. 2017).dartbrains_tools.data.paranoia— load the Paranoia naturalistic-fMRI dataset (Finn et al. 2018).dartbrains_tools.mr_simulations— Bloch equation solvers, signal generators, HRF, and Plotly visualization helpers.dartbrains_tools.mr_widgets— 10 anywidgets for interactive MR physics teaching (PrecessionWidget,SpinEnsembleWidget,KSpaceWidget,ConvolutionWidget,EncodingWidget,CompassWidget,NetMagnetizationWidget,TransformCubeWidget,CostFunctionWidget,SmoothingWidget).dartbrains_tools.storage— course storage behind Dartmouth sign-in: the class copy of the data, each student's private space, assignment data released on a schedule, and a durable cache — on Cloudflare R2, with hour-long credentials the grader mints per prefix. Falls back to a local directory (DARTBRAINS_STORAGE_ROOT) for builds and tests.dartbrains_tools.notebook_utils— marimo helpers:youtube(),image()(the book's figures wherever the notebook runs, including molab),assignment_card()(links to a chapter's assignment on the grader).
Quick start
from dartbrains_tools.mr_widgets import PrecessionWidget
w = PrecessionWidget(b0=3.0, flip_angle=90.0)
w # Interactive 3D Three.js animation in any anywidget host.
# Localizer (default; back-compat — also works as dartbrains_tools.data.localizer)
from dartbrains_tools.data import get_subjects, get_file, load_events
subjects = get_subjects()
bold = get_file("S01", scope="derivatives", suffix="bold")
events = load_events("S01")
# Sherlock
from dartbrains_tools.data import sherlock
bold = sherlock.get_file("sub-01", task="sherlockPart1", suffix="bold")
onsets = sherlock.load_onsets("watch")
# Paranoia
from dartbrains_tools.data import paranoia
bold = paranoia.get_file("sub-tb2994", run=1, suffix="bold")
participants = paranoia.load_participants()
# Course storage (needs a Dartmouth sign-in; public datasets above need none)
from dartbrains_tools import storage
signin = storage.signin_button(); signin # in a marimo cell: never blocks
course = storage.course() if storage.connect(signin) else None # else: public data
path = course.local_path("localizer/sub-S01/func/sub-S01_task-localizer_events.tsv")
storage.private().put("week3/betas.pkl", betas) # pickle/npy/csv/json/nii.gz by extension
storage.private().get("week3/betas.pkl")
storage.assignment("midterm") # NotReleased before release_at
@storage.cache # local -> shared cache -> private cache -> compute
def fit(subject): ...
# Outside marimo (scripts, the instructor uploading data):
storage.signin() # device sign-in, cached afterwards
storage.course().sync("~/data/localizer", "localizer") # instructors: course() is read-write
The notebook's # /// script block tells the library which grader, course and term it belongs to
([tool.grader], written by marimo-book's sync-deps); DARTBRAINS_GRADER_SERVER,
DARTBRAINS_COURSE, DARTBRAINS_TERM and DARTBRAINS_OFFERING override it.
Development
git clone https://github.com/ljchang/dartbrains-tools
cd dartbrains-tools
uv sync
uv run pytest
uv build
License
MIT. The parent course materials at dartbrains remain CC-BY-SA-4.0; this companion library is permissive so it can be reused in any downstream project.
Metadata
Release files for dartbrains-tools 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| dartbrains_tools-0.3.0.tar.gz | 69.4 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dartbrains_tools-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 137.5 kB
Release files / dartbrains_tools-0.3.0.tar.gz
| Download URL | dartbrains_tools-0.3.0.tar.gz |
|---|---|
| Size | 69.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
13745ef76b9408d0355a11173cc8677737037567e846632597a0c4b23a29dc90
|
|
BLAKE2b-256 checksum How to use checksums |
e972817e12e20459ea151be71fb52da1779c1c84c62a236327bb2333bb69f24f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.
Transparency logRelease files / dartbrains_tools-0.3.0-py3-none-any.whl
| Download URL | dartbrains_tools-0.3.0-py3-none-any.whl |
|---|---|
| Size | 68.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
473ec50862c381a23b9b180329334d2922f3c64eb84d3737dcc06ce499cde2d5
|
|
BLAKE2b-256 checksum How to use checksums |
67f379deb3d242274f036ffe126f347801a1c824c4672498300cdeaf44c705e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.
Transparency logSecurity for dartbrains-tools 0.3.0
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for dartbrains_tools-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.
Transparency logA 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.