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.
Release files for ndpi2bids 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ndpi2bids-0.1.2.tar.gz | 13.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ndpi2bids-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 27.0 kB
Release files / ndpi2bids-0.1.2.tar.gz
| Download URL | ndpi2bids-0.1.2.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
587bcd1c2306c92b2ac31b45bc779d5d7cd14943c6b7637d501b3eb293744169
|
|
BLAKE2b-256 checksum How to use checksums |
1489e2fde6e9637e5a6ee4c1d7f11f385c025c97dafa58cbccce48615930568d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.9
|
Release files / ndpi2bids-0.1.2-py3-none-any.whl
| Download URL | ndpi2bids-0.1.2-py3-none-any.whl |
|---|---|
| Size | 13.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
35eccd2e044e8aba75bae3a28785d543232b6ed3b184242b4d7c8f9e27be4f1e
|
|
BLAKE2b-256 checksum How to use checksums |
138ec2e9f283a6777721008c53034ac6085759ae54a447dce77e37d4b286ccd8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.9
|