Python package for evaluating neuron segmentations in terms of the number of splits and merges
Project description
segmentation-skeleton-metrics
The SkeletonMetric class is designed to evaluate the quality of a predicted segmentation by comparing it to ground truth skeletons.
Features
Metrics Computed: The class provides metrics to evaluate segmentation quality:
- Number of Splits: Measures how often a single segment is incorrectly split into multiple segments.
- Number of Merges: Measures how often multiple segments are incorrectly merged into a single segment.
- Percentage of Omit Edges: Proportion of edges in the ground truth that are omitted in the predicted segmentation.
- Percentage of Merged Edges: Proportion of edges that are merged in the predicted segmentation compared to the ground truth.
- Edge Accuracy: Evaluates how accurately the edges of the predicted segmentation match the ground truth.
- Expected Run Length (ERL): Expected length of segments or edges in the predicted segmentation.
Usage
Here is a simple example of evaluating a predicted segmentation. Note that this package supports a number of different input types, see documentation for details.
import os
from aind_segmentation_evaluation.evaluate import run_evaluation
from aind_segmentation_evaluation.conversions import volume_to_graph
from tifffile import imread
if __name__ == "__main__":
# Initializations
data_dir = "./resources"
target_graphs_dir = os.path.join(data_dir, "target_graphs")
path_to_target_labels = os.path.join(data_dir, "target_labels.tif")
pred_labels = imread(os.path.join(data_dir, "pred_labels.tif"))
pred_graphs = volume_to_graph(pred_labels)
# Evaluation
stats = run_evaluation(
target_graphs_dir,
path_to_target_labels,
pred_graphs,
pred_labels,
filetype="tif",
output="tif",
output_dir=data_dir,
permute=[2, 1, 0],
scale=[1.101, 1.101, 1.101],
)
# Write out results
print("Graph-based evaluation...")
for key in stats.keys():
print(" {}: {}".format(key, stats[key])
Installation
To use the software, in the root directory, run
pip install -e .
To develop the code, run
pip install -e .[dev]
To install this package from PyPI, run
pip install aind-segmentation-evaluation
Pull requests
For internal members, please create a branch. For external members, please fork the repository and open a pull request from the fork. We'll primarily use Angular style for commit messages. Roughly, they should follow the pattern:
<type>(<scope>): <short summary>
where scope (optional) describes the packages affected by the code changes and type (mandatory) is one of:
- build: Changes that affect build tools or external dependencies (example scopes: pyproject.toml, setup.py)
- ci: Changes to our CI configuration files and scripts (examples: .github/workflows/ci.yml)
- docs: Documentation only changes
- feat: A new feature
- fix: A bugfix
- perf: A code change that improves performance
- refactor: A code change that neither fixes a bug nor adds a feature
- test: Adding missing tests or correcting existing tests
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for segmentation_skeleton_metrics-4.8.8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e49fff7673126f24f6241458ff9a14c5e5b3952c4353901d372dfc39f71532c7 |
|
MD5 | 9cb8e75d214a64472dd14b25b4a61633 |
|
BLAKE2b-256 | a529797c12a86371593af8407e7db54c489dfc6bcff671346a5172843fc1dd9c |
Hashes for segmentation_skeleton_metrics-4.8.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23198b02f1c7fe10a5f8f90d42815a6748b53ade4f94e4a971c351f778d2c49c |
|
MD5 | 6a68d7498f6d086c80cbc75c3f9d7da7 |
|
BLAKE2b-256 | 56ea9d5380ae80e87173c76202fdc72599d5283d144629a2c37a6bd6fdc20c3f |