tomwer 1.3.7__py3-none-any.whl → 1.3.9__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.
Files changed (109) hide show
  1. tomwer/core/process/reconstruction/nabu/nabuslices.py +0 -48
  2. tomwer/core/process/reconstruction/nabu/utils.py +2 -0
  3. tomwer/gui/control/datawatcher/datawatcher.py +1 -24
  4. tomwer/version.py +1 -1
  5. {tomwer-1.3.7.dist-info → tomwer-1.3.9.dist-info}/METADATA +1 -1
  6. {tomwer-1.3.7.dist-info → tomwer-1.3.9.dist-info}/RECORD +12 -109
  7. orangecontrib/tomwer/test/TestAcquisition.py +0 -246
  8. orangecontrib/tomwer/widgets/cluster/test/test_future_supervisorow.py +0 -87
  9. orangecontrib/tomwer/widgets/cluster/test/test_slurm_clusterow.py +0 -67
  10. orangecontrib/tomwer/widgets/control/test/test_advancement.py +0 -51
  11. orangecontrib/tomwer/widgets/control/test/test_data_validator.py +0 -55
  12. orangecontrib/tomwer/widgets/control/test/test_datadiscovery.py +0 -131
  13. orangecontrib/tomwer/widgets/control/test/test_datalist.py +0 -70
  14. orangecontrib/tomwer/widgets/control/test/test_datalistener.py +0 -137
  15. orangecontrib/tomwer/widgets/control/test/test_dataselector.py +0 -95
  16. orangecontrib/tomwer/widgets/control/test/test_datawatcher.py +0 -436
  17. orangecontrib/tomwer/widgets/control/test/test_emailow.py +0 -29
  18. orangecontrib/tomwer/widgets/control/test/test_notifier.py +0 -51
  19. orangecontrib/tomwer/widgets/control/test/test_nxtomo_concatenate_ow.py +0 -64
  20. orangecontrib/tomwer/widgets/control/test/test_nxtomomill.py +0 -160
  21. orangecontrib/tomwer/widgets/control/test/test_reduce_dark_flat_selector.py +0 -40
  22. orangecontrib/tomwer/widgets/control/test/test_singletomoobj.py +0 -40
  23. orangecontrib/tomwer/widgets/control/test/test_timerow.py +0 -51
  24. orangecontrib/tomwer/widgets/control/test/test_tomoobj_serie.py +0 -96
  25. orangecontrib/tomwer/widgets/control/test/test_volume_selector.py +0 -69
  26. orangecontrib/tomwer/widgets/control/test/test_volumesymlink.py +0 -51
  27. orangecontrib/tomwer/widgets/debugtools/test/test_dataset_generator.py +0 -57
  28. orangecontrib/tomwer/widgets/debugtools/test/test_object_inspector.py +0 -62
  29. orangecontrib/tomwer/widgets/other/test/test_pythonscript.py +0 -31
  30. orangecontrib/tomwer/widgets/reconstruction/test/test_axis.py +0 -224
  31. orangecontrib/tomwer/widgets/reconstruction/test/test_cast_volumeow.py +0 -85
  32. orangecontrib/tomwer/widgets/reconstruction/test/test_dark_refs_widget.py +0 -136
  33. orangecontrib/tomwer/widgets/reconstruction/test/test_delta_beta_selector.py +0 -15
  34. orangecontrib/tomwer/widgets/reconstruction/test/test_i_norm.py +0 -226
  35. orangecontrib/tomwer/widgets/reconstruction/test/test_nabu_helical_prepare_weights_double.py +0 -20
  36. orangecontrib/tomwer/widgets/reconstruction/test/test_nabu_volume.py +0 -100
  37. orangecontrib/tomwer/widgets/reconstruction/test/test_nabu_widget.py +0 -107
  38. orangecontrib/tomwer/widgets/reconstruction/test/test_sa_delta_beta.py +0 -194
  39. orangecontrib/tomwer/widgets/reconstruction/test/test_saaxis.py +0 -220
  40. orangecontrib/tomwer/widgets/stitching/test/test_zstitching.py +0 -308
  41. orangecontrib/tomwer/widgets/test/test_conditions.py +0 -111
  42. orangecontrib/tomwer/widgets/test/test_darkref.py +0 -251
  43. orangecontrib/tomwer/widgets/test/test_foldertransfert.py +0 -131
  44. orangecontrib/tomwer/widgets/visualization/test/test_dataviewerow.py +0 -83
  45. orangecontrib/tomwer/widgets/visualization/test/test_diffviewerow.py +0 -65
  46. orangecontrib/tomwer/widgets/visualization/test/test_live_sliceow.py +0 -63
  47. orangecontrib/tomwer/widgets/visualization/test/test_nxtomo_metadata_viewer.py +0 -29
  48. orangecontrib/tomwer/widgets/visualization/test/test_radio_stackow.py +0 -56
  49. orangecontrib/tomwer/widgets/visualization/test/test_sample_movedow.py +0 -72
  50. orangecontrib/tomwer/widgets/visualization/test/test_sinogram_viewerow.py +0 -56
  51. orangecontrib/tomwer/widgets/visualization/test/test_slice_stackow.py +0 -57
  52. orangecontrib/tomwer/widgets/visualization/test/test_volume_viewerow.py +0 -57
  53. tomwer/core/log/test/test_processlog.py +0 -41
  54. tomwer/core/process/edit/test/test_darkflatpatch.py +0 -269
  55. tomwer/core/process/edit/test/test_imagekey_editor.py +0 -125
  56. tomwer/core/process/icat/test/test_create_screenshots.py +0 -98
  57. tomwer/core/process/icat/test/test_gallery.py +0 -170
  58. tomwer/core/process/reconstruction/nabu/test/test_castvolume.py +0 -143
  59. tomwer/core/process/reconstruction/nabu/test/test_nabu_utils.py +0 -203
  60. tomwer/core/process/reconstruction/nabu/test/test_nabunormalization.py +0 -222
  61. tomwer/core/process/script/test/test_script.py +0 -68
  62. tomwer/core/process/stitching/test/test_metadataholder.py +0 -17
  63. tomwer/core/process/visualization/test/test_data_viewer.py +0 -39
  64. tomwer/core/process/visualization/test/test_diff_viewer.py +0 -39
  65. tomwer/core/process/visualization/test/test_image_stack_viewer.py +0 -41
  66. tomwer/core/process/visualization/test/test_radio_stack.py +0 -39
  67. tomwer/core/process/visualization/test/test_sample_moved.py +0 -41
  68. tomwer/core/process/visualization/test/test_sinogram_viewer.py +0 -39
  69. tomwer/core/process/visualization/test/test_slice_stack.py +0 -39
  70. tomwer/core/process/visualization/test/test_volume_viewer.py +0 -39
  71. tomwer/core/utils/test/test_image.py +0 -30
  72. tomwer/core/utils/test/test_nxtomo.py +0 -66
  73. tomwer/core/utils/test/test_scan_utils.py +0 -46
  74. tomwer/core/utils/test/test_time.py +0 -6
  75. tomwer/core/volume/test/test_volumes.py +0 -21
  76. tomwer/gui/control/serie/test/test_creator.py +0 -451
  77. tomwer/gui/control/serie/test/test_nxtomo_concatenate.py +0 -21
  78. tomwer/gui/icat/test/test_create_screenshots_gui.py +0 -23
  79. tomwer/gui/icat/test/test_gallery_gui.py +0 -37
  80. tomwer/gui/reconstruction/nabu/test/test_check.py +0 -92
  81. tomwer/gui/reconstruction/nabu/test/test_ctf.py +0 -46
  82. tomwer/gui/reconstruction/nabu/test/test_helical.py +0 -21
  83. tomwer/gui/reconstruction/nabu/test/test_nabu_preprocessing.py +0 -81
  84. tomwer/gui/reconstruction/normalization/test/test_intensity.py +0 -119
  85. tomwer/gui/stitching/config/tests/test_axisparams.py +0 -25
  86. tomwer/gui/stitching/tests/test_axis_ordered_list.py +0 -21
  87. tomwer/gui/stitching/tests/test_normalization.py +0 -27
  88. tomwer/gui/stitching/tests/test_preview.py +0 -85
  89. tomwer/gui/stitching/tests/test_stitching_raw.py +0 -110
  90. tomwer/gui/stitching/tests/test_z_stitching.py +0 -67
  91. tomwer/gui/stitching/tests/utils.py +0 -79
  92. tomwer/gui/stitching/z_stitching/tests/test_fine_estimation.py +0 -35
  93. tomwer/gui/stitching/z_stitching/tests/test_raw_estimation.py +0 -215
  94. tomwer/gui/stitching/z_stitching/tests/test_stitching_window.py +0 -51
  95. tomwer/gui/utils/test/test_completer.py +0 -67
  96. tomwer/gui/utils/test/test_line_selector.py +0 -21
  97. tomwer/gui/utils/test/test_splashscreen.py +0 -8
  98. tomwer/gui/utils/test/test_vignettes.py +0 -68
  99. tomwer/io/utils/test/test_raw_and_processed_data.py +0 -10
  100. tomwer/io/utils/test/test_utils.py +0 -92
  101. tomwer/tests/test_ewoks/test_conversion.py +0 -104
  102. tomwer/tests/test_ewoks/test_single_node_execution.py +0 -112
  103. tomwer/tests/test_ewoks/test_workflows.py +0 -160
  104. /tomwer-1.3.7-py3.11-nspkg.pth → /tomwer-1.3.9-py3.11-nspkg.pth +0 -0
  105. {tomwer-1.3.7.dist-info → tomwer-1.3.9.dist-info}/LICENSE +0 -0
  106. {tomwer-1.3.7.dist-info → tomwer-1.3.9.dist-info}/WHEEL +0 -0
  107. {tomwer-1.3.7.dist-info → tomwer-1.3.9.dist-info}/entry_points.txt +0 -0
  108. {tomwer-1.3.7.dist-info → tomwer-1.3.9.dist-info}/namespace_packages.txt +0 -0
  109. {tomwer-1.3.7.dist-info → tomwer-1.3.9.dist-info}/top_level.txt +0 -0
