Skip to content

Commit

Permalink
Merge pull request #826 from odlgroup/issue-822__ray_trafo_impl_default
Browse files Browse the repository at this point in the history
Issue 822  ray trafo impl default
  • Loading branch information
Holger Kohr authored Jan 17, 2017
2 parents 4a9381c + 2e1431b commit 0a8b6ef
Show file tree
Hide file tree
Showing 19 changed files with 79 additions and 107 deletions.
18 changes: 5 additions & 13 deletions examples/solvers/chambolle_pock_tomography.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,8 @@
detector_partition = odl.uniform_partition(-30, 30, 558)
geometry = odl.tomo.Parallel2dGeometry(angle_partition, detector_partition)

# The implementation of the ray transform to use, options:
# 'scikit' Requires scikit-image (can be installed by
# running ``pip install scikit-image``).
# 'astra_cpu', 'astra_cuda' Require astra tomography to be installed.
# Astra is much faster than scikit. Webpage:
# https://github.com/astra-toolbox/astra-toolbox
impl = 'astra_cuda'

# Create the forward operator
ray_trafo = odl.tomo.RayTransform(reco_space, geometry, impl=impl)
ray_trafo = odl.tomo.RayTransform(reco_space, geometry)


# --- Generate artificial data --- #
Expand Down Expand Up @@ -88,7 +80,7 @@
l2_norm = odl.solvers.L2NormSquared(ray_trafo.range).translated(data)

# Isotropic TV-regularization i.e. the l1-norm
l1_norm = 0.01 * odl.solvers.L1Norm(gradient.range)
l1_norm = 0.015 * odl.solvers.L1Norm(gradient.range)

# Combine functionals, order must correspond to the operator K
f = odl.solvers.SeparableSum(l2_norm, l1_norm)
Expand All @@ -98,12 +90,12 @@


# Estimated operator norm, add 10 percent to ensure ||K||_2^2 * sigma * tau < 1
op_norm = 1.3 * odl.power_method_opnorm(op, maxiter=10)
op_norm = 1.5 * odl.power_method_opnorm(op, maxiter=10)

niter = 100 # Number of iterations
niter = 200 # Number of iterations
tau = 1.0 / op_norm # Step size for the primal variable
sigma = 1.0 / op_norm # Step size for the dual variable
gamma = 0.1
gamma = 0.5

# Optionally pass callback to the solver to display intermediate results
callback = (odl.solvers.CallbackPrintIteration() &
Expand Down
10 changes: 1 addition & 9 deletions examples/solvers/conjugate_gradient_tomography.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,8 @@
detector_partition = odl.uniform_partition(-30, 30, 300)
geometry = odl.tomo.Parallel2dGeometry(angle_partition, detector_partition)

# The implementation of the ray transform to use, options:
# 'scikit' Requires scikit-image (can be installed by
# running ``pip install scikit-image``).
# 'astra_cpu', 'astra_cuda' Require astra tomography to be installed.
# Astra is much faster than scikit. Webpage:
# https://github.com/astra-toolbox/astra-toolbox
impl = 'scikit'

# Create the forward operator
ray_trafo = odl.tomo.RayTransform(reco_space, geometry, impl=impl)
ray_trafo = odl.tomo.RayTransform(reco_space, geometry)


# --- Generate artificial data --- #
Expand Down
4 changes: 2 additions & 2 deletions examples/solvers/douglas_rachford_pd_tomography_tv.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
detector_partition = odl.uniform_partition(-30, 30, 512)
geometry = odl.tomo.Parallel2dGeometry(angle_partition, detector_partition)

# Ray transform (= forward projection). We use ASTRA CUDA backend.
ray_trafo = odl.tomo.RayTransform(space, geometry, impl='astra_cuda')
# Ray transform (= forward projection).
ray_trafo = odl.tomo.RayTransform(space, geometry)

# Create sinogram
phantom = odl.phantom.shepp_logan(space, modified=True)
Expand Down
10 changes: 1 addition & 9 deletions examples/solvers/lbfgs_tomography.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,8 @@
detector_partition = odl.uniform_partition(-30, 30, 400)
geometry = odl.tomo.Parallel2dGeometry(angle_partition, detector_partition)

# The implementation of the ray transform to use, options:
# 'scikit' Requires scikit-image (can be installed by
# running ``pip install scikit-image``).
# 'astra_cpu', 'astra_cuda' Require astra tomography to be installed.
# Astra is much faster than scikit. Webpage:
# https://github.com/astra-toolbox/astra-toolbox
impl = 'astra_cuda'

# Create the forward operator
ray_trafo = odl.tomo.RayTransform(reco_space, geometry, impl=impl)
ray_trafo = odl.tomo.RayTransform(reco_space, geometry)

# --- Generate artificial data --- #

Expand Down
10 changes: 1 addition & 9 deletions examples/solvers/lbfgs_tomography_tv.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,8 @@
detector_partition = odl.uniform_partition(-30, 30, 400)
geometry = odl.tomo.Parallel2dGeometry(angle_partition, detector_partition)

# The implementation of the ray transform to use, options:
# 'scikit' Requires scikit-image (can be installed by
# running ``pip install scikit-image``).
# 'astra_cpu', 'astra_cuda' Require astra tomography to be installed.
# Astra is much faster than scikit. Webpage:
# https://github.com/astra-toolbox/astra-toolbox
impl = 'astra_cuda'

# Create the forward operator
ray_trafo = odl.tomo.RayTransform(reco_space, geometry, impl=impl)
ray_trafo = odl.tomo.RayTransform(reco_space, geometry)

# --- Generate artificial data --- #

Expand Down
10 changes: 1 addition & 9 deletions examples/solvers/nuclear_norm_tomography.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,8 @@
detector_partition = odl.uniform_partition(-30, 30, 300)
geometry = odl.tomo.Parallel2dGeometry(angle_partition, detector_partition)

# The implementation of the ray transform to use, options:
# 'scikit' Requires scikit-image (can be installed by
# running ``pip install scikit-image``).
# 'astra_cpu', 'astra_cuda' Requires astra tomography to be installed.
# Astra is much faster than scikit. Webpage:
# https://github.com/astra-toolbox/astra-toolbox
impl = 'astra_cuda'

# Create the forward operator, and also the vectorial forward operator.
ray_trafo = odl.tomo.RayTransform(space, geometry, impl=impl)
ray_trafo = odl.tomo.RayTransform(space, geometry)
forward_op = odl.DiagonalOperator(ray_trafo, 2)

# Create phantom where the first component contains only part of the
Expand Down
10 changes: 1 addition & 9 deletions examples/solvers/proximal_gradient_wavelet_tomography.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,8 @@
detector_partition = odl.uniform_partition(-30, 30, 300)
geometry = odl.tomo.Parallel2dGeometry(angle_partition, detector_partition)

# The implementation of the ray transform to use, options:
# 'scikit' Requires scikit-image (can be installed by
# running ``pip install scikit-image``).
# 'astra_cpu', 'astra_cuda' Requires astra tomography to be installed.
# Astra is much faster than scikit. Webpage:
# https://github.com/astra-toolbox/astra-toolbox
impl = 'astra_cuda'

# Create the forward operator, and also the vectorial forward operator.
ray_trafo = odl.tomo.RayTransform(space, geometry, impl=impl)
ray_trafo = odl.tomo.RayTransform(space, geometry)


# --- Generate artificial data --- #
Expand Down
10 changes: 1 addition & 9 deletions examples/solvers/proximal_lang_tomography.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,8 @@
detector_partition = odl.uniform_partition(-30, 30, 558)
geometry = odl.tomo.Parallel2dGeometry(angle_partition, detector_partition)

# The implementation of the ray transform to use, options:
# 'scikit' Requires scikit-image (can be installed by
# running ``pip install scikit-image``).
# 'astra_cpu', 'astra_cuda' Requires astra tomography to be installed.
# Astra is much faster than scikit. Webpage:
# https://github.com/astra-toolbox/astra-toolbox
impl = 'astra_cuda'

# Initialize the ray transform (forward projection).
ray_trafo = odl.tomo.RayTransform(reco_space, geometry, impl=impl)
ray_trafo = odl.tomo.RayTransform(reco_space, geometry)

# Convert ray transform to proximal language operator
proximal_lang_ray_trafo = odl.as_proximal_lang_operator(ray_trafo)
Expand Down
4 changes: 2 additions & 2 deletions examples/tomo/filtered_backprojection_cone_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
# --- Create Filtered Back-Projection (FBP) operator --- #


# Ray transform (= forward projection). We use the ASTRA CUDA backend.
ray_trafo = odl.tomo.RayTransform(reco_space, geometry, impl='astra_cuda')
# Ray transform (= forward projection).
ray_trafo = odl.tomo.RayTransform(reco_space, geometry)

# Create FBP operator using utility function
# We select a Hann filter, and only use the lowest 80% of frequencies to avoid
Expand Down
4 changes: 2 additions & 2 deletions examples/tomo/filtered_backprojection_cone_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
# --- Create Filteredback-projection (FBP) operator --- #


# Ray transform (= forward projection). We use the ASTRA CUDA backend.
ray_trafo = odl.tomo.RayTransform(reco_space, geometry, impl='astra_cuda')
# Ray transform (= forward projection).
ray_trafo = odl.tomo.RayTransform(reco_space, geometry)

# Create FBP operator using utility function
# We select a Shepp-Logan filter, and only use the lowest 80% of frequencies to
Expand Down
4 changes: 2 additions & 2 deletions examples/tomo/filtered_backprojection_helical_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
# --- Create Filtered Back-Projection (FBP) operator --- #


# Ray transform (= forward projection). We use the ASTRA CUDA backend.
ray_trafo = odl.tomo.RayTransform(reco_space, geometry, impl='astra_cuda')
# Ray transform (= forward projection).
ray_trafo = odl.tomo.RayTransform(reco_space, geometry)

# Unwindowed fbp
# We select a Hamming filter, and only use the lowest 80% of frequencies to
Expand Down
4 changes: 2 additions & 2 deletions examples/tomo/filtered_backprojection_parallel_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
# --- Create Filtered Back-Projection (FBP) operator --- #


# Ray transform (= forward projection). We use the ASTRA CUDA backend.
ray_trafo = odl.tomo.RayTransform(reco_space, geometry, impl='astra_cuda')
# Ray transform (= forward projection).
ray_trafo = odl.tomo.RayTransform(reco_space, geometry)

# Fourier transform in detector direction
fourier = odl.trafos.FourierTransform(ray_trafo.range, axes=[1])
Expand Down
4 changes: 2 additions & 2 deletions examples/tomo/filtered_backprojection_parallel_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
# --- Create Filtered Back-Projection (FBP) operator --- #


# Ray transform (= forward projection). We use the ASTRA CUDA backend.
ray_trafo = odl.tomo.RayTransform(reco_space, geometry, impl='astra_cuda')
# Ray transform (= forward projection).
ray_trafo = odl.tomo.RayTransform(reco_space, geometry)

# Create FBP operator using utility function
# We select a Hann filter, and only use the lowest 80% of frequencies to
Expand Down
4 changes: 2 additions & 2 deletions examples/tomo/ray_trafo_circular_cone.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
angle_partition, detector_partition, src_radius=1000, det_radius=100,
axis=[1, 0, 0])

