tomwer 1.4.19__py3-none-any.whl → 1.5.2rc0__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 (123) hide show
  1. orangecontrib/tomwer/tutorials/simple_volume_local_reconstruction.ows +11 -8
  2. orangecontrib/tomwer/tutorials/simple_volume_to_slurm_reconstruction.ows +12 -9
  3. orangecontrib/tomwer/widgets/control/DataDiscoveryOW.py +1 -1
  4. orangecontrib/tomwer/widgets/control/NXTomomillMixIn.py +21 -10
  5. tomwer/app/axis.py +1 -1
  6. tomwer/app/reducedarkflat.py +2 -2
  7. tomwer/core/process/control/datalistener/rpcserver.py +2 -8
  8. tomwer/core/process/drac/binning.py +2 -2
  9. tomwer/core/process/drac/output.py +1 -1
  10. tomwer/core/process/edit/imagekeyeditor.py +4 -6
  11. tomwer/core/process/edit/nxtomoeditor.py +58 -20
  12. tomwer/core/process/output.py +6 -5
  13. tomwer/core/process/reconstruction/axis/anglemode.py +2 -2
  14. tomwer/core/process/reconstruction/axis/axis.py +1 -0
  15. tomwer/core/process/reconstruction/axis/mode.py +2 -2
  16. tomwer/core/process/reconstruction/axis/params.py +4 -4
  17. tomwer/core/process/reconstruction/axis/projectiontype.py +1 -1
  18. tomwer/core/process/reconstruction/axis/side.py +1 -1
  19. tomwer/core/process/reconstruction/darkref/darkrefs.py +2 -2
  20. tomwer/core/process/reconstruction/darkref/darkrefscopy.py +1 -1
  21. tomwer/core/process/reconstruction/darkref/params.py +2 -3
  22. tomwer/core/process/reconstruction/nabu/castvolume.py +4 -1
  23. tomwer/core/process/reconstruction/nabu/helical.py +3 -1
  24. tomwer/core/process/reconstruction/nabu/nabucommon.py +2 -2
  25. tomwer/core/process/reconstruction/nabu/nabuscores.py +1 -1
  26. tomwer/core/process/reconstruction/nabu/nabuslices.py +4 -4
  27. tomwer/core/process/reconstruction/nabu/plane.py +2 -2
  28. tomwer/core/process/reconstruction/nabu/target.py +1 -1
  29. tomwer/core/process/reconstruction/nabu/test/test_castvolume.py +2 -0
  30. tomwer/core/process/reconstruction/nabu/utils.py +15 -14
  31. tomwer/core/process/reconstruction/normalization/normalization.py +1 -1
  32. tomwer/core/process/reconstruction/normalization/params.py +4 -4
  33. tomwer/core/process/reconstruction/output.py +2 -2
  34. tomwer/core/process/reconstruction/saaxis/params.py +3 -3
  35. tomwer/core/process/reconstruction/saaxis/saaxis.py +1 -1
  36. tomwer/core/process/reconstruction/scores/params.py +2 -2
  37. tomwer/core/process/reconstruction/scores/scores.py +3 -3
  38. tomwer/core/process/reconstruction/tests/test_axis.py +1 -1
  39. tomwer/core/process/stitching/metadataholder.py +5 -5
  40. tomwer/core/process/stitching/nabustitcher.py +1 -4
  41. tomwer/core/process/tests/test_normalization.py +2 -1
  42. tomwer/core/scan/edfscan.py +3 -3
  43. tomwer/core/scan/nxtomoscan.py +3 -3
  44. tomwer/core/scan/scanbase.py +3 -3
  45. tomwer/core/scan/scantype.py +1 -1
  46. tomwer/core/settings.py +1 -1
  47. tomwer/core/tomwer_object.py +1 -1
  48. tomwer/core/utils/nxtomoutils.py +2 -2
  49. tomwer/core/utils/spec.py +6 -3
  50. tomwer/gui/cluster/slurm.py +3 -3
  51. tomwer/gui/configuration/level.py +1 -1
  52. tomwer/gui/control/actions.py +1 -1
  53. tomwer/gui/control/datadiscovery.py +1 -1
  54. tomwer/gui/control/datalist.py +1 -1
  55. tomwer/gui/control/reducedarkflatselector.py +4 -4
  56. tomwer/gui/control/series/seriescreator.py +5 -5
  57. tomwer/gui/control/tomoobjdisplaymode.py +1 -1
  58. tomwer/gui/dataportal/gallery.py +6 -6
  59. tomwer/gui/edit/imagekeyeditor.py +7 -9
  60. tomwer/gui/edit/nxtomoeditor.py +420 -112
  61. tomwer/gui/edit/tests/test_nx_editor.py +155 -83
  62. tomwer/gui/reconstruction/axis/CalculationWidget.py +1 -1
  63. tomwer/gui/reconstruction/axis/EstimatedCORWidget.py +12 -8
  64. tomwer/gui/reconstruction/axis/EstimatedCorComboBox.py +2 -2
  65. tomwer/gui/reconstruction/axis/InputWidget.py +3 -3
  66. tomwer/gui/reconstruction/darkref/darkrefwidget.py +2 -2
  67. tomwer/gui/reconstruction/nabu/castvolume.py +16 -1
  68. tomwer/gui/reconstruction/nabu/nabuconfig/base.py +2 -4
  69. tomwer/gui/reconstruction/nabu/nabuconfig/ctf.py +6 -6
  70. tomwer/gui/reconstruction/nabu/nabuconfig/nabuconfig.py +1 -1
  71. tomwer/gui/reconstruction/nabu/nabuconfig/phase.py +5 -5
  72. tomwer/gui/reconstruction/nabu/nabuconfig/preprocessing.py +2 -4
  73. tomwer/gui/reconstruction/nabu/nabuconfig/reconstruction.py +78 -52
  74. tomwer/gui/reconstruction/nabu/nabuflow.py +3 -13
  75. tomwer/gui/reconstruction/nabu/slices.py +11 -11
  76. tomwer/gui/reconstruction/nabu/test/test_cast_volume.py +19 -0
  77. tomwer/gui/reconstruction/nabu/volume.py +1 -1
  78. tomwer/gui/reconstruction/normalization/intensity.py +8 -12
  79. tomwer/gui/reconstruction/saaxis/corrangeselector.py +2 -2
  80. tomwer/gui/reconstruction/saaxis/dimensionwidget.py +71 -67
  81. tomwer/gui/reconstruction/sacommon.py +1 -1
  82. tomwer/gui/reconstruction/scores/scoreplot.py +18 -10
  83. tomwer/gui/reconstruction/tests/test_saaxis.py +18 -16
  84. tomwer/gui/stitching/SingleAxisStitchingWidget.py +8 -8
  85. tomwer/gui/stitching/StitchingOptionsWidget.py +1 -1
  86. tomwer/gui/stitching/alignment.py +8 -8
  87. tomwer/gui/stitching/config/axisparams.py +2 -2
  88. tomwer/gui/stitching/config/output.py +1 -1
  89. tomwer/gui/stitching/config/positionoveraxis.py +1 -1
  90. tomwer/gui/stitching/config/stitchingstrategies.py +4 -6
  91. tomwer/gui/stitching/config/tomoobjdetails.py +21 -13
  92. tomwer/gui/stitching/normalization.py +6 -6
  93. tomwer/gui/stitching/tests/test_ZStitchingWindow.py +8 -1
  94. tomwer/gui/stitching/tests/test_preview.py +10 -7
  95. tomwer/gui/stitching/tests/utils.py +27 -18
  96. tomwer/gui/stitching/z_stitching/fineestimation.py +7 -9
  97. tomwer/gui/stitching/z_stitching/tests/test_raw_estimation.py +18 -7
  98. tomwer/gui/stitching/z_stitching/tests/test_stitching_window.py +7 -2
  99. tomwer/gui/utils/buttons.py +53 -35
  100. tomwer/gui/utils/flow.py +2 -2
  101. tomwer/gui/utils/loadingmode.py +1 -1
  102. tomwer/gui/utils/unitsystem.py +44 -33
  103. tomwer/gui/utils/vignettes.py +1 -1
  104. tomwer/gui/visualization/dataviewer.py +7 -7
  105. tomwer/gui/visualization/diffviewer/diffviewer.py +4 -4
  106. tomwer/gui/visualization/diffviewer/shiftwidget.py +4 -6
  107. tomwer/gui/visualization/reconstructionparameters.py +35 -23
  108. tomwer/gui/visualization/scanoverview.py +28 -11
  109. tomwer/gui/visualization/test/test_nx_tomo_metadata_viewer.py +25 -13
  110. tomwer/gui/visualization/test/test_reconstruction_parameters.py +2 -2
  111. tomwer/model/dataset.py +0 -0
  112. tomwer/synctools/utils/scanstages.py +3 -3
  113. tomwer/tasks/reconstruction/cleardarkflat.py +42 -0
  114. tomwer/tests/app/test_stitching.py +1 -1
  115. tomwer/tests/orangecontrib/tomwer/widgets/edit/tests/test_nxtomo_editor.py +32 -20
  116. tomwer/tests/orangecontrib/tomwer/widgets/reconstruction/tests/test_nabu_widget.py +1 -1
  117. tomwer/version.py +3 -3
  118. {tomwer-1.4.19.dist-info → tomwer-1.5.2rc0.dist-info}/METADATA +8 -8
  119. {tomwer-1.4.19.dist-info → tomwer-1.5.2rc0.dist-info}/RECORD +123 -121
  120. {tomwer-1.4.19.dist-info → tomwer-1.5.2rc0.dist-info}/WHEEL +1 -1
  121. {tomwer-1.4.19.dist-info → tomwer-1.5.2rc0.dist-info}/entry_points.txt +0 -0
  122. {tomwer-1.4.19.dist-info → tomwer-1.5.2rc0.dist-info}/licenses/LICENSE +0 -0
  123. {tomwer-1.4.19.dist-info → tomwer-1.5.2rc0.dist-info}/top_level.txt +0 -0
