nabu 2024.2.8__py3-none-any.whl → 2024.2.10__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.
nabu/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = "2024.2.8"
1
+ __version__ = "2024.2.10"
2
2
  __nabu_modules__ = [
3
3
  "app",
4
4
  "cuda",
nabu/io/reader.py CHANGED
@@ -688,8 +688,9 @@ class NXTomoReader(VolReaderBase):
688
688
  user_selection_dim0 = self.sub_region[0]
689
689
  indices = np.arange(self.data_shape_total[0])
690
690
  data_selection_indices_axis0 = np.hstack(
691
- [indices[image_key_slice][user_selection_dim0] for image_key_slice in self._image_key_slices]
692
- )
691
+ [indices[image_key_slice] for image_key_slice in self._image_key_slices]
692
+ )[user_selection_dim0]
693
+
693
694
  self._source_selection = (data_selection_indices_axis0,) + self.sub_region[1:]
694
695
 
695
696
  def _get_temporary_buffer(self, convert_after_reading):
@@ -4,7 +4,7 @@ from math import ceil
4
4
  import numpy as np
5
5
  from silx.io.url import DataUrl
6
6
 
7
- from ...utils import get_num_threads, remove_items_from_list
7
+ from ...utils import get_num_threads, remove_items_from_list, get_subregion as get_subregion_xy
8
8
  from ...resources.logger import LoggerOrPrint
9
9
  from ...resources.utils import extract_parameters
10
10
  from ...misc.binning import binning as image_binning
