Skip to main content

N-dimensional bioimaging data I/O with OME metadata in Python

Project description

iohub

PyPI - Python version PyPI - iohub version Docs deployment

N-dimensional bioimaging produces data and metadata in various formats, and iohub aims to become a unified Python interface to the most common formats used at the Biohub and in the broader imaging community.

Supported formats

Read

  • OME-Zarr (OME-NGFF v0.4)
  • Micro-Manager TIFF sequence, OME-TIFF (MMStack), and NDTiff datasets
  • Custom data formats generated by Biohub microscopes
    • Supported: Falcon (PTI), Dorado (ClearControl), Dragonfly (OpenCell OME-TIFF), Mantis (NDTiff)
    • WIP: DaXi

Write

  • OME-Zarr
  • Multi-page TIFF stacks organized in a directory hierarchy that mimics OME-NGFF (WIP)

Quick start

Installation

Install a pre-release of iohub with pip:

pip install iohub

Or install the latest Git version:

git clone https://github.com/czbiohub-sf/iohub.git
pip install /path/to/iohub

For more details about installation, see the related section in the contribution guide.

Command-line interface

To check if iohub works for a dataset:

iohub info /path/to/data/

The CLI can show a summary of the dataset, point to relevant Python calls, and convert other data formats to the latest OME-Zarr. See the full CLI help message by typing iohub or iohub [command] --help in the terminal.

Working with OME-Zarr

Load and modify an example OME-Zarr dataset:

import numpy as np
from iohub import open_ome_zarr

with open_ome_zarr(
    "20200812-CardiomyocyteDifferentiation14-Cycle1.zarr",
    mode="r",
    layout="auto",
) as dataset:
    dataset.print_tree()  # prints the hierarchy of the zarr store
    channel_names = dataset.channel_names
    print(channel_names)
    img_array = dataset[
        "B/03/0/0"
    ]  # lazy Zarr array for the raw image in the first position
    raw_data = img_array.numpy()  # loads a CZYX 4D array into RAM
    print(raw_data.mean())  # does some analysis

with open_ome_zarr(
    "max_intensity_projection.zarr",
    mode="w-",
    layout="hcs",
    channel_names=channel_names,
) as dataset:
    new_fov = dataset.create_position(
        "B", "03", "0"
    )  # creates fov with the same path
    new_fov["0"] = raw_data.max(axis=1).reshape(
        (1, 1, 1, *raw_data.shape[2:])
    )  # max projection along Z axis and prepend dims to 5D
    dataset.print_tree()  # checks that new data has been written

For more about API usage, refer to the documentation and the example scripts.

Reading Micro-Manager TIFF data

Read a directory containing a TIFF dataset:

from iohub import read_micromanager

reader = read_micromanager("/path/to/data/")
print(reader.shape)

Why iohub?

This project is inspired by the existing Python libraries for bioimaging data I/O, including ome-zarr-py, tifffile and aicsimageio. They support some of the most widely adopted and/or promising formats in microscopy, such as OME-Zarr and OME-TIFF.

iohub bridges the gaps among them with the following features:

  • Efficient reading of data in various TIFF-based formats produced by the Micro-Manager/Pycro-Manager acquisition stack.
  • Efficient and customizable conversion of data and metadata from TIFF to OME-Zarr.
  • Pythonic and atomic access of OME-Zarr data with parallelized analysis in mind.
  • OME-Zarr metadata is automatically constructed and updated for writing, and verified against the specification when reading.
  • Adherence to the latest OME-NGFF specification (v0.4) whenever possible.

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

iohub-0.1.0rc0.tar.gz (79.1 kB view details)

Uploaded Source

Built Distribution

iohub-0.1.0rc0-py3-none-any.whl (56.1 kB view details)

Uploaded Python 3

File details

Details for the file iohub-0.1.0rc0.tar.gz.

File metadata

  • Download URL: iohub-0.1.0rc0.tar.gz
  • Upload date:
  • Size: 79.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for iohub-0.1.0rc0.tar.gz
Algorithm Hash digest
SHA256 b2867d100fceed0a2199b429a8e8e9a877c1f814ecfbcec88546fd38b82af920
MD5 7b375d1a536c648f31e6625324e3e7b6
BLAKE2b-256 a7769242726ec0593ef6fdb33b2f241b93663f4f38fea1816fa29e720bd0cae3

See more details on using hashes here.

File details

Details for the file iohub-0.1.0rc0-py3-none-any.whl.

File metadata

  • Download URL: iohub-0.1.0rc0-py3-none-any.whl
  • Upload date:
  • Size: 56.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for iohub-0.1.0rc0-py3-none-any.whl
Algorithm Hash digest
SHA256 e843f551fbb2a950340f1ac28ab513693adbc231da9d1d295fb7aabaf5219ff2
MD5 fab7916735af043bd72930bda2726f06
BLAKE2b-256 83f49fc3f6c21930bea0bc7e61306ab287ba1f3170b1f463849d93aa6b0f7105

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page