@@ -205,7 +205,7 @@ class _NabuBaseReconstructor:
205
205
  axis: NabuPlane = NabuPlane.XY,
206
206
  ) -> None:
207
207
  self._scan = scan
208
- self._target = Target.from_value(target)
208
+ self._target = Target(target)
209
209
  self._dry_run = dry_run
210
210
  self._process_name = process_name
211
211
  self._process = None
@@ -564,7 +564,7 @@ class _NabuBaseReconstructor:
564
564
  )
565
565
 
566
566
  source = extra_infos.get("source", INormSource.NONE)
567
- source = INormSource.from_value(source)
567
+ source = INormSource(source)
568
568
 
569
569
  if source is INormSource.NONE:
570
570
  pass
@@ -390,7 +390,7 @@ class _Reconstructor(_NabuBaseReconstructor):
390
390
  _config["reconstruction"]["end_z"] = self.slice_index
391
391
  else:
392
392
  raise ValueError(
393
- f"self.axis has an invalid value: {self.axis} when expected to be in {NabuPlane.values()}"
393
+ f"self.axis has an invalid value: {self.axis} when expected to be in {[item.value for item in NabuPlane]}"
394
394
  )
395
395
  return _config, file_prefix
396
396
 
@@ -54,7 +54,7 @@ from nabu.pipeline.fullfield.nabu_config import (
54
54
  nabu_config as nabu_fullfield_default_config,
55
55
  )
56
56
  from processview.core.superviseprocess import SuperviseProcess
57
- from silx.utils.enum import Enum as _Enum
57
+ from enum import Enum as _Enum
58
58
 
59
59
  from tomwer.core.process.task import Task
60
60
  from tomwer.core.scan.edfscan import EDFTomoScan
@@ -612,7 +612,7 @@ class SingleSliceRunner(_NabuBaseReconstructor):
612
612
  config["reconstruction"]["end_z"] = self.slice_index
613
613
  else:
614
614
  raise ValueError(
615
- f"self.axis has an invalid value: {self.axis} when expected to be in {NabuPlane.values()}"
615
+ f"self.axis has an invalid value: {self.axis} when expected to be in {[item.value for item in NabuPlane]}"
616
616
  )
617
617
 
618
618
  if self.slice_index is not None:
@@ -842,7 +842,7 @@ class NabuSliceMode(_Enum):
842
842
  def getSlices(slices, scan, axis=NabuPlane.XY) -> tuple:
843
843
  res = []
844
844
  try:
845
- mode = NabuSliceMode.from_value(slices)
845
+ mode = NabuSliceMode(slices)
846
846
  except ValueError:
847
847
  try:
848
848
  res = utils.retrieve_lst_of_value_from_str(slices, type_=int)
@@ -850,7 +850,7 @@ class NabuSliceMode(_Enum):
850
850
  pass
851
851
  else:
852
852
  if mode == mode.MIDDLE:
853
- axis = NabuPlane.from_value(axis)
853
+ axis = NabuPlane(axis)
854
854
  if axis is NabuPlane.XY:
855
855
  n_slice = scan.dim_2 or 2048
856
856
  elif axis in (NabuPlane.YZ, NabuPlane.XZ):
@@ -1,6 +1,6 @@
1
1
  """Define nabu Axis"""
2
2
 
3
- from silx.utils.enum import Enum as _Enum
3
+ from enum import Enum as _Enum
4
4
 
5
5
 
6
6
  class NabuPlane(_Enum):
@@ -16,4 +16,4 @@ class NabuPlane(_Enum):
16
16
  return NabuPlane.XZ
17
17
  elif value == 2:
18
18
  return NabuPlane.YZ
19
- return super().from_value(value=value)
19
+ return NabuPlane(value=value)
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- from silx.utils.enum import Enum as _Enum
3
+ from enum import Enum as _Enum
4
4
 
5
5
 
6
6
  class Target(_Enum):
@@ -107,6 +107,7 @@ def test_cast_volume_32bitstiff_to_16bits_tiff(tmp_path):
107
107
  "output_dir": str(save_dir),
108
108
  "output_file_format": NabuOutputFileFormat.HDF5,
109
109
  "output_data_type": numpy.int16,
110
+ "remove_input_volume": True,
110
111
  },
