roottrait
Root traits from binary masks, and calibrated mask degradations for testing how segmentation error reaches them.
Root segmentation models are usually compared by Dice overlap, but the masks are used to measure
traits. roottrait measures how much error in each trait a given Dice permits:
traits: twelve root traits from a boolean mask (pixel area, total length, mean diameter, lacunarity, convex-hull area, bounding depth and width, tips, branch points, components, holes, fractal dimension), each labelled with its kind: integral, extremum, count or fitted.degrade: six named segmentation failures (dilation, erosion, thin-branch dropout, junction breaks, speckle, false blobs), each with one severity parameter.calibrate: bisection on severity so that a failure reaches an exact Dice loss on a given mask. Applied to one mask at one Dice, the six failures then differ only in how the pixels are wrong.decompose: assigns every wrong pixel of a prediction to one of four error kinds (over-inclusive, detached false positive, under-inclusive, lost structure).clean.fill_pinholes: fills one-pixel annotation holes, which otherwise turn into skeleton loops and inflate junction counts.graph(spur pruning, junction counting) andmorphology(four synthetic root architectures with independent thickness).
Install
pip install roottrait
The library needs only numpy, scipy and scikit-image.
Example
import numpy as np
from roottrait import DEGRADATIONS, SEVERITY_BOUNDS, TRAITS, dice, generate, solve_severity
mask = generate("taproot", size=256, seed=0, thickness=5)
truth = {name: fn(mask) for name, fn in TRAITS.items()}
for failure in ("boundary_dilate", "speckle"):
fn = DEGRADATIONS[failure][0]
lo, hi = SEVERITY_BOUNDS[failure]
severity, _ = solve_severity(fn, mask, 0.01, lo, hi, rng_seed=1) # Dice 0.99
degraded = fn(mask, severity, np.random.default_rng(1))
print(failure, round(dice(mask, degraded), 3),
"components", truth["n_components"], "->", TRAITS["n_components"](degraded))
Both degraded masks score the same Dice; the component count is unchanged by dilation and multiplied by speckle.
Licence
MIT.
Metadata
Release files for roottrait 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| roottrait-1.0.0.tar.gz | 16.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| roottrait-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 37.9 kB
Release files / roottrait-1.0.0.tar.gz
| Download URL | roottrait-1.0.0.tar.gz |
|---|---|
| Size | 16.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d06224b3baf04bc2ee4141efbd54d4f5438754f27e5f7578052937038a1f8154
|
|
BLAKE2b-256 checksum How to use checksums |
9f57cbc20755c37e92cf25aabe32026268b3091eee1ff809f0e08d278ce40304
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Release files / roottrait-1.0.0-py3-none-any.whl
| Download URL | roottrait-1.0.0-py3-none-any.whl |
|---|---|
| Size | 21.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d2ee99923c9e6ea0ff6ac10b4b82d69ffe3b6f95f87476eb9e70073398db036d
|
|
BLAKE2b-256 checksum How to use checksums |
7043ba346dd2e473d280fa70b6f54eb068604c8b24fbc9c0e9a1b3f649783914
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|