microssim 0.0.1__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.
- microssim-0.0.1/.github/pull_request_template.md +39 -0
- microssim-0.0.1/.github/workflows/ci.yml +96 -0
- microssim-0.0.1/.gitignore +168 -0
- microssim-0.0.1/.pre-commit-config.yaml +38 -0
- microssim-0.0.1/LICENSE +21 -0
- microssim-0.0.1/PKG-INFO +120 -0
- microssim-0.0.1/README.md +83 -0
- microssim-0.0.1/notebooks/Download_data.ipynb +178 -0
- microssim-0.0.1/notebooks/Evaluate.ipynb +1889 -0
- microssim-0.0.1/notebooks/bird.jpeg +0 -0
- microssim-0.0.1/notebooks/utils/__init__.py +19 -0
- microssim-0.0.1/notebooks/utils/plot_utils.py +185 -0
- microssim-0.0.1/pyproject.toml +171 -0
- microssim-0.0.1/src/microssim/__init__.py +11 -0
- microssim-0.0.1/src/microssim/conftest.py +39 -0
- microssim-0.0.1/src/microssim/image_processing/__init__.py +13 -0
- microssim-0.0.1/src/microssim/image_processing/background.py +52 -0
- microssim-0.0.1/src/microssim/image_processing/care_normalization.py +124 -0
- microssim-0.0.1/src/microssim/image_processing/linearize.py +21 -0
- microssim-0.0.1/src/microssim/image_processing/micro_ssim_normalization.py +84 -0
- microssim-0.0.1/src/microssim/micro_ms3im.py +200 -0
- microssim-0.0.1/src/microssim/micro_ssim.py +437 -0
- microssim-0.0.1/src/microssim/ri_factor/__init__.py +6 -0
- microssim-0.0.1/src/microssim/ri_factor/mse_ri_factor.py +61 -0
- microssim-0.0.1/src/microssim/ri_factor/ri_factor.py +200 -0
- microssim-0.0.1/src/microssim/ssim/__init__.py +10 -0
- microssim-0.0.1/src/microssim/ssim/ssim_utils.py +397 -0
- microssim-0.0.1/tests/conftest.py +131 -0
- microssim-0.0.1/tests/image_processing/test_background.py +23 -0
- microssim-0.0.1/tests/image_processing/test_linearize.py +13 -0
- microssim-0.0.1/tests/image_processing/test_micro_ssim_normalization.py +63 -0
- microssim-0.0.1/tests/ri_factor/test_mse_ri_factor.py +15 -0
- microssim-0.0.1/tests/ri_factor/test_ri_factor.py +41 -0
- microssim-0.0.1/tests/ssim/test_ssim_utils.py +72 -0
- microssim-0.0.1/tests/test_micro_ms3im.py +132 -0
- microssim-0.0.1/tests/test_micro_ssim.py +268 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
### Description
|
|
2
|
+
|
|
3
|
+
Please provide a brief description of the changes in this PR. Include any relevant context or background information.
|
|
4
|
+
|
|
5
|
+
- **What**: Clearly and concisely describe what changes you have made.
|
|
6
|
+
- **Why**: Explain the reasoning behind these changes. What problem are you solving? Why is this change necessary?
|
|
7
|
+
- **How**: Describe how you implemented these changes. Provide an overview of the approach and any important implementation details.
|
|
8
|
+
|
|
9
|
+
### Changes Made
|
|
10
|
+
|
|
11
|
+
- **Added**: List new features or files added.
|
|
12
|
+
- **Modified**: Describe existing features or files modified.
|
|
13
|
+
- **Removed**: Detail features or files that were removed.
|
|
14
|
+
|
|
15
|
+
### Related Issues
|
|
16
|
+
|
|
17
|
+
Link to any related issues or discussions. Use keywords like "Fixes", "Resolves", or "Closes" to link to issues automatically.
|
|
18
|
+
|
|
19
|
+
- Fixes #
|
|
20
|
+
- Resolves #
|
|
21
|
+
- Closes #
|
|
22
|
+
|
|
23
|
+
### Breaking changes
|
|
24
|
+
|
|
25
|
+
Describe any breaking change.
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Additional Notes and Examples
|
|
29
|
+
|
|
30
|
+
Include any additional notes or context that reviewers should be aware of, including snippets of code illustrating your new feature.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
**Please ensure your PR meets the following requirements:**
|
|
35
|
+
|
|
36
|
+
- [ ] Code builds and passes tests locally, including doctests
|
|
37
|
+
- [ ] New tests have been added (for bug fixes/features)
|
|
38
|
+
- [ ] Pre-commit passes
|
|
39
|
+
- [ ] PR to the documentation exists (for bug fixes / features)
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
tags:
|
|
8
|
+
- "v*"
|
|
9
|
+
pull_request:
|
|
10
|
+
workflow_dispatch:
|
|
11
|
+
schedule:
|
|
12
|
+
# run every week (for --pre release tests)
|
|
13
|
+
- cron: "0 0 * * 0"
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
check-manifest:
|
|
17
|
+
# check-manifest is a tool that checks that all files in version control are
|
|
18
|
+
# included in the sdist (unless explicitly excluded)
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v3
|
|
22
|
+
- run: pipx run check-manifest
|
|
23
|
+
|
|
24
|
+
test:
|
|
25
|
+
name: ${{ matrix.platform }} (${{ matrix.python-version }})
|
|
26
|
+
runs-on: ${{ matrix.platform }}
|
|
27
|
+
strategy:
|
|
28
|
+
fail-fast: false
|
|
29
|
+
matrix:
|
|
30
|
+
python-version: ["3.9", "3.10", "3.11", "3.12"]
|
|
31
|
+
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
|
|
32
|
+
platform: [ubuntu-latest, macos-13, windows-latest]
|
|
33
|
+
|
|
34
|
+
steps:
|
|
35
|
+
- name: 🛑 Cancel Previous Runs
|
|
36
|
+
uses: styfle/cancel-workflow-action@0.11.0
|
|
37
|
+
with:
|
|
38
|
+
access_token: ${{ github.token }}
|
|
39
|
+
|
|
40
|
+
- uses: actions/checkout@v3
|
|
41
|
+
|
|
42
|
+
- name: 🐍 Set up Python ${{ matrix.python-version }}
|
|
43
|
+
uses: actions/setup-python@v4
|
|
44
|
+
with:
|
|
45
|
+
python-version: ${{ matrix.python-version }}
|
|
46
|
+
cache-dependency-path: "pyproject.toml"
|
|
47
|
+
cache: "pip"
|
|
48
|
+
|
|
49
|
+
- name: Install Dependencies
|
|
50
|
+
run: |
|
|
51
|
+
python -m pip install -U pip
|
|
52
|
+
# if running a cron job, we add the --pre flag to test against pre-releases
|
|
53
|
+
python -m pip install .[dev] ${{ github.event_name == 'schedule' && '--pre' || '' }}
|
|
54
|
+
|
|
55
|
+
- name: 🧪 Run Tests
|
|
56
|
+
run: pytest --color=yes --cov --cov-config=pyproject.toml --cov-report=xml --cov-report=term-missing
|
|
57
|
+
|
|
58
|
+
- name: Coverage
|
|
59
|
+
uses: codecov/codecov-action@v3
|
|
60
|
+
with:
|
|
61
|
+
version: v0.7.3
|
|
62
|
+
|
|
63
|
+
deploy:
|
|
64
|
+
name: Release
|
|
65
|
+
needs: test
|
|
66
|
+
if: success() && startsWith(github.ref, 'refs/tags/') && github.event_name != 'schedule'
|
|
67
|
+
runs-on: ubuntu-latest
|
|
68
|
+
|
|
69
|
+
permissions:
|
|
70
|
+
# IMPORTANT: this permission is mandatory for trusted publishing
|
|
71
|
+
id-token: write
|
|
72
|
+
|
|
73
|
+
# This permission allows writing releases
|
|
74
|
+
contents: write
|
|
75
|
+
|
|
76
|
+
steps:
|
|
77
|
+
- uses: actions/checkout@v4
|
|
78
|
+
with:
|
|
79
|
+
fetch-depth: 0
|
|
80
|
+
|
|
81
|
+
- name: Set up Python
|
|
82
|
+
uses: actions/setup-python@v5
|
|
83
|
+
with:
|
|
84
|
+
python-version: "3.9"
|
|
85
|
+
|
|
86
|
+
- name: Build
|
|
87
|
+
run: |
|
|
88
|
+
python -m pip install build
|
|
89
|
+
python -m build
|
|
90
|
+
|
|
91
|
+
- name: Publish to PyPI
|
|
92
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
93
|
+
|
|
94
|
+
- uses: softprops/action-gh-release@v2
|
|
95
|
+
with:
|
|
96
|
+
generate_release_notes: true
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# VSCode
|
|
2
|
+
.vscode
|
|
3
|
+
|
|
4
|
+
# Byte-compiled / optimized / DLL files
|
|
5
|
+
__pycache__/
|
|
6
|
+
*.py[cod]
|
|
7
|
+
*$py.class
|
|
8
|
+
|
|
9
|
+
# C extensions
|
|
10
|
+
*.so
|
|
11
|
+
|
|
12
|
+
# Distribution / packaging
|
|
13
|
+
.Python
|
|
14
|
+
build/
|
|
15
|
+
develop-eggs/
|
|
16
|
+
dist/
|
|
17
|
+
downloads/
|
|
18
|
+
eggs/
|
|
19
|
+
.eggs/
|
|
20
|
+
lib/
|
|
21
|
+
lib64/
|
|
22
|
+
parts/
|
|
23
|
+
sdist/
|
|
24
|
+
var/
|
|
25
|
+
wheels/
|
|
26
|
+
share/python-wheels/
|
|
27
|
+
*.egg-info/
|
|
28
|
+
.installed.cfg
|
|
29
|
+
*.egg
|
|
30
|
+
MANIFEST
|
|
31
|
+
|
|
32
|
+
# PyInstaller
|
|
33
|
+
# Usually these files are written by a python script from a template
|
|
34
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
35
|
+
*.manifest
|
|
36
|
+
*.spec
|
|
37
|
+
|
|
38
|
+
# Installer logs
|
|
39
|
+
pip-log.txt
|
|
40
|
+
pip-delete-this-directory.txt
|
|
41
|
+
|
|
42
|
+
# Unit test / coverage reports
|
|
43
|
+
htmlcov/
|
|
44
|
+
.tox/
|
|
45
|
+
.nox/
|
|
46
|
+
.coverage
|
|
47
|
+
.coverage.*
|
|
48
|
+
.cache
|
|
49
|
+
nosetests.xml
|
|
50
|
+
coverage.xml
|
|
51
|
+
*.cover
|
|
52
|
+
*.py,cover
|
|
53
|
+
.hypothesis/
|
|
54
|
+
.pytest_cache/
|
|
55
|
+
cover/
|
|
56
|
+
|
|
57
|
+
# Translations
|
|
58
|
+
*.mo
|
|
59
|
+
*.pot
|
|
60
|
+
|
|
61
|
+
# Django stuff:
|
|
62
|
+
*.log
|
|
63
|
+
local_settings.py
|
|
64
|
+
db.sqlite3
|
|
65
|
+
db.sqlite3-journal
|
|
66
|
+
|
|
67
|
+
# Flask stuff:
|
|
68
|
+
instance/
|
|
69
|
+
.webassets-cache
|
|
70
|
+
|
|
71
|
+
# Scrapy stuff:
|
|
72
|
+
.scrapy
|
|
73
|
+
|
|
74
|
+
# Sphinx documentation
|
|
75
|
+
docs/_build/
|
|
76
|
+
|
|
77
|
+
# PyBuilder
|
|
78
|
+
.pybuilder/
|
|
79
|
+
target/
|
|
80
|
+
|
|
81
|
+
# Jupyter Notebook
|
|
82
|
+
.ipynb_checkpoints
|
|
83
|
+
|
|
84
|
+
# IPython
|
|
85
|
+
profile_default/
|
|
86
|
+
ipython_config.py
|
|
87
|
+
|
|
88
|
+
# pyenv
|
|
89
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
90
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
91
|
+
# .python-version
|
|
92
|
+
|
|
93
|
+
# pipenv
|
|
94
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
95
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
96
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
97
|
+
# install all needed dependencies.
|
|
98
|
+
#Pipfile.lock
|
|
99
|
+
|
|
100
|
+
# poetry
|
|
101
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
102
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
103
|
+
# commonly ignored for libraries.
|
|
104
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
105
|
+
#poetry.lock
|
|
106
|
+
|
|
107
|
+
# pdm
|
|
108
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
109
|
+
#pdm.lock
|
|
110
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
111
|
+
# in version control.
|
|
112
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
113
|
+
.pdm.toml
|
|
114
|
+
.pdm-python
|
|
115
|
+
.pdm-build/
|
|
116
|
+
|
|
117
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
118
|
+
__pypackages__/
|
|
119
|
+
|
|
120
|
+
# Celery stuff
|
|
121
|
+
celerybeat-schedule
|
|
122
|
+
celerybeat.pid
|
|
123
|
+
|
|
124
|
+
# SageMath parsed files
|
|
125
|
+
*.sage.py
|
|
126
|
+
|
|
127
|
+
# Environments
|
|
128
|
+
.env
|
|
129
|
+
.venv
|
|
130
|
+
env/
|
|
131
|
+
venv/
|
|
132
|
+
ENV/
|
|
133
|
+
env.bak/
|
|
134
|
+
venv.bak/
|
|
135
|
+
|
|
136
|
+
# Spyder project settings
|
|
137
|
+
.spyderproject
|
|
138
|
+
.spyproject
|
|
139
|
+
|
|
140
|
+
# Rope project settings
|
|
141
|
+
.ropeproject
|
|
142
|
+
|
|
143
|
+
# mkdocs documentation
|
|
144
|
+
/site
|
|
145
|
+
|
|
146
|
+
# mypy
|
|
147
|
+
.mypy_cache/
|
|
148
|
+
.dmypy.json
|
|
149
|
+
dmypy.json
|
|
150
|
+
|
|
151
|
+
# Pyre type checker
|
|
152
|
+
.pyre/
|
|
153
|
+
|
|
154
|
+
# pytype static type analyzer
|
|
155
|
+
.pytype/
|
|
156
|
+
|
|
157
|
+
# Cython debug symbols
|
|
158
|
+
cython_debug/
|
|
159
|
+
|
|
160
|
+
# PyCharm
|
|
161
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
162
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
163
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
164
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
165
|
+
#.idea/
|
|
166
|
+
|
|
167
|
+
# Ruff
|
|
168
|
+
.ruff_cache
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
ci:
|
|
2
|
+
autoupdate_schedule: monthly
|
|
3
|
+
autofix_commit_msg: "style(pre-commit.ci): auto fixes [...]"
|
|
4
|
+
autoupdate_commit_msg: "ci(pre-commit.ci): autoupdate"
|
|
5
|
+
|
|
6
|
+
repos:
|
|
7
|
+
- repo: https://github.com/abravalheri/validate-pyproject
|
|
8
|
+
rev: v0.18
|
|
9
|
+
hooks:
|
|
10
|
+
- id: validate-pyproject
|
|
11
|
+
|
|
12
|
+
- repo: https://github.com/psf/black
|
|
13
|
+
rev: 24.4.2
|
|
14
|
+
hooks:
|
|
15
|
+
- id: black
|
|
16
|
+
|
|
17
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
18
|
+
rev: v0.5.0
|
|
19
|
+
hooks:
|
|
20
|
+
- id: ruff
|
|
21
|
+
args: [--fix, --unsafe-fixes, --select, I]
|
|
22
|
+
- id: ruff-format
|
|
23
|
+
|
|
24
|
+
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
25
|
+
rev: v1.10.0
|
|
26
|
+
hooks:
|
|
27
|
+
- id: mypy
|
|
28
|
+
files: "^src/ri_ssim/.*\\.py$"
|
|
29
|
+
additional_dependencies:
|
|
30
|
+
- numpy
|
|
31
|
+
- types-tqdm
|
|
32
|
+
|
|
33
|
+
# check docstrings
|
|
34
|
+
- repo: https://github.com/numpy/numpydoc
|
|
35
|
+
rev: v1.7.0
|
|
36
|
+
hooks:
|
|
37
|
+
- id: numpydoc-validation
|
|
38
|
+
exclude: "^notebooks/.*"
|
microssim-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 JugLab
|
|
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.
|
microssim-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: microssim
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Improved structural similarity metrics for comparing microscopy data.
|
|
5
|
+
Project-URL: homepage, https://github.com/juglab/MicroSSIM
|
|
6
|
+
Project-URL: repository, https://github.com/juglab/MicroSSIM
|
|
7
|
+
Author: Ashesh, Joran Deschamps, Florian Jug
|
|
8
|
+
License: BSD-3-Clause
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Typing :: Typed
|
|
18
|
+
Requires-Python: >=3.9
|
|
19
|
+
Requires-Dist: numpy<2
|
|
20
|
+
Requires-Dist: scikit-image
|
|
21
|
+
Requires-Dist: scipy
|
|
22
|
+
Requires-Dist: torch
|
|
23
|
+
Requires-Dist: torchmetrics
|
|
24
|
+
Requires-Dist: tqdm
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pre-commit; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest-cov; extra == 'dev'
|
|
29
|
+
Requires-Dist: sybil; extra == 'dev'
|
|
30
|
+
Provides-Extra: examples
|
|
31
|
+
Requires-Dist: jupyter; extra == 'examples'
|
|
32
|
+
Requires-Dist: matplotlib; extra == 'examples'
|
|
33
|
+
Requires-Dist: pooch; extra == 'examples'
|
|
34
|
+
Requires-Dist: seaborn; extra == 'examples'
|
|
35
|
+
Requires-Dist: tifffile; extra == 'examples'
|
|
36
|
+
Description-Content-Type: text/markdown
|
|
37
|
+
|
|
38
|
+
# MicroSSIM
|
|
39
|
+
|
|
40
|
+
[](https://github.com/juglab/MicroSSIM/blob/main/LICENSE)
|
|
41
|
+
[](https://pypi.org/project/microssim)
|
|
42
|
+
[](https://python.org)
|
|
43
|
+
[](https://github.com/juglab/MicroSSIM/actions/workflows/ci.yml)
|
|
44
|
+
[](https://codecov.io/gh/juglab/MicroSSIM)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
MicroSSIM is an image measure aimed at addressing the shortcomings of the Structural
|
|
49
|
+
Similarity Index Measure (SSIM), in particular in the context of microscopy images. Indeed,
|
|
50
|
+
in microscopy, degraded images (e.g. lower signal to noise ratio) often have a different
|
|
51
|
+
dynamic range than the original images. This can lead to a poor performance of SSIM.
|
|
52
|
+
|
|
53
|
+
The measure normalizes the images using background subtraction and a more appropriate
|
|
54
|
+
range estimation. It then estimates a scaling factor used to scale the image
|
|
55
|
+
to the target (original image or ground truth). The metric is then computed
|
|
56
|
+
similarly to the SSIM.
|
|
57
|
+
|
|
58
|
+
MicroSSIM is easily extensible to other SSIM-like measures, such as Multi-Scale SSIM
|
|
59
|
+
(MS-SSIM), for which we provide an example.
|
|
60
|
+
|
|
61
|
+
See the [paper](https://arxiv.org/abs/2408.08747) for more details.
|
|
62
|
+
|
|
63
|
+
## Installation
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pip install microssim
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
## Usage
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
import numpy as np
|
|
74
|
+
from microssim import MicroSSIM, micro_structural_similarity
|
|
75
|
+
from skimage.metrics import structural_similarity
|
|
76
|
+
|
|
77
|
+
rng = np.random.default_rng(42)
|
|
78
|
+
N = 5
|
|
79
|
+
gt = 200 + rng.integers(0, 65535, (N, 256, 256)) # stack of different images
|
|
80
|
+
pred = rng.poisson(gt) / 10
|
|
81
|
+
|
|
82
|
+
# using the convenience function
|
|
83
|
+
result = micro_structural_similarity(gt, pred)
|
|
84
|
+
print(f"MicroSSIM: {result} (convenience function)")
|
|
85
|
+
|
|
86
|
+
# using the class allows fitting a large dataset, then scoring a subset
|
|
87
|
+
microssim = MicroSSIM()
|
|
88
|
+
microssim.fit(gt, pred) # fit the parameters
|
|
89
|
+
|
|
90
|
+
for i in range(N):
|
|
91
|
+
score = microssim.score(gt[i], pred[i]) # score a single pair
|
|
92
|
+
print(f"MicroSSIM ({i}): {score}")
|
|
93
|
+
|
|
94
|
+
# compare with SSIM from skimage
|
|
95
|
+
for i in range(N):
|
|
96
|
+
score = structural_similarity(gt[i], pred[i], data_range=65535)
|
|
97
|
+
print(f"SSIM ({i}): {score}")
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The code is similar for MicroMS3IM.
|
|
101
|
+
|
|
102
|
+
## Tips for deep learning
|
|
103
|
+
|
|
104
|
+
MicroSSIM was developed in the context of deep-learning, in which SSIM is often used
|
|
105
|
+
as a measure to compare denoised and ground-truth images. The tips presented here are
|
|
106
|
+
valid beyond deep-learning.
|
|
107
|
+
|
|
108
|
+
The larger the dataset, the better the estimate of the scaling factor will be. Therefore,
|
|
109
|
+
it is recommended to fit the measure on the entire dataset (e.g. the whole training
|
|
110
|
+
dataset). Once the data fitted, the `MSSIM` class has registered the parameters used
|
|
111
|
+
for normalization and scaling. You can then score a subset of the data (e.g. the validation
|
|
112
|
+
or test datasets) using the `score` method.
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
## Cite us
|
|
117
|
+
|
|
118
|
+
If you use MicroSSIM in your research, please cite us:
|
|
119
|
+
|
|
120
|
+
Ashesh, Ashesh, Joran Deschamps, and Florian Jug. "MicroSSIM: Improved Structural Similarity for Comparing Microscopy Data." arXiv preprint arXiv:2408.08747 (2024). [link](https://arxiv.org/abs/2408.08747).
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# MicroSSIM
|
|
2
|
+
|
|
3
|
+
[](https://github.com/juglab/MicroSSIM/blob/main/LICENSE)
|
|
4
|
+
[](https://pypi.org/project/microssim)
|
|
5
|
+
[](https://python.org)
|
|
6
|
+
[](https://github.com/juglab/MicroSSIM/actions/workflows/ci.yml)
|
|
7
|
+
[](https://codecov.io/gh/juglab/MicroSSIM)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
MicroSSIM is an image measure aimed at addressing the shortcomings of the Structural
|
|
12
|
+
Similarity Index Measure (SSIM), in particular in the context of microscopy images. Indeed,
|
|
13
|
+
in microscopy, degraded images (e.g. lower signal to noise ratio) often have a different
|
|
14
|
+
dynamic range than the original images. This can lead to a poor performance of SSIM.
|
|
15
|
+
|
|
16
|
+
The measure normalizes the images using background subtraction and a more appropriate
|
|
17
|
+
range estimation. It then estimates a scaling factor used to scale the image
|
|
18
|
+
to the target (original image or ground truth). The metric is then computed
|
|
19
|
+
similarly to the SSIM.
|
|
20
|
+
|
|
21
|
+
MicroSSIM is easily extensible to other SSIM-like measures, such as Multi-Scale SSIM
|
|
22
|
+
(MS-SSIM), for which we provide an example.
|
|
23
|
+
|
|
24
|
+
See the [paper](https://arxiv.org/abs/2408.08747) for more details.
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install microssim
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
import numpy as np
|
|
37
|
+
from microssim import MicroSSIM, micro_structural_similarity
|
|
38
|
+
from skimage.metrics import structural_similarity
|
|
39
|
+
|
|
40
|
+
rng = np.random.default_rng(42)
|
|
41
|
+
N = 5
|
|
42
|
+
gt = 200 + rng.integers(0, 65535, (N, 256, 256)) # stack of different images
|
|
43
|
+
pred = rng.poisson(gt) / 10
|
|
44
|
+
|
|
45
|
+
# using the convenience function
|
|
46
|
+
result = micro_structural_similarity(gt, pred)
|
|
47
|
+
print(f"MicroSSIM: {result} (convenience function)")
|
|
48
|
+
|
|
49
|
+
# using the class allows fitting a large dataset, then scoring a subset
|
|
50
|
+
microssim = MicroSSIM()
|
|
51
|
+
microssim.fit(gt, pred) # fit the parameters
|
|
52
|
+
|
|
53
|
+
for i in range(N):
|
|
54
|
+
score = microssim.score(gt[i], pred[i]) # score a single pair
|
|
55
|
+
print(f"MicroSSIM ({i}): {score}")
|
|
56
|
+
|
|
57
|
+
# compare with SSIM from skimage
|
|
58
|
+
for i in range(N):
|
|
59
|
+
score = structural_similarity(gt[i], pred[i], data_range=65535)
|
|
60
|
+
print(f"SSIM ({i}): {score}")
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The code is similar for MicroMS3IM.
|
|
64
|
+
|
|
65
|
+
## Tips for deep learning
|
|
66
|
+
|
|
67
|
+
MicroSSIM was developed in the context of deep-learning, in which SSIM is often used
|
|
68
|
+
as a measure to compare denoised and ground-truth images. The tips presented here are
|
|
69
|
+
valid beyond deep-learning.
|
|
70
|
+
|
|
71
|
+
The larger the dataset, the better the estimate of the scaling factor will be. Therefore,
|
|
72
|
+
it is recommended to fit the measure on the entire dataset (e.g. the whole training
|
|
73
|
+
dataset). Once the data fitted, the `MSSIM` class has registered the parameters used
|
|
74
|
+
for normalization and scaling. You can then score a subset of the data (e.g. the validation
|
|
75
|
+
or test datasets) using the `score` method.
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
## Cite us
|
|
80
|
+
|
|
81
|
+
If you use MicroSSIM in your research, please cite us:
|
|
82
|
+
|
|
83
|
+
Ashesh, Ashesh, Joran Deschamps, and Florian Jug. "MicroSSIM: Improved Structural Similarity for Comparing Microscopy Data." arXiv preprint arXiv:2408.08747 (2024). [link](https://arxiv.org/abs/2408.08747).
|