sct_ambiguities_analysis 1.0.0.dev0__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.
- sct_ambiguities_analysis-1.0.0.dev0/.gitignore +198 -0
- sct_ambiguities_analysis-1.0.0.dev0/LICENSE.txt +21 -0
- sct_ambiguities_analysis-1.0.0.dev0/PKG-INFO +103 -0
- sct_ambiguities_analysis-1.0.0.dev0/README.md +37 -0
- sct_ambiguities_analysis-1.0.0.dev0/pyproject.toml +112 -0
- sct_ambiguities_analysis-1.0.0.dev0/src/sct_ambiguities_analysis/__init__.py +9 -0
- sct_ambiguities_analysis-1.0.0.dev0/src/sct_ambiguities_analysis/cli.py +71 -0
- sct_ambiguities_analysis-1.0.0.dev0/src/sct_ambiguities_analysis/config.py +32 -0
- sct_ambiguities_analysis-1.0.0.dev0/src/sct_ambiguities_analysis/core/__init__.py +8 -0
- sct_ambiguities_analysis-1.0.0.dev0/src/sct_ambiguities_analysis/core/analysis.py +65 -0
- sct_ambiguities_analysis-1.0.0.dev0/src/sct_ambiguities_analysis/interface.py +47 -0
- sct_ambiguities_analysis-1.0.0.dev0/src/sct_ambiguities_analysis/main.py +64 -0
- sct_ambiguities_analysis-1.0.0.dev0/src/sct_ambiguities_analysis/resources/__init__.py +8 -0
- sct_ambiguities_analysis-1.0.0.dev0/src/sct_ambiguities_analysis/resources/config_schema.json +38 -0
- sct_ambiguities_analysis-1.0.0.dev0/tests/__init__.py +4 -0
- sct_ambiguities_analysis-1.0.0.dev0/tests/unittest/__init__.py +4 -0
- sct_ambiguities_analysis-1.0.0.dev0/tests/unittest/test_cli.py +32 -0
- sct_ambiguities_analysis-1.0.0.dev0/tests/unittest/test_core_analysis.py +96 -0
- sct_ambiguities_analysis-1.0.0.dev0/tests/unittest/test_main.py +69 -0
- sct_ambiguities_analysis-1.0.0.dev0/tests/unittest/test_plugin_interface.py +72 -0
- sct_ambiguities_analysis-1.0.0.dev0/tests/unittest/test_tar_config.py +112 -0
|
@@ -0,0 +1,198 @@
|
|
|
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
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
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
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# poetry
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
102
|
+
#poetry.lock
|
|
103
|
+
|
|
104
|
+
# pdm
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
106
|
+
#pdm.lock
|
|
107
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
108
|
+
# in version control.
|
|
109
|
+
# https://pdm-project.org/#use-with-ide
|
|
110
|
+
.pdm.toml
|
|
111
|
+
.pdm-python
|
|
112
|
+
.pdm-build/
|
|
113
|
+
|
|
114
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
115
|
+
__pypackages__/
|
|
116
|
+
|
|
117
|
+
# Celery stuff
|
|
118
|
+
celerybeat-schedule
|
|
119
|
+
celerybeat.pid
|
|
120
|
+
|
|
121
|
+
# SageMath parsed files
|
|
122
|
+
*.sage.py
|
|
123
|
+
|
|
124
|
+
# Environments
|
|
125
|
+
.env
|
|
126
|
+
.venv
|
|
127
|
+
env/
|
|
128
|
+
venv/
|
|
129
|
+
ENV/
|
|
130
|
+
env.bak/
|
|
131
|
+
venv.bak/
|
|
132
|
+
|
|
133
|
+
# Spyder project settings
|
|
134
|
+
.spyderproject
|
|
135
|
+
.spyproject
|
|
136
|
+
|
|
137
|
+
# Rope project settings
|
|
138
|
+
.ropeproject
|
|
139
|
+
|
|
140
|
+
# mkdocs documentation
|
|
141
|
+
/site
|
|
142
|
+
|
|
143
|
+
# mypy
|
|
144
|
+
.mypy_cache/
|
|
145
|
+
.dmypy.json
|
|
146
|
+
dmypy.json
|
|
147
|
+
|
|
148
|
+
# Pyre type checker
|
|
149
|
+
.pyre/
|
|
150
|
+
|
|
151
|
+
# pytype static type analyzer
|
|
152
|
+
.pytype/
|
|
153
|
+
|
|
154
|
+
# Cython debug symbols
|
|
155
|
+
cython_debug/
|
|
156
|
+
|
|
157
|
+
# PyCharm
|
|
158
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
159
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
160
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
161
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
162
|
+
#.idea/
|
|
163
|
+
|
|
164
|
+
# Distribution / packaging
|
|
165
|
+
build/
|
|
166
|
+
_build/
|
|
167
|
+
dist/
|
|
168
|
+
*.egg-info/
|
|
169
|
+
.ipynb_checkpoints/
|
|
170
|
+
.nox
|
|
171
|
+
|
|
172
|
+
# Pyenv
|
|
173
|
+
.python-version
|
|
174
|
+
|
|
175
|
+
# VS Code project settings
|
|
176
|
+
.vscode
|
|
177
|
+
|
|
178
|
+
# PyCharm project settings
|
|
179
|
+
.idea
|
|
180
|
+
|
|
181
|
+
# Spyder project settings
|
|
182
|
+
.spyproject
|
|
183
|
+
|
|
184
|
+
# Environments
|
|
185
|
+
venv*
|
|
186
|
+
|
|
187
|
+
# Docker
|
|
188
|
+
docker-compose.yml
|
|
189
|
+
Dockerfile
|
|
190
|
+
.devcontainer
|
|
191
|
+
|
|
192
|
+
# Other
|
|
193
|
+
*.bak
|
|
194
|
+
.coverage
|
|
195
|
+
htmlcov
|
|
196
|
+
*.svg
|
|
197
|
+
|
|
198
|
+
pdm.lock
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (C) Aresys S.r.l. <info@aresys.it>
|
|
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,103 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: sct_ambiguities_analysis
|
|
3
|
+
Version: 1.0.0.dev0
|
|
4
|
+
Summary: SCT Plugin for Point and Distributed Ambiguity Ratio Analysis of L1 SAR Products.
|
|
5
|
+
Project-URL: Homepage, https://github.com/aresys-srl/sct_plugins_analyses
|
|
6
|
+
Project-URL: Repository, https://github.com/aresys-srl/sct_plugins_analyses
|
|
7
|
+
Project-URL: Documentation, https://opensource.aresys.it/sct_plugins_analyses
|
|
8
|
+
Author-email: "Aresys S.R.L." <info@aresys.it>
|
|
9
|
+
License: MIT License
|
|
10
|
+
|
|
11
|
+
Copyright (C) Aresys S.r.l. <info@aresys.it>
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
in the Software without restriction, including without limitation the rights
|
|
16
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
furnished to do so, subject to the following conditions:
|
|
19
|
+
|
|
20
|
+
The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
SOFTWARE.
|
|
30
|
+
License-File: LICENSE.txt
|
|
31
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
32
|
+
Classifier: Intended Audience :: Developers
|
|
33
|
+
Classifier: Intended Audience :: Education
|
|
34
|
+
Classifier: Intended Audience :: Science/Research
|
|
35
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
36
|
+
Classifier: Natural Language :: English
|
|
37
|
+
Classifier: Operating System :: OS Independent
|
|
38
|
+
Classifier: Programming Language :: Python
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
42
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
43
|
+
Classifier: Topic :: Scientific/Engineering
|
|
44
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
45
|
+
Classifier: Topic :: Utilities
|
|
46
|
+
Classifier: Typing :: Typed
|
|
47
|
+
Requires-Python: >=3.11
|
|
48
|
+
Requires-Dist: jsonschema
|
|
49
|
+
Requires-Dist: numpy>2
|
|
50
|
+
Requires-Dist: perseo-core>=1.0.0
|
|
51
|
+
Requires-Dist: perseo-quality>=1.1.0
|
|
52
|
+
Requires-Dist: sct
|
|
53
|
+
Requires-Dist: typer>=0.24.1
|
|
54
|
+
Provides-Extra: dev
|
|
55
|
+
Requires-Dist: pylint; extra == 'dev'
|
|
56
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
57
|
+
Provides-Extra: docs
|
|
58
|
+
Requires-Dist: mkdocstrings-python; extra == 'docs'
|
|
59
|
+
Requires-Dist: zensical; extra == 'docs'
|
|
60
|
+
Provides-Extra: test
|
|
61
|
+
Requires-Dist: pytest; extra == 'test'
|
|
62
|
+
Requires-Dist: pytest-cov; extra == 'test'
|
|
63
|
+
Requires-Dist: pytest-mock; extra == 'test'
|
|
64
|
+
Requires-Dist: sct[graphs]>=3.1.0; extra == 'test'
|
|
65
|
+
Description-Content-Type: text/markdown
|
|
66
|
+
|
|
67
|
+
# SCT Plugin: Ambiguity Ratio Analysis
|
|
68
|
+
|
|
69
|
+
[](https://pypi.org/project/sct-ambiguities-analysis/)
|
|
70
|
+
[](https://python.org)
|
|
71
|
+
[](LICENSE.txt)
|
|
72
|
+
|
|
73
|
+
[](https://github.com/aresys-srl/sct_plugins_analyses/actions/workflows/ambiguities.yml)
|
|
74
|
+
|
|
75
|
+
[SCT (SAR Calibration Toolbox)](https://github.com/aresys-srl/sct) plugin for performing
|
|
76
|
+
Point and Distributed Target Ambiguity Ratio Analysis on L1 SAR products. Enables
|
|
77
|
+
evaluation of signal-to-ambiguity ratios for quality assessment through SCT.
|
|
78
|
+
|
|
79
|
+
## Installation
|
|
80
|
+
|
|
81
|
+
``` bash
|
|
82
|
+
pip install sct-ambiguities-analysis
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
SCT is automatically installed as a dependency.
|
|
86
|
+
|
|
87
|
+
## Compatibility
|
|
88
|
+
|
|
89
|
+
This plugin must be installed in the same Python environment as SCT. Once installed,
|
|
90
|
+
the plugin is automatically discovered and registered by SCT through its entry-point
|
|
91
|
+
based plugin system; no additional configuration is required.
|
|
92
|
+
|
|
93
|
+
## Documentation
|
|
94
|
+
|
|
95
|
+
- [SCT documentation](https://opensource.aresys.it/sct/)
|
|
96
|
+
- [Quality Analysis documentation](https://opensource.aresys.it/perseo/documentation/quality/)
|
|
97
|
+
- [Analysis Plugins documentation](https://opensource.aresys.it/sct_plugins_analyses)
|
|
98
|
+
|
|
99
|
+
## License
|
|
100
|
+
|
|
101
|
+
This project is licensed under the MIT License. See the [LICENSE.txt](LICENSE.txt) file for details.
|
|
102
|
+
|
|
103
|
+
Copyright © 2026-present Aresys S.r.l. <info@aresys.it>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# SCT Plugin: Ambiguity Ratio Analysis
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/sct-ambiguities-analysis/)
|
|
4
|
+
[](https://python.org)
|
|
5
|
+
[](LICENSE.txt)
|
|
6
|
+
|
|
7
|
+
[](https://github.com/aresys-srl/sct_plugins_analyses/actions/workflows/ambiguities.yml)
|
|
8
|
+
|
|
9
|
+
[SCT (SAR Calibration Toolbox)](https://github.com/aresys-srl/sct) plugin for performing
|
|
10
|
+
Point and Distributed Target Ambiguity Ratio Analysis on L1 SAR products. Enables
|
|
11
|
+
evaluation of signal-to-ambiguity ratios for quality assessment through SCT.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
``` bash
|
|
16
|
+
pip install sct-ambiguities-analysis
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
SCT is automatically installed as a dependency.
|
|
20
|
+
|
|
21
|
+
## Compatibility
|
|
22
|
+
|
|
23
|
+
This plugin must be installed in the same Python environment as SCT. Once installed,
|
|
24
|
+
the plugin is automatically discovered and registered by SCT through its entry-point
|
|
25
|
+
based plugin system; no additional configuration is required.
|
|
26
|
+
|
|
27
|
+
## Documentation
|
|
28
|
+
|
|
29
|
+
- [SCT documentation](https://opensource.aresys.it/sct/)
|
|
30
|
+
- [Quality Analysis documentation](https://opensource.aresys.it/perseo/documentation/quality/)
|
|
31
|
+
- [Analysis Plugins documentation](https://opensource.aresys.it/sct_plugins_analyses)
|
|
32
|
+
|
|
33
|
+
## License
|
|
34
|
+
|
|
35
|
+
This project is licensed under the MIT License. See the [LICENSE.txt](LICENSE.txt) file for details.
|
|
36
|
+
|
|
37
|
+
Copyright © 2026-present Aresys S.r.l. <info@aresys.it>
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "sct_ambiguities_analysis"
|
|
3
|
+
description = "SCT Plugin for Point and Distributed Ambiguity Ratio Analysis of L1 SAR Products."
|
|
4
|
+
authors = [{ name = "Aresys S.R.L.", email = "info@aresys.it" }]
|
|
5
|
+
requires-python = ">=3.11"
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
license = { file = "LICENSE.txt" }
|
|
8
|
+
dependencies = [
|
|
9
|
+
"numpy>2",
|
|
10
|
+
"jsonschema",
|
|
11
|
+
"typer>=0.24.1",
|
|
12
|
+
"perseo-core>=1.0.0",
|
|
13
|
+
"perseo-quality>=1.1.0",
|
|
14
|
+
"sct",
|
|
15
|
+
]
|
|
16
|
+
dynamic = ["version"]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Development Status :: 5 - Production/Stable",
|
|
19
|
+
"Intended Audience :: Science/Research",
|
|
20
|
+
"Intended Audience :: Education",
|
|
21
|
+
"Intended Audience :: Developers",
|
|
22
|
+
"License :: OSI Approved :: MIT License",
|
|
23
|
+
"Natural Language :: English",
|
|
24
|
+
"Programming Language :: Python",
|
|
25
|
+
"Programming Language :: Python :: 3.11",
|
|
26
|
+
"Programming Language :: Python :: 3.12",
|
|
27
|
+
"Programming Language :: Python :: 3.13",
|
|
28
|
+
"Programming Language :: Python :: 3.14",
|
|
29
|
+
"Operating System :: OS Independent",
|
|
30
|
+
"Topic :: Software Development :: Libraries",
|
|
31
|
+
"Topic :: Utilities",
|
|
32
|
+
"Topic :: Scientific/Engineering",
|
|
33
|
+
"Typing :: Typed",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[project.urls]
|
|
37
|
+
Homepage = "https://github.com/aresys-srl/sct_plugins_analyses"
|
|
38
|
+
Repository = "https://github.com/aresys-srl/sct_plugins_analyses"
|
|
39
|
+
Documentation = "https://opensource.aresys.it/sct_plugins_analyses"
|
|
40
|
+
|
|
41
|
+
[project.optional-dependencies]
|
|
42
|
+
dev = ["ruff", "pylint"]
|
|
43
|
+
test = ["pytest", "pytest-cov", "pytest-mock", "sct[graphs]>=3.1.0"]
|
|
44
|
+
docs = ["zensical", "mkdocstrings-python"]
|
|
45
|
+
|
|
46
|
+
[build-system]
|
|
47
|
+
requires = ["hatchling"]
|
|
48
|
+
build-backend = "hatchling.build"
|
|
49
|
+
|
|
50
|
+
[project.entry-points."sct.analyses"]
|
|
51
|
+
ambiguities = "sct_ambiguities_analysis.interface:TargetAmbiguityRatioAnalysisPlugin"
|
|
52
|
+
|
|
53
|
+
[tool.hatch.version]
|
|
54
|
+
path = "src/sct_ambiguities_analysis/__init__.py"
|
|
55
|
+
|
|
56
|
+
[tool.hatch.build.targets.sdist]
|
|
57
|
+
only-include = ["src", "tests"]
|
|
58
|
+
|
|
59
|
+
[tool.hatch.metadata]
|
|
60
|
+
allow-direct-references = true
|
|
61
|
+
|
|
62
|
+
[tool.pytest.ini_options]
|
|
63
|
+
minversion = "8.0"
|
|
64
|
+
testpaths = ["tests"]
|
|
65
|
+
python_files = ["test_*.py"]
|
|
66
|
+
python_classes = ["Test*"]
|
|
67
|
+
python_functions = ["test_*"]
|
|
68
|
+
addopts = [
|
|
69
|
+
"-ra",
|
|
70
|
+
"--strict-markers",
|
|
71
|
+
"--strict-config",
|
|
72
|
+
"--tb=short",
|
|
73
|
+
"--cov=sct_ambiguities_analysis",
|
|
74
|
+
"--cov-report=term-missing",
|
|
75
|
+
"--cov-report=html",
|
|
76
|
+
"--no-cov-on-fail",
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
[tool.coverage.run]
|
|
80
|
+
branch = true
|
|
81
|
+
source = ["src"]
|
|
82
|
+
|
|
83
|
+
[tool.coverage.report]
|
|
84
|
+
skip_covered = true
|
|
85
|
+
show_missing = true
|
|
86
|
+
fail_under = 70
|
|
87
|
+
|
|
88
|
+
[tool.pylint.master]
|
|
89
|
+
fail-under = 8
|
|
90
|
+
fail-on = ["unused-import"]
|
|
91
|
+
|
|
92
|
+
[tool.pylint.message_control]
|
|
93
|
+
disable = ["import-error", "logging-fstring-interpolation", "logging-not-lazy"]
|
|
94
|
+
|
|
95
|
+
[tool.pylint.format]
|
|
96
|
+
max-line-length = 120
|
|
97
|
+
|
|
98
|
+
[tool.pdm]
|
|
99
|
+
distribution = true
|
|
100
|
+
|
|
101
|
+
[tool.pdm.resolution]
|
|
102
|
+
respect-source-order = true
|
|
103
|
+
|
|
104
|
+
[tool.pdm.scripts]
|
|
105
|
+
format_check = "ruff format --check"
|
|
106
|
+
format = "ruff format"
|
|
107
|
+
sort = "ruff check --select I --fix-only"
|
|
108
|
+
lint_check = "ruff check"
|
|
109
|
+
lint_fix = "ruff check --show-fixes --fix-only"
|
|
110
|
+
test = "python -m pytest ./tests -v"
|
|
111
|
+
check_code = { composite = ["format_check", "lint_check"] }
|
|
112
|
+
fix_format = { composite = ["format", "sort", "lint_fix"] }
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Aresys S.r.l. <info@aresys.it>
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
"""Command Line Interface for Target Ambiguity Ratio Analysis."""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
import typer
|
|
11
|
+
from sct.cli import common
|
|
12
|
+
from sct.configuration.config import GeneralConfiguration
|
|
13
|
+
from sct.configuration.logger import sct_logger
|
|
14
|
+
|
|
15
|
+
from sct_ambiguities_analysis.config import SCTTargetAmbiguityRatioConfig
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def ptar_analysis(
|
|
19
|
+
ctx: typer.Context,
|
|
20
|
+
product: common.InputProductOption,
|
|
21
|
+
point_target_source: common.InputPointTargetSource,
|
|
22
|
+
output_directory: common.OutputDirectoryOption,
|
|
23
|
+
) -> None:
|
|
24
|
+
"""Point Target Ambiguity Ratio Analysis."""
|
|
25
|
+
|
|
26
|
+
config: GeneralConfiguration = ctx.obj
|
|
27
|
+
|
|
28
|
+
log_path = output_directory / "sct_tar_analysis.log" if config.save_log else None
|
|
29
|
+
|
|
30
|
+
with common.logging_to_file(log_path):
|
|
31
|
+
sct_logger.info(f"Product: {product}")
|
|
32
|
+
sct_logger.info(f"Point targets: {point_target_source}")
|
|
33
|
+
sct_logger.info(f"Output folder: {output_directory}")
|
|
34
|
+
|
|
35
|
+
common.display_title("Ambiguity Ratio Analysis")
|
|
36
|
+
|
|
37
|
+
analysis_config = (
|
|
38
|
+
SCTTargetAmbiguityRatioConfig.from_toml(config.toml_path)
|
|
39
|
+
if config.toml_path is not None
|
|
40
|
+
else SCTTargetAmbiguityRatioConfig()
|
|
41
|
+
)
|
|
42
|
+
pt_ambiguity_ratio_analysis_implementation(
|
|
43
|
+
product=product,
|
|
44
|
+
point_target_source=point_target_source,
|
|
45
|
+
output_directory=output_directory,
|
|
46
|
+
config=analysis_config,
|
|
47
|
+
graphs=True,
|
|
48
|
+
dump_config=config.save_config_copy,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@common.log_elapsed_time("Point Target Ambiguity Ratio Analysis")
|
|
53
|
+
@common.graceful_exit("Point Target Ambiguity Ratio Analysis")
|
|
54
|
+
def pt_ambiguity_ratio_analysis_implementation(
|
|
55
|
+
product: Path,
|
|
56
|
+
point_target_source: Path,
|
|
57
|
+
output_directory: Path,
|
|
58
|
+
config: SCTTargetAmbiguityRatioConfig,
|
|
59
|
+
graphs: bool,
|
|
60
|
+
dump_config: bool,
|
|
61
|
+
) -> None:
|
|
62
|
+
"""Implement the point target ambiguity ratio analysis command."""
|
|
63
|
+
from sct_ambiguities_analysis.main import full_pt_ambiguity_ratio_analysis
|
|
64
|
+
|
|
65
|
+
full_pt_ambiguity_ratio_analysis(
|
|
66
|
+
product=product,
|
|
67
|
+
point_target_source=point_target_source,
|
|
68
|
+
output_directory=output_directory,
|
|
69
|
+
config=config,
|
|
70
|
+
graphs=graphs,
|
|
71
|
+
)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Aresys S.r.l. <info@aresys.it>
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
"""Ambiguity Ratio Analysis configuration."""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from dataclasses import asdict, dataclass, field
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
from perseo_quality.tar_analysis.config import AmbiguityRatioConfig
|
|
12
|
+
from sct.configuration.config_abc import AnalysisConfigABC
|
|
13
|
+
|
|
14
|
+
from sct_ambiguities_analysis.resources import config_schema
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@dataclass
|
|
18
|
+
class SCTTargetAmbiguityRatioConfig(AnalysisConfigABC):
|
|
19
|
+
"""SCT Target Ambiguity Ratio Analysis configuration"""
|
|
20
|
+
|
|
21
|
+
base_config: AmbiguityRatioConfig = field(default_factory=AmbiguityRatioConfig)
|
|
22
|
+
config_group_name = "ambiguity_ratio_analysis"
|
|
23
|
+
validation_schema = Path(config_schema)
|
|
24
|
+
|
|
25
|
+
@classmethod
|
|
26
|
+
def from_dict(cls, arg: dict) -> SCTTargetAmbiguityRatioConfig:
|
|
27
|
+
"""Convert from dict"""
|
|
28
|
+
return cls(base_config=AmbiguityRatioConfig.from_dict(arg))
|
|
29
|
+
|
|
30
|
+
def to_dict(self):
|
|
31
|
+
"""Convert to dict"""
|
|
32
|
+
return {self.config_group_name: asdict(self.base_config)}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Aresys S.r.l. <info@aresys.it>
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
"""Target Ambiguity Ratio Analysis - Core implementation"""
|
|
5
|
+
|
|
6
|
+
from sct_ambiguities_analysis.core.analysis import sct_point_target_ambiguity_ratio_analysis
|
|
7
|
+
|
|
8
|
+
__all__ = ["sct_point_target_ambiguity_ratio_analysis"]
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Aresys S.r.l. <info@aresys.it>
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
"""Target Ambiguity Ratio Analysis"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from perseo_quality.tar_analysis.analysis import point_target_ambiguity_ratio_analysis
|
|
11
|
+
from perseo_quality.tar_analysis.custom_dataclasses import PointTargetAmbiguityRatioDataOutput
|
|
12
|
+
from sct.configuration.logger import sct_logger
|
|
13
|
+
from sct.io.io_manager import InvalidProductType, product_loader
|
|
14
|
+
from sct.io.point_target_manager import convert_df_to_nominal_point_target, extract_point_target_data_from_source
|
|
15
|
+
|
|
16
|
+
from sct_ambiguities_analysis.config import SCTTargetAmbiguityRatioConfig
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def sct_point_target_ambiguity_ratio_analysis(
|
|
20
|
+
product_path: str | Path, external_target_source: str | Path, config: SCTTargetAmbiguityRatioConfig | None = None
|
|
21
|
+
) -> list[PointTargetAmbiguityRatioDataOutput]:
|
|
22
|
+
"""Point Target Ambiguity Ratio Analysis performed on the input product.
|
|
23
|
+
|
|
24
|
+
Parameters
|
|
25
|
+
----------
|
|
26
|
+
product_path : str | Path
|
|
27
|
+
path to the product to be analyzed
|
|
28
|
+
external_target_source : str | Path
|
|
29
|
+
path to external point target source
|
|
30
|
+
config : SCTTargetAmbiguityRatioConfig | None, optional
|
|
31
|
+
configuration parameters, by default None
|
|
32
|
+
|
|
33
|
+
Returns
|
|
34
|
+
-------
|
|
35
|
+
list[PointTargetAmbiguityRatioDataOutput]
|
|
36
|
+
list of PointTargetAmbiguityRatioDataOutput analysis output, one for each product channel and each Point Target
|
|
37
|
+
"""
|
|
38
|
+
# Input parameters analysis
|
|
39
|
+
product_path = Path(product_path)
|
|
40
|
+
sct_logger.info(f"Input product: {product_path}")
|
|
41
|
+
|
|
42
|
+
external_target_source = Path(external_target_source)
|
|
43
|
+
sct_logger.info(f"Using external target source provided: {external_target_source}")
|
|
44
|
+
|
|
45
|
+
config = config or SCTTargetAmbiguityRatioConfig()
|
|
46
|
+
|
|
47
|
+
# LOADING PRODUCT
|
|
48
|
+
try:
|
|
49
|
+
product, _ = product_loader(
|
|
50
|
+
product_path=product_path,
|
|
51
|
+
)
|
|
52
|
+
except InvalidProductType as err:
|
|
53
|
+
sct_logger.critical(f"Unknown product type {product_path}.")
|
|
54
|
+
sct_logger.critical("Please check that the dedicated format plugin is installed.")
|
|
55
|
+
raise InvalidProductType from err
|
|
56
|
+
|
|
57
|
+
# external target source
|
|
58
|
+
point_targets_df = extract_point_target_data_from_source(source=external_target_source)
|
|
59
|
+
|
|
60
|
+
# converting point target data frame in list of NominalPointTarget dataclasses
|
|
61
|
+
point_targets_data = convert_df_to_nominal_point_target(data_df=point_targets_df)
|
|
62
|
+
|
|
63
|
+
return point_target_ambiguity_ratio_analysis(
|
|
64
|
+
product=product, point_targets=point_targets_data, config=config.base_config
|
|
65
|
+
)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Aresys S.r.l. <info@aresys.it>
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
"""Target Ambiguity Ratio Analysis plugin entry point.
|
|
5
|
+
|
|
6
|
+
Lightweight module: importing it must not pull in the heavy analysis implementation
|
|
7
|
+
or the scientific stack. All heavy imports are deferred to the accessor methods.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from typing import TYPE_CHECKING, Callable
|
|
13
|
+
|
|
14
|
+
from sct import __version__
|
|
15
|
+
|
|
16
|
+
if TYPE_CHECKING:
|
|
17
|
+
from sct.core.base import AnalysisHandler
|
|
18
|
+
from typer import Typer
|
|
19
|
+
|
|
20
|
+
ANALYSIS_NAME = "ambiguity_ratio"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class TargetAmbiguityRatioAnalysisPlugin:
|
|
24
|
+
"""Target Ambiguity Ratio Analysis plugin."""
|
|
25
|
+
|
|
26
|
+
version = __version__
|
|
27
|
+
short_help = "Point Target Ambiguity Ratio Analysis."
|
|
28
|
+
|
|
29
|
+
@classmethod
|
|
30
|
+
def get_cli(cls) -> Typer | Callable:
|
|
31
|
+
from sct_ambiguities_analysis.cli import ptar_analysis
|
|
32
|
+
|
|
33
|
+
return ptar_analysis
|
|
34
|
+
|
|
35
|
+
@classmethod
|
|
36
|
+
def get_handlers(cls) -> dict[str, AnalysisHandler]:
|
|
37
|
+
from sct.core.base import AnalysisHandler
|
|
38
|
+
|
|
39
|
+
from sct_ambiguities_analysis.config import SCTTargetAmbiguityRatioConfig
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
ANALYSIS_NAME: AnalysisHandler(
|
|
43
|
+
config=SCTTargetAmbiguityRatioConfig,
|
|
44
|
+
cli=cls.get_cli(),
|
|
45
|
+
testing=None,
|
|
46
|
+
)
|
|
47
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Aresys S.r.l. <info@aresys.it>
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
"""Ambiguity Ratio Analysis implementation."""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from collections.abc import Callable
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
from sct.configuration.logger import sct_logger
|
|
12
|
+
|
|
13
|
+
from sct_ambiguities_analysis.config import SCTTargetAmbiguityRatioConfig
|
|
14
|
+
from sct_ambiguities_analysis.core.analysis import sct_point_target_ambiguity_ratio_analysis
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def full_pt_ambiguity_ratio_analysis(
|
|
18
|
+
product: Path,
|
|
19
|
+
point_target_source: Path,
|
|
20
|
+
output_directory: Path,
|
|
21
|
+
config: SCTTargetAmbiguityRatioConfig | None,
|
|
22
|
+
graphs: bool,
|
|
23
|
+
) -> None:
|
|
24
|
+
"""Full implementation of Point Target Ambiguity Ratio Analysis.
|
|
25
|
+
|
|
26
|
+
Parameters
|
|
27
|
+
----------
|
|
28
|
+
product : Path
|
|
29
|
+
Path to the product to be analyzed
|
|
30
|
+
point_target_source : Path
|
|
31
|
+
Path to the point target source file
|
|
32
|
+
output_directory : Path
|
|
33
|
+
Path to the output directory
|
|
34
|
+
config : SCTTargetAmbiguityRatioConfig | None
|
|
35
|
+
analysis configuration parameters, if needed
|
|
36
|
+
graphs : bool
|
|
37
|
+
flag to enable graphs generation
|
|
38
|
+
"""
|
|
39
|
+
graphs_func = _import_ptar_graphs_func(graphs)
|
|
40
|
+
output = sct_point_target_ambiguity_ratio_analysis(
|
|
41
|
+
product_path=product,
|
|
42
|
+
external_target_source=point_target_source,
|
|
43
|
+
config=config,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
if graphs_func is not None:
|
|
47
|
+
sct_logger.info("Generating graphs...")
|
|
48
|
+
output_graphs_dir = output_directory.joinpath("graphs")
|
|
49
|
+
output_graphs_dir.mkdir(exist_ok=True)
|
|
50
|
+
graphs_func(data=output, output_dir=output_graphs_dir)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _import_ptar_graphs_func(graphs: bool) -> Callable | None:
|
|
54
|
+
"""Importing the target ambiguity ratio analysis graphs plotting function."""
|
|
55
|
+
ambiguities_graphs = None
|
|
56
|
+
if graphs:
|
|
57
|
+
try:
|
|
58
|
+
from perseo_quality.tar_analysis.graphical_output import ambiguities_graphs
|
|
59
|
+
except ImportError as err:
|
|
60
|
+
sct_logger.critical(
|
|
61
|
+
'Cannot generate graphical output: install graphs requirements "pip install sct[graphs]"'
|
|
62
|
+
)
|
|
63
|
+
raise ImportError from err
|
|
64
|
+
return ambiguities_graphs
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"ambiguity_ratio_analysis": {
|
|
6
|
+
"type": "object",
|
|
7
|
+
"description": "Ambiguity ratio analysis configuration",
|
|
8
|
+
"properties": {
|
|
9
|
+
"cropping_size": {
|
|
10
|
+
"type": "array",
|
|
11
|
+
"description": "ROI cropping size in pixels",
|
|
12
|
+
"items": [
|
|
13
|
+
{
|
|
14
|
+
"type": "integer",
|
|
15
|
+
"description": "number of samples"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"type": "integer",
|
|
19
|
+
"description": "number of lines"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"minItems": 2,
|
|
23
|
+
"maxItems": 2
|
|
24
|
+
},
|
|
25
|
+
"interpolation_factor": {
|
|
26
|
+
"type": "integer",
|
|
27
|
+
"description": "ROI interpolation factor"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"required": [
|
|
31
|
+
"cropping_size"
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"required": [
|
|
36
|
+
"ambiguity_ratio_analysis"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Aresys S.r.l. <info@aresys.it>
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
"""Testing CLI module."""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from sct_ambiguities_analysis.cli import pt_ambiguity_ratio_analysis_implementation
|
|
11
|
+
from sct_ambiguities_analysis.config import SCTTargetAmbiguityRatioConfig
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def test_pt_ambiguity_ratio_analysis_implementation_calls_main(mocker) -> None:
|
|
15
|
+
mock_main = mocker.patch("sct_ambiguities_analysis.main.full_pt_ambiguity_ratio_analysis")
|
|
16
|
+
|
|
17
|
+
pt_ambiguity_ratio_analysis_implementation(
|
|
18
|
+
product=Path("/p"),
|
|
19
|
+
point_target_source=Path("/pts"),
|
|
20
|
+
output_directory=Path("/out"),
|
|
21
|
+
config=SCTTargetAmbiguityRatioConfig(),
|
|
22
|
+
graphs=True,
|
|
23
|
+
dump_config=False,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
mock_main.assert_called_once_with(
|
|
27
|
+
product=Path("/p"),
|
|
28
|
+
point_target_source=Path("/pts"),
|
|
29
|
+
output_directory=Path("/out"),
|
|
30
|
+
config=SCTTargetAmbiguityRatioConfig(),
|
|
31
|
+
graphs=True,
|
|
32
|
+
)
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Aresys S.r.l. <info@aresys.it>
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
"""Testing core analysis module."""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
import pytest
|
|
11
|
+
|
|
12
|
+
from sct_ambiguities_analysis.core.analysis import sct_point_target_ambiguity_ratio_analysis
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def test_happy_path(mocker) -> None:
|
|
16
|
+
mock_product = mocker.MagicMock()
|
|
17
|
+
mock_product_loader = mocker.patch(
|
|
18
|
+
"sct_ambiguities_analysis.core.analysis.product_loader",
|
|
19
|
+
return_value=(mock_product, None),
|
|
20
|
+
)
|
|
21
|
+
mock_extract = mocker.patch(
|
|
22
|
+
"sct_ambiguities_analysis.core.analysis.extract_point_target_data_from_source",
|
|
23
|
+
return_value=mocker.MagicMock(),
|
|
24
|
+
)
|
|
25
|
+
mock_convert = mocker.patch(
|
|
26
|
+
"sct_ambiguities_analysis.core.analysis.convert_df_to_nominal_point_target",
|
|
27
|
+
return_value=mocker.MagicMock(),
|
|
28
|
+
)
|
|
29
|
+
mock_perseo = mocker.patch(
|
|
30
|
+
"sct_ambiguities_analysis.core.analysis.point_target_ambiguity_ratio_analysis",
|
|
31
|
+
return_value=[mocker.MagicMock()],
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
config = mocker.MagicMock()
|
|
35
|
+
result = sct_point_target_ambiguity_ratio_analysis(
|
|
36
|
+
product_path="/input/product",
|
|
37
|
+
external_target_source="/input/targets",
|
|
38
|
+
config=config,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
assert len(result) == 1
|
|
42
|
+
mock_product_loader.assert_called_once_with(product_path=Path("/input/product"))
|
|
43
|
+
mock_extract.assert_called_once_with(source=Path("/input/targets"))
|
|
44
|
+
mock_convert.assert_called_once_with(data_df=mock_extract.return_value)
|
|
45
|
+
mock_perseo.assert_called_once_with(
|
|
46
|
+
product=mock_product,
|
|
47
|
+
point_targets=mock_convert.return_value,
|
|
48
|
+
config=config.base_config,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def test_default_config_when_none(mocker) -> None:
|
|
53
|
+
mocker.patch(
|
|
54
|
+
"sct_ambiguities_analysis.core.analysis.product_loader",
|
|
55
|
+
return_value=(mocker.MagicMock(), None),
|
|
56
|
+
)
|
|
57
|
+
mocker.patch(
|
|
58
|
+
"sct_ambiguities_analysis.core.analysis.extract_point_target_data_from_source",
|
|
59
|
+
return_value=mocker.MagicMock(),
|
|
60
|
+
)
|
|
61
|
+
mocker.patch(
|
|
62
|
+
"sct_ambiguities_analysis.core.analysis.convert_df_to_nominal_point_target",
|
|
63
|
+
return_value=mocker.MagicMock(),
|
|
64
|
+
)
|
|
65
|
+
mock_perseo = mocker.patch(
|
|
66
|
+
"sct_ambiguities_analysis.core.analysis.point_target_ambiguity_ratio_analysis",
|
|
67
|
+
return_value=[],
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
sct_point_target_ambiguity_ratio_analysis(
|
|
71
|
+
product_path="/input/product",
|
|
72
|
+
external_target_source="/input/targets",
|
|
73
|
+
config=None,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
# When config is None, a default SCTTargetAmbiguityRatioConfig is created,
|
|
77
|
+
# and its base_config (an AmbiguityRatioConfig) is passed to perseo
|
|
78
|
+
call_config = mock_perseo.call_args[1]["config"]
|
|
79
|
+
from perseo_quality.tar_analysis.config import AmbiguityRatioConfig
|
|
80
|
+
|
|
81
|
+
assert isinstance(call_config, AmbiguityRatioConfig)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def test_invalid_product_type_raises(mocker) -> None:
|
|
85
|
+
from sct.io.io_manager import InvalidProductType
|
|
86
|
+
|
|
87
|
+
mocker.patch(
|
|
88
|
+
"sct_ambiguities_analysis.core.analysis.product_loader",
|
|
89
|
+
side_effect=InvalidProductType,
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
with pytest.raises(InvalidProductType):
|
|
93
|
+
sct_point_target_ambiguity_ratio_analysis(
|
|
94
|
+
product_path="/input/product",
|
|
95
|
+
external_target_source="/input/targets",
|
|
96
|
+
)
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Aresys S.r.l. <info@aresys.it>
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
"""Testing main orchestrator module."""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from perseo_quality.tar_analysis.graphical_output import ambiguities_graphs
|
|
11
|
+
|
|
12
|
+
from sct_ambiguities_analysis.main import _import_ptar_graphs_func, full_pt_ambiguity_ratio_analysis
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def test_full_analysis_with_graphs(mocker) -> None:
|
|
16
|
+
mock_analysis = mocker.patch(
|
|
17
|
+
"sct_ambiguities_analysis.main.sct_point_target_ambiguity_ratio_analysis",
|
|
18
|
+
return_value=[mocker.MagicMock()],
|
|
19
|
+
)
|
|
20
|
+
mocker.patch(
|
|
21
|
+
"sct_ambiguities_analysis.main._import_ptar_graphs_func",
|
|
22
|
+
return_value=mocker.MagicMock(),
|
|
23
|
+
)
|
|
24
|
+
mock_graphs_dir = mocker.MagicMock()
|
|
25
|
+
mock_output_dir = mocker.MagicMock()
|
|
26
|
+
mock_output_dir.joinpath.return_value = mock_graphs_dir
|
|
27
|
+
|
|
28
|
+
full_pt_ambiguity_ratio_analysis(
|
|
29
|
+
product=Path("/p"),
|
|
30
|
+
point_target_source=Path("/pts"),
|
|
31
|
+
output_directory=mock_output_dir,
|
|
32
|
+
config=mocker.MagicMock(),
|
|
33
|
+
graphs=True,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
mock_analysis.assert_called_once_with(
|
|
37
|
+
product_path=Path("/p"),
|
|
38
|
+
external_target_source=Path("/pts"),
|
|
39
|
+
config=mocker.ANY,
|
|
40
|
+
)
|
|
41
|
+
mock_output_dir.joinpath.assert_called_once_with("graphs")
|
|
42
|
+
mock_graphs_dir.mkdir.assert_called_once_with(exist_ok=True)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def test_full_analysis_without_graphs(mocker) -> None:
|
|
46
|
+
mock_analysis = mocker.patch(
|
|
47
|
+
"sct_ambiguities_analysis.main.sct_point_target_ambiguity_ratio_analysis",
|
|
48
|
+
return_value=[],
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
full_pt_ambiguity_ratio_analysis(
|
|
52
|
+
product=Path("/p"),
|
|
53
|
+
point_target_source=Path("/pts"),
|
|
54
|
+
output_directory=Path("/out"),
|
|
55
|
+
config=mocker.MagicMock(),
|
|
56
|
+
graphs=False,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
mock_analysis.assert_called_once()
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def test_import_graphs_func_with_graphs() -> None:
|
|
63
|
+
result = _import_ptar_graphs_func(graphs=True)
|
|
64
|
+
assert result is ambiguities_graphs
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def test_import_graphs_func_without_graphs() -> None:
|
|
68
|
+
result = _import_ptar_graphs_func(graphs=False)
|
|
69
|
+
assert result is None
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Aresys S.r.l. <info@aresys.it>
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
"""Testing SCT Target Ambiguity Ratio Analysis plugin interface."""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from typing import Callable
|
|
9
|
+
|
|
10
|
+
import pytest
|
|
11
|
+
from sct.core.base import AnalysisHandler
|
|
12
|
+
from sct.plugins.loader import import_analysis_plugins
|
|
13
|
+
from sct.plugins.protocols import AnalysisPluginProtocol
|
|
14
|
+
|
|
15
|
+
from sct_ambiguities_analysis.config import SCTTargetAmbiguityRatioConfig
|
|
16
|
+
from sct_ambiguities_analysis.interface import ANALYSIS_NAME, TargetAmbiguityRatioAnalysisPlugin
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@pytest.fixture
|
|
20
|
+
def plugin():
|
|
21
|
+
plugins = import_analysis_plugins()
|
|
22
|
+
candidates = [p for p in plugins if p is TargetAmbiguityRatioAnalysisPlugin]
|
|
23
|
+
assert len(candidates) >= 1
|
|
24
|
+
return candidates[0]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class TestPluginProtocolCompliance:
|
|
28
|
+
"""Test Plugin Protocol Compliance"""
|
|
29
|
+
|
|
30
|
+
def test_installed_plugin(self, plugin) -> None:
|
|
31
|
+
"""Testing correct plugin installation"""
|
|
32
|
+
assert plugin is TargetAmbiguityRatioAnalysisPlugin
|
|
33
|
+
assert plugin.__name__ == "TargetAmbiguityRatioAnalysisPlugin"
|
|
34
|
+
|
|
35
|
+
def test_protocol_compliance(self, plugin) -> None:
|
|
36
|
+
"""Testing analysis plugin protocol compliance"""
|
|
37
|
+
assert isinstance(plugin, AnalysisPluginProtocol)
|
|
38
|
+
|
|
39
|
+
def test_version_field(self, plugin) -> None:
|
|
40
|
+
"""Testing version field presence and type"""
|
|
41
|
+
assert isinstance(plugin.version, str)
|
|
42
|
+
assert len(plugin.version) > 0
|
|
43
|
+
|
|
44
|
+
def test_short_help_field(self, plugin) -> None:
|
|
45
|
+
"""Testing short_help field presence and type"""
|
|
46
|
+
assert isinstance(plugin.short_help, str)
|
|
47
|
+
assert len(plugin.short_help) > 0
|
|
48
|
+
|
|
49
|
+
def test_get_cli(self, plugin) -> None:
|
|
50
|
+
"""Testing CLI retriever protocol compliance"""
|
|
51
|
+
cli = plugin.get_cli()
|
|
52
|
+
assert isinstance(cli, Callable)
|
|
53
|
+
|
|
54
|
+
def test_get_handlers(self, plugin) -> None:
|
|
55
|
+
"""Testing handlers retriever protocol compliance"""
|
|
56
|
+
handlers = plugin.get_handlers()
|
|
57
|
+
assert isinstance(handlers, dict)
|
|
58
|
+
assert ANALYSIS_NAME in handlers
|
|
59
|
+
handler = handlers[ANALYSIS_NAME]
|
|
60
|
+
assert isinstance(handler, AnalysisHandler)
|
|
61
|
+
|
|
62
|
+
def test_handler_structure(self, plugin) -> None:
|
|
63
|
+
"""Testing handler structure: config, cli, testing"""
|
|
64
|
+
handler = plugin.get_handlers()[ANALYSIS_NAME]
|
|
65
|
+
|
|
66
|
+
assert handler.config is SCTTargetAmbiguityRatioConfig
|
|
67
|
+
|
|
68
|
+
assert isinstance(handler.cli, Callable)
|
|
69
|
+
|
|
70
|
+
assert handler.testing is None
|
|
71
|
+
|
|
72
|
+
assert handler.cli_group_name is None or isinstance(handler.cli_group_name, str)
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Aresys S.r.l. <info@aresys.it>
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
"""Testing SCT Target Ambiguity Ratio Analysis Configuration."""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import pytest
|
|
9
|
+
from jsonschema.exceptions import ValidationError
|
|
10
|
+
|
|
11
|
+
from sct_ambiguities_analysis.config import SCTTargetAmbiguityRatioConfig
|
|
12
|
+
|
|
13
|
+
general_config_toml = """
|
|
14
|
+
|
|
15
|
+
[general]
|
|
16
|
+
save_log = true
|
|
17
|
+
save_config_copy = true
|
|
18
|
+
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
ambiguity_ratio_analysis_toml = """
|
|
22
|
+
|
|
23
|
+
[ambiguity_ratio_analysis]
|
|
24
|
+
interpolation_factor = 16
|
|
25
|
+
cropping_size = [150, 120]
|
|
26
|
+
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _validate_ambiguity_config(config: SCTTargetAmbiguityRatioConfig) -> None:
|
|
31
|
+
"""Validating correct reading of ambiguity ratio analysis configuration from file.
|
|
32
|
+
|
|
33
|
+
Parameters
|
|
34
|
+
----------
|
|
35
|
+
config : SCTTargetAmbiguityRatioConfig
|
|
36
|
+
sct ambiguity ratio analysis configuration
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
assert isinstance(config, SCTTargetAmbiguityRatioConfig)
|
|
40
|
+
|
|
41
|
+
assert isinstance(config.base_config.interpolation_factor, int)
|
|
42
|
+
assert config.base_config.interpolation_factor == 16
|
|
43
|
+
assert isinstance(config.base_config.cropping_size, tuple)
|
|
44
|
+
assert config.base_config.cropping_size == (150, 120)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def test_full_ambiguity_ratio_analysis_reading(tmp_path) -> None:
|
|
48
|
+
"""Test ambiguity_ratio_analysis full configuration reading"""
|
|
49
|
+
path_to_file = tmp_path.joinpath("test.toml")
|
|
50
|
+
path_to_file.write_text(ambiguity_ratio_analysis_toml)
|
|
51
|
+
|
|
52
|
+
config = SCTTargetAmbiguityRatioConfig.from_toml(path_to_file)
|
|
53
|
+
|
|
54
|
+
assert isinstance(config, SCTTargetAmbiguityRatioConfig)
|
|
55
|
+
_validate_ambiguity_config(config)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def test_reading_errors_0(tmp_path) -> None:
|
|
59
|
+
"""Test reading with errors"""
|
|
60
|
+
partial_toml = """
|
|
61
|
+
|
|
62
|
+
[ambiguity_ratio_analysis]
|
|
63
|
+
interpolation_factor = 16
|
|
64
|
+
cropping_size = [150, 120, 300]
|
|
65
|
+
|
|
66
|
+
"""
|
|
67
|
+
with pytest.raises(ValidationError):
|
|
68
|
+
path_to_file = tmp_path.joinpath("test.toml")
|
|
69
|
+
path_to_file.write_text(partial_toml)
|
|
70
|
+
|
|
71
|
+
SCTTargetAmbiguityRatioConfig.from_toml(path_to_file)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def test_dump_read(tmp_path) -> None:
|
|
75
|
+
"""Test full configuration dump to toml and reading"""
|
|
76
|
+
path_to_file = tmp_path.joinpath("test.toml")
|
|
77
|
+
path_to_file.write_text(ambiguity_ratio_analysis_toml)
|
|
78
|
+
path_to_new_file = tmp_path.joinpath("dump.toml")
|
|
79
|
+
|
|
80
|
+
# reading config
|
|
81
|
+
config = SCTTargetAmbiguityRatioConfig.from_toml(path_to_file)
|
|
82
|
+
# dumping config
|
|
83
|
+
config.to_toml(path_to_new_file)
|
|
84
|
+
|
|
85
|
+
# compare config
|
|
86
|
+
new_config = SCTTargetAmbiguityRatioConfig.from_toml(path_to_new_file)
|
|
87
|
+
|
|
88
|
+
assert new_config == config
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def test_from_dict():
|
|
92
|
+
config = SCTTargetAmbiguityRatioConfig.from_dict({"interpolation_factor": 16, "cropping_size": [150, 120]})
|
|
93
|
+
assert isinstance(config, SCTTargetAmbiguityRatioConfig)
|
|
94
|
+
assert config.base_config.interpolation_factor == 16
|
|
95
|
+
assert config.base_config.cropping_size == (150, 120)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def test_to_dict():
|
|
99
|
+
config = SCTTargetAmbiguityRatioConfig()
|
|
100
|
+
d = config.to_dict()
|
|
101
|
+
assert "ambiguity_ratio_analysis" in d
|
|
102
|
+
assert "interpolation_factor" in d["ambiguity_ratio_analysis"]
|
|
103
|
+
assert "cropping_size" in d["ambiguity_ratio_analysis"]
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def test_empty_config(tmp_path) -> None:
|
|
107
|
+
"""Test empty configuration"""
|
|
108
|
+
with pytest.raises(ValidationError):
|
|
109
|
+
path_to_file = tmp_path.joinpath("test.toml")
|
|
110
|
+
path_to_file.write_text(general_config_toml)
|
|
111
|
+
|
|
112
|
+
SCTTargetAmbiguityRatioConfig.from_toml(path_to_file)
|