Convert Hamamatsu NDPI whole-slide images to BIDS-compliant microscopy datasets
Project description
BIDS microscopy: ndpi
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7bb20293c7ae8c42af3fb4ae7448d57fe670933c6f93093dde67cc6e3f03446
|
|
| MD5 |
c1f800e358382f49e4a0fe433e781a2f
|
|
| BLAKE2b-256 |
8b0bd11c3b61b0464584cde83ec3e8a8c6c8722771face4b9135924f8fbe9af8
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f52fe7a46b7bc4bc4d62271efa719691cf8766a0f81d938c0dbf3540da1d568
|
|
| MD5 |
070222ded63af9158007d53f979ad242
|
|
| BLAKE2b-256 |
e34f5ef639aa62a9f95569dd267db300e987e23694bb853d291319a00eab6d73
|