MorphoTreeViz – Morphological Trees Visualization
Interactive visualization of morphological trees.
Quick Start (import mtviz as viz)
import mtviz as viz
class Node:
def __init__(self, id, level, area, children=None):
self.id = id
self.level = level
self.area = area
self.children = children or []
root = Node(1, 0, 10, [
Node(2, 1, 5, [Node(4, 2, 3), Node(5, 2, 2)]),
Node(3, 1, 5, [Node(6, 2, 1)])
])
pt = viz.PrintTree(lambda n: n.children, lambda n: f"{n.id}: {n.level}: {n.area}")
pt(root)
Color (optional)
- Pass ANSI codes in
color(e.g.,"\x1b[40m\x1b[37m"for black background + white text). - If you use
coloramain your project, you can passBack.BLACK + Fore.WHITE.
Interactive Tree (viz.makePlotTree)
Use Bokeh to visualize and interact with the tree: hover tooltips, click actions, flood tools, and size/zoom controls.
import mtviz as viz
from bokeh.io import show, output_notebook
output_notebook() # inline in Jupyter; use show(p) to open in browser
class Node:
def __init__(self, id, level, area, children=None):
self.id = id
self.level = level
self.area = area
self.children = children or []
root = Node(1, 0, 10, [
Node(2, 1, 5, [Node(4, 2, 3), Node(5, 2, 2)]),
Node(3, 1, 5, [Node(6, 2, 1)])
])
p = viz.makePlotTree(
root,
lambda n: n.children,
{
"id:": lambda n: n.id,
"level:": "level",
"area:": lambda n: n.area,
"repCNPs": lambda n: getattr(n, 'repCnps', []),
},
lambda n: n.id,
node_size=18,
flood_use=None,
)
show(p.panel)
Image Overlay + Flood
You can compose a figure with a grayscale image and an RGBA overlay, then link DrawTree’s flood tools.
import mtviz as viz
from bokeh.layouts import row, column
img = ... # 2D numpy array (grayscale)
bundle_img = viz.makePlotImage(img)
p_img = bundle_img.panel
img_source = bundle_img.source
alpha_slider = bundle_img.controls[0]
p_tree = viz.makePlotTree(
root,
lambda n: n.children,
{ "id:": lambda n: n.id, "repCNPs": lambda n: getattr(n, 'repCnps', []) },
lambda n: n.id,
image_source=img_source,
alpha_slider=alpha_slider,
flood_use='floodThreshold',
flood_params={'polarity': 255},
)
show(row(p_tree, column(alpha_slider, p_img)))
Pixel selection
makePlotImage exposes the last clicked pixel through
bundle.selection_source. The source contains one row with row, column,
index, and value, and is updated by CustomJS in the browser.
bundle = viz.makePlotImage(
img,
selected_pixel=(20, 35),
title="Click a pixel",
)
selection = bundle.selection_source
viz.show(bundle)
The selection source can drive other Bokeh models without a Bokeh server. For
the common morphological-tree use case, makePlotImageTreeInspector links one
image selector directly to the node support in several trees:
inspector = viz.makePlotImageTreeInspector(
img,
{
"Tree of Shapes": tree_of_shapes,
"Residual Tree": residual_tree,
},
initial_pixel=(20, 35),
width=520,
support_width=390,
)
viz.show(inspector)
The tree objects must expose num_nodes, smallest_node_map, and
parent(node). When available, node altitude, residue, proper-part size, and
branch length are included in the live readout. Clicking the input image
updates every support view immediately in standalone HTML and Jupyter output.
Metadata
Release files for MorphoTreeViz 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| morphotreeviz-0.0.5.tar.gz | 59.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| morphotreeviz-0.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 106.6 kB
Release files / morphotreeviz-0.0.5.tar.gz
| Download URL | morphotreeviz-0.0.5.tar.gz |
|---|---|
| Size | 59.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
82e9f3162ceaf49b76f5f255328e74b012e544f417d5634a17f2b2f8545a50f4
|
|
BLAKE2b-256 checksum How to use checksums |
ab2ab7adbd0a17aa8c7f69de547cce3c28f86750b58952f033a913947ae853b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / morphotreeviz-0.0.5-py3-none-any.whl
| Download URL | morphotreeviz-0.0.5-py3-none-any.whl |
|---|---|
| Size | 47.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bb9dce5be4a4aad465ef2ee66911f693b66543f37872d26e1e8c292f6df6a20d
|
|
BLAKE2b-256 checksum How to use checksums |
24bcde34ad84f5cd4d47d4f54050c70eb01b4ad7d1c7914f01bd7f768b4e6e4e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Security for MorphoTreeViz 0.0.5
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.