Skip to content

Commit

Permalink
docs: fix builds, other code cleanup, isolate fan stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Apr 4, 2018
1 parent f395907 commit 3a74f96
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 93 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ radontea

|PyPI Version| |Tests Status| |Coverage Status| |Docs Status|

Algorithms to compute the inverse Radon trannsform (e.g. SART, backprojection, Fourier interpolation).
Algorithms to compute the inverse Radon transform (e.g. SART, backprojection, Fourier interpolation).


Documentation
Expand Down
55 changes: 20 additions & 35 deletions docs/code_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,24 @@
Code reference
==============



Parallel beam geometry
::::::::::::::::::::::
.. currentmodule:: radontea
.. autosummary::
art
radon_parallel
backproject
fourier_map
radon
integrate
art
sart
sum



Radon transform
---------------
.. automodule:: radontea._Radon
.. currentmodule:: radontea
.. autofunction:: radon
.. autofunction:: radon_parallel

Non-iterative reconstruction
----------------------------
.. currentmodule:: radontea
Computes the inverse Radon transform with non-iterative techniques.
The linear system of equations that describes the forward process can be
inverted with several algorithms, most notably the backprojection
Expand All @@ -41,19 +37,17 @@ Fourier mapping
.. autofunction:: fourier_map


Sum
~~~
Slow integration
~~~~~~~~~~~~~~~~
.. autofunction:: integrate


Iterative reconstruction
------------------------
.. currentmodule:: radontea
Inversion of Radon-based tomography methods using iterative algorithms.
The convegence of these algorithms might be slow. The implementation
is not optimized.


ART
~~~
.. autofunction:: art
Expand All @@ -65,32 +59,23 @@ SART

Fan beam geometry
:::::::::::::::::
.. currentmodule:: radontea

.. autosummary::
get_det_coords
get_fan_coords
lino2sino
radon_fan_translation
sa_interpolate
fan.radon_fan
fan.get_det_coords
fan.get_fan_coords
fan.lino2sino
fan.fan_rec


Coordinate transforms
---------------------

.. autofunction:: get_det_coords
.. autofunction:: get_fan_coords
.. autofunction:: lino2sino
.. autofunction:: radon_fan_translation


Non-iterative reconstruction
----------------------------
.. currentmodule:: radontea
The inverse Radon transform with non-iterative techniques for
a fan-beam geometry.
.. autofunction:: radontea.fan.get_det_coords
.. autofunction:: radontea.fan.get_fan_coords
.. autofunction:: radontea.fan.radon_fan
.. autofunction:: radontea.fan.lino2sino

Interpolation
~~~~~~~~~~~~~
.. autofunction:: sa_interpolate

Reconstruction
--------------
.. autofunction:: radontea.fan.fan_rec
29 changes: 13 additions & 16 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,11 @@
autodoc_member_order = 'bysource'
autodoc_mock_imports = install_requires

# There should be a file "setup.py" that has the property "version"
from setup import author, authors, description, name, version, year
projectname = name
projectdescription = description

# Display link to GitHub repo instead of doc on rtfd
rst_prolog = """
:github_url: https://github.com/RI-imaging/radontea
"""

print("ASDASD")

# -- General configuration ------------------------------------------------

Expand Down Expand Up @@ -77,16 +72,18 @@
master_doc = 'index'

# General information about the project.
project = projectname
copyright = year+", "+author
project = 'radontea'
copyright = '2017, Paul Müller'
author = 'Paul Müller'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
# The full version, including alpha/beta/rc tags.
release = version
exec(open(op.join(pdir, "radontea/_version.py")).read())
release = version #@UndefinedVariable

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down Expand Up @@ -203,7 +200,7 @@
#html_file_suffix = None

# Output file base name for HTML help builder.
htmlhelp_basename = projectname+'doc'
htmlhelp_basename = project+'doc'


# -- Options for LaTeX output ---------------------------------------------
Expand All @@ -223,7 +220,7 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', projectname+'.tex', projectname+' Documentation',
('index', project+'.tex', project+' Documentation',
author, 'manual'),
]

Expand Down Expand Up @@ -253,8 +250,8 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', projectname, projectname+' Documentation',
authors, 1)
('index', project, project+' Documentation',
author, 1)
]

# If true, show URL addresses after external links.
Expand All @@ -267,9 +264,9 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', projectname, projectname+u' Documentation',
author, projectname,
projectdescription,
('index', project, project + ' Documentation',
author, project,
"Methods for the inversion of the Radon transform",
'Numeric'),
]

Expand Down
3 changes: 1 addition & 2 deletions radontea/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
from .alg_art import art # noqa F401
from .alg_sart import sart # noqa F401

from .fan import fan_rec, lino2sino # noqa F401
from . import fan # noqa F401

from .rdn_prl import radon_parallel # noqa F401
from .rdn_fan import radon_fan # noqa F401

from .threed import volume_recon # noqa F401

Expand Down
33 changes: 8 additions & 25 deletions radontea/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
import scipy.interpolate

from .rdn_fan import get_fan_coords
from .rdn_fan import get_det_coords, radon_fan # noqa F401


def fan_rec(linogram, lDS, method, stepsize=1, det_spacing=1,
def fan_rec(linogram, lds, method, stepsize=1, det_spacing=1,
numang=None, count=None, max_count=None, **kwargs):
"""2D synthetic aperture reconstruction
Expand All @@ -16,7 +17,7 @@ def fan_rec(linogram, lDS, method, stepsize=1, det_spacing=1,
----------
linogram: 2d ndarray of shape (D, A)
Input linogram from the synthetic aprture measurement.
lDS: float
lds: float
Distance in pixels between source and detector.
method: callable
Reconstruction method, e.g. `radontea.backproject`.
Expand All @@ -31,30 +32,22 @@ def fan_rec(linogram, lDS, method, stepsize=1, det_spacing=1,
of `count.value` is incremented.
**kwargs: dict
Keyword arguments for `method`.
See Also
--------
radon_fan_translation
The forward process.
lino2sino
Linogram to sinogram conversion.
"""
sino, angles = lino2sino(linogram, lDS, numang=numang, retang=True,
sino, angles = lino2sino(linogram, lds, numang=numang, retang=True,
stepsize=stepsize, det_spacing=det_spacing,
count=count, max_count=max_count)
return method(sino, angles, **kwargs)


def lino2sino(linogram, lDS, stepsize=1, det_spacing=1, numang=None,
def lino2sino(linogram, lds, stepsize=1, det_spacing=1, numang=None,
retang=False, count=None, max_count=None):
"""Convert linogram to sinogram for an equispaced detector.
Parameters
----------
linogram: real 2d ndarray of shape (D, A*)
Linogram from synthetic aperture measurements.
lDS: float
lds: float
Distance from point source to detector in au.
stepsize: float
Translational increment of object in au (stepsize in D).
Expand All @@ -70,28 +63,18 @@ def lino2sino(linogram, lDS, stepsize=1, det_spacing=1, numang=None,
by the total number of steps. At each step, the value
of `count.value` is incremented.
Returns
-------
sinogram: 2d ndarray of shape (D, A)
The distortion-corrected sinogram.
If retang is True, then the equispaced angles are returned as
well.
Notes
-----
This function can be used to convert a linogram obtained with
fan-beam tomography to a sinogram, which then can be reconstructed
with the backprojection or fourier mapping algorithms.
See Also
--------
radon_fan_translation
The forward process.
sa_interpolate
Backprojection that uses this function.
"""
if not np.isreal(linogram):
raise ValueError("`linogram` must be a real-valued array!")
Expand All @@ -107,7 +90,7 @@ def lino2sino(linogram, lDS, stepsize=1, det_spacing=1, numang=None,
max_count.value += D + A

# equispaced angles and corresponding lateral detector positions.
angles, xang = get_fan_coords(det_size, det_spacing, lDS, A)
angles, xang = get_fan_coords(det_size, det_spacing, lds, A)

uorig = linogram
lino = np.zeros((D, A))
Expand Down Expand Up @@ -135,7 +118,7 @@ def lino2sino(linogram, lDS, stepsize=1, det_spacing=1, numang=None,
# depends on the current angle.
# What is the distance b/w the center of the object (centered at
# lDS/2) to the axis alpha = 0?
deltaD = np.tan(alpha) * lDS / 2
deltaD = np.tan(alpha) * lds / 2

# Shearing:
# At larger angles, the object seems bigger on the screen.
Expand Down
9 changes: 1 addition & 8 deletions radontea/rdn_fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


def get_det_coords(size, spacing):
"""Compute pixel-center positions for 2d detector
"""Compute pixel-center positions for 2D detector
The centers of the pixels of a detector are usually not aligned to
a pixel grid. If we center the detector at the origin, odd images
Expand Down Expand Up @@ -51,13 +51,11 @@ def get_fan_coords(size, spacing, distance, numang):
numang: int
Number of angles.
Returns
-------
angles, latpos: two 1D ndarrays
Angles and pixel coordinates at the detector.
Notes
-----
Actually one would not need to define spacing and distance, but for
Expand Down Expand Up @@ -108,7 +106,6 @@ def radon_fan(arr, det_size, det_spacing=1, shift_size=1,
that its lower boundary starts at (det_size/2, 0) and its upper
boundary ends at (-det_size/2, 0) at increments of `shift_size`.
Parameters
----------
arr: ndarray, shape (N,N)
Expand All @@ -134,20 +131,16 @@ def radon_fan(arr, det_size, det_spacing=1, shift_size=1,
by the total number of steps. At each step, the value
of `count.value` is incremented.
Returns
-------
outarr: ndarray of floats, shape (N+det_size,det_size)
Linogram of the input image. Where N+det_size determines the
lateral position of the sample.
See Also
--------
scipy.ndimage.interpolation.rotate :
The interpolator used to rotate the image.
radon_prl
The original Radon transform.
"""
N = arr.shape[0]
if lD is None:
Expand Down
7 changes: 1 addition & 6 deletions radontea/threed.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
import time


def run(method, kwargs, target, target_index):
res = method(**kwargs)
target[target_index] = res


def do_work(in_queue, out_list, count, max_count):
while True:
item = in_queue.get()
Expand Down Expand Up @@ -46,7 +41,7 @@ def volume_recon(func2d, sinogram=None, angles=None,
value of `max_count.value` is set initially and the value
of `count.value` is incremented until it reaches the end
of the algorithm (`max_count.value`).
*kwargs: dict
**kwargs: dict
Additional keyword arguments to `func2d`.
Returns
Expand Down

0 comments on commit 3a74f96

Please sign in to comment.