segmentation-skeleton-metrics 0.1.49__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- segmentation_skeleton_metrics-0.1.49/.flake8 +6 -0
- segmentation_skeleton_metrics-0.1.49/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- segmentation_skeleton_metrics-0.1.49/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- segmentation_skeleton_metrics-0.1.49/.github/ISSUE_TEMPLATE/user-story.md +27 -0
- segmentation_skeleton_metrics-0.1.49/.github/workflows/lint_and_test.yml +27 -0
- segmentation_skeleton_metrics-0.1.49/.github/workflows/tag_and_publish.yml +30 -0
- segmentation_skeleton_metrics-0.1.49/.gitignore +139 -0
- segmentation_skeleton_metrics-0.1.49/CHANGELOG.md +3 -0
- segmentation_skeleton_metrics-0.1.49/LICENSE +21 -0
- segmentation_skeleton_metrics-0.1.49/PKG-INFO +96 -0
- segmentation_skeleton_metrics-0.1.49/README.md +84 -0
- segmentation_skeleton_metrics-0.1.49/doc_template/Makefile +20 -0
- segmentation_skeleton_metrics-0.1.49/doc_template/make.bat +35 -0
- segmentation_skeleton_metrics-0.1.49/doc_template/source/_static/dark-logo.svg +129 -0
- segmentation_skeleton_metrics-0.1.49/doc_template/source/_static/favicon.ico +0 -0
- segmentation_skeleton_metrics-0.1.49/doc_template/source/_static/light-logo.svg +128 -0
- segmentation_skeleton_metrics-0.1.49/doc_template/source/conf.py +50 -0
- segmentation_skeleton_metrics-0.1.49/doc_template/source/index.rst +22 -0
- segmentation_skeleton_metrics-0.1.49/pyproject.toml +80 -0
- segmentation_skeleton_metrics-0.1.49/resources/pred_labels.tif +0 -0
- segmentation_skeleton_metrics-0.1.49/resources/target_graphs/0.swc +1411 -0
- segmentation_skeleton_metrics-0.1.49/resources/target_graphs/1.swc +28 -0
- segmentation_skeleton_metrics-0.1.49/resources/target_graphs/2.swc +61 -0
- segmentation_skeleton_metrics-0.1.49/resources/target_graphs/3.swc +61 -0
- segmentation_skeleton_metrics-0.1.49/resources/target_graphs/4.swc +19 -0
- segmentation_skeleton_metrics-0.1.49/resources/target_graphs/5.swc +25 -0
- segmentation_skeleton_metrics-0.1.49/resources/target_labels.tif +0 -0
- segmentation_skeleton_metrics-0.1.49/setup.cfg +4 -0
- segmentation_skeleton_metrics-0.1.49/setup.py +5 -0
- segmentation_skeleton_metrics-0.1.49/src/segmentation_skeleton_metrics/__init__.py +4 -0
- segmentation_skeleton_metrics-0.1.49/src/segmentation_skeleton_metrics/evaluate.py +187 -0
- segmentation_skeleton_metrics-0.1.49/src/segmentation_skeleton_metrics/merge_metric.py +149 -0
- segmentation_skeleton_metrics-0.1.49/src/segmentation_skeleton_metrics/nx_utils.py +68 -0
- segmentation_skeleton_metrics-0.1.49/src/segmentation_skeleton_metrics/seg_metrics.py +321 -0
- segmentation_skeleton_metrics-0.1.49/src/segmentation_skeleton_metrics/split_metric.py +101 -0
- segmentation_skeleton_metrics-0.1.49/src/segmentation_skeleton_metrics/swc_utils.py +235 -0
- segmentation_skeleton_metrics-0.1.49/src/segmentation_skeleton_metrics/utils.py +224 -0
- segmentation_skeleton_metrics-0.1.49/src/segmentation_skeleton_metrics.egg-info/PKG-INFO +96 -0
- segmentation_skeleton_metrics-0.1.49/src/segmentation_skeleton_metrics.egg-info/SOURCES.txt +41 -0
- segmentation_skeleton_metrics-0.1.49/src/segmentation_skeleton_metrics.egg-info/dependency_links.txt +1 -0
- segmentation_skeleton_metrics-0.1.49/src/segmentation_skeleton_metrics.egg-info/requires.txt +16 -0
- segmentation_skeleton_metrics-0.1.49/src/segmentation_skeleton_metrics.egg-info/top_level.txt +1 -0
- segmentation_skeleton_metrics-0.1.49/tests/__init__.py +1 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Create a report to help us improve
|
|
4
|
+
title: ''
|
|
5
|
+
labels: ''
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Describe the bug**
|
|
11
|
+
A clear and concise description of what the bug is.
|
|
12
|
+
|
|
13
|
+
**To Reproduce**
|
|
14
|
+
Steps to reproduce the behavior:
|
|
15
|
+
1. Go to '...'
|
|
16
|
+
2. Click on '....'
|
|
17
|
+
3. Scroll down to '....'
|
|
18
|
+
4. See error
|
|
19
|
+
|
|
20
|
+
**Expected behavior**
|
|
21
|
+
A clear and concise description of what you expected to happen.
|
|
22
|
+
|
|
23
|
+
**Screenshots**
|
|
24
|
+
If applicable, add screenshots to help explain your problem.
|
|
25
|
+
|
|
26
|
+
**Desktop (please complete the following information):**
|
|
27
|
+
- OS: [e.g. iOS]
|
|
28
|
+
- Browser [e.g. chrome, safari]
|
|
29
|
+
- Version [e.g. 22]
|
|
30
|
+
|
|
31
|
+
**Smartphone (please complete the following information):**
|
|
32
|
+
- Device: [e.g. iPhone6]
|
|
33
|
+
- OS: [e.g. iOS8.1]
|
|
34
|
+
- Browser [e.g. stock browser, safari]
|
|
35
|
+
- Version [e.g. 22]
|
|
36
|
+
|
|
37
|
+
**Additional context**
|
|
38
|
+
Add any other context about the problem here.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature request
|
|
3
|
+
about: Suggest an idea for this project
|
|
4
|
+
title: ''
|
|
5
|
+
labels: ''
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Is your feature request related to a problem? Please describe.**
|
|
11
|
+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
12
|
+
|
|
13
|
+
**Describe the solution you'd like**
|
|
14
|
+
A clear and concise description of what you want to happen.
|
|
15
|
+
|
|
16
|
+
**Describe alternatives you've considered**
|
|
17
|
+
A clear and concise description of any alternative solutions or features you've considered.
|
|
18
|
+
|
|
19
|
+
**Additional context**
|
|
20
|
+
Add any other context or screenshots about the feature request here.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: User story
|
|
3
|
+
about: This template provides a basic structure for user story issues.
|
|
4
|
+
title: ''
|
|
5
|
+
labels: ''
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# User story
|
|
11
|
+
As a ..., I want to ..., so I can ...
|
|
12
|
+
|
|
13
|
+
*Ideally, this is in the issue title, but if not, you can put it here. If so, delete this section.*
|
|
14
|
+
|
|
15
|
+
# Acceptance criteria
|
|
16
|
+
- [ ] This is something that can be verified to show that this user story is satisfied.
|
|
17
|
+
|
|
18
|
+
# Sprint Ready Checklist
|
|
19
|
+
- [ ] 1. Acceptance criteria defined
|
|
20
|
+
- [ ] 2. Team understands acceptance criteria
|
|
21
|
+
- [ ] 3. Team has defined solution / steps to satisfy acceptance criteria
|
|
22
|
+
- [ ] 4. Acceptance criteria is verifiable / testable
|
|
23
|
+
- [ ] 5. External / 3rd Party dependencies identified
|
|
24
|
+
- [ ] 6. Ticket is prioritized and sized
|
|
25
|
+
|
|
26
|
+
# Notes
|
|
27
|
+
*Add any helpful notes here.*
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: Lint and run tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
ci:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
matrix:
|
|
13
|
+
python-version: [ '3.8', '3.9', '3.10' ]
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v3
|
|
16
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
17
|
+
uses: actions/setup-python@v3
|
|
18
|
+
with:
|
|
19
|
+
python-version: ${{ matrix.python-version }}
|
|
20
|
+
- name: Install dependencies
|
|
21
|
+
run: |
|
|
22
|
+
python -m pip install -e .[dev]
|
|
23
|
+
- name: Run linter checks
|
|
24
|
+
run: flake8 . && interrogate --verbose .
|
|
25
|
+
- name: Run tests and coverage
|
|
26
|
+
run: coverage run -m unittest discover && coverage report
|
|
27
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: Tag and publish
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- main
|
|
6
|
+
jobs:
|
|
7
|
+
tag:
|
|
8
|
+
uses: AllenNeuralDynamics/aind-github-actions/.github/workflows/tag.yml@main
|
|
9
|
+
secrets:
|
|
10
|
+
SERVICE_TOKEN: ${{ secrets.SERVICE_TOKEN }}
|
|
11
|
+
publish:
|
|
12
|
+
needs: tag
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v3
|
|
16
|
+
- name: Pull latest changes
|
|
17
|
+
run: git pull origin main
|
|
18
|
+
- name: Set up Python 3.8
|
|
19
|
+
uses: actions/setup-python@v2
|
|
20
|
+
with:
|
|
21
|
+
python-version: 3.8
|
|
22
|
+
- name: Install dependencies
|
|
23
|
+
run: |
|
|
24
|
+
pip install --upgrade setuptools wheel twine build
|
|
25
|
+
python -m build
|
|
26
|
+
twine check dist/*
|
|
27
|
+
- name: Publish on PyPI
|
|
28
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
29
|
+
with:
|
|
30
|
+
password: ${{ secrets.AIND_PYPI_TOKEN }}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
pip-wheel-metadata/
|
|
24
|
+
share/python-wheels/
|
|
25
|
+
*.egg-info/
|
|
26
|
+
.installed.cfg
|
|
27
|
+
*.egg
|
|
28
|
+
MANIFEST
|
|
29
|
+
|
|
30
|
+
# PyInstaller
|
|
31
|
+
# Usually these files are written by a python script from a template
|
|
32
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
33
|
+
*.manifest
|
|
34
|
+
*.spec
|
|
35
|
+
|
|
36
|
+
# Installer logs
|
|
37
|
+
pip-log.txt
|
|
38
|
+
pip-delete-this-directory.txt
|
|
39
|
+
|
|
40
|
+
# Unit test / coverage reports
|
|
41
|
+
htmlcov/
|
|
42
|
+
.tox/
|
|
43
|
+
.nox/
|
|
44
|
+
.coverage
|
|
45
|
+
.coverage.*
|
|
46
|
+
.cache
|
|
47
|
+
nosetests.xml
|
|
48
|
+
coverage.xml
|
|
49
|
+
*.cover
|
|
50
|
+
*.py,cover
|
|
51
|
+
.hypothesis/
|
|
52
|
+
.pytest_cache/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
target/
|
|
76
|
+
|
|
77
|
+
# Jupyter Notebook
|
|
78
|
+
.ipynb_checkpoints
|
|
79
|
+
|
|
80
|
+
# IPython
|
|
81
|
+
profile_default/
|
|
82
|
+
ipython_config.py
|
|
83
|
+
|
|
84
|
+
# pyenv
|
|
85
|
+
.python-version
|
|
86
|
+
|
|
87
|
+
# pipenv
|
|
88
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
89
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
90
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
91
|
+
# install all needed dependencies.
|
|
92
|
+
#Pipfile.lock
|
|
93
|
+
|
|
94
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
|
95
|
+
__pypackages__/
|
|
96
|
+
|
|
97
|
+
# Celery stuff
|
|
98
|
+
celerybeat-schedule
|
|
99
|
+
celerybeat.pid
|
|
100
|
+
|
|
101
|
+
# SageMath parsed files
|
|
102
|
+
*.sage.py
|
|
103
|
+
|
|
104
|
+
# Environments
|
|
105
|
+
.env
|
|
106
|
+
.venv
|
|
107
|
+
env/
|
|
108
|
+
venv/
|
|
109
|
+
ENV/
|
|
110
|
+
env.bak/
|
|
111
|
+
venv.bak/
|
|
112
|
+
|
|
113
|
+
# Spyder project settings
|
|
114
|
+
.spyderproject
|
|
115
|
+
.spyproject
|
|
116
|
+
|
|
117
|
+
# Rope project settings
|
|
118
|
+
.ropeproject
|
|
119
|
+
|
|
120
|
+
# mkdocs documentation
|
|
121
|
+
/site
|
|
122
|
+
|
|
123
|
+
# mypy
|
|
124
|
+
.mypy_cache/
|
|
125
|
+
.dmypy.json
|
|
126
|
+
dmypy.json
|
|
127
|
+
|
|
128
|
+
# Pyre type checker
|
|
129
|
+
.pyre/
|
|
130
|
+
|
|
131
|
+
# PyCharm
|
|
132
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
133
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
134
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
135
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
136
|
+
.idea/
|
|
137
|
+
|
|
138
|
+
# MacOs
|
|
139
|
+
**/.DS_Store
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Allen Institute for Neural Dynamics
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: segmentation_skeleton_metrics
|
|
3
|
+
Version: 0.1.49
|
|
4
|
+
Summary: Python package for evaluating neuron segmentations in terms of the number of splits and merges
|
|
5
|
+
Author-email: Anna Grim <anna.grim@alleninstitute.org>
|
|
6
|
+
License: MIT
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Requires-Python: >=3.7
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Provides-Extra: dev
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
|
|
13
|
+
# segmentation-skeleton-metrics
|
|
14
|
+
|
|
15
|
+
[](LICENSE)
|
|
16
|
+

|
|
17
|
+
|
|
18
|
+
[](https://github.com/semantic-release/semantic-release)
|
|
19
|
+
|
|
20
|
+
Python package for performing a skeleton-based evaluation of a predicted segmentation of neural arbors. This tool detects topological mistakes (i.e. splits and merges) in the predicted segmentation by comparing it to the ground truth skeleton. Once this comparison is complete, several statistics (e.g. edge accuracy, split count, merge count) are computed and returned in a dictionary. There is also an optional to write either tiff or swc files that highlight each topological mistake.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
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.
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
import os
|
|
29
|
+
|
|
30
|
+
from aind_segmentation_evaluation.evaluate import run_evaluation
|
|
31
|
+
from aind_segmentation_evaluation.conversions import volume_to_graph
|
|
32
|
+
from tifffile import imread
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
if __name__ == "__main__":
|
|
36
|
+
|
|
37
|
+
# Initializations
|
|
38
|
+
data_dir = "./resources"
|
|
39
|
+
target_graphs_dir = os.path.join(data_dir, "target_graphs")
|
|
40
|
+
path_to_target_labels = os.path.join(data_dir, "target_labels.tif")
|
|
41
|
+
pred_labels = imread(os.path.join(data_dir, "pred_labels.tif"))
|
|
42
|
+
pred_graphs = volume_to_graph(pred_labels)
|
|
43
|
+
|
|
44
|
+
# Evaluation
|
|
45
|
+
stats = run_evaluation(
|
|
46
|
+
target_graphs_dir,
|
|
47
|
+
path_to_target_labels,
|
|
48
|
+
pred_graphs,
|
|
49
|
+
pred_labels,
|
|
50
|
+
filetype="tif",
|
|
51
|
+
output="tif",
|
|
52
|
+
output_dir=data_dir,
|
|
53
|
+
permute=[2, 1, 0],
|
|
54
|
+
scale=[1.101, 1.101, 1.101],
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
# Write out results
|
|
58
|
+
print("Graph-based evaluation...")
|
|
59
|
+
for key in stats.keys():
|
|
60
|
+
print(" {}: {}".format(key, stats[key])
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Installation
|
|
65
|
+
To use the software, in the root directory, run
|
|
66
|
+
```bash
|
|
67
|
+
pip install -e .
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
To develop the code, run
|
|
71
|
+
```bash
|
|
72
|
+
pip install -e .[dev]
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
To install this package from PyPI, run
|
|
76
|
+
```bash
|
|
77
|
+
pip install aind-segmentation-evaluation
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Pull requests
|
|
81
|
+
|
|
82
|
+
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](https://github.com/angular/angular/blob/main/CONTRIBUTING.md#commit) style for commit messages. Roughly, they should follow the pattern:
|
|
83
|
+
```text
|
|
84
|
+
<type>(<scope>): <short summary>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
where scope (optional) describes the packages affected by the code changes and type (mandatory) is one of:
|
|
88
|
+
|
|
89
|
+
- **build**: Changes that affect build tools or external dependencies (example scopes: pyproject.toml, setup.py)
|
|
90
|
+
- **ci**: Changes to our CI configuration files and scripts (examples: .github/workflows/ci.yml)
|
|
91
|
+
- **docs**: Documentation only changes
|
|
92
|
+
- **feat**: A new feature
|
|
93
|
+
- **fix**: A bugfix
|
|
94
|
+
- **perf**: A code change that improves performance
|
|
95
|
+
- **refactor**: A code change that neither fixes a bug nor adds a feature
|
|
96
|
+
- **test**: Adding missing tests or correcting existing tests
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# segmentation-skeleton-metrics
|
|
2
|
+
|
|
3
|
+
[](LICENSE)
|
|
4
|
+

|
|
5
|
+
|
|
6
|
+
[](https://github.com/semantic-release/semantic-release)
|
|
7
|
+
|
|
8
|
+
Python package for performing a skeleton-based evaluation of a predicted segmentation of neural arbors. This tool detects topological mistakes (i.e. splits and merges) in the predicted segmentation by comparing it to the ground truth skeleton. Once this comparison is complete, several statistics (e.g. edge accuracy, split count, merge count) are computed and returned in a dictionary. There is also an optional to write either tiff or swc files that highlight each topological mistake.
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
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.
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
import os
|
|
17
|
+
|
|
18
|
+
from aind_segmentation_evaluation.evaluate import run_evaluation
|
|
19
|
+
from aind_segmentation_evaluation.conversions import volume_to_graph
|
|
20
|
+
from tifffile import imread
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
if __name__ == "__main__":
|
|
24
|
+
|
|
25
|
+
# Initializations
|
|
26
|
+
data_dir = "./resources"
|
|
27
|
+
target_graphs_dir = os.path.join(data_dir, "target_graphs")
|
|
28
|
+
path_to_target_labels = os.path.join(data_dir, "target_labels.tif")
|
|
29
|
+
pred_labels = imread(os.path.join(data_dir, "pred_labels.tif"))
|
|
30
|
+
pred_graphs = volume_to_graph(pred_labels)
|
|
31
|
+
|
|
32
|
+
# Evaluation
|
|
33
|
+
stats = run_evaluation(
|
|
34
|
+
target_graphs_dir,
|
|
35
|
+
path_to_target_labels,
|
|
36
|
+
pred_graphs,
|
|
37
|
+
pred_labels,
|
|
38
|
+
filetype="tif",
|
|
39
|
+
output="tif",
|
|
40
|
+
output_dir=data_dir,
|
|
41
|
+
permute=[2, 1, 0],
|
|
42
|
+
scale=[1.101, 1.101, 1.101],
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
# Write out results
|
|
46
|
+
print("Graph-based evaluation...")
|
|
47
|
+
for key in stats.keys():
|
|
48
|
+
print(" {}: {}".format(key, stats[key])
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
To use the software, in the root directory, run
|
|
54
|
+
```bash
|
|
55
|
+
pip install -e .
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
To develop the code, run
|
|
59
|
+
```bash
|
|
60
|
+
pip install -e .[dev]
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
To install this package from PyPI, run
|
|
64
|
+
```bash
|
|
65
|
+
pip install aind-segmentation-evaluation
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Pull requests
|
|
69
|
+
|
|
70
|
+
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](https://github.com/angular/angular/blob/main/CONTRIBUTING.md#commit) style for commit messages. Roughly, they should follow the pattern:
|
|
71
|
+
```text
|
|
72
|
+
<type>(<scope>): <short summary>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
where scope (optional) describes the packages affected by the code changes and type (mandatory) is one of:
|
|
76
|
+
|
|
77
|
+
- **build**: Changes that affect build tools or external dependencies (example scopes: pyproject.toml, setup.py)
|
|
78
|
+
- **ci**: Changes to our CI configuration files and scripts (examples: .github/workflows/ci.yml)
|
|
79
|
+
- **docs**: Documentation only changes
|
|
80
|
+
- **feat**: A new feature
|
|
81
|
+
- **fix**: A bugfix
|
|
82
|
+
- **perf**: A code change that improves performance
|
|
83
|
+
- **refactor**: A code change that neither fixes a bug nor adds a feature
|
|
84
|
+
- **test**: Adding missing tests or correcting existing tests
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Minimal makefile for Sphinx documentation
|
|
2
|
+
#
|
|
3
|
+
|
|
4
|
+
# You can set these variables from the command line, and also
|
|
5
|
+
# from the environment for the first two.
|
|
6
|
+
SPHINXOPTS ?=
|
|
7
|
+
SPHINXBUILD ?= sphinx-build
|
|
8
|
+
SOURCEDIR = source
|
|
9
|
+
BUILDDIR = build
|
|
10
|
+
|
|
11
|
+
# Put it first so that "make" without argument is like "make help".
|
|
12
|
+
help:
|
|
13
|
+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
14
|
+
|
|
15
|
+
.PHONY: help Makefile
|
|
16
|
+
|
|
17
|
+
# Catch-all target: route all unknown targets to Sphinx using the new
|
|
18
|
+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
|
19
|
+
%: Makefile
|
|
20
|
+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
@ECHO OFF
|
|
2
|
+
|
|
3
|
+
pushd %~dp0
|
|
4
|
+
|
|
5
|
+
REM Command file for Sphinx documentation
|
|
6
|
+
|
|
7
|
+
if "%SPHINXBUILD%" == "" (
|
|
8
|
+
set SPHINXBUILD=sphinx-build
|
|
9
|
+
)
|
|
10
|
+
set SOURCEDIR=source
|
|
11
|
+
set BUILDDIR=build
|
|
12
|
+
|
|
13
|
+
%SPHINXBUILD% >NUL 2>NUL
|
|
14
|
+
if errorlevel 9009 (
|
|
15
|
+
echo.
|
|
16
|
+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
|
17
|
+
echo.installed, then set the SPHINXBUILD environment variable to point
|
|
18
|
+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
|
19
|
+
echo.may add the Sphinx directory to PATH.
|
|
20
|
+
echo.
|
|
21
|
+
echo.If you don't have Sphinx installed, grab it from
|
|
22
|
+
echo.https://www.sphinx-doc.org/
|
|
23
|
+
exit /b 1
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
if "%1" == "" goto help
|
|
27
|
+
|
|
28
|
+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
|
29
|
+
goto end
|
|
30
|
+
|
|
31
|
+
:help
|
|
32
|
+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
|
33
|
+
|
|
34
|
+
:end
|
|
35
|
+
popd
|