@@ -1,308 +0,0 @@
1
- import os
2
- import pickle
3
- import shutil
4
- import tempfile
5
-
6
- import numpy
7
-
8
- from orangecanvas.scheme.readwrite import literal_dumps
9
- from silx.gui import qt
10
- from silx.gui.utils.testutils import TestCaseQt
11
-
12
- from orangecontrib.tomwer.widgets.stitching.ZStitchingConfigOW import ZStitchingConfigOW
13
- from tomwer.core.utils.scanutils import MockNXtomo
14
- from tomwer.core.volume.hdf5volume import HDF5Volume
15
-
16
-
17
- class TestScansZStitchingConfigOW(TestCaseQt):
18
- """
19
- Test stitching with scans
20
- """
21
-
22
- def setUp(self):
23
- super().setUp()
24
- self._widget = ZStitchingConfigOW()
25
- self._tmp_dir = tempfile.mkdtemp()
26
- self._scans = []
27
- for i_scan in range(3):
28
- scan = MockNXtomo(
29
- scan_path=os.path.join(self._tmp_dir, f"scan_{i_scan}.nx"),
30
- n_ini_proj=20,
31
- n_proj=20,
32
- n_alignement_proj=2,
33
- dim=10,
34
- ).scan
35
- self._scans.append(scan)
36
- self._widget.setConfiguration(
37
- {
38
- "inputs": {
39
- "input_datasets": [
40
- scan.get_identifier().to_str() for scan in self._scans
41
- ],
42
- },
43
- "stitching": {
44
- "type": "z-preproc",
45
- "stitching_strategy": "closest",
46
- "alignment_axis_1": "center",
47
- "alignment_axis_2": "center",
48
- "pad_mode": "constant",
49
- },
50
- "z-preproc": {
51
- "data_path": "myentry",
52
- "location": "/path/to/mynexusfile.nx",
53
- },
54
- }
55
- )
56
- self.qapp.processEvents()
57
-
58
- def test_get_configuration(self):
59
- """Make sure the set configuration will be the get configuration"""
60
- config = self._widget.getConfiguration()
61
- assert config == {
62
- "inputs": {
63
- "input_datasets": list(
64
- [scan.get_identifier().to_str() for scan in self._scans]
65
- ),
66
- "slices": "",
67
- },
68
- "stitching": {
69
- "stitching_strategy": "cosinus weights",
70
- "type": "z-preproc",
71
- "axis_0_pos_px": [0] * len(self._scans),
72
- "axis_0_params": "overlap_size=;img_reg_method=nabu-fft;window_size=400",
73
- "axis_2_pos_px": [0] * len(self._scans),
74
- "axis_2_params": "img_reg_method=None;window_size=400",
75
- "flipud": False,
76
- "fliplr": False,
77
- "rescale_frames": False,
78
- "rescale_params": "rescale_min_percentile=0;rescale_max_percentile=100",
79
- "alignment_axis_1": "center",
80
- "alignment_axis_2": "center",
81
- "pad_mode": "constant",
82
- },
83
- "z-preproc": {
84
- "data_path": "myentry",
85
- "location": "/path/to/mynexusfile.nx",
86
- },
87
- "output": {
88
- "overwrite_results": True,
89
- },
90
- "normalization_by_sample": {
91
- "active": False,
92
- "margin": 0,
93
- "method": "median",
94
- "side": "left",
95
- "width": 30,
96
- },
97
- }
98
- # test setting some metadata for stitching
99
- for i_scan, scan in enumerate(
100
- self._widget.widget._widget._mainWidget.getTomoObjs()
101
- ):
102
- scan.stitching_metadata.setPxPos(-i_scan, axis=0)
103
- scan.stitching_metadata.setPxPos(-i_scan * 10, axis=2)
104
- self.qapp.processEvents()
105
- config = self._widget.getConfiguration()
106
- assert config == {
107
- "inputs": {
108
- "input_datasets": list(
109
- [scan.get_identifier().to_str() for scan in self._scans]
110
- ),
111
- "slices": "",
112
- },
113
- "stitching": {
114
- "type": "z-preproc",
115
- "stitching_strategy": "cosinus weights",
116
- "axis_0_pos_px": [0, -1, -2],
117
- "axis_0_params": "overlap_size=;img_reg_method=nabu-fft;window_size=400",
118
- "axis_2_pos_px": [0, -10, -20],
119
- "axis_2_params": "img_reg_method=None;window_size=400",
120
- "flipud": False,
121
- "fliplr": False,
122
- "rescale_frames": False,
123
- "rescale_params": "rescale_min_percentile=0;rescale_max_percentile=100",
124
- "alignment_axis_1": "center",
125
- "alignment_axis_2": "center",
126
- "pad_mode": "constant",
127
- },
128
- "z-preproc": {
129
- "data_path": "myentry",
130
- "location": "/path/to/mynexusfile.nx",
131
- },
132
- "output": {
133
- "overwrite_results": True,
134
- },
135
- "normalization_by_sample": {
136
- "active": False,
137
- "margin": 0,
138
- "method": "median",
139
- "side": "left",
140
- "width": 30,
141
- },
142
- }
143
- config["stitching"]["axis_2_pos_px"] = [0, -1, -2]
144
- config["output"]["overwrite_results"] = False
145
- self._widget.setConfiguration(config)
146
- assert self._widget.getConfiguration() == config
147
-
148
- def tearDown(self):
149
- self._widget.setAttribute(qt.Qt.WA_DeleteOnClose)
150
- self._widget.close()
151
- self._widget = None
152
- shutil.rmtree(self._tmp_dir)
153
-
154
- def test_serializing(self):
155
- pickle.dumps(self._widget.getConfiguration())
156
-
157
- def test_literal_dumps(self):
158
- literal_dumps(self._widget.getConfiguration())
159
-
160
-
161
- class TestVolumesZStitchingConfigOW(TestCaseQt):
162
- """
163
- Test ZStitchingConfigOW with volumes
164
- """
165
-
166
- def setUp(self):
167
- super().setUp()
168
- self._widget = ZStitchingConfigOW()
169
- self._tmp_dir = tempfile.mkdtemp()
170
- self._volumes = []
171
- for i_volumes in range(4):
172
- volume = HDF5Volume(
173
- file_path=os.path.join(self._tmp_dir, f"volume_{i_volumes}.hdf5"),
174
- data_path="entry0000",
175
- data=numpy.ones(shape=(10, 20, 30)),
176
- metadata={},
177
- )
178
- volume.save()
179
- self._volumes.append(volume)
180
-
181
- self.output_volume = HDF5Volume(
182
- file_path=os.path.join(self._tmp_dir, "result.hdf5"),
183
- data_path="stitched",
184
- )
185
- self._widget.setConfiguration(
186
- {
187
- "inputs": {
188
- "input_datasets": [
189
- volume.get_identifier().to_str() for volume in self._volumes
190
- ],
191
- },
192
- "stitching": {
193
- "type": "z-postproc",
194
- "stitching_strategy": "closest",
195
- "alignment_axis_1": "center",
196
- "alignment_axis_2": "center",
197
- "pad_mode": "constant",
198
- },
199
- "z-postproc": {
200
- "output_volume": self.output_volume.get_identifier().to_str(),
201
- },
202
- }
203
- )
204
- self.qapp.processEvents()
205
-
206
- def test_get_configuration(self):
207
- """Make sure the set configuration will be the get configuration"""
208
- config = self._widget.getConfiguration()
209
- assert config == {
210
- "inputs": {
211
- "input_datasets": list(
212
- [scan.get_identifier().to_str() for scan in self._volumes]
213
- ),
214
- "slices": "",
215
- },
216
- "stitching": {
217
- "stitching_strategy": "cosinus weights",
218
- "type": "z-postproc",
219
- "axis_0_pos_px": [0] * len(self._volumes),
220
- "axis_0_params": "overlap_size=;img_reg_method=nabu-fft;window_size=400",
221
- "axis_2_pos_px": [0] * len(self._volumes),
222
- "axis_2_params": "img_reg_method=None;window_size=400",
223
- "flipud": False,
224
- "fliplr": False,
225
- "rescale_frames": False,
226
- "rescale_params": "rescale_min_percentile=0;rescale_max_percentile=100",
227
- "alignment_axis_1": "center",
228
- "alignment_axis_2": "center",
229
- "pad_mode": "constant",
230
- },
231
- "z-postproc": {
232
- "output_volume": self.output_volume.get_identifier().to_str(),
233
- },
234
- "output": {
235
- "overwrite_results": True,
236
- },
237
- "normalization_by_sample": {
238
- "active": False,
239
- "margin": 0,
240
- "method": "median",
241
- "side": "left",
242
- "width": 30,
243
- },
244
- }
245
- # test setting some metadata for stitching
246
- for i_scan, scan in enumerate(
247
- self._widget.widget._widget._mainWidget.getTomoObjs()
248
- ):
249
- scan.stitching_metadata.setPxPos(-i_scan, axis=0)
250
- scan.stitching_metadata.setPxPos(-i_scan * 10, axis=2)
251
- self.qapp.processEvents()
252
- config = self._widget.getConfiguration()
253
- assert config == {
254
- "inputs": {
255
- "input_datasets": list(
256
- [scan.get_identifier().to_str() for scan in self._volumes]
257
- ),
258
- "slices": "",
259
- },
260
- "stitching": {
261
- "stitching_strategy": "cosinus weights",
262
- "type": "z-postproc",
263
- "axis_0_pos_px": [0, -1, -2, -3],
264
- "axis_0_params": "overlap_size=;img_reg_method=nabu-fft;window_size=400",
265
- "axis_2_pos_px": [0, -10, -20, -30],
266
- "axis_2_params": "img_reg_method=None;window_size=400",
267
- "flipud": False,
268
- "fliplr": False,
269
- "rescale_frames": False,
270
- "rescale_params": "rescale_min_percentile=0;rescale_max_percentile=100",
271
- "alignment_axis_1": "center",
272
- "alignment_axis_2": "center",
273
- "pad_mode": "constant",
274
- },
275
- "z-postproc": {
276
- "output_volume": self.output_volume.get_identifier().to_str(),
277
- },
278
- "output": {
279
- "overwrite_results": True,
280
- },
281
- "normalization_by_sample": {
282
- "active": False,
283
- "margin": 0,
284
- "method": "median",
285
- "side": "left",
286
- "width": 30,
287
- },
288
- }
289
- config["stitching"]["axis_2_pos_px"] = [0, -1, -2, -3]
290
- config["stitching"]["rescale_frames"] = True
291
- config["stitching"][
292
- "rescale_params"
293
- ] = "rescale_min_percentile=10;rescale_max_percentile=35"
294
- config["output"]["overwrite_results"] = False
295
- self._widget.setConfiguration(config)
296
- assert self._widget.getConfiguration() == config
297
-
298
- def tearDown(self):
299
- self._widget.setAttribute(qt.Qt.WA_DeleteOnClose)
300
- self._widget.close()
301
- self._widget = None
302
- shutil.rmtree(self._tmp_dir)
303
-
304
- def test_serializing(self):
305
- pickle.dumps(self._widget.getConfiguration())
306
-
307
- def test_literal_dumps(self):
308
- literal_dumps(self._widget.getConfiguration())
@@ -1,111 +0,0 @@
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
- __authors__ = ["H. Payno"]
27
- __license__ = "MIT"
28
- __date__ = "12/08/2021"
29
-
30
- import gc
31
- import logging
32
- import os
33
- import shutil
34
- import tempfile
35
-
36
- from silx.gui import qt
37
- from silx.gui.utils.testutils import SignalListener, TestCaseQt
38
-
39
- from orangecontrib.tomwer.widgets.control.FilterOW import NameFilterOW
40
- from tomwer.core.scan.edfscan import EDFTomoScan
41
- from tomwer.core.utils.scanutils import MockEDF, MockNXtomo
42
-
43
- logging.disable(logging.INFO)
44
-
45
-
46
- class NameFilterOWCI(NameFilterOW):
47
- sigScanReady = qt.Signal(str)
48
- """signal emitted when a scan is ready; Parameter is folder path of the
49
- scan"""
50
-
51
- def _signalScanReady(self, scan):
52
- self.sigScanReady.emit(scan.path)
53
-
54
-
55
- class TestFilterWidget(TestCaseQt):
56
- """class testing the DarkRefWidget"""
57
-
58
- def setUp(self):
59
- TestCaseQt.setUp(self)
60
- self.widget = NameFilterOWCI(parent=None)
61
-
62
- self.tmpdir = tempfile.mkdtemp()
63
- # create hdf5 dataset
64
- self._hdf5with_mytotodir = MockNXtomo(
65
- scan_path=os.path.join(self.tmpdir, "mytotodir120"), n_proj=10
66
- ).scan
67
- self._hdf5without_mytotodir = MockNXtomo(
68
- scan_path=os.path.join(self.tmpdir, "totodir120"), n_proj=10
69
- ).scan
70
- # create edf dataset
71
- mockEDF1 = MockEDF(
72
- scan_path=os.path.join(self.tmpdir, "mytotodir20"), n_radio=10
73
- )
74
- self.edfwith_mytotodir = EDFTomoScan(scan=mockEDF1.scan_path)
75
-
76
- mockEDF2 = MockEDF(scan_path=os.path.join(self.tmpdir, "dir120"), n_radio=10)
77
- self.edfwithout_mytotodir = EDFTomoScan(scan=mockEDF2.scan_path)
78
-
79
- # add a signal listener
80
- self.signalListener = SignalListener()
81
- self.widget.sigScanReady.connect(self.signalListener)
82
-
83
- # define the unix file pattern
84
- self.widget.setPattern("*mytotodir*")
85
-
86
- def tearDown(self):
87
- shutil.rmtree(self.tmpdir)
88
- self.widget.setAttribute(qt.Qt.WA_DeleteOnClose)
89
- self.widget.close()
90
- self.widget = None
91
- gc.collect()
92
-
93
- def testEDF(self):
94
- """Make sure filtering works with EDF"""
95
- self.assertEqual(self.signalListener.callCount(), 0)
96
- self.widget.applyfilter(self.edfwith_mytotodir)
97
- self.qapp.processEvents()
98
- self.assertEqual(self.signalListener.callCount(), 1)
99
- self.widget.applyfilter(self.edfwithout_mytotodir)
100
- self.qapp.processEvents()
101
- self.assertEqual(self.signalListener.callCount(), 1)
102
-
103
- def testHDF5(self):
104
- """Make sure filtering works with HDF5"""
105
- self.assertEqual(self.signalListener.callCount(), 0)
106
- self.widget.applyfilter(self._hdf5without_mytotodir)
107
- self.qapp.processEvents()
108
- self.assertEqual(self.signalListener.callCount(), 0)
109
- self.widget.applyfilter(self._hdf5with_mytotodir)
110
- self.qapp.processEvents()
111
- self.assertEqual(self.signalListener.callCount(), 1)
@@ -1,251 +0,0 @@
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
- __authors__ = ["H. Payno"]
27
- __license__ = "MIT"
28
- __date__ = "16/06/2021"
29
-
30
- import gc
31
- import logging
32
- import os
33
- import shutil
34
- import tempfile
35
- import time
36
-
37
- import pytest
38
- from silx.gui import qt
39
- from silx.gui.utils.testutils import TestCaseQt
40
-
41
- from orangecontrib.tomwer.widgets.reconstruction.DarkRefAndCopyOW import (
42
- DarkRefAndCopyOW,
43
- )
44
- from tomwer.core.process.reconstruction.darkref.darkrefs import DarkRefsTask
45
- from tomwer.core.process.reconstruction.darkref.params import ReduceMethod as DkrfMethod
46
- from tomwer.core.process.reconstruction.darkref.settings import (
47
- DARKHST_PREFIX,
48
- REFHST_PREFIX,
49
- )
50
- from tomwer.core.scan.edfscan import EDFTomoScan
51
- from tomwer.core.utils.scanutils import MockEDF, MockNXtomo
52
- from tomwer.synctools.darkref import QDKRFRP
53
-
54
- logging.disable(logging.INFO)
55
-
56
-
57
- class TestEDFDarkRefWidget(TestCaseQt):
58
- """class testing the DarkRefWidget"""
59
-
60
- def setUp(self):
61
- TestCaseQt.setUp(self)
62
- self._recons_params = QDKRFRP()
63
- self.widget = DarkRefAndCopyOW(parent=None, reconsparams=self._recons_params)
64
-
65
- def tearDown(self):
66
- self.widget.setAttribute(qt.Qt.WA_DeleteOnClose)
67
- self.widget.close()
68
- self.widget = None
69
- self.qapp.processEvents()
70
- gc.collect()
71
-
72
- def testSyncRead(self):
73
- """Make sure any modification on the self._reconsParams is
74
- applied on the GUI"""
75
- rp = self._recons_params
76
- self.assertTrue(rp["REFSRMV"] is False)
77
- self.assertFalse(
78
- self.widget.widget.mainWidget.tabGeneral._rmOptionCB.isChecked()
79
- )
80
- rp["REFSRMV"] = True
81
- self.assertTrue(
82
- self.widget.widget.mainWidget.tabGeneral._rmOptionCB.isChecked()
83
- )
84
-
85
- pattern = self.widget.widget.mainWidget.tabExpert._refLE.text()
86
- newText = "popo.*"
87
- assert pattern != newText
88
- rp["RFFILE"] = newText
89
- self.assertTrue(
90
- self.widget.widget.mainWidget.tabExpert._refLE.text() == newText
91
- )
92
-
93
- def testSyncWrite(self):
94
- """Test that if we edit through the :class:`DarkRefWidget` then the
95
- modification are fall back into the self._reconsParams"""
96
- rp = self._recons_params
97
-
98
- # test patterns
99
- pattern = self.widget.widget.mainWidget.tabExpert._refLE.text()
100
- newText = "popo.*"
101
- assert pattern != newText
102
- self.widget.widget.mainWidget.tabExpert._refLE.setText(newText)
103
- self.widget.widget.mainWidget.tabExpert._refLE.editingFinished.emit()
104
- qt.QApplication.instance().processEvents()
105
- self.assertTrue(rp["RFFILE"] == newText)
106
- self.widget.widget.mainWidget.tabExpert._darkLE.setText(newText)
107
- self.widget.widget.mainWidget.tabExpert._darkLE.editingFinished.emit()
108
- qt.QApplication.instance().processEvents()
109
- self.assertTrue(rp["DKFILE"] == newText)
110
-
111
- # test calc mode
112
- self.widget.widget.mainWidget.tabGeneral._darkWCB.setMode(DkrfMethod.NONE)
113
- self.widget.widget.mainWidget.tabGeneral._refWCB.setMode(DkrfMethod.MEDIAN)
114
- self.assertTrue(rp["DARKCAL"] == DkrfMethod.NONE)
115
- self.assertTrue(rp["REFSCAL"] == DkrfMethod.MEDIAN)
116
-
117
- # test options
118
- cuRm = self.widget.widget.mainWidget.tabGeneral._rmOptionCB.isChecked()
119
- self.widget.widget.mainWidget.tabGeneral._rmOptionCB.setChecked(not cuRm)
120
- self.assertTrue(rp["REFSRMV"] == (not cuRm))
121
- self.assertTrue(rp["DARKRMV"] == (not cuRm))
122
-
123
- cuSkip = self.widget.widget.mainWidget.tabGeneral._skipOptionCB.isChecked()
124
- self.widget.widget.mainWidget.tabGeneral._skipOptionCB.setChecked(not cuSkip)
125
- # warning : here value of skip and overwrite are of course inverse
126
- self.assertTrue(rp["DARKOVE"] == cuSkip)
127
- self.assertTrue(rp["REFSOVE"] == cuSkip)
128
-
129
-
130
- @pytest.mark.skip("Fail on CI")
131
- class TestDarkRefCopyWithEDFAndHDF5(TestCaseQt):
132
- """Test the DarkRefCopy orange widget behaviour"""
133
-
134
- def setUp(self) -> None:
135
- TestCaseQt.setUp(self)
136
- self._folder = tempfile.mkdtemp()
137
-
138
- # define scans to be treated
139
- hdf5_mock_with_refs = MockNXtomo(
140
- scan_path=os.path.join(self._folder, "h5_with_refs"),
141
- n_proj=10,
142
- n_ini_proj=10,
143
- dim=20,
144
- create_ini_flat=True,
145
- create_ini_dark=True,
146
- create_final_flat=False,
147
- )
148
- self.hdf5_acquisition_with_refs = hdf5_mock_with_refs.scan
149
-
150
- hdf5_mock_without_refs = MockNXtomo(
151
- scan_path=os.path.join(self._folder, "h5_without_refs"),
152
- n_proj=10,
153
- n_ini_proj=10,
154
- dim=20,
155
- create_ini_flat=False,
156
- create_ini_dark=False,
157
- )
158
- self.hdf5_acquisition_without_refs = hdf5_mock_without_refs.scan
159
-
160
- hdf5_mock_without_refs_incoherent_dim = MockNXtomo(
161
- scan_path=os.path.join(self._folder, "h5_without_refs_different_dim"),
162
- n_proj=10,
163
- n_ini_proj=10,
164
- dim=21,
165
- create_ini_flat=False,
166
- create_ini_dark=False,
167
- )
168
- self.hdf5_acquisition_without_refs_incoherent_dim = (
169
- hdf5_mock_without_refs_incoherent_dim.scan
170
- )
171
-
172
- edf_mock_without_ref = MockEDF(
173
- scan_path=os.path.join(self._folder, "edf_without_refs"), dim=20, n_radio=20
174
- )
175
- self.edf_acquisition_without_ref = EDFTomoScan(
176
- scan=edf_mock_without_ref.scan_path
177
- )
178
-
179
- # processes set up
180
- self._recons_params = QDKRFRP()
181
- self.widget = DarkRefAndCopyOW(parent=None, reconsparams=self._recons_params)
182
- self.widget.setForceSync(True)
183
- self.widget.show()
184
-
185
- def tearDown(self) -> None:
186
- time.sleep(0.5)
187
- while self.qapp.hasPendingEvents():
188
- self.qapp.processEvents()
189
- self.widget.setAttribute(qt.Qt.WA_DeleteOnClose)
190
- self.widget.close()
191
- self.widget = None
192
- shutil.rmtree(self._folder)
193
- gc.collect()
194
-
195
- def testCopyInactive(self):
196
- self.widget.setCopyActive(False)
197
-
198
- self.widget.process(self.hdf5_acquisition_with_refs)
199
- self.assertTrue(os.path.exists(self.hdf5_acquisition_with_refs.process_file))
200
-
201
- # make sure no dark or flats exists for the hdf5 without refs
202
- for scan in (
203
- self.hdf5_acquisition_without_refs_incoherent_dim,
204
- self.hdf5_acquisition_without_refs,
205
- ):
206
- self.widget.process(scan)
207
- self.assertFalse(os.path.exists(scan.process_file))
208
-
209
- # make sure no dark or flats exists for the edf one
210
- self.widget.process(self.edf_acquisition_without_ref)
211
-
212
- def testCopyActive(self):
213
- self.widget.setCopyActive(True)
214
- self.widget.setModeAuto(True)
215
-
216
- self.widget.process(self.hdf5_acquisition_with_refs)
217
- self.assertTrue(os.path.exists(self.hdf5_acquisition_with_refs.process_file))
218
- # 1. make sure dark has been processed for the one with ref
219
- self.assertTrue(self.widget.hasDarkStored())
220
- self.assertTrue(self.widget.hasFlatStored())
221
-
222
- # 2. make sure copy has been processed for the the 'compatible hdf5'
223
- self.widget.process(self.hdf5_acquisition_without_refs)
224
- self.assertTrue(os.path.exists(self.hdf5_acquisition_without_refs.process_file))
225
-
226
- # 3. make sure copy has been processed for the the 'compatible edf'
227
- self.widget.process(self.edf_acquisition_without_ref)
228
- self.assertEqual(
229
- len(
230
- DarkRefsTask.getRefHSTFiles(
231
- self.edf_acquisition_without_ref.path, prefix=REFHST_PREFIX
232
- )
233
- ),
234
- 2,
235
- )
236
- self.assertEqual(
237
- len(
238
- DarkRefsTask.getDarkHSTFiles(
239
- self.edf_acquisition_without_ref.path, prefix=DARKHST_PREFIX
240
- )
241
- ),
242
- 1,
243
- )
244
-
245
- # 4. make sure process but no copy made if incompatible size
246
- self.widget.process(self.hdf5_acquisition_without_refs_incoherent_dim)
247
- self.assertFalse(
248
- os.path.exists(
249
- self.hdf5_acquisition_without_refs_incoherent_dim.process_file
250
- )
251
- )