Skip to main content

Pytest

ndbioimage

Exposes (bio) images as a numpy ndarray-like object, but without loading the whole image into memory, reading from the file only when needed. Some metadata is read and stored in an ome structure. Additionally, it can automatically calculate an affine transform that corrects for chromatic aberrations etc. and apply it on the fly to the image.

Currently, it supports imagej tif files, czi files, micromanager tif sequences and anything bioformats can handle.

Installation

One of:

pip install ndbioimage
pip install ndbioimage[bioformats]
pip install ndbioimage[write]
pip install ndbioimage[bioformats, write]
  • bioformats: use bio-formats as fallback when other readers cannot open a file.
  • write: write an image file into a mp4 or mkv file. Work in progress! Make sure ffmpeg is installed.

Usage

Python

  • Reading an image file and plotting the frame at channel=2, time=1
import matplotlib.pyplot as plt
from ndbioimage import Imread
with Imread('image_file.tif', axes='ctyx', dtype=int) as im:
    plt.imshow(im[2, 1])
  • Showing some image metadata
from ndbioimage import Imread
from pprint import pprint
with Imread('image_file.tif') as im:
    pprint(im)
  • Slicing the image without loading the image into memory
from ndbioimage import Imread
with Imread('image_file.tif', axes='cztyx') as im:
    sliced_im = im[1, :, :, 100:200, 100:200]

sliced_im is an instance of Imread which will load any image data from file only when needed

  • Converting (part) of the image to a numpy ndarray
from ndbioimage import Imread
import numpy as np
with Imread('image_file.tif', axes='cztyx') as im:
    array = np.asarray(im[0, 0])

Command line

ndbioimage --help: show help
ndbioimage image: show metadata about image
ndbioimage image -w {name}.tif -r: copy image into image.tif (replacing {name} with image), while registering channels
ndbioimage image -w image.mp4 -C cyan lime red copy image into image.mp4 (z will be max projected), make channel colors cyan lime and red

Adding more formats

Readers for image formats subclass AbstractReader. When an image reader is imported, Imread will automatically recognize it and use it to open the appropriate file format. Image readers are required to implement the following methods:

  • staticmethod _can_open(path): return True if path can be opened by this reader
  • __frame__(self, c, z, t): return the frame at channel=c, z-slice=z, time=t from the file

Optional methods:

  • get_ome: reads metadata from file and adds them to an OME object imported from the ome-types library
  • open(self): maybe open some file handle
  • close(self): close any file handles

Optional fields:

  • priority (int): Imread will try readers with a lower number first, default: 99
  • do_not_pickle (strings): any attributes that should not be included when the object is pickled, for example: any file handles

TODO

  • more image formats

Metadata

Release files for ndbioimage 2026.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ndbioimage 2026.9.0
File Size Uploaded
ndbioimage-2026.9.0.tar.gz 52.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ndbioimage 2026.9.0
File Interpreter ABI Platform
ndbioimage-2026.9.0-py3-none-any.whl Python 3 none any Details

Total release size: 110.0 kB

Release files / ndbioimage-2026.9.0.tar.gz

Download URL ndbioimage-2026.9.0.tar.gz
Size 52.3 kB
Tags Source
SHA-256 checksum
How to use checksums
02229a7058434db6b71ce2d6e2f4c4240a1586d95e24be645326dfd6d083e22b
BLAKE2b-256 checksum
How to use checksums
dd24049c59f1bfc28ead7c1784f0e6ea53e8bd45399c6dd42099b95b40cdb699
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Release files / ndbioimage-2026.9.0-py3-none-any.whl

Download URL ndbioimage-2026.9.0-py3-none-any.whl
Size 57.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fbc6a8b23d8b1b1074e2b21edc72af201ce175b22c34999c26f7743acfe3d915
BLAKE2b-256 checksum
How to use checksums
00dcf9701798704f5f01c3e384eb15fefd210d04516c35f3c237a76a03b693c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Release history Release notifications | RSS feed

This release

2026.9.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page