Skip to content

Commit

Permalink
API: move phantoms to odl.phantoms, closes #463
Browse files Browse the repository at this point in the history
Also did the following fixed to phantoms

* Optimized 2d ellipse phantoms in same way as 3d
* Fixed bug with submarined in non centered geometries
  • Loading branch information
adler-j committed Jun 28, 2016
1 parent d298eca commit d4eb486
Show file tree
Hide file tree
Showing 36 changed files with 1,112 additions and 761 deletions.
20 changes: 20 additions & 0 deletions doc/source/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,26 @@
Release Notes
#############

ODL 0.2.4 Release Notes (2016-06-28)
====================================

New features
------------
- Add ``uniform_discr_fromdiscr`` (`PR 467`).
- Add conda build files (`commit 86ff166`).

Bugfixes
--------
- Fix bug in submarine phantom with non-centered space (`PR 469`).
- Fix crash when plotting in 1d (`commit 3255fa3`).

Changes
-------
- Move phantoms to new module odl.phantom (`PR 469`).
- Rename ``RectPartition.is_uniform`` to ``RectPartition.is_uniform``
(`PR 468`).


ODL 0.2.3 Release Notes (2016-06-12)
====================================

Expand Down
2 changes: 1 addition & 1 deletion examples/solvers/chambolle_pock_deconvolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
# odl.diagnostics.OperatorTest(conv_op).run_tests()

# Create phantom
phantom = odl.util.shepp_logan(space, modified=True)
phantom = odl.phantom.shepp_logan(space, modified=True)

# Create vector of convolved phantom
data = convolution(phantom)
Expand Down
4 changes: 2 additions & 2 deletions examples/solvers/chambolle_pock_tomography.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@


# Create phantom
discr_phantom = odl.util.shepp_logan(reco_space, modified=True)
discr_phantom = odl.phantom.shepp_logan(reco_space, modified=True)

# Create sinogram of forward projected phantom with noise
data = ray_trafo(discr_phantom)
data += odl.util.white_noise(ray_trafo.range) * np.mean(data) * 0.1
data += odl.phantom.white_noise(ray_trafo.range) * np.mean(data) * 0.1


# --- Set up the inverse problem --- #
Expand Down
4 changes: 2 additions & 2 deletions examples/solvers/conjugate_gradient_tomography.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@


# Create phantom
discr_phantom = odl.util.shepp_logan(reco_space, modified=True)
discr_phantom = odl.phantom.shepp_logan(reco_space, modified=True)

# Create sinogram of forward projected phantom with noise
data = ray_trafo(discr_phantom)
data += odl.util.white_noise(ray_trafo.range) * np.mean(data) * 0.1
data += odl.phantom.white_noise(ray_trafo.range) * np.mean(data) * 0.1

# Optionally pass partial to the solver to display intermediate results
partial = (odl.solvers.PrintIterationPartial() &
Expand Down
2 changes: 1 addition & 1 deletion examples/tomo/filtered_backprojection_parallel_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@


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

# Create projection data by calling the ray transform on the phantom
proj_data = ray_trafo(phantom)
Expand Down
2 changes: 1 addition & 1 deletion examples/tomo/ray_trafo_circular_cone.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
ray_trafo = odl.tomo.RayTransform(reco_space, geometry, impl='astra_cuda')

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

# Create projection data by calling the ray transform on the phantom
proj_data = ray_trafo(phantom)
Expand Down
2 changes: 1 addition & 1 deletion examples/tomo/ray_trafo_fanflat.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
ray_trafo = odl.tomo.RayTransform(reco_space, geometry, impl='astra_cuda')

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

# Create projection data by calling the ray transform on the phantom
proj_data = ray_trafo(phantom)
Expand Down
2 changes: 1 addition & 1 deletion examples/tomo/ray_trafo_helical.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
ray_trafo = odl.tomo.RayTransform(reco_space, geometry, impl='astra_cuda')

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

# Create projection data by calling the ray transform on the phantom
proj_data = ray_trafo(phantom)
Expand Down
2 changes: 1 addition & 1 deletion examples/tomo/ray_trafo_parallel_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
ray_trafo = odl.tomo.RayTransform(reco_space, geometry, impl='astra_cuda')

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

# Create projection data by calling the ray transform on the phantom
proj_data = ray_trafo(phantom)
Expand Down
2 changes: 1 addition & 1 deletion examples/tomo/ray_trafo_parallel_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
ray_trafo = odl.tomo.RayTransform(reco_space, geometry, impl='astra_cuda')

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

# Create projection data by calling the ray transform on the phantom
proj_data = ray_trafo(phantom)
Expand Down
2 changes: 1 addition & 1 deletion examples/tomo/scikit_ray_trafo_parallel_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
ray_trafo = odl.tomo.RayTransform(reco_space, geometry, impl='scikit')

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

# Create projection data by calling the ray transform on the phantom
proj_data = ray_trafo(phantom)
Expand Down
2 changes: 1 addition & 1 deletion examples/tomo/stir_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
recon_sp, data_sp, volume, proj_data)

# Create shepp-logan phantom
vol = odl.util.shepp_logan(proj.domain, modified=True)
vol = odl.phantom.shepp_logan(proj.domain, modified=True)

# Project and show
result = proj(vol)
Expand Down
2 changes: 1 addition & 1 deletion examples/tomo/stir_reconstruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
volume_file, projection_file)

# Create shepp-logan phantom
vol = odl.util.shepp_logan(proj.domain, modified=True)
vol = odl.phantom.shepp_logan(proj.domain, modified=True)

# Project data
projections = proj(vol)
Expand Down
4 changes: 2 additions & 2 deletions examples/trafos/fourier_trafo.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
ft_op = odl.trafos.FourierTransform(discr_space)

# Create a phantom and its Fourier transfrom and display them
phantom = odl.util.phantom.shepp_logan(discr_space, modified=True)
phantom = odl.phantom.shepp_logan(discr_space, modified=True)
phantom.show(title='Shepp-Logan phantom', show=True)
phantom_ft = ft_op(phantom)
phantom_ft.show(title='Full Fourier Transform', show=True)
Expand All @@ -51,7 +51,7 @@
# its complex conjugate. This is faster and more memory efficient.
discr_space_real = odl.uniform_discr([-1, -1], [1, 1], (512, 512))
ft_op_halfc = odl.trafos.FourierTransform(discr_space_real, halfcomplex=True)
phantom_real = odl.util.phantom.shepp_logan(discr_space_real, modified=True)
phantom_real = odl.phantom.shepp_logan(discr_space_real, modified=True)
phantom_real.show(title='Shepp-Logan phantom, real version', show=True)
phantom_real_ft = ft_op_halfc(phantom_real)
phantom_real_ft.show(title='Half-complex Fourier Transform', show=True)
2 changes: 1 addition & 1 deletion examples/visualization/show_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import odl

spc = odl.uniform_discr([0, 0], [1, 1], [100, 100])
vec = odl.util.shepp_logan(spc, modified=True)
vec = odl.phantom.shepp_logan(spc, modified=True)

# Show all data
vec.show(show=True)
Expand Down
2 changes: 1 addition & 1 deletion examples/visualization/show_2d_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import odl

spc = odl.uniform_discr([0, 0], [1, 1], [100, 100], dtype='complex')
vec = odl.util.shepp_logan(spc, modified=True) * (1 + 0.5j)
vec = odl.phantom.shepp_logan(spc, modified=True) * (1 + 0.5j)

# Can also force "instant" plotting
vec.show(show=True)
6 changes: 3 additions & 3 deletions examples/visualization/show_productspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
pspace = odl.ProductSpace(spc, m)

# Making a product space element where each component consists of a
# Shepp-Logan phantom multiplied by the constant (i+1), where i is the
# Shepp-Logan phantom multiplied by the constant i, where i is the
# index of the product space component.
vec = pspace.element([odl.util.shepp_logan(spc, modified=True) * i
for i in range(1, m + 1)])
vec = pspace.element([odl.phantom.shepp_logan(spc, modified=True) * i
for i in range(m)])

# By default 4 uniformly spaced elements are shown. Since there are 7 in
# total, the shown components are 0, 2, 4 and 6
Expand Down
2 changes: 1 addition & 1 deletion examples/visualization/show_update_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
n = 100
m = 20
spc = odl.uniform_discr([0, 0], [1, 1], [n, n])
vec = odl.util.shepp_logan(spc, modified=True)
vec = odl.phantom.shepp_logan(spc, modified=True)

# Create a figure by saving the result of show
fig = None
Expand Down
5 changes: 3 additions & 2 deletions odl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

from __future__ import absolute_import

__version__ = '0.2.3'
__version__ = '0.2.4'
__all__ = ('diagnostics', 'discr', 'operator', 'set', 'space', 'solvers',
'tomo', 'trafos', 'util')
'tomo', 'trafos', 'util', 'phantom')

# Propagate names defined in __all__ of all submodules into the top-level
# module
Expand All @@ -53,6 +53,7 @@
from . import trafos
from . import tomo
from . import util
from . import phantom

from .util import test
__all__ += ('test',)
39 changes: 39 additions & 0 deletions odl/phantom/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2014-2016 The ODL development group
#
# This file is part of ODL.
#
# ODL is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ODL is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ODL. If not, see <http://www.gnu.org/licenses/>.

"""Test data for tomography problems."""

from __future__ import absolute_import

__all__ = ()

from . import phantom_utils

from .emission import *
__all__ += emission.__all__

from .geometric import *
__all__ += geometric.__all__

from .misc_phantoms import *
__all__ += misc_phantoms.__all__

from .noise import *
__all__ += noise.__all__

from .transmission import *
__all__ += transmission.__all__

0 comments on commit d4eb486

Please sign in to comment.