Skip to main content

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

Project description

BIDS microscopy: ndpi


Version PyPI 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.2.tar.gz (13.9 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.2-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ndpi2bids-0.1.2.tar.gz
  • Upload date:
  • Size: 13.9 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.2.tar.gz
Algorithm Hash digest
SHA256 587bcd1c2306c92b2ac31b45bc779d5d7cd14943c6b7637d501b3eb293744169
MD5 037188be6a69ebf1b4fb34d732f67171
BLAKE2b-256 1489e2fde6e9637e5a6ee4c1d7f11f385c025c97dafa58cbccce48615930568d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ndpi2bids-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 13.1 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 35eccd2e044e8aba75bae3a28785d543232b6ed3b184242b4d7c8f9e27be4f1e
MD5 670b82222e95a598835c1e140a6b2355
BLAKE2b-256 138ec2e9f283a6777721008c53034ac6085759ae54a447dce77e37d4b286ccd8

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