| name | anybioimage |
| description | Integrate and use the anybioimage BioImageViewer widget to display biological images, overlays, and annotations in Jupyter and marimo notebooks. Use this skill when asked to display images with BioImageViewer, add mask overlays or segmentation results, annotate images with rectangles/polygons/points, enable SAM (Segment Anything Model) for interactive segmentation, load multi-dimensional 5D images (TCZYX) with BioImage, show multichannel fluorescence images with per-channel colors and contrast, export annotations as DataFrames, or integrate anybioimage into a marimo or Jupyter workflow. |
anybioimage Skill
anybioimage provides BioImageViewer, an interactive widget for visualizing biological images with mask overlays, annotations, and SAM segmentation in Jupyter and marimo notebooks.
Installation
uv pip install -e ".[all]"
uv pip install -e ".[sam]"
Quickstart
Jupyter
from anybioimage import BioImageViewer
import numpy as np
viewer = BioImageViewer()
viewer.set_image(np.random.randint(0, 255, (512, 512), dtype=np.uint8))
viewer
Marimo
import marimo as mo
from anybioimage import BioImageViewer
@app.cell
def _():
viewer = BioImageViewer()
viewer.set_image(image_data)
return mo.ui.anywidget(viewer)
Marimo rules:
- Always wrap with
mo.ui.anywidget(viewer)
- Only edit code inside
@app.cell decorators
- Run
marimo check --fix after editing
Image Input
| Input | Method | Notes |
|---|
| numpy array | set_image(arr) | Auto-squeezed to 2D |
| BioImage | set_image(BioImage("file.tif")) | Full 5D, lazy loading |
| OME-Zarr | set_image(BioImage("file.ome.zarr")) | Multi-resolution |
BioImage (5D multichannel)
from bioio import BioImage
viewer = BioImageViewer()
img = BioImage("multichannel.ome.tiff")
viewer.set_image(img)
Masks / Overlays
mask_id = viewer.add_mask(labels_array, name="Nuclei", color="#ff0000", opacity=0.5)
mask_id2 = viewer.add_mask(cell_labels, name="Cells", contours_only=True, contour_width=2)
viewer.set_mask(labels_array, name="Segmentation")
viewer.update_mask_settings(mask_id, opacity=0.8, visible=False)
viewer.remove_mask(mask_id)
viewer.clear_masks()
print(viewer.masks_df)
color accepts hex strings. Colors auto-cycle from a 10-color palette if not specified.
Annotations
rois = viewer.rois_df
polygons = viewer.polygons_df
points = viewer.points_df
rois.to_csv("rois.csv")
viewer.rois_df = existing_rois_df
viewer.clear_rois()
viewer.clear_polygons()
viewer.clear_points()
viewer.clear_all_annotations()
Drawing tools (keyboard shortcuts): Pan (P), Select (V), Rectangle (R), Polygon (G), Point (O)
SAM Integration
viewer.enable_sam("mobile_sam")
viewer.clear_sam_masks()
viewer.disable_sam()
Model options: "mobile_sam" (default), "sam_b", "sam_l", "fast_sam"
Visual Settings
viewer.image_visible = True
viewer.image_brightness = 0.2
viewer.image_contrast = 0.3
viewer.canvas_height = 600
viewer.roi_color = "#ff0000"
viewer.polygon_color = "#00ff00"
viewer.point_color = "#0000ff"
viewer.point_radius = 5
Reference Files
- api_reference.md — Full method signatures, all traitlets, channel settings, internal details
- examples.md — Complete workflow examples (fluorescence imaging, segmentation pipelines, annotation export)