Skip to content
Snippets Groups Projects
Commit d83be5b6 authored by Stephan Seitz's avatar Stephan Seitz
Browse files

Re-introduce ConeBeamProjector.from_conrad_config()

parent 2b78ea9c
No related branches found
No related tags found
No related merge requests found
...@@ -78,37 +78,40 @@ class ConeBeamProjector: ...@@ -78,37 +78,40 @@ class ConeBeamProjector:
class BackwardProjection(torch.autograd.Function): class BackwardProjection(torch.autograd.Function):
pass pass
# def __init__(self, def __init__(self,
# volume_shape, volume_shape,
# volume_spacing, volume_spacing,
# volume_origin, volume_origin,
# projection_shape, projection_shape,
# projection_spacing, projection_spacing,
# projection_origin, projection_origin,
# projection_matrices): projection_matrices):
# self._volume_shape = volume_shape self._volume_shape = volume_shape
# self._volume_origin = volume_origin self._volume_origin = volume_origin
# self._volume_spacing = volume_spacing self._volume_spacing = volume_spacing
# self._projection_shape = projection_shape self._projection_shape = projection_shape
# self._projection_matrices = projection_matrices self._projection_matrices_numpy = projection_matrices
# self._projection_spacing = projection_spacing self._projection_spacing = projection_spacing
# self._projection_origin = projection_origin self._projection_origin = projection_origin
# self._calc_inverse_matrices() self._calc_inverse_matrices()
def __init__(self): @classmethod
def from_conrad_config(cls):
obj = cls(*([None]*7))
import pyconrad.autoinit import pyconrad.autoinit
import pyconrad.config import pyconrad.config
self._volume_shape = pyconrad.config.get_reco_shape() obj._volume_shape = pyconrad.config.get_reco_shape()
self._volume_spacing = pyconrad.config.get_reco_spacing() obj._volume_spacing = pyconrad.config.get_reco_spacing()
self._volume_origin = pyconrad.config.get_reco_origin() obj._volume_origin = pyconrad.config.get_reco_origin()
self._projection_shape = pyconrad.config.get_sino_shape() obj._projection_shape = pyconrad.config.get_sino_shape()
self._projection_spacing = [pyconrad.config.get_geometry().getPixelDimensionY(), obj._projection_spacing = [pyconrad.config.get_geometry().getPixelDimensionY(),
pyconrad.config.get_geometry().getPixelDimensionX()] pyconrad.config.get_geometry().getPixelDimensionX()]
self._projection_origin = [pyconrad.config.get_geometry().getDetectorOffsetV(), obj._projection_origin = [pyconrad.config.get_geometry().getDetectorOffsetV(),
pyconrad.config.get_geometry().getDetectorOffsetU()] pyconrad.config.get_geometry().getDetectorOffsetU()]
self._projection_matrices_numpy = pyconrad.config.get_projection_matrices() obj._projection_matrices_numpy = pyconrad.config.get_projection_matrices()
self._calc_inverse_matrices() obj._calc_inverse_matrices()
return obj
def new_volume_tensor(self, requires_grad=False): def new_volume_tensor(self, requires_grad=False):
return torch.zeros(self._volume_shape, requires_grad=requires_grad).cuda() return torch.zeros(self._volume_shape, requires_grad=requires_grad).cuda()
...@@ -131,6 +134,8 @@ class ConeBeamProjector: ...@@ -131,6 +134,8 @@ class ConeBeamProjector:
return self.BackwardProjection(projection_stack) return self.BackwardProjection(projection_stack)
def _calc_inverse_matrices(self): def _calc_inverse_matrices(self):
if self._projection_matrices_numpy is None:
return
self._projection_matrices = torch.stack(tuple( self._projection_matrices = torch.stack(tuple(
map(torch.from_numpy, self._projection_matrices_numpy))).cuda().contiguous() map(torch.from_numpy, self._projection_matrices_numpy))).cuda().contiguous()
......
...@@ -9,13 +9,12 @@ ...@@ -9,13 +9,12 @@
import pyronn_torch import pyronn_torch
def init(): def test_init():
assert pyronn_torch.cpp_extension assert pyronn_torch.cpp_extension
def test_projection(): def test_projection():
breakpoint() projector = pyronn_torch.ConeBeamProjector.from_conrad_config()
projector = pyronn_torch.ConeBeamProjector()
volume = projector.new_volume_tensor() volume = projector.new_volume_tensor()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment