Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tomotools
Nabu
Commits
d607c223
Commit
d607c223
authored
May 04, 2021
by
Pierre Paleo
Browse files
Patch sinogram cuda generation for external CoR
parent
b730f1d9
Changes
1
Hide whitespace changes
Inline
Side-by-side
nabu/preproc/sinogram_cuda.py
View file @
d607c223
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__
(
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment