Skip to main content

anybioimage

PyPI version Python versions Open in molab Binder

Interactive bioimage viewer widget for Jupyter and marimo notebooks. Built on anywidget, it supports multi-dimensional images, multi-channel composites, mask overlays, annotation tools, and HCS plate navigation.

Documentation: https://maartenpaul.github.io/anybioimage/

Installation

uv pip install anybioimage

# With OME-Zarr support (local stores, HCS plates, Canvas2D zarr loading)
uv pip install "anybioimage[zarr]"

# With all recommended dependencies (excludes SAM/PyTorch)
uv pip install "anybioimage[all]"

# With SAM support (Python 3.11–3.12, requires PyTorch)
uv pip install "anybioimage[complete]"

Try anybioimage online

If you want to try anybioimage without any installation you can make use of molab . Open the demo notebook, login to fork the notebook and run anybioimage directly in your browser.
anybioimage_notebook_demo.py

Or run it in jupyterlab on mybinder.org: anybioimage_example.ipynb

Quick Start

Minimal example (NumPy only)

import numpy as np
from anybioimage import BioImageViewer

viewer = BioImageViewer()
viewer.set_image(np.random.randint(0, 255, (512, 512), dtype=np.uint8))
viewer  # displays in notebook

Example with a tiff image

from anybioimage import BioImageViewer
from bioio import BioImage
import bioio_tifffile

viewer = BioImageViewer()
viewer.set_image(BioImage("image.tif", reader=bioio_tifffile.Reader))
viewer  # renders inline

marimo

import marimo as mo
from anybioimage import BioImageViewer
from bioio import BioImage
import bioio_tifffile

viewer = BioImageViewer()
viewer.set_image(BioImage("image.tif", reader=bioio_tifffile.Reader))
mo.ui.anywidget(viewer)

Features

Multi-dimensional images

Supports 5D arrays (TCZYX: Time, Channel, Z-stack, Y, X) with sliders for T, Z, and per-channel controls. Pass a BioImage object for lazy loading — efficient for large TIFF and OME-Zarr files.

from bioio import BioImage
import bioio_tifffile
import bioio_ome_zarr

img = BioImage("image.tif",  reader=bioio_tifffile.Reader)
viewer.set_image(img)  # activates T/Z sliders, per-channel LUT controls

Multi-channel composites

Each channel has independent color, brightness/contrast (LUT), and visibility controls via the Layers panel in the toolbar. Channel settings can also be set programmatically:

# Access and modify channel settings
settings = list(viewer._channel_settings)
settings[0] = {**settings[0], "name": "DAPI", "color": "#0000ff"}
viewer._channel_settings = settings

Mask overlays

Add segmentation masks as overlay layers with configurable color, opacity, and contour rendering:

viewer.add_mask(labels, name="Nuclei", color="#ff0000", opacity=0.5)

# Manage masks
viewer.update_mask_settings(mask_id, opacity=0.3)
viewer.remove_mask(mask_id)
viewer.clear_masks()

HCS plate support

Load OME-Zarr HCS plates with well and FOV navigation dropdowns built into the widget:

viewer = BioImageViewer()
viewer.set_plate("plate.zarr")
viewer  # shows Well / FOV dropdowns

Annotation tools

Tool Shortcut Description
Pan P Navigate and zoom
Select V Select annotations; Delete to remove
Rectangle R Draw bounding boxes
Polygon G Click vertices, double-click to close
Point O Place point markers

Export annotations as DataFrames:

viewer.rois_df      # rectangles: id, x, y, width, height
viewer.polygons_df  # polygons: id, points, num_vertices
viewer.points_df    # points: id, x, y

SAM integration

Automatic segmentation with Segment Anything Model when drawing rectangles or placing points:

viewer.enable_sam(model_type="mobile_sam")  # ~40 MB, fastest
viewer.enable_sam(model_type="sam_b")       # SAM base, ~375 MB

Requires uv pip install "anybioimage[sam]" (Python 3.11–3.12).

Rendering backends

