darfix 0.2.0__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.
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/__init__.py +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/__pycache__/__init__.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/__pycache__/setup.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/__init__.py +29 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/__pycache__/__init__.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/__pycache__/autofocus.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/__pycache__/dataset.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/__pycache__/geneticShiftDetection.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/__pycache__/imageOperations.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/__pycache__/imageRegistration.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/__pycache__/roi.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/autofocus.py +40 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/dataset.py +473 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/geneticShiftDetection.py +210 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/imageOperations.py +160 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/imageRegistration.py +316 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/roi.py +83 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/test/__init__.py +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/test/__pycache__/__init__.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/test/__pycache__/test_dataset.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/test/__pycache__/test_ga.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/test/__pycache__/test_image_operations.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/test/__pycache__/test_image_registration.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/test/__pycache__/test_roi.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/test/__pycache__/test_workflow.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/test/test_dataset.py +152 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/test/test_ga.py +165 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/test/test_image_operations.py +150 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/test/test_image_registration.py +371 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/test/test_roi.py +120 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/test/test_workflow.py +108 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/gui/__init__.py +29 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/gui/__pycache__/__init__.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/gui/__pycache__/backgroundSubstractionWidget.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/gui/__pycache__/datasetSelectionWidget.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/gui/__pycache__/dimensionsWidget.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/gui/__pycache__/hotPixelRemovalWidget.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/gui/__pycache__/metadataWidget.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/gui/__pycache__/operationThread.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/gui/__pycache__/roiSelectionWidget.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/gui/__pycache__/shiftCorrectionWidget.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/gui/__pycache__/utils.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/gui/backgroundSubstractionWidget.py +109 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/gui/datasetSelectionWidget.py +214 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/gui/dimensionsWidget.py +475 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/gui/hotPixelRemovalWidget.py +108 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/gui/metadataWidget.py +113 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/gui/operationThread.py +54 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/gui/roiSelectionWidget.py +163 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/gui/shiftCorrectionWidget.py +263 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/gui/utils.py +133 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/io/__init__.py +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/io/__pycache__/__init__.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/io/__pycache__/utils.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/io/utils.py +67 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/setup.py +47 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/test/__init__.py +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/test/__pycache__/__init__.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/test/__pycache__/utils.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/test/utils.py +151 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix-0.2.0-py3.7-nspkg.pth +1 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix-0.2.0-py3.7.egg-info/PKG-INFO +49 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix-0.2.0-py3.7.egg-info/SOURCES.txt +73 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix-0.2.0-py3.7.egg-info/dependency_links.txt +1 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix-0.2.0-py3.7.egg-info/entry_points.txt +9 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix-0.2.0-py3.7.egg-info/namespace_packages.txt +1 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix-0.2.0-py3.7.egg-info/not-zip-safe +1 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix-0.2.0-py3.7.egg-info/requires.txt +3 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix-0.2.0-py3.7.egg-info/top_level.txt +2 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/__init__.py +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/__pycache__/__init__.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/test/__init__.py +23 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/test/__pycache__/__init__.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/test/__pycache__/orangeWorkflowTest.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/test/__pycache__/test_widgets.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/test/orangeWorkflowTest.py +323 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/test/test_widgets.py +79 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/tutorials/__init__.py +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/tutorials/__pycache__/__init__.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/__init__.py +30 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/__pycache__/__init__.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/__pycache__/datacopy.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/__pycache__/dataselection.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/__pycache__/dimensions.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/__pycache__/metadata.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/__pycache__/noisereduction.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/__pycache__/roiselection.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/__pycache__/shiftcorrection.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/__pycache__/zsum.cpython-37.pyc +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/datacopy.py +66 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/dataselection.py +125 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/dimensions.py +153 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/icons/category.svg +9 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/icons/copy.svg +163 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/icons/image-select-box.svg +2 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/icons/metadata.png +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/icons/metadata.svg +91 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/icons/mywidget.svg +10 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/icons/noise_removal.png +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/icons/noise_removal.svg +127 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/icons/noise_removal_backup.svg +223 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/icons/param_dims.png +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/icons/param_dims.svg +130 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/icons/random.svg +69 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/icons/roi.png +0 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/icons/roi.svg +227 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/icons/save.svg +87 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/icons/shift_correction.svg +177 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/icons/upload.svg +141 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/icons/zsum.svg +71 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/metadata.py +66 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/noisereduction.py +78 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/roiselection.py +93 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/shiftcorrection.py +97 -0
- users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/orangecontrib/darfix/widgets/zsum.py +89 -0
|
File without changes
|
|
Binary file
|
|
Binary file
|
users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/__init__.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
# /*##########################################################################
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2016-2017 European Synchrotron Radiation Facility
|
|
5
|
+
#
|
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
# furnished to do so, subject to the following conditions:
|
|
12
|
+
#
|
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
|
14
|
+
# all copies or substantial portions of the Software.
|
|
15
|
+
#
|
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
+
# THE SOFTWARE.
|
|
23
|
+
#
|
|
24
|
+
# ###########################################################################*/
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
__authors__ = ["J. Garriga"]
|
|
28
|
+
__license__ = "MIT"
|
|
29
|
+
__date__ = "18/07/2019"
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/autofocus.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
# /*##########################################################################
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2016-2017 European Synchrotron Radiation Facility
|
|
5
|
+
#
|
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
# furnished to do so, subject to the following conditions:
|
|
12
|
+
#
|
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
|
14
|
+
# all copies or substantial portions of the Software.
|
|
15
|
+
#
|
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
+
# THE SOFTWARE.
|
|
23
|
+
#
|
|
24
|
+
# ###########################################################################*/
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
__authors__ = ["J. Garriga"]
|
|
28
|
+
__license__ = "MIT"
|
|
29
|
+
__date__ = "02/09/2019"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
import numpy
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def normalized_variance(img):
|
|
36
|
+
"""
|
|
37
|
+
Computes the normalized variance autofocus function into the given image.
|
|
38
|
+
"""
|
|
39
|
+
img = numpy.asanyarray(img)
|
|
40
|
+
return img.var() / img.mean()
|
users/garrigaf/.local/share/virtualenvs/darfix/lib/python3.7/site-packages/darfix/core/dataset.py
ADDED
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
# /*##########################################################################
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2016-2017 European Synchrotron Radiation Facility
|
|
5
|
+
#
|
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
# furnished to do so, subject to the following conditions:
|
|
12
|
+
#
|
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
|
14
|
+
# all copies or substantial portions of the Software.
|
|
15
|
+
#
|
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
+
# THE SOFTWARE.
|
|
23
|
+
#
|
|
24
|
+
# ###########################################################################*/
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
__authors__ = ["J. Garriga"]
|
|
28
|
+
__license__ = "MIT"
|
|
29
|
+
__date__ = "14/10/2019"
|
|
30
|
+
|
|
31
|
+
import copy
|
|
32
|
+
import numpy
|
|
33
|
+
import logging
|
|
34
|
+
import cv2
|
|
35
|
+
|
|
36
|
+
import fabio
|
|
37
|
+
|
|
38
|
+
from silx.io import utils
|
|
39
|
+
from silx.io import fabioh5
|
|
40
|
+
from silx.io.url import DataUrl
|
|
41
|
+
from silx.gui import qt
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
_logger = logging.getLogger(__file__)
|
|
45
|
+
|
|
46
|
+
DEFAULT_METADATA = fabioh5.FabioReader.DEFAULT
|
|
47
|
+
|
|
48
|
+
COUNTER_METADATA = fabioh5.FabioReader.COUNTER
|
|
49
|
+
|
|
50
|
+
POSITIONER_METADATA = fabioh5.FabioReader.POSITIONER
|
|
51
|
+
|
|
52
|
+
_METADATA_TYPES = {'default': DEFAULT_METADATA,
|
|
53
|
+
'counter': COUNTER_METADATA,
|
|
54
|
+
'positioner': POSITIONER_METADATA}
|
|
55
|
+
|
|
56
|
+
_METADATA_TYPES_I = {}
|
|
57
|
+
"""used to retrieve the metadata name (str) for the silx.io.fabioh5 id"""
|
|
58
|
+
for key, value in _METADATA_TYPES.items():
|
|
59
|
+
assert value not in _METADATA_TYPES_I
|
|
60
|
+
_METADATA_TYPES_I[value] = key
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class Dataset(qt.QObject):
|
|
64
|
+
"""Class to define a dataset from a series of raw data and dark data.
|
|
65
|
+
|
|
66
|
+
:param raw_filename: first filename of raw data to iterate from.
|
|
67
|
+
:param dark_filename: first filename of dark data to iterate from.
|
|
68
|
+
:param Union[Generator,Iterator,List] filenames: Ordered list of filenames
|
|
69
|
+
to process as a file series.
|
|
70
|
+
:param Union[List,numpy.ndarray] data: list or numpy array of the dataset
|
|
71
|
+
data.
|
|
72
|
+
:param Union[List,numpy.ndarray] dark_data: list or numpy array of the
|
|
73
|
+
dataset dark data.
|
|
74
|
+
:param Union[Bool, None] load_data: If False, the data is not computed
|
|
75
|
+
after the creation of the file_series. It waits until the load_data()
|
|
76
|
+
method is called.
|
|
77
|
+
"""
|
|
78
|
+
signalProgress = qt.Signal(int)
|
|
79
|
+
|
|
80
|
+
def __init__(self, raw_filename=None, dark_filename=None, filenames=None,
|
|
81
|
+
filter_data=False, load_data=True):
|
|
82
|
+
qt.QObject.__init__(self)
|
|
83
|
+
|
|
84
|
+
self._data = None
|
|
85
|
+
self._reshaped_data = None
|
|
86
|
+
self._filter_data = filter_data
|
|
87
|
+
self.dark_frames = []
|
|
88
|
+
self.metadata = []
|
|
89
|
+
self.raw_filename = raw_filename
|
|
90
|
+
self.dark_filename = dark_filename
|
|
91
|
+
self.filenames = filenames
|
|
92
|
+
self.__dims = AcquisitionDims()
|
|
93
|
+
|
|
94
|
+
# Initialize data
|
|
95
|
+
self._file_series = fabio.open_series(first_filename=raw_filename,
|
|
96
|
+
filenames=filenames)
|
|
97
|
+
|
|
98
|
+
if load_data:
|
|
99
|
+
self.load_data()
|
|
100
|
+
|
|
101
|
+
if dark_filename is not None:
|
|
102
|
+
|
|
103
|
+
with fabio.open_series(first_filename=dark_filename) as series:
|
|
104
|
+
for dark_frame in series.frames():
|
|
105
|
+
# TODO: save only data, headers??
|
|
106
|
+
self.dark_frames.append(dark_frame.data)
|
|
107
|
+
self.dark_frames = numpy.array(self.dark_frames)
|
|
108
|
+
|
|
109
|
+
def load_data(self):
|
|
110
|
+
"""
|
|
111
|
+
Function that saves the data of the frames into DataUrls and the metadata
|
|
112
|
+
into fabio Readers.
|
|
113
|
+
"""
|
|
114
|
+
data_urls = []
|
|
115
|
+
self.metadata = []
|
|
116
|
+
|
|
117
|
+
for iFrame in numpy.arange(start=0, stop=self._file_series.nframes):
|
|
118
|
+
frame = self._file_series.getframe(iFrame).file_container
|
|
119
|
+
data_urls.append(DataUrl(file_path=frame.filename,
|
|
120
|
+
scheme='fabio').path())
|
|
121
|
+
self.metadata.append(fabioh5.EdfFabioReader(fabio_image=frame))
|
|
122
|
+
self.signalProgress.emit(int(iFrame / self._file_series.nframes * 100))
|
|
123
|
+
|
|
124
|
+
self.data_urls = numpy.array(data_urls)
|
|
125
|
+
|
|
126
|
+
def compute_intensity_threshold(self):
|
|
127
|
+
"""
|
|
128
|
+
Function that computes the data from the set of urls.
|
|
129
|
+
If the filter_data flag is activated it filters the data following the next:
|
|
130
|
+
-- First, it computes the intensity for each frame, by calculating the variance after
|
|
131
|
+
passing a gaussian filter.
|
|
132
|
+
-- Second, computes the histogram of the intensity.
|
|
133
|
+
-- Finally, saves the data of the frames with an intensity bigger than a threshold.
|
|
134
|
+
The threshold is set to be the second bin of the histogram.
|
|
135
|
+
"""
|
|
136
|
+
# TODO: enter the number of bins per parameter??
|
|
137
|
+
intensity = []
|
|
138
|
+
for i, frame in enumerate(self.data):
|
|
139
|
+
intensity += [cv2.GaussianBlur(frame, (3, 3), 20).var()]
|
|
140
|
+
values, bins = numpy.histogram(intensity, int(self._data.shape[0]))
|
|
141
|
+
self.threshold = numpy.array(intensity) >= bins[1]
|
|
142
|
+
|
|
143
|
+
@property
|
|
144
|
+
def data(self):
|
|
145
|
+
"""
|
|
146
|
+
If data has not been computed, it reads the data from the urls.
|
|
147
|
+
If flag for filter data is activated, computes the threshold.
|
|
148
|
+
|
|
149
|
+
:returns: numpy.ndarray
|
|
150
|
+
"""
|
|
151
|
+
if self._data is None:
|
|
152
|
+
self._data = numpy.array([utils.get_data(url)
|
|
153
|
+
for url in self.data_urls])
|
|
154
|
+
if self._filter_data:
|
|
155
|
+
self.compute_intensity_threshold()
|
|
156
|
+
|
|
157
|
+
return self._data
|
|
158
|
+
|
|
159
|
+
@data.setter
|
|
160
|
+
def data(self, data):
|
|
161
|
+
"""
|
|
162
|
+
Sets data and reshapes the data in case reshaping has been done before.
|
|
163
|
+
"""
|
|
164
|
+
self._data = data
|
|
165
|
+
if self._reshaped_data is not None:
|
|
166
|
+
self.reshape_data()
|
|
167
|
+
|
|
168
|
+
@property
|
|
169
|
+
def hi_data(self):
|
|
170
|
+
"""
|
|
171
|
+
:returns: The high intensity data if filter flag is activated, else data.
|
|
172
|
+
"""
|
|
173
|
+
return self.data[self.threshold] if self._filter_data else self.data
|
|
174
|
+
|
|
175
|
+
@hi_data.setter
|
|
176
|
+
def hi_data(self, data):
|
|
177
|
+
self.data[self.threshold] = data
|
|
178
|
+
|
|
179
|
+
@property
|
|
180
|
+
def li_data(self):
|
|
181
|
+
"""
|
|
182
|
+
:returns: The low intensity data. The filter flag has to be activated.
|
|
183
|
+
"""
|
|
184
|
+
assert self._filter_data, "Empty frames only exist when the flag filter_data \
|
|
185
|
+
is activated"
|
|
186
|
+
|
|
187
|
+
return self.data[~self.threshold]
|
|
188
|
+
|
|
189
|
+
@li_data.setter
|
|
190
|
+
def li_data(self, li_data):
|
|
191
|
+
self.data[~self.threshold] = li_data
|
|
192
|
+
|
|
193
|
+
def reshape_data(self):
|
|
194
|
+
"""
|
|
195
|
+
Function that reshapes the data to fit the dimensions.
|
|
196
|
+
"""
|
|
197
|
+
if self.__dims.ndim > 1:
|
|
198
|
+
try:
|
|
199
|
+
shape = list(self.__dims.shape)
|
|
200
|
+
shape.append(self.data.shape[-2])
|
|
201
|
+
shape.append(self.data.shape[-1])
|
|
202
|
+
self._reshaped_data = self.data.reshape(shape)
|
|
203
|
+
except Exception as e:
|
|
204
|
+
raise ValueError('Failed to define all dimension size: %s' % e)
|
|
205
|
+
else:
|
|
206
|
+
_logger.warning("Not enough dimensions where found")
|
|
207
|
+
|
|
208
|
+
@property
|
|
209
|
+
def reshaped_data(self):
|
|
210
|
+
return self._reshaped_data
|
|
211
|
+
|
|
212
|
+
def set_reshaped_data(self, data, axis, index):
|
|
213
|
+
"""
|
|
214
|
+
Function to substitue data in a certain dimension.
|
|
215
|
+
|
|
216
|
+
:param ndarray data: data to be inserted.
|
|
217
|
+
:param int axis: axis of the data.
|
|
218
|
+
:param int index: index of the data.
|
|
219
|
+
"""
|
|
220
|
+
self.data = self.data.astype(numpy.float32, copy=False)
|
|
221
|
+
if self._filter_data:
|
|
222
|
+
threshold = numpy.take(self.threshold.view().reshape(self.__dims.shape), index, axis=axis)
|
|
223
|
+
numpy.swapaxes(self._reshaped_data, 0, axis)[index, :][threshold] = data
|
|
224
|
+
else:
|
|
225
|
+
numpy.swapaxes(self._reshaped_data, 0, axis)[index, :] = data
|
|
226
|
+
|
|
227
|
+
def get_reshaped_data(self, axis, index):
|
|
228
|
+
"""
|
|
229
|
+
Returns reshaped data.
|
|
230
|
+
If axis is given returns data at a certain index along the axis.
|
|
231
|
+
If not returns all the reshaped data.
|
|
232
|
+
|
|
233
|
+
:param int axis: axis of the data.
|
|
234
|
+
:param int index: index of the data.
|
|
235
|
+
"""
|
|
236
|
+
if self._filter_data:
|
|
237
|
+
threshold = numpy.take(self.threshold.reshape(self.__dims.shape), index, axis=axis)
|
|
238
|
+
return numpy.take(self._reshaped_data, index, axis=axis)[threshold]
|
|
239
|
+
return numpy.take(self._reshaped_data, index, axis=axis)
|
|
240
|
+
|
|
241
|
+
@property
|
|
242
|
+
def nframes(self):
|
|
243
|
+
if self.data is None:
|
|
244
|
+
return 0
|
|
245
|
+
else:
|
|
246
|
+
return self.data.shape[0]
|
|
247
|
+
|
|
248
|
+
@property
|
|
249
|
+
def dims(self):
|
|
250
|
+
return self.__dims
|
|
251
|
+
|
|
252
|
+
@dims.setter
|
|
253
|
+
def dims(self, _dims):
|
|
254
|
+
self.__dims = _dims
|
|
255
|
+
|
|
256
|
+
def add_dim(self, axis, dim):
|
|
257
|
+
"""
|
|
258
|
+
Adds a dimension to the dimension's dictionary.
|
|
259
|
+
|
|
260
|
+
:param int axis: axis of the dimension.
|
|
261
|
+
:param :class:`Dimension` dim: dimension to be added.
|
|
262
|
+
"""
|
|
263
|
+
self.__dims.add_dim(axis, dim)
|
|
264
|
+
|
|
265
|
+
def find_dimensions(self, kind):
|
|
266
|
+
"""
|
|
267
|
+
Goes over all the headers from a given kind and finds the modified
|
|
268
|
+
dimensions around the data. From this, tries to reshape the data to
|
|
269
|
+
each of the dimensions shape. To know the order of the reshaping,
|
|
270
|
+
it takes the first ``dimension.size`` frames and checks how many
|
|
271
|
+
unique values there are.
|
|
272
|
+
|
|
273
|
+
:param int kind: Type of metadata to find the dimensions.
|
|
274
|
+
"""
|
|
275
|
+
self.__dims.clear()
|
|
276
|
+
|
|
277
|
+
keys = numpy.array(list(self.metadata[0].get_keys(kind)))
|
|
278
|
+
values = numpy.array([[data.get_value(kind=kind, name=key)[0] for data in self.metadata] for key in keys])
|
|
279
|
+
# Unique values for each key.
|
|
280
|
+
unique_values = [numpy.unique(value, return_counts=True) for value in values]
|
|
281
|
+
dimensions = []
|
|
282
|
+
dataset_size = len(self.metadata)
|
|
283
|
+
# For every key that has more than one different value, creates a new Dimension.
|
|
284
|
+
for i, value in enumerate(unique_values):
|
|
285
|
+
if value[1][0] != dataset_size:
|
|
286
|
+
dimension = Dimension(kind, keys[i], size=len(value[0]))
|
|
287
|
+
dimension.setUniqueValues(value[0])
|
|
288
|
+
# Value that tells when does the change of value occur. It is used to know the order
|
|
289
|
+
# of the reshaping.
|
|
290
|
+
dimension.changing_value = numpy.unique(values[i, :int(dataset_size / value[1][0])],
|
|
291
|
+
return_counts=True)[1][0]
|
|
292
|
+
dimensions.append(dimension)
|
|
293
|
+
|
|
294
|
+
reshaped_size = dataset_size
|
|
295
|
+
# For every dimension, sorted using the changing value, tries to reshape the data.
|
|
296
|
+
# If two or more dimensions change at the same time (i.e only one reshaping is needed), it uses
|
|
297
|
+
# the first dimension that appears.
|
|
298
|
+
for dimension in sorted(dimensions, key=lambda x: x.changing_value):
|
|
299
|
+
if reshaped_size % dimension.size == 0:
|
|
300
|
+
reshaped_size /= dimension.size
|
|
301
|
+
self.__dims.add_dim(axis=self.__dims.ndim, dim=dimension)
|
|
302
|
+
_logger.info("Dimension {} of size {} has been added for reshaping".format(dimension.name, dimension.size))
|
|
303
|
+
else:
|
|
304
|
+
_logger.warning("The reshaped size {} of the data does not support reshaping into dimension {}."
|
|
305
|
+
.format(reshaped_size, dimension.name))
|
|
306
|
+
|
|
307
|
+
def __deepcopy__(self, memo):
|
|
308
|
+
"""
|
|
309
|
+
Create copy of the dataset. The data numpy array is also copied using
|
|
310
|
+
deep copy. The rest of the attributes are the same.
|
|
311
|
+
"""
|
|
312
|
+
dataset = type(self)(self.raw_filename, self.dark_filename, self.filenames,
|
|
313
|
+
filter_data=self._filter_data, load_data=False)
|
|
314
|
+
dataset.data_urls = self.data_urls
|
|
315
|
+
dataset.metadata = self.metadata
|
|
316
|
+
dataset.data = copy.deepcopy(self.data, memo)
|
|
317
|
+
dataset.dark_frames = copy.deepcopy(self.dark_frames, memo)
|
|
318
|
+
dataset.dims = copy.deepcopy(self.__dims, memo)
|
|
319
|
+
dataset.reshape_data()
|
|
320
|
+
return dataset
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
class AcquisitionDims(object):
|
|
324
|
+
"""
|
|
325
|
+
Define the view of the data which has to be made
|
|
326
|
+
"""
|
|
327
|
+
def __init__(self):
|
|
328
|
+
self.__dims = {}
|
|
329
|
+
|
|
330
|
+
def add_dim(self, axis, dim):
|
|
331
|
+
assert isinstance(dim, Dimension)
|
|
332
|
+
self.__dims[axis] = dim
|
|
333
|
+
|
|
334
|
+
def clear(self):
|
|
335
|
+
self.__dims = {}
|
|
336
|
+
|
|
337
|
+
@property
|
|
338
|
+
def ndim(self):
|
|
339
|
+
return len(self.__dims)
|
|
340
|
+
|
|
341
|
+
def get(self, axis):
|
|
342
|
+
"""
|
|
343
|
+
Get Dimension at certain axis.
|
|
344
|
+
|
|
345
|
+
:param int axis: axis of the dimension.
|
|
346
|
+
:return: the requested dimension if exists.
|
|
347
|
+
"""
|
|
348
|
+
assert type(axis) is int
|
|
349
|
+
if axis in self.__dims:
|
|
350
|
+
return self.__dims[axis]
|
|
351
|
+
else:
|
|
352
|
+
return None
|
|
353
|
+
|
|
354
|
+
@property
|
|
355
|
+
def shape(self):
|
|
356
|
+
"""
|
|
357
|
+
:return: shape of the currently defined dims
|
|
358
|
+
"""
|
|
359
|
+
shape = []
|
|
360
|
+
for iDim in range(self.ndim):
|
|
361
|
+
if iDim not in self.__dims:
|
|
362
|
+
shape.append(1)
|
|
363
|
+
else:
|
|
364
|
+
shape.append(self.__dims[iDim].size or -1)
|
|
365
|
+
return tuple(shape)
|
|
366
|
+
|
|
367
|
+
def set_size(self, axis, size):
|
|
368
|
+
"""
|
|
369
|
+
Recreated new dimension with new size and same name and kind.
|
|
370
|
+
|
|
371
|
+
:param int axis: axis of the dimension
|
|
372
|
+
:param int size: new size for the dimension
|
|
373
|
+
"""
|
|
374
|
+
if axis not in self.__dims:
|
|
375
|
+
_logger.error('axis %s is not defined yet, cannot define a size '
|
|
376
|
+
'for it' % axis)
|
|
377
|
+
else:
|
|
378
|
+
self.__dims[axis] = Dimension(name=self.__dims[axis].name,
|
|
379
|
+
kind=self.__dims[axis].kind,
|
|
380
|
+
size=size)
|
|
381
|
+
|
|
382
|
+
def __iter__(self):
|
|
383
|
+
for iAxis, dim in self.__dims.items():
|
|
384
|
+
yield (iAxis, dim)
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
class Dimension(object):
|
|
388
|
+
def __init__(self, kind, name, size=None):
|
|
389
|
+
"""
|
|
390
|
+
Define a dimension used during the dataset
|
|
391
|
+
|
|
392
|
+
:param int or str kind: metadata typr in fabioh5 mapping
|
|
393
|
+
:param str name: name of the dimension (should fit the fabioh5 mapping
|
|
394
|
+
for now)
|
|
395
|
+
:param int or None size: length of the dimension.
|
|
396
|
+
"""
|
|
397
|
+
if type(kind) is str:
|
|
398
|
+
assert kind in _METADATA_TYPES
|
|
399
|
+
self.__kind = _METADATA_TYPES[kind]
|
|
400
|
+
else:
|
|
401
|
+
self.__kind = kind
|
|
402
|
+
self.__name = name
|
|
403
|
+
self._size = size
|
|
404
|
+
self.__unique_values = []
|
|
405
|
+
self.changing_value = 0
|
|
406
|
+
"""Ordered values through the dimension"""
|
|
407
|
+
|
|
408
|
+
@property
|
|
409
|
+
def kind(self):
|
|
410
|
+
return self.__kind
|
|
411
|
+
|
|
412
|
+
def _setKind(self, kind):
|
|
413
|
+
self.__kind = kind
|
|
414
|
+
|
|
415
|
+
@property
|
|
416
|
+
def name(self):
|
|
417
|
+
return self.__name
|
|
418
|
+
|
|
419
|
+
def _setName(self, name):
|
|
420
|
+
self.__name = name
|
|
421
|
+
|
|
422
|
+
@property
|
|
423
|
+
def size(self):
|
|
424
|
+
return self._size
|
|
425
|
+
|
|
426
|
+
def _setSize(self, size):
|
|
427
|
+
self._size = size
|
|
428
|
+
|
|
429
|
+
@property
|
|
430
|
+
def unique_values(self):
|
|
431
|
+
return self.__unique_values
|
|
432
|
+
|
|
433
|
+
def setUniqueValues(self, values):
|
|
434
|
+
if len(values) != self.size:
|
|
435
|
+
_logger.warning('Unique values set for %s, is incoherent with size' % self)
|
|
436
|
+
raise ValueError('Unique values set for %s, is incoherent with size' % self)
|
|
437
|
+
self.__unique_values = values
|
|
438
|
+
|
|
439
|
+
def __str__(self):
|
|
440
|
+
return " ".join((str(self.kind), str(self.name), 'size:', str(self.size)))
|
|
441
|
+
|
|
442
|
+
def to_dict(self):
|
|
443
|
+
"""Translate the current Dimension to a dictionary"""
|
|
444
|
+
return {
|
|
445
|
+
'name': self.name,
|
|
446
|
+
'kind': self.kind,
|
|
447
|
+
'size': self.size
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
@staticmethod
|
|
451
|
+
def from_dict(_dict):
|
|
452
|
+
"""
|
|
453
|
+
|
|
454
|
+
:param dict _dict: dict defining the dimension. Should contains the
|
|
455
|
+
following keys: name, kind, size.
|
|
456
|
+
Unique values are not stored into it because it
|
|
457
|
+
depends on the metadata and should be obtained from a
|
|
458
|
+
fit / set_dims
|
|
459
|
+
:return: Dimension corresponding to the dict given
|
|
460
|
+
:rtype: :class:`Dimension`
|
|
461
|
+
"""
|
|
462
|
+
assert type(_dict) is dict
|
|
463
|
+
missing_keys = []
|
|
464
|
+
for _key in ('name', 'kind', 'size'):
|
|
465
|
+
if _key not in _dict:
|
|
466
|
+
missing_keys.append(missing_keys)
|
|
467
|
+
if len(missing_keys) > 0:
|
|
468
|
+
raise ValueError('There is some missing keys (%s), unable to create'
|
|
469
|
+
'a valid Dim')
|
|
470
|
+
else:
|
|
471
|
+
return Dimension(name=_dict['name'],
|
|
472
|
+
kind=_dict['kind'],
|
|
473
|
+
size=_dict['size'])
|