@@ -457,7 +457,8 @@ class ChunkedPipeline:
457
457
  self.double_flatfield = self.DoubleFlatFieldClass(
458
458
  self.radios_shape,
459
459
  result_url=result_url,
460
- sub_region=self.sub_region[1:],
460
+ # DoubleFlatField expects sub_region as (start_x, end_x, start_y, end_y)
461
+ sub_region=get_subregion_xy(self.sub_region[1:][::-1]),
461
462
  input_is_mlog=False,
462
463
  output_is_mlog=False,
463
464
  average_is_on_log=avg_is_on_log,
@@ -397,7 +397,7 @@ class PostProcessingStitching(SingleAxisStitcher):
397
397
 
398
398
  data_type = self.get_output_data_type()
399
399
 
400
- if self.progress:
400
+ if self.progress is not None:
401
401
  self.progress.total = final_volume_shape[1]
402
402
 
403
403
  y_index = 0
@@ -678,7 +678,7 @@ class PreProcessingStitching(SingleAxisStitcher):
678
678
  scans_projections_indexes = []
679
679
  for scan, reverse in zip(self.series, self.reading_orders):
680
680
  scans_projections_indexes.append(sorted(scan.projections.keys(), reverse=(reverse == -1)))
681
- if self.progress:
681
+ if self.progress is not None:
682
682
  self.progress.total = self.get_n_slices_to_stitch()
683
683
 
684
684
  if isinstance(self._slices_to_stitch, slice):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: nabu
3
- Version: 2024.2.8
3
+ Version: 2024.2.10
4
4
  Summary: Nabu - Tomography software
5
5
  Author-email: Pierre Paleo <pierre.paleo@esrf.fr>, Henri Payno <henri.payno@esrf.fr>, Alessandro Mirone <mirone@esrf.fr>, Jérôme Lesaint <jerome.lesaint@esrf.fr>
6
6
  Maintainer-email: Pierre Paleo <pierre.paleo@esrf.fr>
@@ -1,8 +1,7 @@
1
1
  doc/conf.py,sha256=3xtCarCHrXPr50GbeRDuH-o3Jzojw7mpr7vpGfZPLAE,3787
2
2
  doc/create_conf_doc.py,sha256=IVOdP70KvbW9WS_UQu3Iyd0YfS60E2fJ5IDtQ_s4cDw,1143
3
- doc/doc_config.py,sha256=anqeOVjqE2e7eVzg7yuh9dvIneTkrA5doGl1cVBqT7Q,730
4
3
  doc/get_mathjax.py,sha256=VIvKRCdDuF2VoY8JD3mSey9XX13AZMmwTJBHdt1tUs4,1012
5
- nabu/__init__.py,sha256=zSq-gJem_m5BV0pkafmuCesRi5_d0UbEMfnIUh2eStg,270
4
+ nabu/__init__.py,sha256=gyS0VYok0DgF0ObcNi8DY1i-yeyB5n_Tr2s1cjdM7Zk,271
6
5
  nabu/tests.py,sha256=cew9OY2uTyncHI_HM32W8CP6B1GTGKaOW65XtMEqs7o,1417
7
6
  nabu/testutils.py,sha256=VkSL9tbY0XEH49Z5OjDFFhzkSxrCv4UIuvSVFgegSUY,7632
8
7
  nabu/utils.py,sha256=V1B_sD54XGNKn5pORa2yNCATyswOzybey3sv8BuIYWY,26355
@@ -80,7 +79,7 @@ nabu/estimation/tests/test_translation.py,sha256=RkOnCYgk9DZGKlIka1snqTv4wbIz_nG
80
79
  nabu/io/__init__.py,sha256=AbQgj4-fCCHOKynO_PyAR9ejnFSuWKgroxxhxWVpjyQ,120
81
80
  nabu/io/cast_volume.py,sha256=gYsqHGdeiuTlOBCb9B7koRZ_bO0IQnN-XrzsSvR1s_I,16737
82
81
  nabu/io/detector_distortion.py,sha256=Or4icugi0fGRKWIG0I9hCuR1UZA5Cel25ZGY7cR2j4I,11744
83
- nabu/io/reader.py,sha256=ZrDlpJe4qn5mxGBccJi-C2hTganvuUnmbIwYkyE1Y_E,40517
82
+ nabu/io/reader.py,sha256=McWg7w04zrI0mt2z-BBwUr7rryMWYjdg7aHqbNeZ45A,40518
84
83
  nabu/io/reader_helical.py,sha256=_6vZBH-US_VT7oOGJUtYXqPwFws7xZKcmdOthpwvlIQ,4477
85
84
  nabu/io/utils.py,sha256=pFRULSlmGzJnzBbeSNKRhnKbBPbV0XaeUsxnWmnMtR4,9223
86
85
  nabu/io/writer.py,sha256=01S1nz6u3QxE-nGR6lcVuLEGYSZLNaKModvTaD4bLv8,15895
@@ -138,7 +137,7 @@ nabu/pipeline/reader.py,sha256=wkxPHYOi_C8dHNc7kddB8AMtFuW7GjsP_tm6SJeHlEY,4792
138
137
  nabu/pipeline/utils.py,sha256=0O1GLyYLQ8oA2ErI_T3BIfEVjP48dl-u_gl91eX7pjU,3543
139
138
  nabu/pipeline/writer.py,sha256=MG_R1oU8Ff9NdKRHiBkLMz0CmvEXY47zBUE-DpjXElQ,8172
140
139
  nabu/pipeline/fullfield/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
141
- nabu/pipeline/fullfield/chunked.py,sha256=6fHkofoFcCEYbdowCJU7s7c-hPaM62qv8PGSV_mNOkc,40795
140
+ nabu/pipeline/fullfield/chunked.py,sha256=UhNbaxfGgiTdeDdfSBPJhCd3Xo1bNR0EHfEHYf5SQxs,40939
142
141
  nabu/pipeline/fullfield/chunked_cuda.py,sha256=Jdkk6ZIt3S6UZYbupHtSj2vrj3krWMcqRHHprfblDfk,5848
143
142
  nabu/pipeline/fullfield/computations.py,sha256=AEp3qvwyY-l8-GzjH1E6kmcmU6OgDp6sB-mltq0Jnxg,9970
144
143
  nabu/pipeline/fullfield/dataset_validator.py,sha256=Iy6oOnXnBldDcg0ifm_zzrzMQ6YdkR_hkHFySZgxbno,2943
@@ -221,7 +220,6 @@ nabu/processing/tests/test_rotation.py,sha256=vedRXV9RePJywBKoyBkGANP1dhZCjphbYO
221
220
  nabu/processing/tests/test_transpose.py,sha256=hTG17wTaB5Wv6twbW3ZFhBv6BYfqJY7DTQPoO0-KdkM,2760
222
221
  nabu/processing/tests/test_unsharp.py,sha256=R3ovbwDDp3ccy2A8t6CcUVELXRWkED5EnQdN2FQOfQM,4391
223
222
  nabu/reconstruction/__init__.py,sha256=EmKVvx_-FJvzJngG4ielIC7FhMCpI1Waaflg_lF44tk,163
224
- nabu/reconstruction/astra.py,sha256=qnFYabU-Bzgys8hXjIBcwO2NazrvhNXUYFIkMHc6BmM,10444
225
223
  nabu/reconstruction/cone.py,sha256=RZj1JoxqskShvglgxUnsbYw7qbm6Rralt7hJ96eU-8c,19015
226
224
  nabu/reconstruction/fbp.py,sha256=uwEniGdEOn1atc9mTAHEDeF1y-ZqneifCKVr-ieHZss,5015
227
225
  nabu/reconstruction/fbp_base.py,sha256=DwZCilPXgGMRPV8_XfkWiaXUzWFM8rNBa8IyMdy5nno,17092
@@ -280,8 +278,8 @@ nabu/stitching/y_stitching.py,sha256=Urt2lBXokxXxX5HFHEiLBqC69yy5b_KyuKFoU8smah4
280
278
  nabu/stitching/z_stitching.py,sha256=gNwj7qWvDFQaGroLVoQnKBPlbvr_CReUQEqxW15m2Ag,1835
281
279
  nabu/stitching/stitcher/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
282
280
  nabu/stitching/stitcher/base.py,sha256=t6nb9pWPQjijVjlUO-LHauPUxohjwhTkpo-X0Yj1VV8,4229
283
- nabu/stitching/stitcher/post_processing.py,sha256=PDjMaFRLsnX_UD-vVviiOjzQ8DRewaJ_06XVFp183zE,26154
284
- nabu/stitching/stitcher/pre_processing.py,sha256=RpaJcgP2bhxqRXiX6GQUps7WSy9ThzYa0PgAV4GgZR4,51404
281
+ nabu/stitching/stitcher/post_processing.py,sha256=NIwRVyy_yhasswGI1SvlQfmD9FRjomcfcjgh1Drct_M,26166
282
+ nabu/stitching/stitcher/pre_processing.py,sha256=pI1ypS6HVTwb-OBXPKT5tXv-wQa7noetesV2GuUHShg,51416
285
283
  nabu/stitching/stitcher/single_axis.py,sha256=INsUgWmSKAcuFiE7NhJ72ChRLBqrlaUCSW6PG19XrYE,19978
286
284
  nabu/stitching/stitcher/stitcher.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
287
285
  nabu/stitching/stitcher/y_stitcher.py,sha256=KXwkyw6cCFcuSBCq5OyAait2Ob_5WRrtawrAlAhk60k,317
@@ -311,9 +309,9 @@ nabu/thirdparty/pore3d_deringer_munch.py,sha256=o4bisnFc-wMjuohWBT8wgWmfNehPQGtC
311
309
  nabu/thirdparty/tomocupy_remove_stripe.py,sha256=Khe4zFf0kRzu65Yxnvq58gt1ljOztqJGdMDhVAiM7lM,24363
312
310
  nabu/thirdparty/tomopy_phase.py,sha256=hK4oPpkogLOhv23XzzEXQY2u3r8fJvASY_bINVs6ERE,8634
313
311
  nabu/thirdparty/tomwer_load_flats_darks.py,sha256=ZNoVAinUb_wGYbfvs_4BVnWsjsQmNxSvCh1bWhR2WWg,5611
314
- nabu-2024.2.8.dist-info/LICENSE,sha256=1eAIPSnEsnSFNUODnLtNtQTs76exG3ZxJ1DJR6zoUBA,1066
315
- nabu-2024.2.8.dist-info/METADATA,sha256=5JnlQzXe6xXuHXklw49GyMS08SUq1hiIPSTUhG6jbiw,5514
316
- nabu-2024.2.8.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
317
- nabu-2024.2.8.dist-info/entry_points.txt,sha256=cJKGkBeykVL7uK3E4R0RLRqMXifTL2qdO573syPAvJc,1288
318
- nabu-2024.2.8.dist-info/top_level.txt,sha256=fsm_N3eXLRZk2QXF9OSKPNDPFXOz8FAQjHh5avT3dok,9
319
- nabu-2024.2.8.dist-info/RECORD,,
312
+ nabu-2024.2.10.dist-info/LICENSE,sha256=1eAIPSnEsnSFNUODnLtNtQTs76exG3ZxJ1DJR6zoUBA,1066
313
+ nabu-2024.2.10.dist-info/METADATA,sha256=1fyJOUVzs2_a8aGO9vlklgC6NvYuLV3usvDbI7zKki0,5515
314
+ nabu-2024.2.10.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
315
+ nabu-2024.2.10.dist-info/entry_points.txt,sha256=cJKGkBeykVL7uK3E4R0RLRqMXifTL2qdO573syPAvJc,1288
316
+ nabu-2024.2.10.dist-info/top_level.txt,sha256=fsm_N3eXLRZk2QXF9OSKPNDPFXOz8FAQjHh5avT3dok,9
317
+ nabu-2024.2.10.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (76.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
doc/doc_config.py DELETED
@@ -1,32 +0,0 @@
1
- #!/usr/bin/env python
2
-
3
- from nabu.resources.nabu_config import nabu_config
4
-
5
-
6
- def generate(file_):
7
- def write(content):
8
- print(content, file=file_)
9
- for section, values in nabu_config.items():
10
- if section == "about":
11
- continue
12
- write("## %s\n" % section)
13
- for key, val in values.items():
14
- if val["type"] == "unsupported":
15
- continue
16
- write(val["help"] + "\n")
17
- write(
18
- "```ini\n%s = %s\n```"
19
- % (key, val["default"])
20
- )
21
-
22
-
23
-
24
- if __name__ == "__main__":
25
-
26
- import sys, os
27
- print(os.path.abspath(__file__))
28
- exit(0)
29
-
30
- fname = "/tmp/test.md"
31
- with open(fname, "w") as f:
32
- generate(f)
@@ -1,245 +0,0 @@
1
- # ruff: noqa
2
- try:
3
- import astra
4
-
5
- __have_astra__ = True
6
- except ImportError:
7
- __have_astra__ = False
8
- astra = None
9
-
10
-
11
- class AstraReconstructor:
12
- """
13
- Base class for reconstructors based on the Astra toolbox
14
- """
15
-
16
- default_extra_options = {
17
- "axis_correction": None,
18
- "clip_outer_circle": False,
19
- "scale_factor": None,
20
- "filter_cutoff": 1.0,
21
- "outer_circle_value": 0.0,
22
- }
23
-
24
- def __init__(
25
- self,
26
- sinos_shape,
27
- angles=None,
28
- volume_shape=None,
29
- rot_center=None,
30
- pixel_size=None,
31
- padding_mode="zeros",
32
- filter_name=None,
33
- slice_roi=None,
34
- cuda_options=None,
35
- extra_options=None,
36
- ):
37
- self._configure_extra_options(extra_options)
38
- self._init_cuda(cuda_options)
39
- self._set_sino_shape(sinos_shape)
40
- self._orig_prog_geom = None
41
- self._init_geometry(
42
- source_origin_dist,
43
- origin_detector_dist,
44
- pixel_size,
45
- angles,
46
- volume_shape,
47
- rot_center,
48
- relative_z_position,
49
- slice_roi,
50
- )
51
- self._init_fdk(padding_mode, filter_name)
52
- self._alg_id = None
53
- self._vol_id = None
54
- self._proj_id = None
55
-
56
- def _configure_extra_options(self, extra_options):
57
- self.extra_options = self.default_extra_options.copy()
58
- self.extra_options.update(extra_options or {})
59
-
60
- def _init_cuda(self, cuda_options):
61
- cuda_options = cuda_options or {}
62
- self.cuda = CudaProcessing(**cuda_options)
63
-
64
- def _set_sino_shape(self, sinos_shape):
65
- if len(sinos_shape) != 3:
66
- raise ValueError("Expected a 3D shape")
67
- self.sinos_shape = sinos_shape
68
- self.n_sinos, self.n_angles, self.prj_width = sinos_shape
69
-
70
- def _set_pixel_size(self, pixel_size):
71
- if pixel_size is None:
72
- det_spacing_y = det_spacing_x = 1
73
- elif np.iterable(pixel_size):
74
- det_spacing_y, det_spacing_x = pixel_size
75
- else:
76
- # assuming scalar
77
- det_spacing_y = det_spacing_x = pixel_size
78
- self._det_spacing_y = det_spacing_y
79
- self._det_spacing_x = det_spacing_x
80
-
81
- def _set_slice_roi(self, slice_roi):
82
- self.slice_roi = slice_roi
83
- self._vol_geom_n_x = self.n_x
84
- self._vol_geom_n_y = self.n_y
85
- self._crop_data = True
86
- if slice_roi is None:
87
- return
88
- start_x, end_x, start_y, end_y = slice_roi
89
- if roi_is_centered(self.volume_shape[1:], (slice(start_y, end_y), slice(start_x, end_x))):
90
- # Astra can only reconstruct subregion centered around the origin
91
- self._vol_geom_n_x = self.n_x - start_x * 2
92
- self._vol_geom_n_y = self.n_y - start_y * 2
93
- else:
94
- raise NotImplementedError(
95
- "Astra supports only slice_roi centered around origin (got slice_roi=%s with n_x=%d, n_y=%d)"
96
- % (str(slice_roi), self.n_x, self.n_y)
97
- )
98
-
99
- def _init_geometry(
100
- self,
101
- source_origin_dist,
102
- origin_detector_dist,
103
- pixel_size,
104
- angles,
105
- volume_shape,
106
- rot_center,
107
- relative_z_position,
108
- slice_roi,
109
- ):
110
- if angles is None:
111
- self.angles = np.linspace(0, 2 * np.pi, self.n_angles, endpoint=True)
112
- else:
113
- self.angles = angles
114
- if volume_shape is None:
115
- volume_shape = (self.sinos_shape[0], self.sinos_shape[2], self.sinos_shape[2])
116
- self.volume_shape = volume_shape
117
- self.n_z, self.n_y, self.n_x = self.volume_shape
118
- self.source_origin_dist = source_origin_dist
119
- self.origin_detector_dist = origin_detector_dist
120
- self.magnification = 1 + origin_detector_dist / source_origin_dist
121
- self._set_slice_roi(slice_roi)
122
- self.vol_geom = astra.create_vol_geom(self._vol_geom_n_y, self._vol_geom_n_x, self.n_z)
123
- self.vol_shape = astra.geom_size(self.vol_geom)
124
- self._cor_shift = 0.0
125
- self.rot_center = rot_center
126
- if rot_center is not None:
127
- self._cor_shift = (self.sinos_shape[-1] - 1) / 2.0 - rot_center
128
- self._set_pixel_size(pixel_size)
129
- self._axis_corrections = self.extra_options.get("axis_correction", None)
130
- self._create_astra_proj_geometry(relative_z_position)
131
-
132
- def _create_astra_proj_geometry(self, relative_z_position):
133
- # This object has to be re-created each time, because once the modifications below are done,
134
- # it is no more a "cone" geometry but a "cone_vec" geometry, and cannot be updated subsequently
135
- # (see astra/functions.py:271)
136
- self.proj_geom = astra.create_proj_geom(
137
- "cone",
138
- self._det_spacing_x,
139
- self._det_spacing_y,
140
- self.n_sinos,
141
- self.prj_width,
142
- self.angles,
143
- self.source_origin_dist,
144
- self.origin_detector_dist,
145
- )
146
- self.relative_z_position = relative_z_position or 0.0
147
- # This will turn the geometry of type "cone" into a geometry of type "cone_vec"
148
- if self._orig_prog_geom is None:
149
- self._orig_prog_geom = self.proj_geom
150
- self.proj_geom = astra.geom_postalignment(self.proj_geom, (self._cor_shift, 0))
151
- # (src, detector_center, u, v) = (srcX, srcY, srcZ, dX, dY, dZ, uX, uY, uZ, vX, vY, vZ)
152
- vecs = self.proj_geom["Vectors"]
153
-
154
- # To adapt the center of rotation:
155
- # dX = cor_shift * cos(theta) - origin_detector_dist * sin(theta)
156
- # dY = origin_detector_dist * cos(theta) + cor_shift * sin(theta)
157
- if self._axis_corrections is not None:
158
- # should we check that dX and dY match the above formulas ?
159
- cor_shifts = self._cor_shift + self._axis_corrections
160
- vecs[:, 3] = cor_shifts * np.cos(self.angles) - self.origin_detector_dist * np.sin(self.angles)
161
- vecs[:, 4] = self.origin_detector_dist * np.cos(self.angles) + cor_shifts * np.sin(self.angles)
162
-
163
- # To adapt the z position:
164
- # Component 2 of vecs is the z coordinate of the source, component 5 is the z component of the detector position
165
- # We need to re-create the same inclination of the cone beam, thus we need to keep the inclination of the two z positions.
166
- # The detector is centered on the rotation axis, thus moving it up or down, just moves it out of the reconstruction volume.
167
- # We can bring back the detector in the correct volume position, by applying a rigid translation of both the detector and the source.
168
- # The translation is exactly the amount that brought the detector up or down, but in the opposite direction.
169
- vecs[:, 2] = -self.relative_z_position
170
-
171
- def _set_output(self, volume):
172
- if volume is not None:
173
- expected_shape = self.vol_shape # if not (self._crop_data) else self._output_cropped_shape
174
- self.cuda.check_array(volume, expected_shape)
175
- self.cuda.set_array("output", volume)
176
- if volume is None:
177
- self.cuda.allocate_array("output", self.vol_shape)
178
- d_volume = self.cuda.get_array("output")
179
- z, y, x = d_volume.shape
180
- self._vol_link = astra.data3d.GPULink(d_volume.ptr, x, y, z, d_volume.strides[-2])
181
- self._vol_id = astra.data3d.link("-vol", self.vol_geom, self._vol_link)
182
-
183
- def _set_input(self, sinos):
184
- self.cuda.check_array(sinos, self.sinos_shape)
185
- self.cuda.set_array("sinos", sinos) # self.cuda.sinos is now a GPU array
186
- # TODO don't create new link/proj_id if ptr is the same ?
187
- # But it seems Astra modifies the input sinogram while doing FDK, so this might be not relevant
188
- d_sinos = self.cuda.get_array("sinos")
189
-
190
- # self._proj_data_link = astra.data3d.GPULink(d_sinos.ptr, self.prj_width, self.n_angles, self.n_z, sinos.strides[-2])
191
- self._proj_data_link = astra.data3d.GPULink(
192
- d_sinos.ptr, self.prj_width, self.n_angles, self.n_sinos, d_sinos.strides[-2]
193
- )
194
- self._proj_id = astra.data3d.link("-sino", self.proj_geom, self._proj_data_link)
195
-
196
- def _preprocess_data(self):
197
- d_sinos = self.cuda.sinos
198
- for i in range(d_sinos.shape[0]):
199
- self.sino_filter.filter_sino(d_sinos[i], output=d_sinos[i])
200
-
201
- def _update_reconstruction(self):
202
- cfg = astra.astra_dict("BP3D_CUDA")
203
- cfg["ReconstructionDataId"] = self._vol_id
204
- cfg["ProjectionDataId"] = self._proj_id
205
- if self._alg_id is not None:
206
- astra.algorithm.delete(self._alg_id)
207
- self._alg_id = astra.algorithm.create(cfg)
208
-
209
- def reconstruct(self, sinos, output=None, relative_z_position=None):
210
- """
211
- sinos: numpy.ndarray or pycuda.gpuarray
212
- Sinograms, with shape (n_sinograms, n_angles, width)
213
- output: pycuda.gpuarray, optional
214
- Output array. If not provided, a new numpy array is returned
215
- relative_z_position: int, optional
216
- Position of the central slice of the slab, with respect to the full stack of slices.
217
- By default it is set to zero, meaning that the current slab is assumed in the middle of the stack
218
- """
219
- self._create_astra_proj_geometry(relative_z_position)
220
- self._set_input(sinos)
221
- self._set_output(output)
222
- self._preprocess_data()
223
- self._update_reconstruction()
224
- astra.algorithm.run(self._alg_id)
225
- #
226
- # NB: Could also be done with
227
- # from astra.experimental import direct_BP3D
228
- # projector_id = astra.create_projector("cuda3d", self.proj_geom, self.vol_geom, options=None)
229
- # direct_BP3D(projector_id, self._vol_link, self._proj_data_link)
230
- #
231
- result = self.cuda.get_array("output")
232
- if output is None:
233
- result = result.get()
234
- if self.extra_options.get("scale_factor", None) is not None:
235
- result *= np.float32(self.extra_options["scale_factor"]) # in-place for pycuda
236
- self.cuda.recover_arrays_references(["sinos", "output"])
237
- return result
238
-
239
- def __del__(self):
240
- if getattr(self, "_alg_id", None) is not None:
241
- astra.algorithm.delete(self._alg_id)
242
- if getattr(self, "_vol_id", None) is not None:
243
- astra.data3d.delete(self._vol_id)
244
- if getattr(self, "_proj_id", None) is not None:
245
- astra.data3d.delete(self._proj_id)