Skip to main content

Visualize 3D numpy arrays in the browser.

Project description

PyPI version

microviewer

Multiplatform 3D numpy image browser based viewer.

from microviewer import view, hyperview, objects

view(numpy_image) # for gray and color images
view(numpy_image, seg=True) # for segmentation labels
view(numpy_image, seg=True, port=8082)

hyperview(image, labels) # interactive overlay

# uses vtk to visualize meshes, bounding boxes, 
# skeletons, and point clouds
objects([ mesh, skeleton, bbox, point_cloud ])
uview image.npy.gz # view as image
uview labels.npy.gz --seg # view as segmentation
uview image.npy.gz labels.npy.gz # view image w/ overlay
uview image.npy.gz --paint # view image w/ blank overlay

Segmentation display in microviewer

Visualize 3D numpy arrays in your browser without difficult installation procedures or reformatting your data. The code is CPU based and the image is uncompressed in memory. You're limited to images that are at most 2^31 bytes large (~2.1 GB) due to browser limitations.

Features

  • 3 axis visualization of 3D images.
  • Grayscale images with segmentation overlay.
  • Segmentation selection with brush tools.
  • Direct voxel painting.
  • Save segmentation as .npy or .ckl, an advanced compresssion format.
  • Undo/Redo

3D Image Support

  • 8-bit grayscale 3D images
  • color images (including 3 channel 3D images)
  • floating point images
  • boolean images
  • segmentation labels
  • .npy, .ckl, .nrrd, or .nii format

For .ckl, .nrrd, and .nii formats, you must install crackle-codec, pynrrd, and nibabel respectively. All are installed by the "all_formats" optional installation argument.

3D Object Support

  • osteoid Skeletons
    • Color By: Connected Component, Radius, Cross Sectional Area
  • zmesh and CloudVolume Meshes
  • Point Clouds
  • Bounding Boxes

Example

import numpy as np
import zmesh
import kimimaro
import crackle
import microviewer
from osteoid.lib import Bbox

labels = crackle.load("connectomics.npy.ckl.gz", label=62347522)
resolution = np.array([16,16,40])

skel = kimimaro.skeletonize(
  labels, 
  teasar_params={
    'scale': 3,
    'pdrf_exponent': 8,
  },
  anisotropy=resolution,
)[1]

mesher = zmesh.Mesher(resolution)
mesher.mesh(labels)
mesh = mesher.get(1)

bbox = Bbox([0,0,0], np.array(labels.shape) * resolution)

microviewer.objects([ bbox, mesh, skel ], skeleton_color_by='radius')


# x = cross sectional area (if precomputed)
# r = radius (if precomputed, but usually is)
# c = connected components
microviewer.objects([ bbox, mesh, skel ], skeleton_color_by='x', skeleton_heatmap={
  "min": 100, # automatically determined if unspecified
  "max": 100000, # automatically determined if unspecified
  "scale": "log", # linear (default) or log
})

3D object display in microviewer via vtk

Installation

pip install microviewer

By default, only .npy files are supported. Additional formats are supported via optional downloads.

Possible optional arguments:

all_formats, nii, nrrd, ckl, jxl,
objects,
all

Note: jxl and objects have relatively heavy downloads.

pip install "microviewer[all]"

History

This microviewer package has been a part of CloudVolume since 2018, but is now broken out into its own package for more flexible wider use. Microviewer uses a modified version of https://github.com/seung-lab/data-cube-x/ (2016) to represent the array in Javascript, which was originally developed for eyewire.org.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

microviewer-1.20.0.tar.gz (1.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

microviewer-1.20.0-py3-none-any.whl (160.9 kB view details)

Uploaded Python 3

File details

Details for the file microviewer-1.20.0.tar.gz.

File metadata

  • Download URL: microviewer-1.20.0.tar.gz
  • Upload date:
  • Size: 1.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for microviewer-1.20.0.tar.gz
Algorithm Hash digest
SHA256 84e4955bedf5a2c8432f3d1a025136cfee6e4ccbd3eead2e8e433f2effc8da00
MD5 8a485022260ab7eddd8a30a9bba1ea40
BLAKE2b-256 aab47915daac9c32e3c63db6238ac666fd42ff2f317af63c4bf1ccc8d353db92

See more details on using hashes here.

File details

Details for the file microviewer-1.20.0-py3-none-any.whl.

File metadata

  • Download URL: microviewer-1.20.0-py3-none-any.whl
  • Upload date:
  • Size: 160.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for microviewer-1.20.0-py3-none-any.whl
Algorithm Hash digest
SHA256 31cffb4f27e20c1a78154429cfabef173187a77d6ccae7dc79b5f20526cf4fea
MD5 752c9280ee347a2b7374cc97703cd4e9
BLAKE2b-256 43b7b1dab5f4e0532765c1559e72705d2a34f858972e4f20a97e7b0b256405fc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page