Skip to content

Repository files navigation

Batch MRI Quality Control

Batch MRI QC demo

Batch MRI Quality Control is a local Django application for high-throughput MRI screening. It uses Django Templates for the browser UI and django-ninja for API endpoints.

The application is designed for large MRI folders on local disks or mounted volumes. It can browse MRI files in pages, preview NIfTI/DICOM/image files, switch axes and slices, rotate previews, select files in bulk, and save selected MRI paths into filtered/.

Features

  • Django + django-ninja + Django Templates.
  • Configurable MRI roots in config.py.
  • Default page layout: 15 columns x 10 rows, 150 MRI previews per page.
  • Dynamic slice range based on the current page's real NIfTI dimensions.
  • Previous/next slice buttons plus a slice slider.
  • Left/right 90-degree preview rotation.
  • Select all, invert selection, clear selection.
  • Save selected MRI paths as timestamped .txt and .json files under filtered/.
  • Excludes dotfiles such as macOS/exFAT ._xxx fake files.
  • Optional current-page PNG preloading in browser memory.
  • Optional current-page NIfTI volume caching in Django memory to avoid repeated HDD reads when changing slices.
  • Docker support on port 11451.

Quick Start

Local Python is recommended when reading large MRI datasets from external HDDs.

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python manage.py runserver 127.0.0.1:11451

Open:

http://127.0.0.1:11451/

Configuration

Edit config.py or use the in-browser configuration dialog.

Important defaults:

MRI_ROOTS = [
    "/Volumes/LuZhang16T/IU_Datasets",
    "/Volumes/LuZhang16T/generated_mri",
]

PAGE_ROWS = 10
PAGE_COLS = 15
PRELOAD_PAGE_IMAGES = True
CACHE_PAGE_VOLUMES_IN_MEMORY = True
EXCLUDE_DOTFILES = True

Docker

Build:

docker build -t batch-mri-qc .

Run with the MRI volume mounted:

docker run --rm \
  -p 11451:11451 \
  -v /Volumes/LuZhang16T:/Volumes/LuZhang16T \
  -v "$(pwd)/filtered:/app/filtered" \
  -v "$(pwd)/.cache:/app/.cache" \
  -e DJANGO_ALLOWED_HOSTS=127.0.0.1,localhost,0.0.0.0 \
  batch-mri-qc

Open:

http://127.0.0.1:11451/

API

Main endpoints:

GET  /api/config
POST /api/config
GET  /api/folders
GET  /api/mri
GET  /api/preview-progress/{task_id}
POST /api/save-selection
GET  /preview/{file_id}/

Swagger UI:

Swagger UI

http://127.0.0.1:11451/api/docs

Example:

curl "http://127.0.0.1:11451/api/mri?folder=/Volumes/LuZhang16T/IU_Datasets&axis=axial&page=1"

About

High-throughput MRI quality control system built with Django and Django Ninja for local screening, review workflows, and large-scale imaging inspection.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages