Commit d607c223 authored by Pierre Paleo's avatar Pierre Paleo
Browse files

Patch sinogram cuda generation for external CoR

parent b730f1d9
import numpy as np
import pycuda.gpuarray as garray
from .sinogram import SinoProcessing, SinoNormalization
from .sinogram import _convert_halftomo_right # FIXME Temporary patch
from ..cuda.processing import CudaProcessing
from ..cuda.kernel import CudaKernel
from ..utils import get_cuda_srcfile, updiv
......@@ -75,14 +76,8 @@ class CudaSinoProcessing(SinoProcessing, CudaProcessing):
return output
# Overwrite parent method
def _radios_to_sinos_halftomo(self, radios, sinos):
# TODO
if not(np.isscalar(self.rot_center)):
raise NotImplementedError("Half tomo with varying rotation axis position is not implemented yet")
#
n_a, n_z, n_x = radios.shape
n_a2 = n_a // 2
rc = self._rot_center_int
......@@ -98,6 +93,11 @@ class CudaSinoProcessing(SinoProcessing, CudaProcessing):
else:
sinos = garray.zeros(self.sinos_halftomo_shape, dtype=np.float32)
# FIXME: TEMPORARY PATCH
if self._rot_center_int > self.n_x:
return self._radios_to_sinos_halftomo_external_cor(radios, sinos)
#
# need to use a contiguous 2D, array otherwise kernel does not work
d_radio = radios[:, 0, :].copy()
for i in range(n_z):
......@@ -123,6 +123,36 @@ class CudaSinoProcessing(SinoProcessing, CudaProcessing):
return sinos
def _radios_to_sinos_halftomo_external_cor(self, radios, sinos):
"""
TEMPORARY PATCH waiting to fix cuda kernel
Processing is done by getting reach radio on host, which is suboptimal
"""
n_a, n_z, n_x = radios.shape
n_a2 = n_a // 2
rc = self._rot_center_int
out_dwidth = 2 * rc
# need to use a contiguous 2D, array otherwise kernel does not work
sino = radios[:, 0, :].get()
for i in range(n_z):
radios[:, i, :].get(sino)
if self._halftomo_flip:
sino = sino[:, ::-1]
sino_half = _convert_halftomo_right(sino, self._rot_center_int)
sinos[i, :, :] = sino_half[:]
if self._halftomo_flip:
self.xflip_kernel(
sinos[i], 2*rc, n_a2,
grid=self._xflip_gridsize_2, block=self._xflip_blksize
)
return sinos
class CudaSinoNormalization(SinoNormalization, CudaProcessing):
def __init__(self, kind="chebyshev", sinos_shape=None, radios_shape=None, rot_center=None, halftomo=False, cuda_options=None):
SinoNormalization.__init__(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment