tomwer 1.3.0rc9__py3-none-any.whl → 1.3.0rc10__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.
- orangecontrib/tomwer/widgets/__init__.py +5 -8
- orangecontrib/tomwer/widgets/control/NXTomomillOW.py +5 -5
- tomwer/core/process/control/datalistener/datalistener.py +15 -10
- tomwer/core/process/control/nxtomomill.py +1 -1
- tomwer/core/process/edit/imagekeyeditor.py +1 -1
- tomwer/core/process/reconstruction/axis/axis.py +199 -31
- tomwer/core/process/reconstruction/axis/params.py +8 -5
- tomwer/core/process/reconstruction/nabu/nabucommon.py +2 -2
- tomwer/core/process/reconstruction/nabu/nabuslices.py +4 -4
- tomwer/core/process/reconstruction/nabu/nabuvolume.py +4 -2
- tomwer/core/process/task.py +2 -2
- tomwer/core/process/test/test_axis.py +3 -2
- tomwer/core/process/test/test_data_transfer.py +3 -3
- tomwer/core/scan/blissscan.py +3 -3
- tomwer/core/scan/nxtomoscan.py +2 -2
- tomwer/core/scan/scanbase.py +6 -4
- tomwer/core/scan/test/test_process_registration.py +2 -2
- tomwer/core/settings.py +3 -3
- tomwer/gui/cluster/slurm.py +14 -9
- tomwer/gui/cluster/test/test_cluster.py +1 -2
- tomwer/gui/control/datawatcher/controlwidget.py +2 -4
- tomwer/gui/control/reducedarkflatselector.py +2 -2
- tomwer/gui/edit/dkrfpatch.py +4 -4
- tomwer/gui/edit/nxtomowarmer.py +2 -2
- tomwer/gui/imagefromfile.py +2 -2
- tomwer/gui/reconstruction/darkref/darkrefwidget.py +2 -1
- tomwer/gui/test/test_axis_gui.py +4 -10
- tomwer/gui/visualization/volumeviewer.py +16 -14
- tomwer/io/utils/h5pyutils.py +3 -3
- tomwer/io/utils/utils.py +3 -3
- tomwer/version.py +1 -1
- {tomwer-1.3.0rc9.dist-info → tomwer-1.3.0rc10.dist-info}/METADATA +8 -8
- {tomwer-1.3.0rc9.dist-info → tomwer-1.3.0rc10.dist-info}/RECORD +39 -39
- /tomwer-1.3.0rc9-py3.11-nspkg.pth → /tomwer-1.3.0rc10-py3.11-nspkg.pth +0 -0
- {tomwer-1.3.0rc9.dist-info → tomwer-1.3.0rc10.dist-info}/LICENSE +0 -0
- {tomwer-1.3.0rc9.dist-info → tomwer-1.3.0rc10.dist-info}/WHEEL +0 -0
- {tomwer-1.3.0rc9.dist-info → tomwer-1.3.0rc10.dist-info}/entry_points.txt +0 -0
- {tomwer-1.3.0rc9.dist-info → tomwer-1.3.0rc10.dist-info}/namespace_packages.txt +0 -0
- {tomwer-1.3.0rc9.dist-info → tomwer-1.3.0rc10.dist-info}/top_level.txt +0 -0
@@ -22,8 +22,6 @@
|
|
22
22
|
#
|
23
23
|
#############################################################################
|
24
24
|
|
25
|
-
import sysconfig
|
26
|
-
|
27
25
|
try:
|
28
26
|
from orangecanvas.utils.pkgmeta import get_distribution
|
29
27
|
except ImportError:
|
@@ -57,10 +55,9 @@ WIDGET_HELP_PATH = (
|
|
57
55
|
# You still need to build help pages using
|
58
56
|
# make htmlhelp
|
59
57
|
# inside doc folder
|
60
|
-
(
|
61
|
-
|
62
|
-
|
63
|
-
),
|
64
|
-
(
|
65
|
-
("https://readthedocs.org/projects/tomwer/1.3/", None),
|
58
|
+
# (
|
59
|
+
# "/home/payno/Documents/dev/tomography/tomwer/build/html/canvas/widgets/widgets.html",
|
60
|
+
# None,
|
61
|
+
# ),
|
62
|
+
("https://tomwer.readthedocs.io/en/latest/canvas/widgets/widgets.html", None),
|
66
63
|
)
|
@@ -163,11 +163,11 @@ class NXTomomillOW(
|
|
163
163
|
"""
|
164
164
|
# for now we want to avoid propagation any processing.
|
165
165
|
# task will be executed only when the user validates the dialog
|
166
|
-
|
167
|
-
if
|
168
|
-
if not isinstance(
|
169
|
-
raise TypeError("
|
170
|
-
self.add(
|
166
|
+
bliss_scan = super().get_task_inputs().get("bliss_scan", None)
|
167
|
+
if bliss_scan is not None:
|
168
|
+
if not isinstance(bliss_scan, BlissScan):
|
169
|
+
raise TypeError("bliss_scan is expected to be an instance of BlissScan")
|
170
|
+
self.add(bliss_scan.master_file)
|
171
171
|
|
172
172
|
def _convertAndSend(self, bliss_url: str):
|
173
173
|
"""
|
@@ -102,6 +102,11 @@ class DataListener(BaseProcessInfo):
|
|
102
102
|
TIMOUT_READ_FILE = 30
|
103
103
|
"When the event 'scan_ended' is received all data might not have been write" " yet"
|
104
104
|
|
105
|
+
SWMR_MODE = None
|
106
|
+
"""The bliss writer is not using the swmr mode. This class has independant behavior regarding the tomoscan / nxotmo get_swmr_mode which is
|
107
|
+
dedicated to the internal tomotools behavior
|
108
|
+
"""
|
109
|
+
|
105
110
|
def __init__(self):
|
106
111
|
super().__init__()
|
107
112
|
self._host = settings.JSON_RPC_HOST
|
@@ -224,7 +229,7 @@ class DataListener(BaseProcessInfo):
|
|
224
229
|
"""Return the list of scans dir for this bliss_file / entry"""
|
225
230
|
|
226
231
|
def get_scan_indexes():
|
227
|
-
with HDF5File(bliss_file, "r", swmr=
|
232
|
+
with HDF5File(bliss_file, "r", swmr=DataListener.SWMR_MODE) as h5f:
|
228
233
|
entry_node = h5f[entry]
|
229
234
|
if _SCAN_NUMBER_PATH in entry_node:
|
230
235
|
return h5py_read_dataset(entry_node[_SCAN_NUMBER_PATH])
|
@@ -249,7 +254,7 @@ class DataListener(BaseProcessInfo):
|
|
249
254
|
"""Return the proposal file of the experimentation if registred by the
|
250
255
|
data listener"""
|
251
256
|
if entry is None:
|
252
|
-
with HDF5File(process_file, "r", swmr=
|
257
|
+
with HDF5File(process_file, "r", swmr=DataListener.SWMR_MODE) as h5f:
|
253
258
|
entries = BaseProcessInfo._get_process_nodes(
|
254
259
|
root_node=h5f, process=DataListener
|
255
260
|
)
|
@@ -264,7 +269,7 @@ class DataListener(BaseProcessInfo):
|
|
264
269
|
entry = list(entries.keys())[0]
|
265
270
|
_logger.info("take %s as default entry" % entry)
|
266
271
|
|
267
|
-
with HDF5File(process_file, "r", swmr=
|
272
|
+
with HDF5File(process_file, "r", swmr=DataListener.SWMR_MODE) as h5f:
|
268
273
|
dl_nodes = BaseProcessInfo._get_process_nodes(
|
269
274
|
root_node=h5f[entry], process=DataListener
|
270
275
|
)
|
@@ -306,7 +311,7 @@ class DataListener(BaseProcessInfo):
|
|
306
311
|
"""Return the proposal file of the experimentation if registred by the
|
307
312
|
data listener"""
|
308
313
|
if entry is None:
|
309
|
-
with HDF5File(process_file, "r", swmr=
|
314
|
+
with HDF5File(process_file, "r", swmr=DataListener.SWMR_MODE) as h5f:
|
310
315
|
entries = BaseProcessInfo._get_process_nodes(
|
311
316
|
root_node=h5f, process=DataListener
|
312
317
|
)
|
@@ -321,7 +326,7 @@ class DataListener(BaseProcessInfo):
|
|
321
326
|
entry = list(entries.keys())[0]
|
322
327
|
_logger.info("take %s as default entry" % entry)
|
323
328
|
|
324
|
-
with HDF5File(process_file, "r", swmr=
|
329
|
+
with HDF5File(process_file, "r", swmr=DataListener.SWMR_MODE) as h5f:
|
325
330
|
dl_nodes = BaseProcessInfo._get_process_nodes(
|
326
331
|
root_node=h5f[entry], process=DataListener
|
327
332
|
)
|
@@ -355,7 +360,7 @@ class DataListener(BaseProcessInfo):
|
|
355
360
|
"""Return the proposal file of the experimentation if registred by the
|
356
361
|
data listener"""
|
357
362
|
if entry is None:
|
358
|
-
with HDF5File(process_file, "r", swmr=
|
363
|
+
with HDF5File(process_file, "r", swmr=DataListener.SWMR_MODE) as h5f:
|
359
364
|
entries = BaseProcessInfo._get_process_nodes(
|
360
365
|
root_node=h5f, process=DataListener
|
361
366
|
)
|
@@ -370,7 +375,7 @@ class DataListener(BaseProcessInfo):
|
|
370
375
|
entry = list(entries.keys())[0]
|
371
376
|
_logger.info("take %s as default entry" % entry)
|
372
377
|
|
373
|
-
with HDF5File(process_file, "r", swmr=
|
378
|
+
with HDF5File(process_file, "r", swmr=DataListener.SWMR_MODE) as h5f:
|
374
379
|
dl_nodes = BaseProcessInfo._get_process_nodes(
|
375
380
|
root_node=h5f[entry], process=DataListener
|
376
381
|
)
|
@@ -405,7 +410,7 @@ class DataListener(BaseProcessInfo):
|
|
405
410
|
specific sequence data
|
406
411
|
"""
|
407
412
|
if entry is None:
|
408
|
-
with HDF5File(process_file, "r", swmr=
|
413
|
+
with HDF5File(process_file, "r", swmr=DataListener.SWMR_MODE) as h5f:
|
409
414
|
entries = BaseProcessInfo._get_process_nodes(
|
410
415
|
root_node=h5f, process=DataListener
|
411
416
|
)
|
@@ -420,7 +425,7 @@ class DataListener(BaseProcessInfo):
|
|
420
425
|
entry = list(entries.keys())[0]
|
421
426
|
_logger.info("take %s as default entry" % entry)
|
422
427
|
|
423
|
-
with HDF5File(process_file, "r", swmr=
|
428
|
+
with HDF5File(process_file, "r", swmr=DataListener.SWMR_MODE) as h5f:
|
424
429
|
dl_nodes = BaseProcessInfo._get_process_nodes(
|
425
430
|
root_node=h5f[entry], process=DataListener
|
426
431
|
)
|
@@ -498,7 +503,7 @@ class DataListener(BaseProcessInfo):
|
|
498
503
|
# write
|
499
504
|
def sequence_is_finished():
|
500
505
|
try:
|
501
|
-
with HDF5File(bliss_file, "r", swmr=
|
506
|
+
with HDF5File(bliss_file, "r", swmr=DataListener.SWMR_MODE) as h5f:
|
502
507
|
end_scan_path = "/".join((entry, "end_time"))
|
503
508
|
return end_scan_path in h5f
|
504
509
|
except Exception:
|
@@ -83,7 +83,7 @@ def change_image_key_control(scan: NXtomoScan, config: dict) -> TomwerScanBase:
|
|
83
83
|
filter(lambda item: item[1] is image_key_type, modifications.items())
|
84
84
|
)
|
85
85
|
frame_indexes = tuple(frame_indexes_dict.keys())
|
86
|
-
_logger.
|
86
|
+
_logger.info(f"will modify {frame_indexes} to {image_key_type}")
|
87
87
|
_change_image_key_control(
|
88
88
|
file_path=scan.master_file,
|
89
89
|
entry=scan.entry,
|
@@ -40,7 +40,7 @@ from nabu.estimation.cor import (
|
|
40
40
|
CenterOfRotationSlidingWindow,
|
41
41
|
CenterOfRotationOctaveAccurate,
|
42
42
|
)
|
43
|
-
from nabu.pipeline.estimators import SinoCORFinder
|
43
|
+
from nabu.pipeline.estimators import SinoCORFinder, CORFinder
|
44
44
|
from nabu.resources.nxflatfield import update_dataset_info_flats_darks
|
45
45
|
from processview.core.manager import DatasetState, ProcessManager
|
46
46
|
from processview.core.superviseprocess import SuperviseProcess
|
@@ -76,7 +76,7 @@ else:
|
|
76
76
|
has_composite_cor_finder = True
|
77
77
|
from silx.io.url import DataUrl
|
78
78
|
from silx.io.utils import h5py_read_dataset
|
79
|
-
from tomoscan.io import HDF5File
|
79
|
+
from tomoscan.io import HDF5File, get_swmr_mode
|
80
80
|
|
81
81
|
_logger = logging.getLogger(__name__)
|
82
82
|
if not has_composite_cor_finder:
|
@@ -174,6 +174,50 @@ def compute_cor_nabu_growing_window(
|
|
174
174
|
return res
|
175
175
|
|
176
176
|
|
177
|
+
def compute_cor_nabu_growing_window_radios(
|
178
|
+
scan: TomwerScanBase,
|
179
|
+
):
|
180
|
+
"""
|
181
|
+
Call nabu.preproc.alignement.CenterOfRotationGrowingWindow.find_shift
|
182
|
+
|
183
|
+
:param TomwerScanBase scan:
|
184
|
+
|
185
|
+
:return:
|
186
|
+
"""
|
187
|
+
has_darks = scan.reduced_darks is not None and len(scan.reduced_darks) > 0
|
188
|
+
has_flats = scan.reduced_flats is not None and len(scan.reduced_flats) > 0
|
189
|
+
|
190
|
+
projection_angles = scan.get_proj_angle_url()
|
191
|
+
projection_angles_i = {
|
192
|
+
value.path(): key for key, value in projection_angles.items()
|
193
|
+
}
|
194
|
+
url_radio_1, url_radio_2 = AxisTask.get_inputs_urls(scan=scan)
|
195
|
+
angle_radio_1 = float(projection_angles_i[url_radio_1.url.path()])
|
196
|
+
angle_radio_2 = float(projection_angles_i[url_radio_2.url.path()])
|
197
|
+
radio_angles = tuple(numpy.radians((angle_radio_1, angle_radio_2)))
|
198
|
+
|
199
|
+
corfinder = CORFinder(
|
200
|
+
dataset_info=adapt_tomwer_scan_to_nabu(scan),
|
201
|
+
method="growing-window",
|
202
|
+
do_flatfield=has_darks and has_flats,
|
203
|
+
cor_options=scan.axis_params.get_nabu_cor_options_as_dict(),
|
204
|
+
radio_angles=radio_angles,
|
205
|
+
logger=_logger,
|
206
|
+
)
|
207
|
+
res = corfinder.find_cor() # Returns absolute cor
|
208
|
+
if isinstance(res, numpy.ndarray):
|
209
|
+
if len(res) == 1:
|
210
|
+
res = res[0]
|
211
|
+
else:
|
212
|
+
raise ValueError(
|
213
|
+
"nabu rsult is expected to be a scalar, numpy array found. Please upgrade nabu this issue is expected to be solved"
|
214
|
+
)
|
215
|
+
|
216
|
+
return _absolute_pos_to_relative_with_warning(
|
217
|
+
absolute_pos=res, det_width=scan.dim_1
|
218
|
+
)
|
219
|
+
|
220
|
+
|
177
221
|
def compute_cor_nabu_growing_window_sinogram(
|
178
222
|
scan: TomwerScanBase,
|
179
223
|
):
|
@@ -322,13 +366,7 @@ def compute_scan_cor_nabu_growing_window(scan):
|
|
322
366
|
if scan.axis_params.use_sinogram:
|
323
367
|
return compute_cor_nabu_growing_window_sinogram(scan=scan)
|
324
368
|
else:
|
325
|
-
return
|
326
|
-
radio_1=radio_1.copy(),
|
327
|
-
radio_2=radio_2.copy(),
|
328
|
-
side=scan.axis_params.side,
|
329
|
-
padding_mode=scan.axis_params.padding_mode,
|
330
|
-
flip_frame_2_lr=scan.axis_params.flip_lr,
|
331
|
-
)
|
369
|
+
return compute_cor_nabu_growing_window_radios(scan=scan)
|
332
370
|
|
333
371
|
|
334
372
|
def compute_cor_nabu_sliding_window(
|
@@ -367,6 +405,42 @@ def compute_cor_nabu_sliding_window(
|
|
367
405
|
return res
|
368
406
|
|
369
407
|
|
408
|
+
def compute_cor_nabu_sliding_window_radios(
|
409
|
+
scan,
|
410
|
+
):
|
411
|
+
"""
|
412
|
+
Call nabu.preproc.alignement.CenterOfRotationGrowingWindow.find_shift
|
413
|
+
|
414
|
+
:param TomwerScanBase scan:
|
415
|
+
|
416
|
+
:return:
|
417
|
+
"""
|
418
|
+
has_darks = scan.reduced_darks is not None and len(scan.reduced_darks) > 0
|
419
|
+
has_flats = scan.reduced_flats is not None and len(scan.reduced_flats) > 0
|
420
|
+
|
421
|
+
projection_angles = scan.get_proj_angle_url()
|
422
|
+
projection_angles_i = {
|
423
|
+
value.path(): key for key, value in projection_angles.items()
|
424
|
+
}
|
425
|
+
url_radio_1, url_radio_2 = AxisTask.get_inputs_urls(scan=scan)
|
426
|
+
angle_radio_1 = float(projection_angles_i[url_radio_1.url.path()])
|
427
|
+
angle_radio_2 = float(projection_angles_i[url_radio_2.url.path()])
|
428
|
+
radio_angles = tuple(numpy.radians((angle_radio_1, angle_radio_2)))
|
429
|
+
|
430
|
+
corfinder = CORFinder(
|
431
|
+
dataset_info=adapt_tomwer_scan_to_nabu(scan),
|
432
|
+
method="sliding-window",
|
433
|
+
do_flatfield=has_darks and has_flats,
|
434
|
+
cor_options=scan.axis_params.get_nabu_cor_options_as_dict(),
|
435
|
+
radio_angles=radio_angles,
|
436
|
+
logger=_logger,
|
437
|
+
)
|
438
|
+
res = corfinder.find_cor() # Returns absolute cor.
|
439
|
+
return _absolute_pos_to_relative_with_warning(
|
440
|
+
absolute_pos=res, det_width=scan.dim_1
|
441
|
+
)
|
442
|
+
|
443
|
+
|
370
444
|
def compute_cor_nabu_sliding_window_sinogram(
|
371
445
|
scan,
|
372
446
|
):
|
@@ -422,13 +496,7 @@ def compute_scan_cor_nabu_sliding_window(scan):
|
|
422
496
|
if scan.axis_params.use_sinogram:
|
423
497
|
return compute_cor_nabu_sliding_window_sinogram(scan=scan)
|
424
498
|
else:
|
425
|
-
return
|
426
|
-
radio_1=radio_1.copy(),
|
427
|
-
radio_2=radio_2.copy(),
|
428
|
-
side=scan.axis_params.side,
|
429
|
-
padding_mode=scan.axis_params.padding_mode,
|
430
|
-
flip_frame_2_lr=scan.axis_params.flip_lr,
|
431
|
-
)
|
499
|
+
return compute_cor_nabu_sliding_window_radios(scan=scan)
|
432
500
|
|
433
501
|
|
434
502
|
def compute_scan_fourier_angles(scan):
|
@@ -453,6 +521,45 @@ def compute_scan_fourier_angles(scan):
|
|
453
521
|
)
|
454
522
|
|
455
523
|
|
524
|
+
def compute_scan_octave_accurate_radios(
|
525
|
+
scan,
|
526
|
+
):
|
527
|
+
"""
|
528
|
+
Call nabu.preproc.alignement.CenterOfRotationGrowingWindow.find_shift
|
529
|
+
|
530
|
+
:param TomwerScanBase scan:
|
531
|
+
|
532
|
+
:return:
|
533
|
+
"""
|
534
|
+
has_darks = scan.reduced_darks is not None and len(scan.reduced_darks) > 0
|
535
|
+
has_flats = scan.reduced_flats is not None and len(scan.reduced_flats) > 0
|
536
|
+
|
537
|
+
has_darks = scan.reduced_darks is not None and len(scan.reduced_darks) > 0
|
538
|
+
has_flats = scan.reduced_flats is not None and len(scan.reduced_flats) > 0
|
539
|
+
|
540
|
+
projection_angles = scan.get_proj_angle_url()
|
541
|
+
projection_angles_i = {
|
542
|
+
value.path(): key for key, value in projection_angles.items()
|
543
|
+
}
|
544
|
+
url_radio_1, url_radio_2 = AxisTask.get_inputs_urls(scan=scan)
|
545
|
+
angle_radio_1 = float(projection_angles_i[url_radio_1.url.path()])
|
546
|
+
angle_radio_2 = float(projection_angles_i[url_radio_2.url.path()])
|
547
|
+
radio_angles = tuple(numpy.radians((angle_radio_1, angle_radio_2)))
|
548
|
+
|
549
|
+
corfinder = CORFinder(
|
550
|
+
dataset_info=adapt_tomwer_scan_to_nabu(scan),
|
551
|
+
method="octave-accurate",
|
552
|
+
do_flatfield=has_darks and has_flats,
|
553
|
+
cor_options=scan.axis_params.get_nabu_cor_options_as_dict(),
|
554
|
+
radio_angles=radio_angles,
|
555
|
+
logger=_logger,
|
556
|
+
)
|
557
|
+
res = corfinder.find_cor()
|
558
|
+
return _absolute_pos_to_relative_with_warning(
|
559
|
+
absolute_pos=res, det_width=scan.dim_1
|
560
|
+
)
|
561
|
+
|
562
|
+
|
456
563
|
def compute_scan_octave_accurate(scan):
|
457
564
|
"""
|
458
565
|
Compute center of rotation from `octave-accurate` algorithm
|
@@ -478,6 +585,42 @@ def compute_scan_octave_accurate(scan):
|
|
478
585
|
return res
|
479
586
|
|
480
587
|
|
588
|
+
def compute_cor_nabu_centered_radios(
|
589
|
+
scan,
|
590
|
+
):
|
591
|
+
"""
|
592
|
+
Call nabu.preproc.alignement.CenterOfRotationGrowingWindow.find_shift
|
593
|
+
|
594
|
+
:param TomwerScanBase scan:
|
595
|
+
|
596
|
+
:return:
|
597
|
+
"""
|
598
|
+
has_darks = scan.reduced_darks is not None and len(scan.reduced_darks) > 0
|
599
|
+
has_flats = scan.reduced_flats is not None and len(scan.reduced_flats) > 0
|
600
|
+
|
601
|
+
projection_angles = scan.get_proj_angle_url()
|
602
|
+
projection_angles_i = {
|
603
|
+
value.path(): key for key, value in projection_angles.items()
|
604
|
+
}
|
605
|
+
url_radio_1, url_radio_2 = AxisTask.get_inputs_urls(scan=scan)
|
606
|
+
angle_radio_1 = float(projection_angles_i[url_radio_1.url.path()])
|
607
|
+
angle_radio_2 = float(projection_angles_i[url_radio_2.url.path()])
|
608
|
+
radio_angles = tuple(numpy.radians((angle_radio_1, angle_radio_2)))
|
609
|
+
|
610
|
+
corfinder = CORFinder(
|
611
|
+
dataset_info=adapt_tomwer_scan_to_nabu(scan),
|
612
|
+
method="centered",
|
613
|
+
do_flatfield=has_darks and has_flats,
|
614
|
+
cor_options=scan.axis_params.get_nabu_cor_options_as_dict(),
|
615
|
+
radio_angles=radio_angles,
|
616
|
+
logger=_logger,
|
617
|
+
)
|
618
|
+
res = corfinder.find_cor()
|
619
|
+
return _absolute_pos_to_relative_with_warning(
|
620
|
+
absolute_pos=res, det_width=scan.dim_1
|
621
|
+
)
|
622
|
+
|
623
|
+
|
481
624
|
def compute_cor_nabu_centered(
|
482
625
|
radio_1: numpy.ndarray,
|
483
626
|
radio_2: numpy.ndarray,
|
@@ -532,12 +675,7 @@ def compute_scan_cor_nabu_centered(scan):
|
|
532
675
|
"mode %s" % scan.axis_params.padding_mode
|
533
676
|
)
|
534
677
|
|
535
|
-
return
|
536
|
-
radio_1=radio_1.copy(),
|
537
|
-
radio_2=radio_2.copy(),
|
538
|
-
padding_mode=scan.axis_params.padding_mode,
|
539
|
-
flip_frame_2_lr=scan.axis_params.flip_lr,
|
540
|
-
)
|
678
|
+
return compute_cor_nabu_centered_radios(scan)
|
541
679
|
|
542
680
|
|
543
681
|
def compute_cor_nabu_global(
|
@@ -567,6 +705,42 @@ def compute_cor_nabu_global(
|
|
567
705
|
)
|
568
706
|
|
569
707
|
|
708
|
+
def compute_cor_nabu_global_radios(
|
709
|
+
scan: TomwerScanBase,
|
710
|
+
):
|
711
|
+
"""
|
712
|
+
Call nabu.preproc.alignement.CenterOfRotationGrowingWindow.find_shift
|
713
|
+
|
714
|
+
:param TomwerScanBase scan:
|
715
|
+
|
716
|
+
:return:
|
717
|
+
"""
|
718
|
+
has_darks = scan.reduced_darks is not None and len(scan.reduced_darks) > 0
|
719
|
+
has_flats = scan.reduced_flats is not None and len(scan.reduced_flats) > 0
|
720
|
+
|
721
|
+
projection_angles = scan.get_proj_angle_url()
|
722
|
+
projection_angles_i = {
|
723
|
+
value.path(): key for key, value in projection_angles.items()
|
724
|
+
}
|
725
|
+
url_radio_1, url_radio_2 = AxisTask.get_inputs_urls(scan=scan)
|
726
|
+
angle_radio_1 = float(projection_angles_i[url_radio_1.url.path()])
|
727
|
+
angle_radio_2 = float(projection_angles_i[url_radio_2.url.path()])
|
728
|
+
radio_angles = tuple(numpy.radians((angle_radio_1, angle_radio_2)))
|
729
|
+
|
730
|
+
corfinder = CORFinder(
|
731
|
+
dataset_info=adapt_tomwer_scan_to_nabu(scan),
|
732
|
+
method="global",
|
733
|
+
do_flatfield=has_darks and has_flats,
|
734
|
+
cor_options=scan.axis_params.get_nabu_cor_options_as_dict(),
|
735
|
+
radio_angles=radio_angles,
|
736
|
+
logger=_logger,
|
737
|
+
)
|
738
|
+
res = corfinder.find_cor()
|
739
|
+
return _absolute_pos_to_relative_with_warning(
|
740
|
+
absolute_pos=res, det_width=scan.dim_1
|
741
|
+
)
|
742
|
+
|
743
|
+
|
570
744
|
def compute_scan_cor_nabu_global(scan):
|
571
745
|
"""
|
572
746
|
Call to nabu.preproc.alignment.CenterOfRotation from the scan axis_params
|
@@ -585,13 +759,7 @@ def compute_scan_cor_nabu_global(scan):
|
|
585
759
|
"compute scan axis from nabu CenterOfRotation with padding "
|
586
760
|
"mode %s" % scan.axis_params.padding_mode
|
587
761
|
)
|
588
|
-
|
589
|
-
return compute_cor_nabu_global(
|
590
|
-
radio_1=radio_1.copy(),
|
591
|
-
radio_2=radio_2.copy(),
|
592
|
-
padding_mode=scan.axis_params.padding_mode,
|
593
|
-
flip_frame_2_lr=scan.axis_params.flip_lr,
|
594
|
-
)
|
762
|
+
return compute_cor_nabu_global_radios(scan)
|
595
763
|
|
596
764
|
|
597
765
|
def get_stdmax_column(x: numpy.ndarray) -> float:
|
@@ -996,7 +1164,7 @@ class AxisTask(
|
|
996
1164
|
:return:
|
997
1165
|
"""
|
998
1166
|
if entry is None:
|
999
|
-
with HDF5File(process_file, "r", swmr=
|
1167
|
+
with HDF5File(process_file, "r", swmr=get_swmr_mode()) as h5f:
|
1000
1168
|
entries = AxisTask._get_process_nodes(root_node=h5f, process=AxisTask)
|
1001
1169
|
if len(entries) == 0:
|
1002
1170
|
_logger.info("unable to find a Axis process in %s" % process_file)
|
@@ -1007,7 +1175,7 @@ class AxisTask(
|
|
1007
1175
|
entry = list(entries.keys())[0]
|
1008
1176
|
_logger.info("take %s as default entry" % entry)
|
1009
1177
|
|
1010
|
-
with HDF5File(process_file, "r", swmr=
|
1178
|
+
with HDF5File(process_file, "r", swmr=get_swmr_mode()) as h5f:
|
1011
1179
|
axis_nodes = AxisTask._get_process_nodes(
|
1012
1180
|
root_node=h5f[entry], process=AxisTask
|
1013
1181
|
)
|
@@ -905,14 +905,17 @@ class AxisRP:
|
|
905
905
|
self.side = "near"
|
906
906
|
request_side = len(AXIS_MODE_METADATAS[self.mode].valid_sides) > 0
|
907
907
|
if request_side:
|
908
|
-
|
908
|
+
|
909
|
+
if self.side == "near":
|
910
|
+
options["side"] = self.composite_options.get(
|
911
|
+
"near_pos", self.estimated_cor
|
912
|
+
)
|
913
|
+
else:
|
914
|
+
options["side"] = self.side
|
915
|
+
|
909
916
|
if self.side == "near":
|
910
|
-
near_pos = self.composite_options.get("near_pos", 0.0)
|
911
917
|
near_width = self.composite_options.get("near_width", 20.0)
|
912
|
-
options["near_pos"] = near_pos
|
913
918
|
options["near_width"] = near_width
|
914
|
-
else:
|
915
|
-
options["near_pos"] = "ignore"
|
916
919
|
|
917
920
|
# append "extra_cor_options" to already handled cor options
|
918
921
|
extra_cor_options = self.extra_cor_options.replace(" ", "")
|
@@ -45,7 +45,7 @@ import numpy
|
|
45
45
|
from silx.io.url import DataUrl
|
46
46
|
from sluurp.executor import submit as submit_to_slurm_cluster
|
47
47
|
from sluurp.job import SBatchScriptJob
|
48
|
-
from tomoscan.io import HDF5File
|
48
|
+
from tomoscan.io import HDF5File, get_swmr_mode
|
49
49
|
from tomoscan.normalization import Method as INormMethod
|
50
50
|
from tomoscan.identifier import VolumeIdentifier
|
51
51
|
|
@@ -582,7 +582,7 @@ class _NabuBaseReconstructor:
|
|
582
582
|
dataset_url = DataUrl(path=dataset_url)
|
583
583
|
if os.path.exists(dataset_url.file_path()):
|
584
584
|
with HDF5File(
|
585
|
-
dataset_url.file_path(), mode="r", swmr=
|
585
|
+
dataset_url.file_path(), mode="r", swmr=get_swmr_mode()
|
586
586
|
) as h5f:
|
587
587
|
if dataset_url.data_path() not in h5f:
|
588
588
|
dataset_url = None
|
@@ -84,7 +84,7 @@ from processview.core.superviseprocess import SuperviseProcess
|
|
84
84
|
from silx.io.dictdump import h5todict
|
85
85
|
from silx.io.utils import h5py_read_dataset
|
86
86
|
from silx.utils.enum import Enum as _Enum
|
87
|
-
from tomoscan.io import HDF5File
|
87
|
+
from tomoscan.io import HDF5File, get_swmr_mode
|
88
88
|
|
89
89
|
from tomwer.core.process.task import Task
|
90
90
|
from tomwer.core.scan.edfscan import EDFTomoScan
|
@@ -494,7 +494,7 @@ class NabuSlicesTask(
|
|
494
494
|
:rtype:dict
|
495
495
|
"""
|
496
496
|
if entry is None:
|
497
|
-
with HDF5File(process_file, "r", swmr=
|
497
|
+
with HDF5File(process_file, "r", swmr=get_swmr_mode()) as h5f:
|
498
498
|
entries = NabuSlicesTask._get_process_nodes(
|
499
499
|
root_node=h5f, process=NabuSlicesTask
|
500
500
|
)
|
@@ -510,7 +510,7 @@ class NabuSlicesTask(
|
|
510
510
|
configuration_path = None
|
511
511
|
res = {}
|
512
512
|
|
513
|
-
with HDF5File(process_file, "r", swmr=
|
513
|
+
with HDF5File(process_file, "r", swmr=get_swmr_mode()) as h5f:
|
514
514
|
nabu_nodes = NabuSlicesTask._get_process_nodes(
|
515
515
|
root_node=h5f[entry], process=NabuSlicesTask
|
516
516
|
)
|
@@ -845,7 +845,7 @@ class SingleSliceRunner(_NabuBaseReconstructor):
|
|
845
845
|
basename, _ = os.path.splitext(scan.master_file)
|
846
846
|
basename = os.path.basename(basename)
|
847
847
|
try:
|
848
|
-
with HDF5File(scan.master_file, mode="r", swmr=
|
848
|
+
with HDF5File(scan.master_file, mode="r", swmr=get_swmr_mode()) as h5f:
|
849
849
|
if len(h5f.keys()) > 1:
|
850
850
|
# if there is more than one entry in the file append the entry name to the file basename
|
851
851
|
basename = "_".join((basename, scan.entry.lstrip("/")))
|
@@ -45,7 +45,7 @@ from processview.core.superviseprocess import SuperviseProcess
|
|
45
45
|
from silx.io.utils import h5py_read_dataset
|
46
46
|
from tomwer.core.utils.deprecation import deprecated_warning
|
47
47
|
|
48
|
-
from tomoscan.io import HDF5File
|
48
|
+
from tomoscan.io import HDF5File, get_swmr_mode
|
49
49
|
|
50
50
|
from tomwer.core.cluster.cluster import SlurmClusterConfiguration
|
51
51
|
from tomwer.core.futureobject import FutureTomwerObject
|
@@ -352,7 +352,9 @@ class VolumeRunner(_NabuBaseReconstructor):
|
|
352
352
|
basename = os.path.basename(basename)
|
353
353
|
try:
|
354
354
|
# if there is more than one entry in the file append the entry name to the file basename
|
355
|
-
with HDF5File(
|
355
|
+
with HDF5File(
|
356
|
+
self.scan.master_file, mode="r", swmr=get_swmr_mode()
|
357
|
+
) as h5f:
|
356
358
|
if len(h5f.keys()) > 1:
|
357
359
|
basename = "_".join((basename, self.scan.entry.strip("/")))
|
358
360
|
except Exception:
|
tomwer/core/process/task.py
CHANGED
@@ -46,7 +46,7 @@ from ewokscore.task import Task as _EwoksTask
|
|
46
46
|
from ewokscore.taskwithprogress import TaskWithProgress as _EwoksTaskWithProgress
|
47
47
|
from silx.io.dictdump import dicttoh5, h5todict
|
48
48
|
from silx.io.utils import h5py_read_dataset
|
49
|
-
from tomoscan.io import HDF5File
|
49
|
+
from tomoscan.io import HDF5File, get_swmr_mode
|
50
50
|
from tomwer.core.utils.locker import FileLockerManager
|
51
51
|
|
52
52
|
|
@@ -376,7 +376,7 @@ class BaseProcessInfo:
|
|
376
376
|
:rtype: list
|
377
377
|
"""
|
378
378
|
# retrieve process to load
|
379
|
-
with HDF5File(process_file, mode="r", swmr=
|
379
|
+
with HDF5File(process_file, mode="r", swmr=get_swmr_mode()) as h5f:
|
380
380
|
if entry is None:
|
381
381
|
if len(h5f.keys()) > 0:
|
382
382
|
root = h5f[list(h5f.keys())[0]]
|
@@ -34,6 +34,7 @@ import tempfile
|
|
34
34
|
import unittest
|
35
35
|
|
36
36
|
import h5py
|
37
|
+
from tomoscan.io import get_swmr_mode
|
37
38
|
import numpy
|
38
39
|
from silx.io.utils import h5py_read_dataset
|
39
40
|
|
@@ -131,7 +132,7 @@ class TestAxis(unittest.TestCase):
|
|
131
132
|
axis_process.run()
|
132
133
|
self.assertTrue(os.path.exists(scan.process_file))
|
133
134
|
|
134
|
-
with h5py.File(scan.process_file, "r", swmr=
|
135
|
+
with h5py.File(scan.process_file, "r", swmr=get_swmr_mode()) as h5f:
|
135
136
|
self.assertTrue("entry" in h5f)
|
136
137
|
self.assertTrue("tomwer_process_0" in h5f["entry"])
|
137
138
|
group_axis = h5f["entry"]["tomwer_process_0"]
|
@@ -183,7 +184,7 @@ class TestAxis(unittest.TestCase):
|
|
183
184
|
# make sure center of position has been computed
|
184
185
|
self.assertTrue(os.path.exists(scan.process_file))
|
185
186
|
|
186
|
-
with h5py.File(scan.process_file, "r", swmr=
|
187
|
+
with h5py.File(scan.process_file, "r", swmr=get_swmr_mode()) as h5f:
|
187
188
|
self.assertTrue("entry" in h5f)
|
188
189
|
self.assertTrue("tomwer_process_0" in h5f["entry"])
|
189
190
|
group_axis = h5f["entry"]["tomwer_process_0"]
|
@@ -42,7 +42,7 @@ from nxtomomill.converter import from_h5_to_nx
|
|
42
42
|
from nxtomomill.io.config.hdf5config import TomoHDF5Config
|
43
43
|
from nxtomo.nxobject.nxdetector import ImageKey
|
44
44
|
|
45
|
-
from tomoscan.io import HDF5File
|
45
|
+
from tomoscan.io import HDF5File, get_swmr_mode
|
46
46
|
from tomoscan.validator import is_valid_for_reconstruction
|
47
47
|
|
48
48
|
from tomwer.core.process.control.datalistener import DataListener
|
@@ -335,9 +335,9 @@ class NXTomoDataTransferBase(unittest.TestCase):
|
|
335
335
|
dst_scan = process.outputs.data
|
336
336
|
assert dst_scan.master_file != self.nexus_file_path
|
337
337
|
assert is_valid_for_reconstruction(dst_scan, check_values=True)
|
338
|
-
with HDF5File(src_scan.master_file, mode="r", swmr=
|
338
|
+
with HDF5File(src_scan.master_file, mode="r", swmr=get_swmr_mode()) as h5s_src:
|
339
339
|
src_dataset = h5s_src["entry0000/detector/data"][...]
|
340
|
-
with HDF5File(dst_scan.master_file, mode="r", swmr=
|
340
|
+
with HDF5File(dst_scan.master_file, mode="r", swmr=get_swmr_mode()) as h5s_dst:
|
341
341
|
dst_dataset = h5s_dst["entry0000/detector/data"][...]
|
342
342
|
assert numpy.array_equal(src_dataset, dst_dataset)
|
343
343
|
|
tomwer/core/scan/blissscan.py
CHANGED
@@ -54,7 +54,7 @@ import logging
|
|
54
54
|
from typing import Optional
|
55
55
|
|
56
56
|
from silx.io.utils import h5py_read_dataset
|
57
|
-
from tomoscan.io import HDF5File
|
57
|
+
from tomoscan.io import HDF5File, get_swmr_mode
|
58
58
|
|
59
59
|
_logger = logging.getLogger(__name__)
|
60
60
|
|
@@ -203,7 +203,7 @@ class BlissScan:
|
|
203
203
|
return True
|
204
204
|
return False
|
205
205
|
|
206
|
-
with HDF5File(file_path, mode="r", swmr=
|
206
|
+
with HDF5File(file_path, mode="r", swmr=get_swmr_mode()) as h5s:
|
207
207
|
if not isinstance(h5s, h5py.Group) or not isinstance(
|
208
208
|
h5s[entry], h5py.Group
|
209
209
|
):
|
@@ -227,7 +227,7 @@ class BlissScan:
|
|
227
227
|
return tuple()
|
228
228
|
else:
|
229
229
|
res = []
|
230
|
-
with HDF5File(file_path, mode="r", swmr=
|
230
|
+
with HDF5File(file_path, mode="r", swmr=get_swmr_mode()) as h5s:
|
231
231
|
for entry in h5s:
|
232
232
|
if BlissScan.is_bliss_valid_entry(file_path=file_path, entry=entry):
|
233
233
|
res.append(entry)
|