darfix 4.2.0__py3-none-any.whl → 4.3.0__py3-none-any.whl
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.
- darfix/core/data_selection.py +11 -2
- darfix/core/dataset.py +72 -157
- darfix/core/grainplot.py +44 -56
- darfix/core/{imageStack.py → image_stack.py} +9 -15
- darfix/core/moment_types.py +6 -0
- darfix/core/{noiseremoval.py → noise_removal.py} +25 -24
- darfix/core/noise_removal_type.py +14 -0
- darfix/core/positioners.py +6 -0
- darfix/core/rocking_curves.py +6 -3
- darfix/core/rocking_curves_map.py +1 -1
- darfix/core/{shiftcorrection.py → shift_correction.py} +1 -2
- darfix/core/state_of_operation.py +7 -46
- darfix/core/utils.py +0 -39
- darfix/dtypes.py +1 -9
- darfix/gui/{binningWidget.py → binning_widget.py} +2 -29
- darfix/gui/{blindSourceSeparationWidget.py → blind_source_separation_widget.py} +4 -16
- darfix/gui/{chooseDimensions.py → choose_dimensions.py} +1 -1
- darfix/gui/concatenate_scans.py +4 -4
- darfix/gui/data_selection/{hdf5_data_selection_widgets.py → hdf5_dataset_selection_widget.py} +3 -56
- darfix/gui/data_selection/line_edits.py +54 -8
- darfix/gui/data_selection/scan_selection_widgets.py +24 -11
- darfix/gui/data_selection/utils.py +11 -0
- darfix/gui/data_selection/{WorkingDirSelectionWidget.py → working_dir_selection_widget.py} +15 -14
- darfix/gui/{dimensionsWidget.py → dimensions_widget.py} +1 -1
- darfix/gui/{displayComponentsWidget.py → display_components_widget.py} +1 -1
- darfix/gui/{filterByDimension.py → filter_by_dimension.py} +1 -1
- darfix/gui/{grainplot/dimensionRangeSlider2D.py → grain_plot/dimension_range_slider_2d.py} +2 -2
- darfix/gui/{grainplot/grainPlotWidget.py → grain_plot/grain_plot_widget.py} +1 -1
- darfix/gui/{grainplot/mosaicityWidget.py → grain_plot/mosaicity_widget.py} +21 -23
- darfix/gui/{magnificationWidget.py → magnification_widget.py} +1 -1
- darfix/gui/{noiseremoval → noise_removal}/noise_removal_widget.py +12 -16
- darfix/gui/{noiseremoval → noise_removal}/operation_list_widget.py +2 -2
- darfix/gui/{noiseremoval → noise_removal}/parameters_widget.py +6 -6
- darfix/gui/{PCAWidget.py → pca_widget.py} +2 -4
- darfix/gui/{projectionWidget.py → projection_widget.py} +1 -1
- darfix/gui/rocking_curves/{rockingCurvesPlot.py → rocking_curves_plot.py} +13 -13
- darfix/gui/rocking_curves/{rockingCurvesWidget.py → rocking_curves_widget.py} +10 -18
- darfix/gui/{roiSelectionWidget.py → roi_selection_widget.py} +9 -101
- darfix/gui/{shiftcorrection/shiftCorrectionWidget.py → shift_correction/shift_correction_widget.py} +4 -7
- darfix/gui/utils/data_path_completer.py +7 -7
- darfix/gui/utils/data_path_selection.py +4 -4
- darfix/gui/utils/{rangeSlider.py → range_slider.py} +1 -1
- darfix/gui/{weakBeamWidget.py → weak_beam_widget.py} +13 -28
- darfix/gui/{zSumWidget.py → zsum_widget.py} +1 -2
- darfix/main.py +19 -3
- darfix/processing/rocking_curves.py +12 -13
- darfix/tasks/binning.py +6 -17
- darfix/tasks/blind_source_separation.py +121 -0
- darfix/tasks/blindsourceseparation.py +8 -131
- darfix/tasks/copy.py +0 -2
- darfix/tasks/data_partition.py +39 -0
- darfix/tasks/datapartition.py +8 -50
- darfix/tasks/dimension_definition.py +197 -0
- darfix/tasks/dimensiondefinition.py +8 -197
- darfix/tasks/grain_plot.py +93 -0
- darfix/tasks/grainplot.py +8 -103
- darfix/tasks/hdf5_data_selection.py +5 -11
- darfix/tasks/hdf5_scans_concatenation.py +4 -4
- darfix/tasks/noise_removal.py +88 -0
- darfix/tasks/noiseremoval.py +8 -86
- darfix/tasks/pca.py +1 -3
- darfix/tasks/projection.py +1 -6
- darfix/tasks/rocking_curves.py +10 -5
- darfix/tasks/roi.py +0 -2
- darfix/tasks/shift_correction.py +45 -0
- darfix/tasks/shiftcorrection.py +8 -43
- darfix/tasks/transformation.py +0 -2
- darfix/tasks/weak_beam.py +71 -0
- darfix/tasks/weakbeam.py +8 -67
- darfix/tasks/zsum.py +1 -1
- darfix/tests/conftest.py +1 -1
- darfix/tests/gui/test_data_path_completer.py +4 -4
- darfix/tests/gui/test_dimension_range_slider_2d.py +2 -2
- darfix/tests/gui/test_range_slider_with_spinboxes.py +1 -1
- darfix/tests/orange/test_ewoks.py +13 -9
- darfix/tests/orange/widgets/test_hdf5_data_selection.py +93 -0
- darfix/tests/tasks/test_data_copy.py +0 -2
- darfix/tests/tasks/{test_dimensiondefinition.py → test_dimension_definition.py} +1 -1
- darfix/tests/tasks/test_weak_beam.py +9 -0
- darfix/tests/test_components_matching.py +2 -2
- darfix/tests/test_dataset.py +2 -28
- darfix/tests/test_dimension.py +1 -1
- darfix/tests/test_generate_grain_maps_nxdict.py +4 -5
- darfix/tests/test_image_operations.py +4 -4
- darfix/tests/test_image_registration.py +17 -17
- darfix/tests/test_image_stack.py +2 -13
- darfix/tests/test_mask.py +1 -1
- darfix/tests/test_moments.py +2 -2
- darfix/tests/test_rocking_curves.py +1 -3
- darfix/tests/test_shift.py +7 -7
- darfix/tests/test_workflow.py +4 -4
- darfix/tests/test_zsum.py +3 -6
- {darfix-4.2.0.dist-info → darfix-4.3.0.dist-info}/METADATA +5 -3
- {darfix-4.2.0.dist-info → darfix-4.3.0.dist-info}/RECORD +141 -135
- orangecontrib/darfix/widgets/__init__.py +10 -1
- orangecontrib/darfix/widgets/binning.py +3 -3
- orangecontrib/darfix/widgets/blindsourceseparation.py +4 -6
- orangecontrib/darfix/widgets/concatenateHDF5.py +1 -1
- orangecontrib/darfix/widgets/datacopy.py +1 -1
- orangecontrib/darfix/widgets/datapartition.py +7 -102
- orangecontrib/darfix/widgets/{datasetWidgetBase.py → dataset_widget_base.py} +17 -5
- orangecontrib/darfix/widgets/dimensions.py +6 -6
- orangecontrib/darfix/widgets/grainplot.py +3 -3
- orangecontrib/darfix/widgets/hdf5dataselection.py +34 -14
- orangecontrib/darfix/widgets/metadata.py +2 -2
- orangecontrib/darfix/widgets/noiseremoval.py +4 -4
- orangecontrib/darfix/widgets/{operationWidgetBase.py → operation_widget_base.py} +2 -2
- orangecontrib/darfix/widgets/pca.py +2 -2
- orangecontrib/darfix/widgets/projection.py +2 -2
- orangecontrib/darfix/widgets/rockingcurves.py +5 -2
- orangecontrib/darfix/widgets/roiselection.py +24 -106
- orangecontrib/darfix/widgets/rsmhistogram.py +2 -2
- orangecontrib/darfix/widgets/shiftcorrection.py +3 -3
- orangecontrib/darfix/widgets/transformation.py +4 -4
- orangecontrib/darfix/widgets/weakbeam.py +20 -103
- orangecontrib/darfix/widgets/zsum.py +3 -5
- darfix/gui/dataPartitionWidget.py +0 -167
- darfix/gui/data_selection/DataSelectionBase.py +0 -59
- darfix/tests/tasks/test_datapartition.py +0 -52
- /darfix/core/{componentsMatching.py → components_matching.py} +0 -0
- /darfix/core/{datapathfinder.py → data_path_finder.py} +0 -0
- /darfix/core/{imageRegistration.py → image_registration.py} +0 -0
- /darfix/gui/{grainplot → grain_plot}/__init__.py +0 -0
- /darfix/gui/{grainplot → grain_plot}/_oridist_toolbar_buttons.py +0 -0
- /darfix/gui/{grainplot → grain_plot}/flashlight.py +0 -0
- /darfix/gui/{grainplot → grain_plot}/flashlight_mode_action.py +0 -0
- /darfix/gui/{grainplot → grain_plot}/oridist_toolbar.py +0 -0
- /darfix/gui/{grainplot → grain_plot}/utils.py +0 -0
- /darfix/gui/{metadataWidget.py → metadata_widget.py} +0 -0
- /darfix/gui/{operationProcess.py → parallel/operation_process.py} +0 -0
- /darfix/gui/{operationThread.py → parallel/operation_thread.py} +0 -0
- /darfix/gui/rocking_curves/{fitComboBox.py → fit_combobox.py} +0 -0
- /darfix/gui/{roiLimitsToolbar.py → roi_limits_toolbar.py} +0 -0
- /darfix/gui/{rsmHistogramWidget.py → rsm_histogram_widget.py} +0 -0
- /darfix/gui/{rsmWidget.py → rsm_widget.py} +0 -0
- /darfix/gui/{shiftcorrection → shift_correction}/__init__.py +0 -0
- /darfix/gui/{shiftcorrection/shiftInput.py → shift_correction/shift_input.py} +0 -0
- /darfix/gui/utils/{standardButtonBox.py → standard_buttonbox.py} +0 -0
- /darfix/processing/{imageOperations.py → image_operations.py} +0 -0
- /darfix/tests/{test_datapathfinder.py → test_data_path_finder.py} +0 -0
- {darfix-4.2.0.dist-info → darfix-4.3.0.dist-info}/WHEEL +0 -0
- {darfix-4.2.0.dist-info → darfix-4.3.0.dist-info}/entry_points.txt +0 -0
- {darfix-4.2.0.dist-info → darfix-4.3.0.dist-info}/licenses/LICENSE +0 -0
- {darfix-4.2.0.dist-info → darfix-4.3.0.dist-info}/top_level.txt +0 -0
|
@@ -6,17 +6,17 @@ import pytest
|
|
|
6
6
|
from ewoks import load_graph
|
|
7
7
|
from ewoks import save_graph
|
|
8
8
|
from ewokscore import execute_graph
|
|
9
|
-
from ewoksorange.
|
|
9
|
+
from ewoksorange.gui.workflows.owscheme import ows_to_ewoks
|
|
10
10
|
|
|
11
11
|
from darfix.core.moment_types import MomentType
|
|
12
|
-
from darfix.tasks.
|
|
13
|
-
from darfix.tasks.
|
|
14
|
-
from darfix.tasks.
|
|
15
|
-
from darfix.tasks.
|
|
12
|
+
from darfix.tasks.blind_source_separation import BlindSourceSeparation
|
|
13
|
+
from darfix.tasks.blind_source_separation import Method
|
|
14
|
+
from darfix.tasks.dimension_definition import DimensionDefinition
|
|
15
|
+
from darfix.tasks.grain_plot import GrainPlot
|
|
16
16
|
from darfix.tasks.hdf5_data_selection import HDF5DataSelection
|
|
17
|
-
from darfix.tasks.
|
|
17
|
+
from darfix.tasks.noise_removal import NoiseRemoval
|
|
18
18
|
from darfix.tasks.roi import RoiSelection
|
|
19
|
-
from darfix.tasks.
|
|
19
|
+
from darfix.tasks.shift_correction import ShiftCorrection
|
|
20
20
|
|
|
21
21
|
try:
|
|
22
22
|
from importlib.resources import files as resource_files
|
|
@@ -122,7 +122,9 @@ def test_example_workflow1(tmpdir, silx_resources):
|
|
|
122
122
|
)
|
|
123
123
|
|
|
124
124
|
numpy.testing.assert_allclose(
|
|
125
|
-
ref_entry["Mosaicity/Mosaicity"],
|
|
125
|
+
ref_entry["Mosaicity/Mosaicity"],
|
|
126
|
+
output_entry["Mosaicity/Mosaicity"],
|
|
127
|
+
atol=0.002,
|
|
126
128
|
)
|
|
127
129
|
numpy.testing.assert_allclose(
|
|
128
130
|
ref_entry["Orientation distribution/key/image"],
|
|
@@ -175,7 +177,9 @@ def test_example_workflow2(tmpdir, load_from_json, silx_resources):
|
|
|
175
177
|
)
|
|
176
178
|
|
|
177
179
|
numpy.testing.assert_allclose(
|
|
178
|
-
ref_entry["Mosaicity/Mosaicity"],
|
|
180
|
+
ref_entry["Mosaicity/Mosaicity"],
|
|
181
|
+
output_entry["Mosaicity/Mosaicity"],
|
|
182
|
+
atol=0.002,
|
|
179
183
|
)
|
|
180
184
|
numpy.testing.assert_allclose(
|
|
181
185
|
ref_entry["Orientation distribution/key/image"],
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import os
|
|
2
|
+
from unittest import mock
|
|
2
3
|
|
|
3
4
|
import h5py
|
|
4
5
|
import numpy
|
|
@@ -58,3 +59,95 @@ def test_HDF5DataSelectionWidgetOW(tmp_path, qtapp): # noqa F811
|
|
|
58
59
|
|
|
59
60
|
dataset = window.get_task_output_value("dataset")
|
|
60
61
|
assert isinstance(dataset, Dataset)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def test_bad_file_selection(qtapp): # noqa F811
|
|
65
|
+
|
|
66
|
+
window = HDF5DataSelectionWidgetOW()
|
|
67
|
+
window._rawDataSelection.setFilePath("file_with_bad_name")
|
|
68
|
+
|
|
69
|
+
# Border color is red
|
|
70
|
+
assert (
|
|
71
|
+
window._rawDataSelection._fileLineEdit._lineEdit.styleSheet()
|
|
72
|
+
== window._rawDataSelection._fileLineEdit._ERROR_LINE_EDIT_STYLE_SHEET
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
with mock.patch(
|
|
76
|
+
"orangecontrib.darfix.widgets.hdf5dataselection.show_error_msg"
|
|
77
|
+
) as mock_error_msg:
|
|
78
|
+
|
|
79
|
+
window._executeTask()
|
|
80
|
+
# Should pop an error message because file path does not exist
|
|
81
|
+
mock_error_msg.assert_called_once()
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def test_file_with_unexpected_format(tmp_path, qtapp): # noqa F811
|
|
85
|
+
raw_data_dir = tmp_path / "raw_data"
|
|
86
|
+
raw_data_dir.mkdir()
|
|
87
|
+
|
|
88
|
+
raw_data_file = os.path.join(raw_data_dir, "raw.hdf5")
|
|
89
|
+
with h5py.File(raw_data_file, mode="w") as h5f:
|
|
90
|
+
detector = h5f.create_group("/my_detector/")
|
|
91
|
+
detector.create_dataset("dataset", (10, 100, 100), numpy.uint16)
|
|
92
|
+
h5f.create_group("/my_positioners/")
|
|
93
|
+
|
|
94
|
+
window = HDF5DataSelectionWidgetOW()
|
|
95
|
+
|
|
96
|
+
fileLineEdit = window._rawDataSelection._fileLineEdit
|
|
97
|
+
detectorLineEdit = window._rawDataSelection._detectorLineEdit
|
|
98
|
+
positionerLineEdit = window._rawDataSelection._positionersLineEdit
|
|
99
|
+
|
|
100
|
+
fileLineEdit._lineEdit.setText(raw_data_file)
|
|
101
|
+
fileLineEdit._lineEdit.editingFinished.emit()
|
|
102
|
+
|
|
103
|
+
# Border color is red
|
|
104
|
+
assert (
|
|
105
|
+
detectorLineEdit._lineEdit.styleSheet()
|
|
106
|
+
== detectorLineEdit._ERROR_LINE_EDIT_STYLE_SHEET
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
# Border color is red
|
|
110
|
+
assert (
|
|
111
|
+
positionerLineEdit._lineEdit.styleSheet()
|
|
112
|
+
== positionerLineEdit._ERROR_LINE_EDIT_STYLE_SHEET
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
with mock.patch(
|
|
116
|
+
"orangecontrib.darfix.widgets.hdf5dataselection.show_error_msg"
|
|
117
|
+
) as mock_error_msg:
|
|
118
|
+
|
|
119
|
+
window._executeTask()
|
|
120
|
+
# Should pop an error message because positioners and detector paths are bad
|
|
121
|
+
mock_error_msg.assert_called_once()
|
|
122
|
+
|
|
123
|
+
window._rawDataSelection.setDetectorPath("/my_detector/dataset")
|
|
124
|
+
|
|
125
|
+
# Border recover normal stylesheet
|
|
126
|
+
assert (
|
|
127
|
+
detectorLineEdit._lineEdit.styleSheet()
|
|
128
|
+
== detectorLineEdit._defaultLineEditStyle
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
with mock.patch(
|
|
132
|
+
"orangecontrib.darfix.widgets.hdf5dataselection.show_error_msg"
|
|
133
|
+
) as mock_error_msg:
|
|
134
|
+
|
|
135
|
+
window._executeTask()
|
|
136
|
+
# Should pop an error message because positioners path is bad
|
|
137
|
+
mock_error_msg.assert_called_once()
|
|
138
|
+
|
|
139
|
+
window._rawDataSelection.setPositionersPath("/my_positioners")
|
|
140
|
+
|
|
141
|
+
# Border recover normal stylesheet
|
|
142
|
+
assert (
|
|
143
|
+
positionerLineEdit._lineEdit.styleSheet()
|
|
144
|
+
== positionerLineEdit._defaultLineEditStyle
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
with mock.patch(
|
|
148
|
+
"orangecontrib.darfix.widgets.hdf5dataselection.show_error_msg"
|
|
149
|
+
) as mock_error_msg:
|
|
150
|
+
|
|
151
|
+
window._executeTask()
|
|
152
|
+
# No error message as all field are valid now
|
|
153
|
+
mock_error_msg.assert_not_called()
|
|
@@ -8,11 +8,9 @@ from darfix.tests.utils import createDataset
|
|
|
8
8
|
def test_data_copy():
|
|
9
9
|
dataset = Dataset(
|
|
10
10
|
dataset=createDataset(data=numpy.linspace(1, 10, 100).reshape(10, 5, 2)),
|
|
11
|
-
indices=None,
|
|
12
11
|
bg_dataset=numpy.ones(
|
|
13
12
|
100,
|
|
14
13
|
).reshape(10, 5, 2),
|
|
15
|
-
bg_indices=None,
|
|
16
14
|
)
|
|
17
15
|
|
|
18
16
|
task = DataCopy(
|
|
@@ -6,7 +6,7 @@ import pytest
|
|
|
6
6
|
from ewokscore.missing_data import MISSING_DATA
|
|
7
7
|
|
|
8
8
|
from darfix import dtypes
|
|
9
|
-
from darfix.tasks.
|
|
9
|
+
from darfix.tasks.dimension_definition import DimensionDefinition
|
|
10
10
|
from darfix.tests.utils import create_3_motors_metadata
|
|
11
11
|
from darfix.tests.utils import createDataset
|
|
12
12
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
from darfix.dtypes import Dataset
|
|
2
|
+
from darfix.tasks.weak_beam import WeakBeam
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def test_weakbeam(input_dataset, tmp_path):
|
|
6
|
+
input_dataset.find_dimensions()
|
|
7
|
+
input_dataset.reshape_data()
|
|
8
|
+
task = WeakBeam(inputs={"dataset": Dataset(input_dataset), "nvalue": 1})
|
|
9
|
+
task.execute()
|
|
@@ -3,8 +3,8 @@ import pytest
|
|
|
3
3
|
from silx.opencl.common import ocl
|
|
4
4
|
from skimage import data
|
|
5
5
|
|
|
6
|
-
from darfix.core.
|
|
7
|
-
from darfix.core.
|
|
6
|
+
from darfix.core.components_matching import ComponentsMatching
|
|
7
|
+
from darfix.core.components_matching import Method
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
@pytest.fixture(scope="module")
|
darfix/tests/test_dataset.py
CHANGED
|
@@ -37,9 +37,8 @@ class _BaseDatasetTest:
|
|
|
37
37
|
result = numpy.sum(self.dataset.as_array3d(), axis=0)
|
|
38
38
|
numpy.testing.assert_array_equal(zsum, result)
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
result = numpy.sum(self.dataset.as_array3d(indices), axis=0)
|
|
40
|
+
zsum = self.dataset.zsum()
|
|
41
|
+
result = numpy.sum(self.dataset.as_array3d(), axis=0)
|
|
43
42
|
numpy.testing.assert_array_equal(zsum, result)
|
|
44
43
|
|
|
45
44
|
def test_filter_data(self):
|
|
@@ -66,10 +65,6 @@ class _BaseDatasetTest:
|
|
|
66
65
|
|
|
67
66
|
self.assertEqual(len(shift), 2)
|
|
68
67
|
|
|
69
|
-
shift = self.dataset.find_shift(indices=[0, 1])
|
|
70
|
-
|
|
71
|
-
self.assertEqual(len(shift), 2)
|
|
72
|
-
|
|
73
68
|
def test_pca(self):
|
|
74
69
|
|
|
75
70
|
H, W = self.dataset.pca()
|
|
@@ -79,13 +74,6 @@ class _BaseDatasetTest:
|
|
|
79
74
|
)
|
|
80
75
|
self.assertEqual(W.shape, (self.dataset.nframes, self.dataset.nframes))
|
|
81
76
|
|
|
82
|
-
n_components = 1
|
|
83
|
-
indices = [1, 2]
|
|
84
|
-
H, W = self.dataset.pca(num_components=n_components, indices=indices)
|
|
85
|
-
|
|
86
|
-
self.assertEqual(H.shape, (n_components, len(self.dataset.data[0].flatten())))
|
|
87
|
-
self.assertEqual(W.shape, (2, n_components))
|
|
88
|
-
|
|
89
77
|
def test_nmf(self):
|
|
90
78
|
|
|
91
79
|
num_components = 2
|
|
@@ -94,13 +82,6 @@ class _BaseDatasetTest:
|
|
|
94
82
|
self.assertEqual(H.shape, (num_components, len(self.dataset.data[0].flatten())))
|
|
95
83
|
self.assertEqual(W.shape, (self.dataset.nframes, num_components))
|
|
96
84
|
|
|
97
|
-
num_components = 1
|
|
98
|
-
indices = [1, 2]
|
|
99
|
-
H, W = self.dataset.nmf(num_components=num_components, indices=indices)
|
|
100
|
-
|
|
101
|
-
self.assertEqual(H.shape, (num_components, len(self.dataset.data[0].flatten())))
|
|
102
|
-
self.assertEqual(W.shape, (2, num_components))
|
|
103
|
-
|
|
104
85
|
def test_nica(self):
|
|
105
86
|
|
|
106
87
|
num_components = 2
|
|
@@ -109,13 +90,6 @@ class _BaseDatasetTest:
|
|
|
109
90
|
self.assertEqual(H.shape, (num_components, len(self.dataset.data[0].flatten())))
|
|
110
91
|
self.assertEqual(W.shape, (self.dataset.nframes, num_components))
|
|
111
92
|
|
|
112
|
-
num_components = 1
|
|
113
|
-
indices = [1, 2]
|
|
114
|
-
H, W = self.dataset.nica(num_components=num_components, indices=indices)
|
|
115
|
-
|
|
116
|
-
self.assertEqual(H.shape, (num_components, len(self.dataset.data[0].flatten())))
|
|
117
|
-
self.assertEqual(W.shape, (2, num_components))
|
|
118
|
-
|
|
119
93
|
|
|
120
94
|
class TestHDF5Dataset(_BaseDatasetTest, unittest.TestCase):
|
|
121
95
|
def setUp(self):
|
darfix/tests/test_dimension.py
CHANGED
|
@@ -10,7 +10,7 @@ from darfix.core.dataset import ImageDataset
|
|
|
10
10
|
from darfix.core.dimension import AcquisitionDims
|
|
11
11
|
from darfix.core.dimension import Dimension
|
|
12
12
|
from darfix.dtypes import Dataset
|
|
13
|
-
from darfix.tasks.
|
|
13
|
+
from darfix.tasks.dimension_definition import get_dimensions_error
|
|
14
14
|
from darfix.tests.utils import createHDF5Dataset
|
|
15
15
|
|
|
16
16
|
|
|
@@ -5,8 +5,8 @@ import numpy
|
|
|
5
5
|
from silx.io.dictdump import dicttonx
|
|
6
6
|
from silx.io.nxdata import NXdata
|
|
7
7
|
|
|
8
|
+
from darfix.core.grainplot import GrainPlotData
|
|
8
9
|
from darfix.core.grainplot import MultiDimMomentType
|
|
9
|
-
from darfix.core.grainplot import OrientationDistData
|
|
10
10
|
from darfix.core.grainplot import generate_grain_maps_nxdict
|
|
11
11
|
from darfix.core.moment_types import MomentType
|
|
12
12
|
|
|
@@ -19,7 +19,7 @@ def test_generate_grain_maps_nxdict_1d():
|
|
|
19
19
|
dset = createHDF5Dataset1D(numpy.random.rand(10, 10, 10))
|
|
20
20
|
dset.find_dimensions()
|
|
21
21
|
dset.apply_moments()
|
|
22
|
-
nxdict = generate_grain_maps_nxdict(dset, None
|
|
22
|
+
nxdict = generate_grain_maps_nxdict(dset, None)
|
|
23
23
|
|
|
24
24
|
for moment_type in MomentType:
|
|
25
25
|
assert moment_type.value in nxdict["entry"]
|
|
@@ -33,10 +33,9 @@ def test_generate_grain_maps_nxdict_3d():
|
|
|
33
33
|
dset = createHDF5Dataset3D(numpy.random.rand(5, 5, 5, 6, 6))
|
|
34
34
|
dset.find_dimensions()
|
|
35
35
|
dset.apply_moments()
|
|
36
|
-
orientation_dist_data =
|
|
37
|
-
mosa = numpy.zeros((10, 10))
|
|
36
|
+
orientation_dist_data = GrainPlotData(dset, 0, 1, [0, 1], [0, 1], dset.zsum())
|
|
38
37
|
|
|
39
|
-
nxdict = generate_grain_maps_nxdict(dset,
|
|
38
|
+
nxdict = generate_grain_maps_nxdict(dset, orientation_dist_data)
|
|
40
39
|
|
|
41
40
|
for motor in ("motor1", "motor2", "motor3"):
|
|
42
41
|
for moment_type in MomentType:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import numpy
|
|
2
2
|
import pytest
|
|
3
3
|
|
|
4
|
-
from darfix.processing import
|
|
4
|
+
from darfix.processing import image_operations
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
@pytest.fixture
|
|
@@ -45,7 +45,7 @@ def test_background_subtraction(data, dark):
|
|
|
45
45
|
dtype=numpy.uint16,
|
|
46
46
|
)
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
image_operations.background_subtraction(data, dark)
|
|
49
49
|
numpy.testing.assert_array_equal(expected, data)
|
|
50
50
|
|
|
51
51
|
|
|
@@ -62,7 +62,7 @@ def test_hot_pixel_removal(data):
|
|
|
62
62
|
dtype=numpy.uint16,
|
|
63
63
|
)
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
image_operations.hot_pixel_removal(data)
|
|
66
66
|
numpy.testing.assert_array_equal(expected, data)
|
|
67
67
|
|
|
68
68
|
|
|
@@ -80,6 +80,6 @@ def test_threshold_removal(data):
|
|
|
80
80
|
dtype=numpy.uint16,
|
|
81
81
|
)
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
image_operations.threshold_removal(data, 2, 4)
|
|
84
84
|
|
|
85
85
|
numpy.testing.assert_array_equal(expected, data)
|
|
@@ -6,7 +6,7 @@ try:
|
|
|
6
6
|
except ImportError:
|
|
7
7
|
scipy = None
|
|
8
8
|
|
|
9
|
-
from darfix.core import
|
|
9
|
+
from darfix.core import image_registration
|
|
10
10
|
from darfix.tests import utils
|
|
11
11
|
|
|
12
12
|
|
|
@@ -63,8 +63,8 @@ def test_find_shift(data):
|
|
|
63
63
|
shift = (-1.4, 1.32)
|
|
64
64
|
for img in data:
|
|
65
65
|
# The shift corresponds to the pixel offset relative to the reference image
|
|
66
|
-
offset_image =
|
|
67
|
-
computed_shift =
|
|
66
|
+
offset_image = image_registration._opencv_fft_shift(img, shift[1], shift[0])
|
|
67
|
+
computed_shift = image_registration.find_shift(img, offset_image, 100)
|
|
68
68
|
numpy.testing.assert_allclose(shift, -computed_shift, rtol=1e-04)
|
|
69
69
|
|
|
70
70
|
|
|
@@ -72,10 +72,10 @@ def test_apply_shift(data):
|
|
|
72
72
|
"""Tests the correct apply of the shift"""
|
|
73
73
|
shift = (0, 0)
|
|
74
74
|
for img in data:
|
|
75
|
-
shifted_image =
|
|
75
|
+
shifted_image = image_registration.apply_opencv_shift(img, shift)
|
|
76
76
|
numpy.testing.assert_allclose(img, shifted_image, rtol=1e-04)
|
|
77
77
|
for img in data:
|
|
78
|
-
shifted_image =
|
|
78
|
+
shifted_image = image_registration.apply_opencv_shift(
|
|
79
79
|
img, shift, shift_approach="linear"
|
|
80
80
|
)
|
|
81
81
|
numpy.testing.assert_allclose(img, shifted_image, rtol=1e-04)
|
|
@@ -83,11 +83,11 @@ def test_apply_shift(data):
|
|
|
83
83
|
|
|
84
84
|
def test_improve_shift(data):
|
|
85
85
|
"""Tests the shift improvement"""
|
|
86
|
-
h =
|
|
86
|
+
h = image_registration.improve_linear_shift(
|
|
87
87
|
data, [1, 1], 0.1, 0.1, 1, shift_approach="fft"
|
|
88
88
|
)
|
|
89
89
|
numpy.testing.assert_allclose(h, 0.0)
|
|
90
|
-
h =
|
|
90
|
+
h = image_registration.improve_linear_shift(
|
|
91
91
|
data, [1, 1], 0.1, 0.1, 1, shift_approach="linear"
|
|
92
92
|
)
|
|
93
93
|
numpy.testing.assert_allclose(h, 0.0)
|
|
@@ -108,7 +108,7 @@ def test_shift_detection10(rstate):
|
|
|
108
108
|
).real
|
|
109
109
|
]
|
|
110
110
|
data = numpy.asanyarray(data, dtype=numpy.int16)
|
|
111
|
-
optimal_shift =
|
|
111
|
+
optimal_shift = image_registration.shift_detection(data, 100, shift_approach="fft")
|
|
112
112
|
|
|
113
113
|
shift = [-1, 0]
|
|
114
114
|
|
|
@@ -130,7 +130,7 @@ def test_shift_detection01(rstate):
|
|
|
130
130
|
).real
|
|
131
131
|
]
|
|
132
132
|
data = numpy.asanyarray(data, dtype=numpy.int16)
|
|
133
|
-
optimal_shift =
|
|
133
|
+
optimal_shift = image_registration.shift_detection(data, 100, shift_approach="fft")
|
|
134
134
|
|
|
135
135
|
shift = [0, -1]
|
|
136
136
|
|
|
@@ -153,7 +153,7 @@ def test_shift_detection11(rstate):
|
|
|
153
153
|
]
|
|
154
154
|
data = numpy.asanyarray(data, dtype=numpy.int16)
|
|
155
155
|
|
|
156
|
-
optimal_shift =
|
|
156
|
+
optimal_shift = image_registration.shift_detection(data, 100)
|
|
157
157
|
|
|
158
158
|
shift = [-1, -1]
|
|
159
159
|
|
|
@@ -175,7 +175,7 @@ def test_shift_detection_float(rstate):
|
|
|
175
175
|
).real
|
|
176
176
|
]
|
|
177
177
|
data = numpy.asanyarray(data, dtype=numpy.int16)
|
|
178
|
-
optimal_shift =
|
|
178
|
+
optimal_shift = image_registration.shift_detection(data, 100)
|
|
179
179
|
shift = [-0.5, -0.2]
|
|
180
180
|
|
|
181
181
|
numpy.testing.assert_allclose(shift, numpy.round(optimal_shift, 1))
|
|
@@ -184,7 +184,7 @@ def test_shift_detection_float(rstate):
|
|
|
184
184
|
def test_shift_correction00(data):
|
|
185
185
|
"""Tests the shift correction of a [0,0] shift."""
|
|
186
186
|
|
|
187
|
-
data =
|
|
187
|
+
data = image_registration.shift_correction(
|
|
188
188
|
data, numpy.outer([0, 0], numpy.arange(3))
|
|
189
189
|
)
|
|
190
190
|
numpy.testing.assert_allclose(data, data, rtol=1e-03)
|
|
@@ -219,7 +219,7 @@ def test_shift_correction01(data):
|
|
|
219
219
|
]
|
|
220
220
|
)
|
|
221
221
|
|
|
222
|
-
new_data =
|
|
222
|
+
new_data = image_registration.shift_correction(
|
|
223
223
|
data, numpy.outer([1, 0], numpy.arange(3))
|
|
224
224
|
)
|
|
225
225
|
numpy.testing.assert_allclose(new_data, expected, rtol=1e-03)
|
|
@@ -254,7 +254,7 @@ def test_shift_correction10(data):
|
|
|
254
254
|
]
|
|
255
255
|
)
|
|
256
256
|
|
|
257
|
-
new_data =
|
|
257
|
+
new_data = image_registration.shift_correction(
|
|
258
258
|
data, numpy.outer([0, 1], numpy.arange(3))
|
|
259
259
|
)
|
|
260
260
|
numpy.testing.assert_allclose(new_data, expected, rtol=1e-05)
|
|
@@ -288,7 +288,7 @@ def test_shift_correction11(data):
|
|
|
288
288
|
],
|
|
289
289
|
]
|
|
290
290
|
)
|
|
291
|
-
new_data =
|
|
291
|
+
new_data = image_registration.shift_correction(
|
|
292
292
|
data, numpy.outer([1, 1], numpy.arange(3))
|
|
293
293
|
)
|
|
294
294
|
numpy.testing.assert_allclose(new_data, expected, rtol=1e-05)
|
|
@@ -321,7 +321,7 @@ def test_shift_correction_float(data):
|
|
|
321
321
|
],
|
|
322
322
|
]
|
|
323
323
|
|
|
324
|
-
new_data =
|
|
324
|
+
new_data = image_registration.shift_correction(
|
|
325
325
|
data, numpy.outer([0.25, 0.1], numpy.arange(3))
|
|
326
326
|
)
|
|
327
327
|
numpy.testing.assert_allclose(new_data, expected, rtol=1e-05)
|
|
@@ -411,4 +411,4 @@ def test_shift_correction0(tmpdir, first_frame, metadata_dict):
|
|
|
411
411
|
|
|
412
412
|
for frame in dataset.data.take(0, 0):
|
|
413
413
|
# Check if the difference between the shifted frames and the sample frame is small enough
|
|
414
|
-
numpy.testing.assert_allclose(dataset.as_array3d(0
|
|
414
|
+
numpy.testing.assert_allclose(dataset.as_array3d()[0], frame, atol=6)
|
darfix/tests/test_image_stack.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import numpy
|
|
2
2
|
import pytest
|
|
3
3
|
|
|
4
|
-
from darfix.core.
|
|
5
|
-
from darfix.core.
|
|
4
|
+
from darfix.core.image_stack import FixedDimension
|
|
5
|
+
from darfix.core.image_stack import ImageStack
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
def flatten_scans(data: numpy.ndarray):
|
|
@@ -100,10 +100,6 @@ def test_filter_indices(image_stack: ImageStack):
|
|
|
100
100
|
def test_get_filtered_data(image_stack: ImageStack):
|
|
101
101
|
# Should give the same result as old ImageDataset::get_data
|
|
102
102
|
|
|
103
|
-
numpy.testing.assert_array_equal(
|
|
104
|
-
image_stack.get_filtered_data([0, 1, 2]),
|
|
105
|
-
legacy_get_data(image_stack, [0, 1, 2]),
|
|
106
|
-
)
|
|
107
103
|
numpy.testing.assert_array_equal(
|
|
108
104
|
image_stack.get_filtered_data(None), legacy_get_data(image_stack, None)
|
|
109
105
|
)
|
|
@@ -120,10 +116,3 @@ def test_get_filtered_data(image_stack: ImageStack):
|
|
|
120
116
|
image_stack.get_filtered_data(fixed_dimension=FixedDimension(2, 1)),
|
|
121
117
|
legacy_get_data(image_stack, dimension=[[2], [1]]),
|
|
122
118
|
)
|
|
123
|
-
|
|
124
|
-
numpy.testing.assert_array_equal(
|
|
125
|
-
image_stack.get_filtered_data(
|
|
126
|
-
fixed_dimension=FixedDimension(2, 1), indices=numpy.arange(0, 18)
|
|
127
|
-
),
|
|
128
|
-
legacy_get_data(image_stack, dimension=[[2], [1]], indices=numpy.arange(0, 18)),
|
|
129
|
-
)
|
darfix/tests/test_mask.py
CHANGED
darfix/tests/test_moments.py
CHANGED
|
@@ -7,10 +7,10 @@ from darfix.core.utils import NoDimensionsError
|
|
|
7
7
|
def test_apply_moments(dataset):
|
|
8
8
|
|
|
9
9
|
with pytest.raises(NoDimensionsError):
|
|
10
|
-
dataset.apply_moments(
|
|
10
|
+
dataset.apply_moments()
|
|
11
11
|
|
|
12
12
|
dataset.find_dimensions()
|
|
13
13
|
dataset.reshape_data()
|
|
14
|
-
moments = dataset.apply_moments(
|
|
14
|
+
moments = dataset.apply_moments()
|
|
15
15
|
assert moments[0][MomentType.COM].shape == dataset.frame_shape
|
|
16
16
|
assert moments[1][MomentType.SKEWNESS].shape == dataset.frame_shape
|
|
@@ -54,13 +54,11 @@ def test_apply_fit_on_2d_dataset():
|
|
|
54
54
|
with pytest.raises(NoDimensionsError):
|
|
55
55
|
fit_dataset, maps = dataset.apply_fit()
|
|
56
56
|
dataset.find_dimensions()
|
|
57
|
-
|
|
58
|
-
fit_dataset, maps = dataset.apply_fit(indices=indices)
|
|
57
|
+
fit_dataset, maps = dataset.apply_fit()
|
|
59
58
|
|
|
60
59
|
assert dataset.dims.ndim == 2
|
|
61
60
|
assert len(maps) == 7
|
|
62
61
|
assert fit_dataset.nframes == dataset.nframes
|
|
63
|
-
numpy.testing.assert_equal(fit_dataset.as_array3d(10), dataset.as_array3d(10))
|
|
64
62
|
|
|
65
63
|
|
|
66
64
|
def test_apply_fit_on_3d_dataset():
|
darfix/tests/test_shift.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import numpy
|
|
2
2
|
import pytest
|
|
3
3
|
|
|
4
|
-
from darfix.core.
|
|
4
|
+
from darfix.core.image_registration import apply_opencv_shift
|
|
5
5
|
from darfix.tests.utils import createHDF5Dataset2D
|
|
6
6
|
|
|
7
7
|
|
|
@@ -15,7 +15,7 @@ def two_motors_dataset():
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
def test_find_shift(two_motors_dataset):
|
|
18
|
-
"""Tests the shift detection
|
|
18
|
+
"""Tests the shift detection"""
|
|
19
19
|
dataset = two_motors_dataset
|
|
20
20
|
|
|
21
21
|
dataset.find_dimensions()
|
|
@@ -39,7 +39,7 @@ def test_find_shift(two_motors_dataset):
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
def test_apply_shift(two_motors_dataset):
|
|
42
|
-
"""Tests the shift correction
|
|
42
|
+
"""Tests the shift correction"""
|
|
43
43
|
dataset = two_motors_dataset
|
|
44
44
|
|
|
45
45
|
dataset.find_dimensions()
|
|
@@ -50,7 +50,7 @@ def test_apply_shift(two_motors_dataset):
|
|
|
50
50
|
# Axis 1 : dim size is 10
|
|
51
51
|
assert dataset.dims[1].size == 10
|
|
52
52
|
|
|
53
|
-
input_img = dataset.as_array3d(4
|
|
53
|
+
input_img = dataset.as_array3d()[4].copy()
|
|
54
54
|
# Check fit is well applied at index 4
|
|
55
55
|
result_idx4 = apply_opencv_shift(input_img, shift=(0.5 * 4, 0.5 * 4))
|
|
56
56
|
|
|
@@ -60,9 +60,9 @@ def test_apply_shift(two_motors_dataset):
|
|
|
60
60
|
AssertionError,
|
|
61
61
|
numpy.testing.assert_array_equal,
|
|
62
62
|
input_img,
|
|
63
|
-
dataset.as_array3d(4
|
|
63
|
+
dataset.as_array3d()[4],
|
|
64
64
|
)
|
|
65
|
-
numpy.testing.assert_allclose(result_idx4, dataset.as_array3d(4)
|
|
65
|
+
numpy.testing.assert_allclose(result_idx4, dataset.as_array3d()[4])
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
def test_find_shift_along_dimension(two_motors_dataset):
|
|
@@ -79,7 +79,7 @@ def test_find_shift_along_dimension(two_motors_dataset):
|
|
|
79
79
|
|
|
80
80
|
|
|
81
81
|
def test_apply_shift_along_dimension(two_motors_dataset):
|
|
82
|
-
"""Tests the shift correction
|
|
82
|
+
"""Tests the shift correction"""
|
|
83
83
|
dataset = two_motors_dataset
|
|
84
84
|
|
|
85
85
|
dataset.find_dimensions()
|
darfix/tests/test_workflow.py
CHANGED
|
@@ -7,7 +7,7 @@ except ImportError:
|
|
|
7
7
|
pytest.skip("scipy is missing", allow_module_level=True)
|
|
8
8
|
|
|
9
9
|
from darfix.core import roi
|
|
10
|
-
from darfix.processing import
|
|
10
|
+
from darfix.processing import image_operations
|
|
11
11
|
from darfix.tests import utils
|
|
12
12
|
|
|
13
13
|
|
|
@@ -61,15 +61,15 @@ def test_workflow0(dataset, dark_dataset):
|
|
|
61
61
|
)
|
|
62
62
|
|
|
63
63
|
# Background substraction of the data
|
|
64
|
-
|
|
65
|
-
data,
|
|
64
|
+
image_operations.background_subtraction(
|
|
65
|
+
data, image_operations.compute_background(dark_frames, "median")
|
|
66
66
|
)
|
|
67
67
|
# ROI of the data
|
|
68
68
|
data = roi.apply_3D_ROI(
|
|
69
69
|
data, size=[3, 1], center=(numpy.array(data[0].shape) / 2).astype(int)
|
|
70
70
|
)
|
|
71
71
|
# Threshold removal of the data
|
|
72
|
-
|
|
72
|
+
image_operations.threshold_removal(data, 1, 20)
|
|
73
73
|
numpy.testing.assert_array_equal(data, expected)
|
|
74
74
|
|
|
75
75
|
|
darfix/tests/test_zsum.py
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import numpy
|
|
2
2
|
|
|
3
|
-
from darfix.core.
|
|
3
|
+
from darfix.core.image_stack import FixedDimension
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
def test_zsum(dataset):
|
|
7
|
-
indices = [1, 2, 3, 6]
|
|
8
7
|
|
|
9
8
|
dataset.find_dimensions()
|
|
10
9
|
dataset.reshape_data()
|
|
11
10
|
result = numpy.sum(
|
|
12
|
-
dataset.get_filtered_data(
|
|
13
|
-
fixed_dimension=FixedDimension(0, 1), indices=indices
|
|
14
|
-
),
|
|
11
|
+
dataset.get_filtered_data(fixed_dimension=FixedDimension(0, 1)),
|
|
15
12
|
axis=0,
|
|
16
13
|
)
|
|
17
|
-
zsum = dataset.zsum(
|
|
14
|
+
zsum = dataset.zsum(dimension=FixedDimension(0, 1))
|
|
18
15
|
numpy.testing.assert_array_equal(zsum, result)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: darfix
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.3.0
|
|
4
4
|
Summary: Computer vision software for the interpretation of diffraction images
|
|
5
5
|
Author-email: ESRF <dau-pydev@esrf.fr>
|
|
6
6
|
License: The MIT license follows:
|
|
@@ -50,11 +50,13 @@ Requires-Dist: scikit-learn
|
|
|
50
50
|
Requires-Dist: scipy
|
|
51
51
|
Requires-Dist: tqdm
|
|
52
52
|
Requires-Dist: joblib
|
|
53
|
+
Requires-Dist: esrf-pathlib
|
|
54
|
+
Requires-Dist: colorstamps
|
|
53
55
|
Requires-Dist: eval_type_backport
|
|
54
56
|
Provides-Extra: full-noqt
|
|
55
57
|
Requires-Dist: opencv-python-headless>=4.3.0.36; extra == "full-noqt"
|
|
56
58
|
Requires-Dist: scikit-image>=0.17.1; extra == "full-noqt"
|
|
57
|
-
Requires-Dist: ewoksorange
|
|
59
|
+
Requires-Dist: ewoksorange>=3.0.0; extra == "full-noqt"
|
|
58
60
|
Requires-Dist: hdf5plugin; extra == "full-noqt"
|
|
59
61
|
Provides-Extra: full
|
|
60
62
|
Requires-Dist: darfix[full_noqt]; extra == "full"
|
|
@@ -70,7 +72,7 @@ Requires-Dist: flake8_nb>=0.3.1; extra == "dev"
|
|
|
70
72
|
Requires-Dist: isort; extra == "dev"
|
|
71
73
|
Provides-Extra: doc
|
|
72
74
|
Requires-Dist: darfix[test]; extra == "doc"
|
|
73
|
-
Requires-Dist: sphinx
|
|
75
|
+
Requires-Dist: sphinx<9,>=7.2; extra == "doc"
|
|
74
76
|
Requires-Dist: sphinx-autodoc-typehints>=1.16; extra == "doc"
|
|
75
77
|
Requires-Dist: sphinxcontrib-video; extra == "doc"
|
|
76
78
|
Requires-Dist: sphinx-copybutton; extra == "doc"
|