httomolibgpu 2.6__py3-none-any.whl → 2.7.1__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.
@@ -44,7 +44,7 @@ __all__ = [
44
44
 
45
45
 
46
46
  def sino_360_to_180(
47
- data: cp.ndarray, overlap: int = 0, rotation: Literal["left", "right"] = "left"
47
+ data: cp.ndarray, overlap: float = 0, side: Literal["left", "right"] = "left"
48
48
  ) -> cp.ndarray:
49
49
  """
50
50
  Converts 0-360 degrees sinogram to a 0-180 sinogram.
@@ -55,9 +55,9 @@ def sino_360_to_180(
55
55
  ----------
56
56
  data : cp.ndarray
57
57
  Input 3D data.
58
- overlap : scalar, optional
59
- Overlapping number of pixels.
60
- rotation : string, optional
58
+ overlap : float
59
+ Overlapping number of pixels. Floats will be converted to integers.
60
+ side : string
61
61
  'left' if rotation center is close to the left of the
62
62
  field-of-view, 'right' otherwise.
63
63
  Returns
@@ -74,18 +74,20 @@ def sino_360_to_180(
74
74
 
75
75
  overlap = int(np.round(overlap))
76
76
  if overlap >= dz:
77
- raise ValueError("overlap must be less than data.shape[2]")
77
+ raise ValueError("Overlap must be less than data.shape[2]")
78
78
  if overlap < 0:
79
- raise ValueError("only positive overlaps are allowed.")
79
+ raise ValueError("Only positive overlaps are allowed.")
80
80
 
81
- if rotation not in ["left", "right"]:
82
- raise ValueError('rotation parameter must be either "left" or "right"')
81
+ if side not in ["left", "right"]:
82
+ raise ValueError(
83
+ f'The value {side} is invalid, only "left" or "right" strings are accepted'
84
+ )
83
85
 
84
86
  n = dx // 2
85
87
 
86
88
  out = cp.empty((n, dy, 2 * dz - overlap), dtype=data.dtype)
87
89
 
88
- if rotation == "left":
90
+ if side == "left":
89
91
  weights = cp.linspace(0, 1.0, overlap, dtype=cp.float32)
90
92
  out[:, :, -dz + overlap :] = data[:n, :, overlap:]
91
93
  out[:, :, : dz - overlap] = data[n : 2 * n, :, overlap:][:, :, ::-1]
@@ -93,7 +95,7 @@ def sino_360_to_180(
93
95
  weights * data[:n, :, :overlap]
94
96
  + (weights * data[n : 2 * n, :, :overlap])[:, :, ::-1]
95
97
  )
96
- if rotation == "right":
98
+ if side == "right":
97
99
  weights = cp.linspace(1.0, 0, overlap, dtype=cp.float32)
98
100
  out[:, :, : dz - overlap] = data[:n, :, :-overlap]
99
101
  out[:, :, -dz + overlap :] = data[n : 2 * n, :, :-overlap][:, :, ::-1]
@@ -162,7 +162,7 @@ def data_checker(
162
162
  ) -> bool:
163
163
  """
164
164
  Function that performs the variety of checks on input data, in some cases also correct the data and prints warnings.
165
- Currently it checks for: the presence of infs and nans in data; the number of zero elements.
165
+ Currently it checks for: the presence of infs and nans in data.
166
166
 
167
167
  Parameters
168
168
  ----------
@@ -181,11 +181,12 @@ def data_checker(
181
181
 
182
182
  data = _naninfs_check(data, verbosity=verbosity, method_name=method_name)
183
183
 
184
- _zeros_check(
185
- data,
186
- verbosity=verbosity,
187
- percentage_threshold=50,
188
- method_name=method_name,
189
- )
184
+ # ! The number of zero elements check is currently switched off as it requires sorting or AtomicAdd, which makes it inefficient on GPUs. !
185
+ # _zeros_check(
186
+ # data,
187
+ # verbosity=verbosity,
188
+ # percentage_threshold=50,
189
+ # method_name=method_name,
190
+ # )
190
191
 
191
192
  return data
@@ -73,7 +73,7 @@ def FBP2d_astra(
73
73
  This is a 2D recon using ASTRA's API for the FBP method, see for more parameters ASTRA's documentation here:
74
74
  https://astra-toolbox.com/docs/algs/FBP_CUDA.html.
75
75
 
76
- Parameters`
76
+ Parameters
77
77
  ----------
78
78
  data : np.ndarray
79
79
  Projection data as a 3d numpy array.
@@ -416,11 +416,11 @@ def find_center_360(
416
416
  data: cp.ndarray,
417
417
  ind: Optional[int] = None,
418
418
  win_width: int = 10,
419
- side: Optional[Literal[0, 1]] = None,
419
+ side: Optional[Literal["left", "right"]] = None,
420
420
  denoise: bool = True,
421
421
  norm: bool = False,
422
422
  use_overlap: bool = False,
423
- ) -> Tuple[float, float, Optional[Literal[0, 1]], float]:
423
+ ) -> Tuple[np.float32, np.float32, Optional[Literal["left", "right"]], np.float32]:
424
424
  """
425
425
  Find the center-of-rotation (COR) in a 360-degree scan and also an offset
426
426
  to perform data transformation from 360 to 180 degrees scan. See :cite:`vo2021data`.
@@ -433,10 +433,9 @@ def find_center_360(
433
433
  Index of the slice to be used for estimate the CoR and the overlap.
434
434
  win_width : int, optional
435
435
  Window width used for finding the overlap area.
436
- side : {None, 0, 1}, optional
437
- Overlap size. Only there options: None, 0, or 1. "None" corresponds
438
- to fully automated determination. "0" corresponds to the left side.
439
- "1" corresponds to the right side.
436
+ side : {None, left, right}, optional
437
+ Chose between "left", "right" or "None" which corresponds to fully
438
+ automated determination of the side.
440
439
  denoise : bool, optional
441
440
  Apply the Gaussian filter if True.
442
441
  norm : bool, optional
@@ -451,8 +450,8 @@ def find_center_360(
451
450
  Center-of-rotation.
452
451
  overlap : float
453
452
  Width of the overlap area between two halves of the sinogram.
454
- side : int
455
- Overlap side between two halves of the sinogram.
453
+ side : str
454
+ Overlap side (left or right) between two halves of the sinogram.
456
455
  overlap_position : float
457
456
  Position of the window in the first image giving the best
458
457
  correlation metric.
@@ -475,10 +474,7 @@ def find_center_360(
475
474
  (overlap, side, overlap_position) = _find_overlap(
476
475
  sino_top, sino_bot, win_width, side, denoise, norm, use_overlap
477
476
  )
478
- if side == 0:
479
- cor = overlap / 2.0 - 1.0
480
- else:
481
- cor = ncol - overlap / 2.0 - 1.0
477
+ cor = ncol - overlap / 2
482
478
 
483
479
  return cor, overlap, side, overlap_position
484
480
 
@@ -498,10 +494,9 @@ def _find_overlap(
498
494
  2D array. Projection image or sinogram image.
499
495
  win_width : int
500
496
  Width of the searching window.
501
- side : {None, 0, 1}, optional
502
- Only there options: None, 0, or 1. "None" corresponding to fully
503
- automated determination. "0" corresponding to the left side. "1"
504
- corresponding to the right side.
497
+ side : {None, left, right}, optional
498
+ Chose between "left", "right" or "None" which corresponds to fully
499
+ automated determination of the side.
505
500
  denoise : bool, optional
506
501
  Apply the Gaussian filter if True.
507
502
  norm : bool, optional
@@ -514,8 +509,8 @@ def _find_overlap(
514
509
  -------
515
510
  overlap : float
516
511
  Width of the overlap area between two images.
517
- side : int
518
- Overlap side between two images.
512
+ side : str
513
+ Overlap side (left or right) between two images.
519
514
  overlap_position : float
520
515
  Position of the window in the first image giving the best
521
516
  correlation metric.
@@ -525,12 +520,12 @@ def _find_overlap(
525
520
  ncol2 = mat2.shape[1]
526
521
  win_width = int(np.clip(win_width, 6, min(ncol1, ncol2) // 2))
527
522
 
528
- if side == 1:
523
+ if side == "right":
529
524
  (list_metric, offset) = _search_overlap(
530
525
  mat1,
531
526
  mat2,
532
527
  win_width,
533
- side=side,
528
+ side=1, # right side
534
529
  denoise=denoise,
535
530
  norm=norm,
536
531
  use_overlap=use_overlap,
@@ -538,12 +533,12 @@ def _find_overlap(
538
533
  overlap_position = _calculate_curvature(list_metric)[1]
539
534
  overlap_position += offset
540
535
  overlap = ncol1 - overlap_position + win_width // 2
541
- elif side == 0:
536
+ elif side == "left":
542
537
  (list_metric, offset) = _search_overlap(
543
538
  mat1,
544
539
  mat2,
545
540
  win_width,
546
- side=side,
541
+ side=0, # left side
547
542
  denoise=denoise,
548
543
  norm=norm,
549
544
  use_overlap=use_overlap,
@@ -556,7 +551,7 @@ def _find_overlap(
556
551
  mat1,
557
552
  mat2,
558
553
  win_width,
559
- side=1,
554
+ side=1, # right side
560
555
  denoise=denoise,
561
556
  norm=norm,
562
557
  use_overlap=use_overlap,
@@ -565,7 +560,7 @@ def _find_overlap(
565
560
  mat1,
566
561
  mat2,
567
562
  win_width,
568
- side=0,
563
+ side=0, # left side
569
564
  denoise=denoise,
570
565
  norm=norm,
571
566
  use_overlap=use_overlap,
@@ -577,11 +572,11 @@ def _find_overlap(
577
572
  overlap_position2 += offset2
578
573
 
579
574
  if curvature1 > curvature2:
580
- side = 1
575
+ side = "right"
581
576
  overlap_position = overlap_position1
582
577
  overlap = ncol1 - overlap_position + win_width // 2
583
578
  else:
584
- side = 0
579
+ side = "left"
585
580
  overlap_position = overlap_position2
586
581
  overlap = overlap_position + win_width // 2
587
582
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: httomolibgpu
3
- Version: 2.6
3
+ Version: 2.7.1
4
4
  Summary: Commonly used tomography data processing methods at DLS.
5
5
  Author-email: Daniil Kazantsev <daniil.kazantsev@diamond.ac.uk>, Yousef Moazzam <yousef.moazzam@diamond.ac.uk>, Naman Gera <naman.gera@diamond.ac.uk>
6
6
  License: BSD-3-Clause
@@ -11,19 +11,19 @@ httomolibgpu/cuda_kernels/remove_nan_inf.cu,sha256=gv0ihkf6A_D_po9x7pmgFsQFhwZ1d
11
11
  httomolibgpu/misc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  httomolibgpu/misc/corr.py,sha256=ZRkDv_RmrRbL-Mr3uNaj2joEjcq6ImRlTDrWD75EtXw,4597
13
13
  httomolibgpu/misc/denoise.py,sha256=6dpsEjnkew-hG6BxR2crTQLfPLhqs2jvrCiJ3XJolYw,4728
14
- httomolibgpu/misc/morph.py,sha256=NIWXax8mBDmcaSnMIrpPcHQK-mtEIvHQanjV9o1eGr8,7432
14
+ httomolibgpu/misc/morph.py,sha256=AlLk_kGFHF6vNrdICMpsXmTUDnCc7ey97-_DqwZb3Wc,7475
15
15
  httomolibgpu/misc/rescale.py,sha256=ODO-WI3jmfyVIcfMsD_Pb39hUt4YiHqIWncpemuFhks,5058
16
- httomolibgpu/misc/supp_func.py,sha256=gGAxwi0KYLwnBRnfsXitDZ16QMaycPexJ4vzzKx6Plk,6101
16
+ httomolibgpu/misc/supp_func.py,sha256=g68-YLg8sHcq7qZEC5LbgbTF2iHslQnU1BUg6mLxvjg,6228
17
17
  httomolibgpu/prep/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  httomolibgpu/prep/alignment.py,sha256=BuFTfLZD5_THQAKP_ikQ3fRE8JpN-JItGllZgrHRU5s,5657
19
19
  httomolibgpu/prep/normalize.py,sha256=ozVUAs4UY2DY7MQtJKllUgahp_4wRFKPuc_3iQl6bCE,4879
20
20
  httomolibgpu/prep/phase.py,sha256=KyzLJKq6ft1WexvjojpDiVwyCSGkar6DMOQEawW_olo,12043
21
21
  httomolibgpu/prep/stripe.py,sha256=-KRZHMSs2xkfCzPQGOl2RbLtV3VAr7tulMui36brdP8,15093
22
22
  httomolibgpu/recon/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
- httomolibgpu/recon/algorithm.py,sha256=O1URBdhXKw5He4AQDLdC4XhdcnlGY355qBpStBeZVZs,19461
24
- httomolibgpu/recon/rotation.py,sha256=VDrma5uDcRu3NLxHw1NmwKgtURZdV1kT5wZZiZMD4HI,27792
25
- httomolibgpu-2.6.dist-info/licenses/LICENSE,sha256=bXeLsgelPUUXw8HCIYiVC97Dpjhm2nB54m7TACdH8ng,48032
26
- httomolibgpu-2.6.dist-info/METADATA,sha256=rUZvlCFe9bC4eqXR2dFnWSnWpu_QjQaYd8RUUYAqJ3g,3399
27
- httomolibgpu-2.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
28
- httomolibgpu-2.6.dist-info/top_level.txt,sha256=nV0Ty_YvSPVd1O6MNWuIplD0w1nwk5hT76YgBZ-bzUw,13
29
- httomolibgpu-2.6.dist-info/RECORD,,
23
+ httomolibgpu/recon/algorithm.py,sha256=Lqp3o8e_P-PyOTssqlmdFO0k0fArc5pNM_0i8rQFT2E,19460
24
+ httomolibgpu/recon/rotation.py,sha256=k_E0lBRprJz6AGclagIkrzk_9dipADxPtL5BxrggSwM,27729
25
+ httomolibgpu-2.7.1.dist-info/licenses/LICENSE,sha256=bXeLsgelPUUXw8HCIYiVC97Dpjhm2nB54m7TACdH8ng,48032
26
+ httomolibgpu-2.7.1.dist-info/METADATA,sha256=2TTgpJesuIdRsJ-6cG36ZrpbLN7IxiulljVWN3MBZo4,3401
27
+ httomolibgpu-2.7.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
28
+ httomolibgpu-2.7.1.dist-info/top_level.txt,sha256=nV0Ty_YvSPVd1O6MNWuIplD0w1nwk5hT76YgBZ-bzUw,13
29
+ httomolibgpu-2.7.1.dist-info/RECORD,,