# Ray transform (= forward projection). We use the ASTRA CUDA backend.
ray_trafo = odl.tomo.RayTransform(reco_space, geometry, impl='astra_cuda')
# Ray transform (= forward projection).
ray_trafo = odl.tomo.RayTransform(reco_space, geometry)

# Create a discrete Shepp-Logan phantom (modified version)
phantom = odl.phantom.shepp_logan(reco_space, True)
Expand Down
4 changes: 2 additions & 2 deletions examples/tomo/ray_trafo_fanflat.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
geometry = odl.tomo.FanFlatGeometry(angle_partition, detector_partition,
src_radius=1000, det_radius=100)

# Ray transform (= forward projection). We use the ASTRA CUDA backend.
ray_trafo = odl.tomo.RayTransform(reco_space, geometry, impl='astra_cuda')
# Ray transform (= forward projection).
ray_trafo = odl.tomo.RayTransform(reco_space, geometry)

# Create a discrete Shepp-Logan phantom (modified version)
phantom = odl.phantom.shepp_logan(reco_space, modified=True)
Expand Down
4 changes: 2 additions & 2 deletions examples/tomo/ray_trafo_helical.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
angle_partition, detector_partition, src_radius=100, det_radius=100,
pitch=5.0)

# Ray transform (= forward projection). We use ASTRA CUDA backend.
ray_trafo = odl.tomo.RayTransform(reco_space, geometry, impl='astra_cuda')
# Ray transform (= forward projection).
ray_trafo = odl.tomo.RayTransform(reco_space, geometry)

# Create a discrete Shepp-Logan phantom (modified version)
phantom = odl.phantom.shepp_logan(reco_space, modified=True)
Expand Down
4 changes: 2 additions & 2 deletions examples/tomo/ray_trafo_parallel_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
detector_partition = odl.uniform_partition(-30, 30, 558)
geometry = odl.tomo.Parallel2dGeometry(angle_partition, detector_partition)

# Ray transform (= forward projection). We use ASTRA CUDA backend.
ray_trafo = odl.tomo.RayTransform(reco_space, geometry, impl='astra_cuda')
# Ray transform (= forward projection).
ray_trafo = odl.tomo.RayTransform(reco_space, geometry)

# Create a discrete Shepp-Logan phantom (modified version)
phantom = odl.phantom.shepp_logan(reco_space, modified=True)
Expand Down
4 changes: 2 additions & 2 deletions examples/tomo/ray_trafo_parallel_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
# give a zero result.
geometry = odl.tomo.Parallel3dAxisGeometry(angle_partition, detector_partition)

# Ray transform (= forward projection). We use ASTRA CUDA backend.
ray_trafo = odl.tomo.RayTransform(reco_space, geometry, impl='astra_cuda')
# Ray transform (= forward projection).
ray_trafo = odl.tomo.RayTransform(reco_space, geometry)

# Create a discrete Shepp-Logan phantom (modified version)
phantom = odl.phantom.shepp_logan(reco_space, modified=True)
Expand Down
Loading

0 comments on commit 0a8b6ef

Please sign in to comment.