GitHub tools talk/tutorial: a minimal dMRI (diffusion MRI) QC pipeline used to demonstrate a full GitHub Actions workflow — container builds, GHCR, release-driven data fetch, caching, GitHub Pages deployment, and optional email notifications.
process_dmri.py loads a diffusion MRI scan, computes a mock SNR (signal-to-noise ratio) and
a mock FA (fractional anisotropy) map, and writes:
output/qc_slice.png— mid-axial FA slice imageoutput/stats.json— SNR, resolution, volume count, PASS/FAIL status (pass threshold: SNR > 10)
Input data, in order of preference:
sample_dmri.nii.gzdownloaded from a GitHub Release asset- Stanford HARDI dataset, auto-fetched via
dipy(cached across runs) - Synthetic data, generated on the fly (last-resort fallback, e.g. no network)
Two chained GitHub Actions workflows:
build-container.yml— builds theDockerfileand pushes it to GHCR on push tomain(whenDockerfilechanges) or manual dispatch.run-pipeline.yml— runs the pipeline inside that prebuilt container, builds a small HTML report, deploys it to GitHub Pages, and optionally emails the result.
-
Enable GitHub Pages — not inherited by forks. Go to Settings → Pages → Build and deployment → Source → GitHub Actions.
-
Check Actions workflow permissions —
build-container.ymlneeds to push to GHCR. Go to Settings → Actions → General → Workflow permissions → Read and write permissions. (A repo's default token permissions can only be narrowed by the workflow YAML, not widened, so this must be enabled at the repo/org level.) -
(Optional) Real scan data — create a GitHub Release (tag
v1.0-databy default) and attach asample_dmri.nii.gzasset. Skip this to let the pipeline fall back to the Stanford HARDI dataset automatically. -
(Optional) Email notifications — add these repository secrets (Settings → Secrets and variables → Actions → New repository secret) to get an email with the SNR/status/report link after each run:
MAIL_USERNAME— sender email addressMAIL_PASSWORD— app password (not your real account password; for Gmail: Google Account → Security → 2-Step Verification → App Passwords)MAIL_TO— recipient addressMAIL_SERVER/MAIL_PORT— optional, default tosmtp.gmail.com/465
If these secrets aren't set, the notify step is skipped silently — nothing breaks.
No image names, package names, or paths need editing — the container image name is derived
from ${{ github.repository }} automatically.
Automatic: publish a GitHub Release — run-pipeline.yml runs automatically and tries to
pull sample_dmri.nii.gz from that release's own assets.
Manual: Actions tab → "Execute dMRI Pipeline" → Run workflow. Two optional inputs:
release_tag— which release to pull the data asset from (defaultv1.0-data)asset_name— name of the data asset to download (defaultsample_dmri.nii.gz)
Leave both blank to use the defaults.
Result: once the run finishes, the QC report is live at
https://<owner>.github.io/<repo>/ (also linked from the run's deploy-pages job and the
repo's Environments tab).
pip install numpy nibabel dipy matplotlib
python process_dmri.pyOr use the provided Dockerfile / .devcontainer/devcontainer.json (same dependency set).