Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pyronn-torch
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stephan Seitz
pyronn-torch
Commits
d83be5b6
Commit
d83be5b6
authored
5 years ago
by
Stephan Seitz
Browse files
Options
Downloads
Patches
Plain Diff
Re-introduce ConeBeamProjector.from_conrad_config()
parent
2b78ea9c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/pyronn_torch/conebeam.py
+34
-29
34 additions, 29 deletions
src/pyronn_torch/conebeam.py
tests/test_projection.py
+2
-3
2 additions, 3 deletions
tests/test_projection.py
with
36 additions
and
32 deletions
src/pyronn_torch/conebeam.py
+
34
−
29
View file @
d83be5b6
...
@@ -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
()
...
...
This diff is collapsed.
Click to expand it.
tests/test_projection.py
+
2
−
3
View file @
d83be5b6
...
@@ -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
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment