-
Notifications
You must be signed in to change notification settings - Fork 204
/
Copy pathAtb.py
40 lines (32 loc) · 1.42 KB
/
Atb.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import copy
import numpy as np
from _Atb import _Atb_ext
from .gpu import GpuIds
def Atb(projections, geo, angles, backprojection_type="FDK", **kwargs):
if projections.dtype != np.float32:
raise TypeError("Input data should be float32, not " + str(projections.dtype))
if not np.isreal(projections).all():
raise ValueError("Complex types not compatible for back projection.")
geox = copy.deepcopy(geo)
geox.check_geo(angles)
"""
Here we cast all values in geo to single point precision float. This way we know what behavior
to expect from pytigre to Cuda and can change single parameters accordingly.
"""
geox.cast_to_single()
# geox.checknans()
if projections.shape != (geox.angles.shape[0], geox.nDetector[0], geox.nDetector[1]):
raise ValueError(
"Expected data shape: "
+ str((geox.angles.shape[0], geox.nDetector[0], geox.nDetector[1]))
+ " not compatible with: "
+ str(projections.shape)
)
if kwargs.get("gpuids", None) is None:
gpuids = GpuIds()
else:
gpuids = kwargs["gpuids"]
# if we have more GPUs than slices to compute, reduce the amount of GPUs.
if geo.nVoxel[0]< len(gpuids):
gpuids.devices = list(gpuids.devices[0:geo.nVoxel[0]])
return _Atb_ext(projections, geox, geox.angles, backprojection_type, geox.mode, gpuids=gpuids)