From 70079dfe9ba79549e0577956762fc5ed613b7ad4 Mon Sep 17 00:00:00 2001 From: Jonas Adler Date: Tue, 17 Jan 2017 16:16:13 +0100 Subject: [PATCH 1/2] ENH: Made impl default for ray transform more intelligent, closes #822 --- odl/tomo/operators/ray_trafo.py | 64 +++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 18 deletions(-) diff --git a/odl/tomo/operators/ray_trafo.py b/odl/tomo/operators/ray_trafo.py index e9bea552218..4e7b98179c4 100644 --- a/odl/tomo/operators/ray_trafo.py +++ b/odl/tomo/operators/ray_trafo.py @@ -30,7 +30,7 @@ from odl.space import FunctionSpace from odl.tomo.geometry import Geometry, Parallel2dGeometry from odl.tomo.backends import ( - ASTRA_AVAILABLE, ASTRA_CUDA_AVAILABLE, + ASTRA_AVAILABLE, ASTRA_CUDA_AVAILABLE, SCIKIT_IMAGE_AVAILABLE, astra_cpu_forward_projector, astra_cpu_back_projector, AstraCudaProjectorImpl, AstraCudaBackProjectorImpl, scikit_radon_forward, scikit_radon_back_projector) @@ -47,7 +47,7 @@ class RayTransform(Operator): """Discrete Ray transform between L^p spaces.""" - def __init__(self, discr_domain, geometry, impl='astra_cpu', **kwargs): + def __init__(self, discr_domain, geometry, **kwargs): """Initialize a new instance. Parameters @@ -57,18 +57,19 @@ def __init__(self, discr_domain, geometry, impl='astra_cpu', **kwargs): geometry : `Geometry` Geometry of the transform, containing information about the operator range - impl : {'astra_cpu', 'astra_cuda', 'scikit'}, optional + + Other Parameters + ---------------- + impl : {`None`, 'astra_cuda', 'astra_cpu', 'scikit'}, optional Implementation back-end for the transform. Supported back-ends: - 'astra_cpu': ASTRA toolbox using CPU, only 2D - 'astra_cuda': ASTRA toolbox, using CUDA, 2D or 3D - 'scikit': scikit-image, only 2D parallel with square domain + * 'astra_cuda': ASTRA toolbox, using CUDA, 2D or 3D + * 'astra_cpu': ASTRA toolbox using CPU, only 2D + * 'scikit': scikit-image, only 2D parallel with square domain + If `None` is given, prefers the fastest available backend. interp : {'nearest', 'linear'} Interpolation type for the discretization of the operator range. Default: 'nearest' - - Other Parameters - ---------------- discr_range : `DiscreteLp` Discretized space, the range of the forward projector. Default: Infered from parameters. @@ -92,6 +93,18 @@ def __init__(self, discr_domain, geometry, impl='astra_cpu', **kwargs): raise TypeError('`geometry` {!r} is not a `Geometry` instance' ''.format(geometry)) + impl = kwargs.pop('impl', None) + if impl is None: + # Select fastest available + if ASTRA_CUDA_AVAILABLE: + impl = 'astra_cuda' + elif ASTRA_AVAILABLE: + impl = 'astra_cpu' + elif SCIKIT_IMAGE_AVAILABLE: + impl = 'scikit' + else: + raise ValueError('no valid `impl` installed') + impl, impl_in = str(impl).lower(), impl if impl not in _SUPPORTED_IMPL: raise ValueError('`impl` {!r} not supported' @@ -228,7 +241,8 @@ def adjoint(self): kwargs = self.kwargs.copy() kwargs['discr_domain'] = self.range self.backproj = RayBackProjection(self.domain, self.geometry, - self.impl, use_cache=self.use_cache, + impl=self.impl, + use_cache=self.use_cache, **kwargs) return self.backproj @@ -236,7 +250,7 @@ def adjoint(self): class RayBackProjection(Operator): """Adjoint of the discrete Ray transform between L^p spaces.""" - def __init__(self, discr_range, geometry, impl='astra_cpu', **kwargs): + def __init__(self, discr_range, geometry, **kwargs): """Initialize a new instance. Parameters @@ -246,17 +260,18 @@ def __init__(self, discr_range, geometry, impl='astra_cpu', **kwargs): geometry : `Geometry` The geometry of the transform, contains information about the operator domain + + Other Parameters + ---------------- impl : {'astra_cpu', 'astra_cuda', 'scikit'}, optional Implementation back-end for the transform. Supported back-ends: - 'astra_cpu': ASTRA toolbox using CPU, only 2D - 'astra_cuda': ASTRA toolbox, using CUDA, 2D or 3D - 'scikit': scikit-image, only 2D parallel with square domain + * 'astra_cuda': ASTRA toolbox, using CUDA, 2D or 3D + * 'astra_cpu': ASTRA toolbox using CPU, only 2D + * 'scikit': scikit-image, only 2D parallel with square domain + If `None` is given, prefers the fastest available backend. interp : {'nearest', 'linear'} Interpolation type for the discretization of the operator range. Default: 'nearest' - - Other Parameters - ---------------- discr_domain : `DiscreteLp` Discretized space, the range of the forward projector. Default: Infered from parameters. @@ -274,6 +289,18 @@ def __init__(self, discr_range, geometry, impl='astra_cpu', **kwargs): raise TypeError('`geometry` {!r} is not a `Geometry` instance' ''.format(geometry)) + impl = kwargs.pop('impl', None) + if impl is None: + # Select fastest available + if ASTRA_CUDA_AVAILABLE: + impl = 'astra_cuda' + elif ASTRA_AVAILABLE: + impl = 'astra_cpu' + elif SCIKIT_IMAGE_AVAILABLE: + impl = 'scikit' + else: + raise ValueError('no valid `impl` installed') + impl, impl_in = str(impl).lower(), impl if impl not in _SUPPORTED_IMPL: raise ValueError("`impl` '{}' not supported" @@ -381,7 +408,8 @@ def adjoint(self): kwargs = self.kwargs.copy() kwargs['discr_range'] = self.domain self.ray_trafo = RayTransform(self.range, self.geometry, - impl=self.impl, use_cache=self.use_cache, + impl=self.impl, + use_cache=self.use_cache, **kwargs) return self.ray_trafo From 2e1431bc79c65072940f532f3f1b753d9f6f766f Mon Sep 17 00:00:00 2001 From: Jonas Adler Date: Tue, 17 Jan 2017 16:24:33 +0100 Subject: [PATCH 2/2] MAINT: Change examples to use default ray transform impl --- examples/solvers/chambolle_pock_tomography.py | 18 +++++------------- .../solvers/conjugate_gradient_tomography.py | 10 +--------- .../douglas_rachford_pd_tomography_tv.py | 4 ++-- examples/solvers/lbfgs_tomography.py | 10 +--------- examples/solvers/lbfgs_tomography_tv.py | 10 +--------- examples/solvers/nuclear_norm_tomography.py | 10 +--------- .../proximal_gradient_wavelet_tomography.py | 10 +--------- examples/solvers/proximal_lang_tomography.py | 10 +--------- .../tomo/filtered_backprojection_cone_2d.py | 4 ++-- .../tomo/filtered_backprojection_cone_3d.py | 4 ++-- .../tomo/filtered_backprojection_helical_3d.py | 4 ++-- .../filtered_backprojection_parallel_2d.py | 4 ++-- .../filtered_backprojection_parallel_3d.py | 4 ++-- examples/tomo/ray_trafo_circular_cone.py | 4 ++-- examples/tomo/ray_trafo_fanflat.py | 4 ++-- examples/tomo/ray_trafo_helical.py | 4 ++-- examples/tomo/ray_trafo_parallel_2d.py | 4 ++-- examples/tomo/ray_trafo_parallel_3d.py | 4 ++-- odl/tomo/operators/ray_trafo.py | 16 ++++++++-------- 19 files changed, 41 insertions(+), 97 deletions(-) diff --git a/examples/solvers/chambolle_pock_tomography.py b/examples/solvers/chambolle_pock_tomography.py index 5ce27664b30..9b596ebcab2 100644 --- a/examples/solvers/chambolle_pock_tomography.py +++ b/examples/solvers/chambolle_pock_tomography.py @@ -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 --- # @@ -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) @@ -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() & diff --git a/examples/solvers/conjugate_gradient_tomography.py b/examples/solvers/conjugate_gradient_tomography.py index fc140622bd4..ece7780b66e 100644 --- a/examples/solvers/conjugate_gradient_tomography.py +++ b/examples/solvers/conjugate_gradient_tomography.py @@ -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 --- # diff --git a/examples/solvers/douglas_rachford_pd_tomography_tv.py b/examples/solvers/douglas_rachford_pd_tomography_tv.py index d2e67a47dcc..06d617d5967 100644 --- a/examples/solvers/douglas_rachford_pd_tomography_tv.py +++ b/examples/solvers/douglas_rachford_pd_tomography_tv.py @@ -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) diff --git a/examples/solvers/lbfgs_tomography.py b/examples/solvers/lbfgs_tomography.py index 81c1b41e98a..64a7d88d65c 100644 --- a/examples/solvers/lbfgs_tomography.py +++ b/examples/solvers/lbfgs_tomography.py @@ -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 --- # diff --git a/examples/solvers/lbfgs_tomography_tv.py b/examples/solvers/lbfgs_tomography_tv.py index c49f03259e4..4595db65eb3 100644 --- a/examples/solvers/lbfgs_tomography_tv.py +++ b/examples/solvers/lbfgs_tomography_tv.py @@ -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 --- # diff --git a/examples/solvers/nuclear_norm_tomography.py b/examples/solvers/nuclear_norm_tomography.py index 5817f022021..7c46061df23 100644 --- a/examples/solvers/nuclear_norm_tomography.py +++ b/examples/solvers/nuclear_norm_tomography.py @@ -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 diff --git a/examples/solvers/proximal_gradient_wavelet_tomography.py b/examples/solvers/proximal_gradient_wavelet_tomography.py index b6ce5fb1565..447495321d7 100644 --- a/examples/solvers/proximal_gradient_wavelet_tomography.py +++ b/examples/solvers/proximal_gradient_wavelet_tomography.py @@ -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 --- # diff --git a/examples/solvers/proximal_lang_tomography.py b/examples/solvers/proximal_lang_tomography.py index 72d357d1012..a426723ca8c 100644 --- a/examples/solvers/proximal_lang_tomography.py +++ b/examples/solvers/proximal_lang_tomography.py @@ -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) diff --git a/examples/tomo/filtered_backprojection_cone_2d.py b/examples/tomo/filtered_backprojection_cone_2d.py index dd4d3d98fce..f70faaec3f3 100644 --- a/examples/tomo/filtered_backprojection_cone_2d.py +++ b/examples/tomo/filtered_backprojection_cone_2d.py @@ -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 diff --git a/examples/tomo/filtered_backprojection_cone_3d.py b/examples/tomo/filtered_backprojection_cone_3d.py index c5df8e0ddbd..e0b0e4bb795 100644 --- a/examples/tomo/filtered_backprojection_cone_3d.py +++ b/examples/tomo/filtered_backprojection_cone_3d.py @@ -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 diff --git a/examples/tomo/filtered_backprojection_helical_3d.py b/examples/tomo/filtered_backprojection_helical_3d.py index d0c179009c4..b9d12baa8e8 100644 --- a/examples/tomo/filtered_backprojection_helical_3d.py +++ b/examples/tomo/filtered_backprojection_helical_3d.py @@ -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 diff --git a/examples/tomo/filtered_backprojection_parallel_2d.py b/examples/tomo/filtered_backprojection_parallel_2d.py index f685a9301e0..122bee60c0a 100644 --- a/examples/tomo/filtered_backprojection_parallel_2d.py +++ b/examples/tomo/filtered_backprojection_parallel_2d.py @@ -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]) diff --git a/examples/tomo/filtered_backprojection_parallel_3d.py b/examples/tomo/filtered_backprojection_parallel_3d.py index c69c2d29f29..e52a9cc9355 100644 --- a/examples/tomo/filtered_backprojection_parallel_3d.py +++ b/examples/tomo/filtered_backprojection_parallel_3d.py @@ -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 diff --git a/examples/tomo/ray_trafo_circular_cone.py b/examples/tomo/ray_trafo_circular_cone.py index 31cc040b42c..a5b25ca886b 100644 --- a/examples/tomo/ray_trafo_circular_cone.py +++ b/examples/tomo/ray_trafo_circular_cone.py @@ -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) diff --git a/examples/tomo/ray_trafo_fanflat.py b/examples/tomo/ray_trafo_fanflat.py index d406ddaad8c..355c32f394b 100644 --- a/examples/tomo/ray_trafo_fanflat.py +++ b/examples/tomo/ray_trafo_fanflat.py @@ -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) diff --git a/examples/tomo/ray_trafo_helical.py b/examples/tomo/ray_trafo_helical.py index 92fcc589d58..c92d620d74b 100644 --- a/examples/tomo/ray_trafo_helical.py +++ b/examples/tomo/ray_trafo_helical.py @@ -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) diff --git a/examples/tomo/ray_trafo_parallel_2d.py b/examples/tomo/ray_trafo_parallel_2d.py index 5797678bebb..caf7b7d7f87 100644 --- a/examples/tomo/ray_trafo_parallel_2d.py +++ b/examples/tomo/ray_trafo_parallel_2d.py @@ -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) diff --git a/examples/tomo/ray_trafo_parallel_3d.py b/examples/tomo/ray_trafo_parallel_3d.py index c961910cbdf..8ddc5de11a9 100644 --- a/examples/tomo/ray_trafo_parallel_3d.py +++ b/examples/tomo/ray_trafo_parallel_3d.py @@ -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) diff --git a/odl/tomo/operators/ray_trafo.py b/odl/tomo/operators/ray_trafo.py index 4e7b98179c4..e156c9e5e40 100644 --- a/odl/tomo/operators/ray_trafo.py +++ b/odl/tomo/operators/ray_trafo.py @@ -62,10 +62,10 @@ def __init__(self, discr_domain, geometry, **kwargs): ---------------- impl : {`None`, 'astra_cuda', 'astra_cpu', 'scikit'}, optional Implementation back-end for the transform. Supported back-ends: - * 'astra_cuda': ASTRA toolbox, using CUDA, 2D or 3D - * 'astra_cpu': ASTRA toolbox using CPU, only 2D - * 'scikit': scikit-image, only 2D parallel with square domain - If `None` is given, prefers the fastest available backend. + * ``'astra_cuda'``: ASTRA toolbox, using CUDA, 2D or 3D + * ``'astra_cpu'``: ASTRA toolbox using CPU, only 2D + * ``'scikit'``: scikit-image, only 2D parallel with square domain + If ``None`` is given, the fastest available back-end is used. interp : {'nearest', 'linear'} Interpolation type for the discretization of the operator range. @@ -265,10 +265,10 @@ def __init__(self, discr_range, geometry, **kwargs): ---------------- impl : {'astra_cpu', 'astra_cuda', 'scikit'}, optional Implementation back-end for the transform. Supported back-ends: - * 'astra_cuda': ASTRA toolbox, using CUDA, 2D or 3D - * 'astra_cpu': ASTRA toolbox using CPU, only 2D - * 'scikit': scikit-image, only 2D parallel with square domain - If `None` is given, prefers the fastest available backend. + * ``'astra_cuda'``: ASTRA toolbox, using CUDA, 2D or 3D + * ``'astra_cpu'``: ASTRA toolbox using CPU, only 2D + * ``'scikit'``: scikit-image, only 2D parallel with square domain + If ``None`` is given, the fastest available back-end is used. interp : {'nearest', 'linear'} Interpolation type for the discretization of the operator range. Default: 'nearest'