111
112
  "output_volume": output_volume.get_identifier().to_str(),
112
113
  },
@@ -114,3 +115,4 @@ def test_cast_volume_32bitstiff_to_16bits_tiff(tmp_path):
114
115
  task.run()
115
116
  assert task.outputs.volume.load_data().shape == (20, 100, 100)
116
117
  assert task.outputs.volume.load_data().dtype == numpy.int16
118
+ assert not os.path.exists(volume.data_url.file_path())
@@ -10,7 +10,7 @@ from nabu.pipeline.config import generate_nabu_configfile, parse_nabu_config_fil
10
10
  from nabu.pipeline.fullfield.nabu_config import (
11
11
  nabu_config as nabu_fullfield_default_config,
12
12
  )
13
- from silx.utils.enum import Enum as _Enum
13
+ from enum import Enum
14
14
 
15
15
  from tomoscan.identifier import VolumeIdentifier
16
16
  import tomwer.version
@@ -240,13 +240,13 @@ def get_multi_cor_recons_volume_identifiers(
240
240
  return res
241
241
 
242
242
 
243
- class _NabuMode(_Enum):
243
+ class _NabuMode(Enum):
244
244
  FULL_FIELD = "standard acquisition"
245
245
  HALF_ACQ = "half acquisition"
246
246
  # HELICAL = "helical acquisition"
247
247
 
248
248
 
249
- class _NabuStages(_Enum):
249
+ class _NabuStages(Enum):
250
250
  INI = "initialization"
251
251
  PRE = "pre-processing"
252
252
  PHASE = "phase"
@@ -267,7 +267,7 @@ class _NabuStages(_Enum):
267
267
  @staticmethod
268
268
  def getProcessEnum(stage):
269
269
  """Return the process Enum associated to the stage"""
270
- stage = _NabuStages.from_value(stage)
270
+ stage = _NabuStages(stage)
271
271
  if stage is _NabuStages.INI:
272
272
  raise NotImplementedError()
273
273
  elif stage is _NabuStages.PRE:
@@ -281,7 +281,7 @@ class _NabuStages(_Enum):
281
281
  raise NotImplementedError()
282
282
 
283
283
 
284
- class _NabuPreprocessing(_Enum):
284
+ class _NabuPreprocessing(Enum):
285
285
  """Define all the preprocessing action possible and the order they
286
286
  are applied on"""
287
287
 
@@ -296,7 +296,7 @@ class _NabuPreprocessing(_Enum):
296
296
  )
297
297
 
298
298
 
299
- class _NabuPhase(_Enum):
299
+ class _NabuPhase(Enum):
300
300
  """Define all the phase action possible and the order they
301
301
  are applied on"""
302
302
 
@@ -309,7 +309,7 @@ class _NabuPhase(_Enum):
309
309
  return (_NabuPhase.PHASE, _NabuPhase.UNSHARP_MASK, _NabuPhase.LOGARITHM)
310
310
 
311
311
 
312
- class _NabuProcessing(_Enum):
312
+ class _NabuProcessing(Enum):
313
313
  """Define all the processing action possible"""
314
314
 
315
315
  RECONSTRUCTION = "reconstruction"
@@ -319,7 +319,7 @@ class _NabuProcessing(_Enum):
319
319
  return (_NabuProcessing.RECONSTRUCTION,)
320
320
 
321
321
 
322
- class _NabuPostProcessing(_Enum):
322
+ class _NabuPostProcessing(Enum):
323
323
  """Define all the post processing action available"""
324
324
 
325
325
  SAVE_DATA = "save"
@@ -329,11 +329,12 @@ class _NabuPostProcessing(_Enum):
329
329
  return (_NabuPostProcessing.SAVE_DATA,)
330
330
 
331
331
 
332
- class _NabuReconstructionMethods(_Enum):
332
+ class _NabuReconstructionMethods(Enum):
333
333
  FBP = "FBP"
334
+ MLEM = "MLEM"
334
335
 
335
336
 
336
- class _NabuPhaseMethod(_Enum):
337
+ class _NabuPhaseMethod(Enum):
337
338
  """
338
339
  Nabu phase method
339
340
  """
@@ -354,10 +355,10 @@ class _NabuPhaseMethod(_Enum):
354
355
  elif value.lower() == "ctf":
355
356
  return _NabuPhaseMethod.CTF
356
357
  else:
357
- return super().from_value(value=value)
358
+ return _NabuPhaseMethod(value=value)
358
359
 
359
360
 
360
- class _NabuFBPFilterType(_Enum):
361
+ class _NabuFBPFilterType(Enum):
361
362
  RAMLAK = "ramlak"
362
363
  SHEPP_LOGAN = "shepp-logan"
363
364
  COSINE = "cosine"
