Skip to main content

Convert Hamamatsu NDPI whole-slide images to BIDS-compliant microscopy datasets

Project description

BIDS microscopy: ndpi


Version Docker Image Version Docker Pulls GitHub issues GitHub stars

Convert whole-slide images in .ndpi format to Brain Imaging Data Structure (BIDS) microscopy compliant datasets. https://hub.docker.com/r/micalab/ndpi2bids

Overview

BIDS_ndpi automates the conversion of Hamamatsu .ndpi whole-slide microscopy images into a BIDS-compliant directory structure, generating the required JSON sidecars, participants.tsv, and metadata files along the way.


Repository structure

BIDS_ndpi/
├── CHANGELOG.md
├── Dockerfile
├── LICENSE
├── README.md
├── boutiques
│   └── ndpi2bids.json                  # Boutique descriptor 
├── environment.yml
├── .gitignore
├── ndpi2bids
│   ├── __init__.py
│   ├── ndpi2bids.py                    # Main conversion script
│   └── templates
│       ├── dataset_description.json
│       ├── participants.json
│       ├── stain-AT8_BF.json           # Stain-specific JSON sidecar template
│       └── CITATION.cff
└── pyproject.toml

Requirements

  • Docker (recommended), or
  • conda with the provided environment.yml
  • pip

Quick start

With Docker

# Build the image
docker build -t bids_ndpi .

# Run conversion
docker run --rm \
  -v /path/to/ndpi/files:/input \
  -v /path/to/output:/output \
  bids_ndpi \
  python ndpi2bids/ndpi2bids.py --input /input --output /output

With conda

# Create environment
conda env create -f environment.yml
conda activate bids_ndpi

# Run conversion
python ndpi2bids/ndpi2bids.py --input /path/to/ndpi --output /path/to/bids

Usage

python ndpi2bids/ndpi2bids.py [OPTIONS]

Mandatory arguments:
  --ndpi_path  PATH   Path to raw Hamamatsu .ndpi file             [required]
  --bids       PATH   Path to the root of the BIDS dataset         [required]
  --sub        LABEL  Subject ID (e.g., PX067)                     [required]
  --stain      LABEL  Stain entity (e.g., AT8)                     [required]
  --suffix     LABEL  BIDS suffix (e.g., BF)                       [required]

Optional BIDS entities:
  --ses        LABEL  Session ID
  --sample     LABEL  Sample ID (e.g., NP24709)
  --acq        LABEL  Acquisition label
  --run        INDEX  Run index
  --chunk      LABEL  Chunk label (e.g., A3)
  --template   PATH   JSON template for metadata (overrides defaults)

Operational flags:
  --convert           Convert NDPI to OME-TIFF via bfconvert
  --force             Overwrite existing BIDS files and sidecars
  --dry_run           Print the intendet output.

Example

python ndpi2bids/ndpi2bids.py \
  --ndpi_path /data/raw/PX067_AT8.ndpi \
  --bids      /data/bids \
  --sub       S001 \
  --stain     AT8 \
  --suffix    BF \
  --ses       01 \
  --sample    NP24709A1 \
  --convert

Templates

JSON templates in ./templates/ define stain-specific metadata injected into BIDS sidecars.

File Purpose
stain-AT8_BF.json Sidecar template for AT8 brightfield staining
participants.json Column definitions for participants.tsv
participants_description.json Dataset-level participant metadata
CITATION.cff Citation metadata for the dataset (authors, title, version, DOI)

To add a new stain, copy an existing template and update the fields, then pass it via --template.


BIDS output structure

output/
├── CITATION.cff
├── dataset_description.json
├── participants.tsv
├── participants.json
├── README
└── sub-<label>/
    └── ses-<label>/
        └── micr/
            ├── sub-<label>_ses-<label>_stain-AT8_BF.ome.tif
            └── sub-<label>_ses-<label>_stain-AT8_BF.json

License

MIT License — see LICENSE for details.

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

ndpi2bids-0.1.1.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

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

ndpi2bids-0.1.1-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file ndpi2bids-0.1.1.tar.gz.

File metadata

  • Download URL: ndpi2bids-0.1.1.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for ndpi2bids-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a7bb20293c7ae8c42af3fb4ae7448d57fe670933c6f93093dde67cc6e3f03446
MD5 c1f800e358382f49e4a0fe433e781a2f
BLAKE2b-256 8b0bd11c3b61b0464584cde83ec3e8a8c6c8722771face4b9135924f8fbe9af8

See more details on using hashes here.

File details

Details for the file ndpi2bids-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ndpi2bids-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for ndpi2bids-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6f52fe7a46b7bc4bc4d62271efa719691cf8766a0f81d938c0dbf3540da1d568
MD5 070222ded63af9158007d53f979ad242
BLAKE2b-256 e34f5ef639aa62a9f95569dd267db300e987e23694bb853d291319a00eab6d73

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