Skip to main content

napari-bboxes

PyPI Python Version Tests License

Axis-aligned 2-D and 3-D bounding boxes (detections, annotations) as napari layers that you can see in every 2-D plane and in 3-D, aligned with the image they belong to.

napari's own layers cannot do this for 3-D boxes: a Shapes rectangle lives in one plane, and a Surface mesh shows nothing in 2-D slices (only faces lying entirely in the slice are drawn). napari-bboxes draws a 3-D box as a one-voxel outline on the image grid, computed per slice on demand: an axial, coronal or sagittal slice shows the rectangle where it cuts the box, the 3-D view shows the box, and the array costs no memory.

pip install napari-bboxes

Usage

import napari
from napari_bboxes import add_bboxes

viewer = napari.Viewer()
image = viewer.add_image(ct, affine=ct_affine)
add_bboxes(
    viewer,
    mins=[[40, 60, 70], [10, 20, 30]],      # inclusive corners in index coordinates of the image grid
    maxs=[[60, 90, 110], [18, 35, 44]],
    labels=[1, 2],                          # class per box
    scores=[0.97, 0.41],                    # optional
    names={1: "tumor", 2: "node"},          # optional display names
    colors={1: (230, 60, 60)},              # optional; other classes get palette colours
    grid_shape=ct.shape,
    affine=image.affine.affine_matrix,      # same index -> world transform as the image: boxes align with it
)
napari.run()
  • 3-D boxes become a Labels layer: each box has its own number, coloured by class, and hovering shows name (label) score.
  • 2-D boxes become a Shapes layer of rectangles, with the same text next to each box.
  • bbox_layers(...) returns the same as layer data tuples (data, kwargs, layer_type), for napari readers.
  • BoxShells(shape, bounds) is the lazy outline array on its own.

Coordinates are array indices of a grid (voxel centres, inclusive bounds). Boxes in world or physical coordinates are converted by the caller: map the corners through the inverse of the image affine and take the bounding box.

Used by napari-mlarray for the boxes stored in MLArray files.

Development

pip install -e ".[test]"
pytest

License

MIT

Metadata

Release files for napari-bboxes 0.1.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 napari-bboxes 0.1.0
File Size Uploaded Provenance Actions
napari_bboxes-0.1.0.tar.gz 12.4 kB With provenance Details for napari_bboxes-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for napari-bboxes 0.1.0
File Interpreter ABI Platform Actions
napari_bboxes-0.1.0-py3-none-any.whl Python 3 none any Details for napari_bboxes-0.1.0-py3-none-any.whl

Total release size: 21.5 kB

Release files / napari_bboxes-0.1.0.tar.gz

Download URL napari_bboxes-0.1.0.tar.gz
Size 12.4 kB
Tags Source
SHA-256 checksum
How to use checksums
45f38432a5527c9d5c334be0566209afc777d07250c5c047e396fd5688ec487a
BLAKE2b-256 checksum
How to use checksums
003e3c46c4dab3e50d08297d5713714948c72a93caab14bb2b4230bfae3fbf3f
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 6, 2026.

Transparency log

Release files / napari_bboxes-0.1.0-py3-none-any.whl

Download URL napari_bboxes-0.1.0-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3ae4ae65b671e9f1ee3d2b014c8bd32743b96eb69828bf7065400d09956406db
BLAKE2b-256 checksum
How to use checksums
ee381e691554aaa8d104906e535d205fdd85c0362bc9cea5db136f089162a33a
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 6, 2026.

Transparency log

Security for napari-bboxes 0.1.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 napari_bboxes-0.1.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 6, 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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