@@ -368,12 +369,12 @@ class _NabuFBPFilterType(_Enum):
368
369
  HILBERT = "hilbert"
369
370
 
370
371
 
371
- class _NabuPaddingType(_Enum):
372
+ class _NabuPaddingType(Enum):
372
373
  ZEROS = "zeros"
373
374
  EDGES = "edges"
374
375
 
375
376
 
376
- class RingCorrectionMethod(_Enum):
377
+ class RingCorrectionMethod(Enum):
377
378
  NONE = "None"
378
379
  MUNCH = "munch"
379
380
  VO = "vo"
@@ -140,7 +140,7 @@ class SinoNormalizationTask(
140
140
  if calc_fct is None:
141
141
  raise ValueError("calc_fct should be provided")
142
142
  else:
143
- calc_fct = _ValueCalculationFct.from_value(calc_fct)
143
+ calc_fct = _ValueCalculationFct(calc_fct)
144
144
 
145
145
  try:
146
146
  value = self._cache_compute_from_manual_roi(
@@ -4,7 +4,7 @@ material for radio and sinogram normalization
4
4
  """
5
5
  from __future__ import annotations
6
6
 
7
- from silx.utils.enum import Enum as _Enum
7
+ from enum import Enum as _Enum
8
8
  from tomoscan.normalization import Method
9
9
 
10
10
 
@@ -39,7 +39,7 @@ class _DatasetInfos:
39
39
 
40
40
  @scope.setter
41
41
  def scope(self, scope: str | _DatasetScope):
42
- self._scope = _DatasetScope.from_value(scope)
42
+ self._scope = _DatasetScope(scope)
43
43
 
44
44
  @property
45
45
  def file_path(self):
@@ -86,7 +86,7 @@ class SinoNormalizationParams:
86
86
  def method(self, method: str | Method | None):
87
87
  if method is None:
88
88
  method = Method.NONE
89
- self._method = Method.from_value(method)
89
+ self._method = Method(method)
90
90
 
91
91
  @property
92
92
  def source(self):
@@ -96,7 +96,7 @@ class SinoNormalizationParams:
96
96
  def source(self, source):
97
97
  if source is None:
98
98
  source = _ValueSource.NONE
99
- self._source = _ValueSource.from_value(source)
99
+ self._source = _ValueSource(source)
100
100
 
101
101
  @property
102
102
  def extra_infos(self):
@@ -1,7 +1,7 @@
1
1
  from __future__ import annotations
2
2
  import os
3
3
  import logging
4
- from silx.utils.enum import Enum as _Enum
4
+ from enum import Enum as _Enum
5
5
  from tomwer.io.utils.raw_and_processed_data import (
6
6
  to_processed_data_path,
7
7
  )
@@ -30,7 +30,7 @@ class NabuOutputFileFormat(_Enum):
30
30
  def from_value(cls, value):
31
31
  if isinstance(value, str):
32
32
  value = value.lstrip(".")
33
- return super().from_value(value)
33
+ return NabuOutputFileFormat(value)
34
34
 
35
35
 
36
36
  def get_file_format(file_str):
@@ -4,7 +4,7 @@ from __future__ import annotations
4
4
  from typing import Iterable
5
5
 
6
6
  import numpy
7
- from silx.utils.enum import Enum as _Enum
7
+ from enum import Enum as _Enum
8
8
 
9
9
  from tomwer.core.process.reconstruction.scores.params import SABaseParams
10
10
 
@@ -56,7 +56,7 @@ class SAAxisParams(SABaseParams):
56
56
 
57
57
  @mode.setter
58
58
  def mode(self, mode):
59
- mode = ReconstructionMode.from_value(mode)
59
+ mode = ReconstructionMode(mode)
60
60
  self._mode = mode
61
61
 
62
62
  @property
@@ -91,7 +91,7 @@ class SAAxisParams(SABaseParams):
91
91
  if "n_reconstruction" in dict_:
92
92
  self.n_reconstruction = dict_["n_reconstruction"]
93
93
  if "mode" in dict_:
94
- self.mode = ReconstructionMode.from_value(dict_["mode"])
94
+ self.mode = ReconstructionMode(dict_["mode"])
95
95
 
96
96
  @staticmethod
97
97
  def from_dict(dict_):
@@ -430,7 +430,7 @@ class SAAxisTask(
430
430
  params.image_width = scan.dim_1
431
431
  scan.saaxis_params = params
432
432
 
433
- mode = ReconstructionMode.from_value(params.mode)
433
+ mode = ReconstructionMode(params.mode)
434
434
  if mode is not ReconstructionMode.VERTICAL:
435
435
  raise ValueError(f"{mode} is not handled for now")
436
436
 
@@ -102,7 +102,7 @@ class SABaseParams:
102
102
 
103
103
  @score_method.setter
104
104
  def score_method(self, method):
105
- self._score_method = ScoreMethod.from_value(method)
105
+ self._score_method = ScoreMethod(method)
106
106
 
107
107
  @property
108
108
  def scores(self) -> dict | None:
@@ -170,7 +170,7 @@ class SABaseParams:
170
170
  output_dir = None
171
171
  self.output_dir = output_dir
172
172
  if "score_method" in dict_:
173
- self.score_method = ScoreMethod.from_value(dict_["score_method"])
173
+ self.score_method = ScoreMethod(dict_["score_method"])
174
174
  if "cluster_config" in dict_:
175
175
  if dict_["cluster_config"] in (None, ""):
176
176
  self.cluster_config = None
@@ -4,7 +4,7 @@ import logging
4
4
  import sys
5
5
 
6
6
  import numpy
7
- from silx.utils.enum import Enum as _Enum
7
+ from enum import Enum as _Enum
8
8
 
9
9
  _logger = logging.getLogger(__name__)
10
10
 
@@ -36,7 +36,7 @@ class ComputedScore:
36
36
  return self._tomo_consistency
37
37
 
38
38
  def get(self, method: ScoreMethod):
39
- method = ScoreMethod.from_value(method)
39
+ method = ScoreMethod(method)
40
40
  if method is ScoreMethod.TV:
41
41
  return self.total_variation / float(10e5)
42
42
  elif method is ScoreMethod.TV_INVERSE:
@@ -135,7 +135,7 @@ def compute_score(
135
135
  :param method:
136
136
  :return: score of the frame
137
137
  """
138
- method = ScoreMethod.from_value(method)
138
+ method = ScoreMethod(method)
139
139
  if data.ndim == 3:
140
140
  if data.shape[0] == 1:
141
141
  data = data.reshape(data.shape[1], data.shape[2])
@@ -40,7 +40,7 @@ def test_read_x_rotation_axis_pixel_position(nxtomo_scan_360): # noqa F811
40
40
  with h5py.File(nxtomo_scan_360.master_file, mode="a") as h5f:
41
41
  h5f[x_rotation_axis_pixel_position_path] = 12.5
42
42
 
43
- nxtomo_scan_360.clear_caches()
43
+ nxtomo_scan_360.clear_cache()
44
44
  task.run()
45
45
  assert nxtomo_scan_360.axis_params.absolute_cor_value == 22.5
46
46
  assert nxtomo_scan_360.axis_params.relative_cor_value == 12.5
@@ -41,19 +41,19 @@ class StitchingMetadata:
41
41
  if value is not None and not isinstance(
42
42
  value, (float, numpy.float32, numpy.float64)
43
43
  ):
44
- raise TypeError
44
+ raise TypeError(f"Invalid type for value. Got {type(value)}")
45
45
  self._pixel_or_voxel_size[axis] = value
46
46
 
47
47
  def setPxPos(self, value, axis):
48
48
  if value is not None and not isinstance(value, (int, numpy.int32)):
49
- raise TypeError
49
+ raise TypeError(f"Invalid type for value. Got {type(value)}")
50
50
  self._pos_as_px[axis] = value
51
51
 
52
52
  def setMetricPos(self, value, axis):
53
53
  if value is not None and not isinstance(
54
54
  value, (int, numpy.float32, numpy.float64, float)
55
55
  ):
56
- raise TypeError
56
+ raise TypeError(f"Invalid type for value. Got {type(value)}")
57
57
  self._pos_as_m[axis] = value
58
58
 
59
59
  def get_raw_position_m(self, axis):
@@ -111,9 +111,9 @@ class StitchingMetadata:
111
111
  return self._pixel_or_voxel_size[axis]
112
112
  elif isinstance(self.tomo_obj, TomoScanBase):
113
113
  if axis == 0:
114
- return self.tomo_obj.y_pixel_size
114
+ return self.tomo_obj.sample_y_pixel_size
115
115
  elif axis in (1, 2):
116
- return self.tomo_obj.x_pixel_size
116
+ return self.tomo_obj.sample_x_pixel_size
117
117
  else:
118
118
  raise TypeError(f"axis is expected to be in (0, 1, 2). {axis} provided")
119
119
  elif isinstance(self.tomo_obj, VolumeBase):
@@ -162,12 +162,9 @@ class StitchingPostProcAggregation(_StitchingPostProcAggregation):
162
162
 
163
163
  def __init__(self, *args, **kwargs) -> None:
164
164
  super().__init__(*args, **kwargs)
165
- print("creates StitchingPostProcAggregation")
166
165
 
167
166
  if isinstance(self.stitching_config, dict):
168
- stitching_type = StitchingType.from_value(
169
- self.stitching_config["stitching"]["type"]
170
- )
167
+ stitching_type = StitchingType(self.stitching_config["stitching"]["type"])
171
168
  if stitching_type is StitchingType.Z_PREPROC:
172
169
  self._stitching_config = PreProcessedZStitchingConfiguration.from_dict(
173
170
  self.stitching_config
@@ -54,7 +54,8 @@ class TestNormalization(unittest.TestCase):
54
54
  "median": numpy.array([800.5, 10800.5]),
55
55
  }
56
56
 
57
- for calc_fct in params._ValueCalculationFct.values():
57
+ for item in params._ValueCalculationFct:
58
+ calc_fct = item.value
58
59
  with self.subTest(calc_fct=calc_fct):
59
60
  process_params.extra_infos = {
60
61
  "start_x": 0,
@@ -127,9 +127,9 @@ class EDFTomoScan(_tsEDFTomoScan, TomwerScanBase):
127
127
  )
128
128
  return EDFTomoScan(scan=identifier.folder)
129
129
 
130
- def clear_caches(self):
131
- _tsEDFTomoScan.clear_caches(self)
132
- TomwerScanBase.clear_caches(self)
130
+ def clear_cache(self):
131
+ _tsEDFTomoScan.clear_cache(self)
132
+ TomwerScanBase.clear_cache(self)
133
133
 
134
134
  @staticmethod
135
135
  def directory_contains_scan(directory, src_pattern, dest_pattern):
@@ -178,9 +178,9 @@ class NXtomoScan(_tsNXtomoScan, TomwerScanBase):
178
178
  else:
179
179
  return os.path.exists(master_file + ".h5")
180
180
 
181
- def clear_caches(self):
182
- _tsNXtomoScan.clear_caches(self)
183
- TomwerScanBase.clear_caches(self)
181
+ def clear_cache(self):
182
+ _tsNXtomoScan.clear_cache(self)
183
+ TomwerScanBase.clear_cache(self)
184
184
 
185
185
  def is_abort(self, src_pattern, dest_pattern):
186
186
  """
@@ -10,7 +10,7 @@ from typing import Iterable
10
10
 
11
11
  import numpy
12
12
  from silx.io.url import DataUrl
13
- from silx.utils.enum import Enum as _Enum
13
+ from enum import Enum as _Enum
14
14
 
15
15
  from tomoscan.identifier import VolumeIdentifier
16
16
  from tomoscan.normalization import IntensityNormalization
@@ -92,10 +92,10 @@ class TomwerScanBase(TomwerObject):
92
92
  """
93
93
  raise NotImplementedError("Base class")
94
94
 
95
- def clear_caches(self):
95
+ def clear_cache(self):
96
96
  self._cache_proj_urls = None
97
97
  self._notify_ffc_rsc_missing = True
98
- super().clear_caches()
98
+ super().clear_cache()
99
99
 
100
100
  def _flat_field_correction(
101
101
  self,
@@ -1,4 +1,4 @@
1
- from silx.utils.enum import Enum as _Enum
1
+ from enum import Enum as _Enum
2
2
 
3
3
 
4
4
  class ScanType(_Enum):
tomwer/core/settings.py CHANGED
@@ -1,5 +1,5 @@
1
1
  import os
2
- from silx.utils.enum import Enum as _Enum
2
+ from enum import Enum as _Enum
3
3
 
4
4
 
5
5
  __LBSRAM_PATH = "/lbsram"
@@ -19,7 +19,7 @@ class TomwerObject(Dataset):
19
19
  """util function to clear some heavy object from the cache"""
20
20
  raise NotImplementedError()
21
21
 
22
- def clear_caches(self):
22
+ def clear_cache(self):
23
23
  pass
24
24
 
25
25
  @property
@@ -11,12 +11,12 @@ def get_n_series(image_key_values: tuple | list, image_key_type: ImageKey) -> in
11
11
 
12
12
  :param image_key_values: list or tuple of image_keys to consider. Can be integers or tomoscan.esrf.scan.hdf5scan.ImageKey
13
13
  """
14
- image_key_type = ImageKey.from_value(image_key_type)
14
+ image_key_type = ImageKey(image_key_type)
15
15
  if image_key_type is ImageKey.INVALID:
16
16
  raise ValueError(
17
17
  "we can't count Invalid image keys series because those are ignored from tomoscan"
18
18
  )
19
- image_key_values = [ImageKey.from_value(img_key) for img_key in image_key_values]
19
+ image_key_values = [ImageKey(img_key) for img_key in image_key_values]
20
20
 
21
21
  # remove invalid frames
22
22
  image_key_values = numpy.array(
tomwer/core/utils/spec.py CHANGED
@@ -3,14 +3,17 @@ from __future__ import annotations
3
3
  import fileinput
4
4
  import logging
5
5
  import os
6
+ import pint
7
+
8
+ import fabio
6
9
 
7
- import fabio.edfimage
8
10
  from lxml import etree
9
- from pyunitsystem.metricsystem import MetricSystem
10
11
 
11
12
 
12
13
  _logger = logging.getLogger(__name__)
13
14
 
15
+ _ureg = pint.get_application_registry()
16
+
14
17
 
15
18
  def _getInformation(scan, refFile, information, _type, aliases=None):
16
19
  """
@@ -258,6 +261,6 @@ def getPixelSize(scan) -> float | None:
258
261
  value = float(ddict["IMAGE_PIXEL_SIZE_1".lower()])
259
262
  # for now pixel size are stored in microns. We want to return them in meter
260
263
  if value is not None:
261
- return value * MetricSystem.MICROMETER.value
264
+ return (value * _ureg.micrometer).to_base_units().magnitude
262
265
  else:
263
266
  return None
@@ -94,7 +94,7 @@ class SlurmSettingsWindow(qt.QMainWindow):
94
94
 
95
95
  self._modeCombox = qt.QComboBox(self)
96
96
  self._mainWidget.layout().addRow("configuration: ", self._modeCombox)
97
- self._modeCombox.addItems(SlurmSettingsMode.values())
97
+ self._modeCombox.addItems([item.value for item in SlurmSettingsMode])
98
98
  self._modeCombox.setCurrentText(SlurmSettingsMode.GENERIC.value)
99
99
 
100
100
  self._settingsWidget = SlurmSettingsWidget(self, jobLimitation=None)
@@ -155,10 +155,10 @@ class SlurmSettingsWindow(qt.QMainWindow):
155
155
  self._modeCombox.setCurrentText(SlurmSettingsMode.MANUAL.value)
156
156
 
157
157
  def getCurrentSettingsMode(self) -> SlurmSettingsMode:
158
- return SlurmSettingsMode.from_value(self._modeCombox.currentText())
158
+ return SlurmSettingsMode(self._modeCombox.currentText())
159
159
 
160
160
  def setCurrentSettingsMode(self, mode: SlurmSettingsMode) -> SlurmSettingsMode:
161
- mode = SlurmSettingsMode.from_value(mode)
161
+ mode = SlurmSettingsMode(mode)
162
162
  self._modeCombox.setCurrentText(mode.value)
163
163
 
164
164
  def setMode(self, mode: SlurmSettingsMode) -> None:
@@ -1,4 +1,4 @@
1
- from silx.utils.enum import Enum as _Enum
1
+ from enum import Enum as _Enum
2
2
 
3
3
 
4
4
  class ConfigurationLevel(_Enum):
@@ -86,7 +86,7 @@ class TomoObjDisplayModeToolButton(qt.QToolButton):
86
86
  urlDescAction.triggered.connect(partial(self.setDisplayMode, DisplayMode.URL))
87
87
 
88
88
  def setDisplayMode(self, mode: DisplayMode):
89
- mode = DisplayMode.from_value(mode)
89
+ mode = DisplayMode(mode)
90
90
  if mode is DisplayMode.SHORT:
91
91
  self.setIcon(self._shortDescIcon)
92
92
  self.setToolTip(self._SHORT_DESC_TOOLTIP)
@@ -44,7 +44,7 @@ class ScanDiscoveryConfigWidget(qt.QGroupBox):
44
44
  raise NotImplementedError
45
45
 
46
46
  def setScanType(self, mode: ScanType):
47
- mode = ScanType.from_value(mode)
47
+ mode = ScanType(mode)
48
48
  if mode is ScanType.SPEC:
49
49
  self._specQRB.setChecked(True)
50
50
  elif mode is ScanType.BLISS:
@@ -616,7 +616,7 @@ class _TomwerObjectList(qt.QTableWidget):
616
616
  self.setDisplayMode(DisplayMode.SHORT)
617
617
 
618
618
  def setDisplayMode(self, mode: DisplayMode) -> None:
619
- self._displayMode = DisplayMode.from_value(mode)
619
+ self._displayMode = DisplayMode(mode)
620
620
  self._update()
621
621
 
622
622
  def n_data(self):
@@ -287,11 +287,11 @@ class ReduceDarkFlatSelectorTableWidget(qt.QWidget):
287
287
  h5file=url.file_path(),
288
288
  path=url.data_path(),
289
289
  )
290
- for target in REDUCER_TARGET.values():
291
- if target in reduced_info_dict:
292
- reduced_frames = reduced_info_dict[target]
290
+ for target in REDUCER_TARGET:
291
+ if target.value in reduced_info_dict:
292
+ reduced_frames = reduced_info_dict[target.value]
293
293
  reduced_frames["reduce_frames_name"] = (
294
- f"{target} from {url.data_path()}@{os.path.basename(url.file_path())}"
294
+ f"{target.value} from {url.data_path()}@{os.path.basename(url.file_path())}"
295
295
  )
296
296
  result.append(reduced_frames)
297
297