Backend Default Best for
canvas2d ✅ Local arrays, BioImage/TIFF/CZI/ND2, full annotation & SAM toolset
viv opt-in OME-Zarr — remote URLs browser-direct; local / S3 / GCS stores via the kernel chunk bridge (any size, zarr v2 + v3)
# Opt in to the Viv backend for OME-Zarr:
viewer = BioImageViewer(render_backend="viv")
viewer.set_image("https://example.com/data.ome.zarr")
viewer.set_plate("https://example.com/plate.zarr")  # well/FOV switching stays browser-side

viewer.set_image("/data/big.ome.zarr")                                        # local, any size; needs anybioimage[zarr]
viewer.set_image("s3://bucket/x.ome.zarr", storage_options={"anon": True})   # needs anybioimage[remote]

# A single HCS field, on a non-AWS S3 endpoint (e.g. EBI BioImage Archive):
viewer.set_image(
    "s3://bioimaging-integrator-data/S-BIAD855/<uuid>/<uuid>.zarr/B/2/8",
    storage_options={"anon": True,
                     "client_kwargs": {"endpoint_url": "https://livingobjects.ebi.ac.uk"}},
)

Browser-direct http(s) zarr URLs on the viv backend work with the base install; everything the kernel has to open itself (local paths, s3://, gs://, plates, and zarr on the Canvas2D backend) needs the zarr extra.

Non-zarr inputs on the viv backend fall back to Canvas2D automatically (one info log). Alpha limitations on Viv-rendered images: annotation/SAM tools, brightness/contrast sliders, histograms, and the toolbar Reset-view button are inactive (use per-channel min/max for contrast); they remain fully functional on the Canvas2D backend. Set render_backend="canvas2d" (default) to retain the full annotation and SAM toolset.

Attribution

The Viv backend builds on Viv (MIT), deck.gl (MIT), and Viv's zarr loader (zarr.js lineage, MIT).

Optional dependencies

Extra Installs Use case
bioio bioio, bioio-tifffile TIFF loading
zarr zarr, bioio, bioio-ome-zarr OME-Zarr: local stores, HCS plates, zarr.Group input
remote zarr + s3fs, gcsfs s3:// / gs:// OME-Zarr stores
contours scipy Contour-only mask rendering
sam ultralytics (PyTorch) SAM segmentation
all bioio + zarr + remote + contours Recommended (no PyTorch)
complete all + sam Everything

Using anybioimage with AI coding agents

skills/anybioimage/ is an agent skill (the SKILL.md format used by Claude Code and other agents) that teaches an agent how to use the viewer correctly: how numpy axes are read, reshaping time-lapses and z-stacks, label stacks that follow the sliders, reading user annotations back in marimo, the Viv backend and its limits, and common mistakes. Install it by linking the folder into your agent's skills directory, for example for Claude Code:

ln -s "$(pwd)/skills/anybioimage" ~/.claude/skills/anybioimage

The skill is kept next to the code so it changes with it; update it in the same pull request when behaviour it describes changes.

License

MIT

Metadata

Release files for anybioimage 0.4.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 anybioimage 0.4.0
File Size Uploaded Provenance Actions
anybioimage-0.4.0.tar.gz 148.2 kB With provenance Details for anybioimage-0.4.0.tar.gz

Built distribution (wheel)

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

Total release size: 803.7 kB

Release files / anybioimage-0.4.0.tar.gz

Download URL anybioimage-0.4.0.tar.gz
Size 148.2 kB
Tags Source
SHA-256 checksum
How to use checksums
8c78ce8000307260498ac6e904b323e2f68aaac84f6841d6ea377b9650ad287a
BLAKE2b-256 checksum
How to use checksums
0e9e024572f1021b2e2f9a5c002fc38f7d2ead2cd33f6beafdc6450849f60eff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Release files / anybioimage-0.4.0-py3-none-any.whl

Download URL anybioimage-0.4.0-py3-none-any.whl
Size 655.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
44576ec8774a406453ef7c6b657bfa90328a1863aed4d6ef85c9486d37d00946
BLAKE2b-256 checksum
How to use checksums
d0c3957aa5f04f8ff54b407231d4a96d796c86ab5cb2de1e3cec00ec48635fe8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Security for anybioimage 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for anybioimage-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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