Interactive image viewer widget for Jupyter/marimo with annotation tools and SAM integration
Project description
anybioimage
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.
Installation
uv pip install anybioimage
# With all recommended dependencies (excludes SAM/PyTorch)
uv pip install "anybioimage[all]"
# With SAM support (Python 3.10–3.12, requires PyTorch)
uv pip install "anybioimage[complete]"
Quick Start
Jupyter
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)
img = BioImage("image.zarr", reader=bioio_ome_zarr.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)
viewer.add_mask(cells, name="Cells", color="#00ff00", contours_only=True)
# 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.10–3.12).
Optional dependencies
| Extra | Installs | Use case |
|---|---|---|
bioio |
bioio, bioio-tifffile |
TIFF / OME-Zarr loading |
contours |
scipy |
Contour-only mask rendering |
sam |
ultralytics (PyTorch) |
SAM segmentation |
all |
bioio + contours | Recommended (no PyTorch) |
complete |
all + sam | Everything |
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file anybioimage-0.3.0.tar.gz.
File metadata
- Download URL: anybioimage-0.3.0.tar.gz
- Upload date:
- Size: 42.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
881c80660c6a64f5c6f189c41b87250b050945f073ff959be66346feb88bb79a
|
|
| MD5 |
ef97599cbdd84c24a0caea29ba9e58ee
|
|
| BLAKE2b-256 |
c8b0989b91e98721b06f78dbf70eb42e232595976822d11fe83545a5ecf3254d
|
Provenance
The following attestation bundles were made for anybioimage-0.3.0.tar.gz:
Publisher:
publish.yml on maartenpaul/anybioimage
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anybioimage-0.3.0.tar.gz -
Subject digest:
881c80660c6a64f5c6f189c41b87250b050945f073ff959be66346feb88bb79a - Sigstore transparency entry: 1155023546
- Sigstore integration time:
-
Permalink:
maartenpaul/anybioimage@5e749be414d7eeb546322866a69d6745e3b9e301 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/maartenpaul
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5e749be414d7eeb546322866a69d6745e3b9e301 -
Trigger Event:
release
-
Statement type:
File details
Details for the file anybioimage-0.3.0-py3-none-any.whl.
File metadata
- Download URL: anybioimage-0.3.0-py3-none-any.whl
- Upload date:
- Size: 40.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
075f16aa057f8bd6fb8ce0b4b1846f94f988c32c948c86ec07344970cf42ce71
|
|
| MD5 |
f7016d465136bfc1221314859fb20842
|
|
| BLAKE2b-256 |
31b163b7b700c80a057045a1c78522d3c60de3cb1babcd5f3f9128c1b14f9cc3
|
Provenance
The following attestation bundles were made for anybioimage-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on maartenpaul/anybioimage
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anybioimage-0.3.0-py3-none-any.whl -
Subject digest:
075f16aa057f8bd6fb8ce0b4b1846f94f988c32c948c86ec07344970cf42ce71 - Sigstore transparency entry: 1155023548
- Sigstore integration time:
-
Permalink:
maartenpaul/anybioimage@5e749be414d7eeb546322866a69d6745e3b9e301 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/maartenpaul
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5e749be414d7eeb546322866a69d6745e3b9e301 -
Trigger Event:
release
-
Statement type: