diff --git a/docs/demos/Wet_sidebyside.png b/docs/demos/Wet_sidebyside.png deleted file mode 100644 index 82e10d4..0000000 Binary files a/docs/demos/Wet_sidebyside.png and /dev/null differ diff --git a/docs/source/api.rst b/docs/source/api.rst index 8bc1e1b..59bb4c6 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -8,6 +8,8 @@ API api/xdesign.acquisition api/xdesign.algorithms api/xdesign.geometry + api/xdesign.constants + api/xdesign.formats api/xdesign.material api/xdesign.metrics api/xdesign.phantom diff --git a/docs/source/api/xdesign.acquisition.rst b/docs/source/api/xdesign.acquisition.rst index 5493604..93f4771 100644 --- a/docs/source/api/xdesign.acquisition.rst +++ b/docs/source/api/xdesign.acquisition.rst @@ -2,20 +2,22 @@ ========================== .. automodule:: xdesign.acquisition - :members: - :show-inheritance: - :undoc-members: - :synopsis: Defines objects related to collection and organization of probe data. + :members: + :show-inheritance: + :undoc-members: - .. rubric:: **Functions:** + .. rubric:: **Classes:** - .. autosummary:: + .. autosummary:: - Beam - Probe - sinogram - angleogram - raster_scan - angle_scan + Beam + Probe -.. moduleauthor:: Doga Gursoy + .. rubric:: **Functions:** + + .. autosummary:: + + sinogram + angleogram + raster_scan + angle_scan diff --git a/docs/source/api/xdesign.algorithms.rst b/docs/source/api/xdesign.algorithms.rst index 2e5b807..eb5c306 100644 --- a/docs/source/api/xdesign.algorithms.rst +++ b/docs/source/api/xdesign.algorithms.rst @@ -5,16 +5,13 @@ :members: :show-inheritance: :undoc-members: - :synopsis: Defines methods for reconstructing data from the :mod:`.acquisition` module. .. rubric:: **Functions:** .. autosummary:: - reconstruct art sirt mlem stream - -.. moduleauthor:: Doga Gursoy + update_progress diff --git a/docs/source/api/xdesign.constants.rst b/docs/source/api/xdesign.constants.rst new file mode 100644 index 0000000..93f724f --- /dev/null +++ b/docs/source/api/xdesign.constants.rst @@ -0,0 +1,4 @@ +:mod:`xdesign.constants` +======================== + +.. automodule:: xdesign.constants diff --git a/docs/source/api/xdesign.formats.rst b/docs/source/api/xdesign.formats.rst new file mode 100644 index 0000000..4815d14 --- /dev/null +++ b/docs/source/api/xdesign.formats.rst @@ -0,0 +1,11 @@ +:mod:`xdesign.formats` +====================== + +.. automodule:: xdesign.formats + :members: + :show-inheritance: + :undoc-members: + + .. rubric:: **Functions:** + + .. autosummary:: diff --git a/docs/source/api/xdesign.geometry.rst b/docs/source/api/xdesign.geometry.rst index 005d3b3..1913054 100644 --- a/docs/source/api/xdesign.geometry.rst +++ b/docs/source/api/xdesign.geometry.rst @@ -2,15 +2,14 @@ ======================= .. automodule:: xdesign.geometry - :members: - :show-inheritance: - :inherited-members: - :undoc-members: - :synopsis: Defines geometric objects for the purpose of supporting :class:`.Phantom` definition and calculating intersections for the :mod:`.acquisition` module. + :members: + :show-inheritance: + :inherited-members: - .. rubric:: **Classes:** + .. rubric:: **Classes:** + + .. autosummary:: - .. autosummary:: Entity Point Circle @@ -20,6 +19,3 @@ Square Polygon Mesh - -.. moduleauthor:: Doga Gursoy -.. moduleauthor:: Daniel J Ching diff --git a/docs/source/api/xdesign.material.rst b/docs/source/api/xdesign.material.rst index 3bdc481..a37b862 100644 --- a/docs/source/api/xdesign.material.rst +++ b/docs/source/api/xdesign.material.rst @@ -5,13 +5,13 @@ :members: :show-inheritance: :undoc-members: - :synopsis: Defines objects which auto-generate a parameterized :class:`.Phantom`. - .. rubric:: **Functions:** + .. rubric:: **Classes:** .. autosummary:: Material + XDesignDefault HyperbolicConcentric DynamicRange DogaCircles @@ -25,5 +25,3 @@ SoftBiomaterial Electronics FiberComposite - -.. moduleauthor:: Daniel J Ching diff --git a/docs/source/api/xdesign.metrics.rst b/docs/source/api/xdesign.metrics.rst index c39805a..ae07688 100644 --- a/docs/source/api/xdesign.metrics.rst +++ b/docs/source/api/xdesign.metrics.rst @@ -5,21 +5,23 @@ :members: :show-inheritance: :undoc-members: - :synopsis: Objects and methods for computing the quality of reconstructions. - .. rubric:: **Functions:** + .. rubric:: **Classes:** .. autosummary:: ImageQuality - probability_mask - compute_quality + + .. rubric:: **Functions:** + + .. autosummary:: + compute_PCC compute_likeness compute_background_ttest compute_mtf - compute_mtf_siemens - compute_nps - compute_neq - -.. moduleauthor:: Daniel J Ching + compute_mtf_ffst + compute_mtf_lwkj + compute_nps_ffst + compute_neq_d + compute_quality diff --git a/docs/source/api/xdesign.phantom.rst b/docs/source/api/xdesign.phantom.rst index 05b602a..5fab562 100644 --- a/docs/source/api/xdesign.phantom.rst +++ b/docs/source/api/xdesign.phantom.rst @@ -5,12 +5,9 @@ :members: :show-inheritance: :undoc-members: - :synopsis: Defines an object for simulating X-ray phantoms. - .. rubric:: **Functions:** + .. rubric:: **Classes:** .. autosummary:: Phantom - -.. moduleauthor:: Daniel J Ching diff --git a/docs/source/api/xdesign.plot.rst b/docs/source/api/xdesign.plot.rst index 0ba6a64..29af153 100644 --- a/docs/source/api/xdesign.plot.rst +++ b/docs/source/api/xdesign.plot.rst @@ -5,7 +5,6 @@ :members: :show-inheritance: :undoc-members: - :synopsis: Contains functions for visualizing :class:`.Phantom` and :class:`.ImageQuality` metrics. .. rubric:: **Functions:** @@ -21,5 +20,3 @@ plot_mtf plot_nps plot_neq - -.. moduleauthor:: Daniel J Ching diff --git a/docs/source/bibtex/cite.bib b/docs/source/bibtex/cite.bib index 6f6c202..921643d 100644 --- a/docs/source/bibtex/cite.bib +++ b/docs/source/bibtex/cite.bib @@ -1,6 +1,6 @@ -@Article{ching:17, -author = "Ching, Daniel J. and G{\"{u}}rsoy, Do{\v{g}}a", -title = "{{\it XDesign}: an open-source software package for designing X-ray imaging phantoms and experiments}", +@Article{ching:17, +author = "Ching, Daniel J. and G{\"{u}}rsoy, Do{\v{g}}a", +title = "{XDesign: an open-source software package for designing X-ray imaging phantoms and experiments}", journal = "Journal of Synchrotron Radiation", year = "2017", volume = "24", diff --git a/docs/source/bibtex/refs.bib b/docs/source/bibtex/refs.bib index 3f3335a..9dd01c5 100644 --- a/docs/source/bibtex/refs.bib +++ b/docs/source/bibtex/refs.bib @@ -39,6 +39,15 @@ @article{Sufian:15 year = {2015} } +@inproceedings{loebich2007digital, + title={Digital camera resolution measurement using sinusoidal Siemens stars}, + author={Loebich, Christian and Wueller, Dietmar and Klingen, Bruno and Jaeger, Anke}, + booktitle={Electronic Imaging 2007}, + pages={65020N--65020N}, + year={2007}, + organization={International Society for Optics and Photonics} +} + @article{Bergamaschi:fv5047, author = "Bergamaschi, Antoine and Medjoubi, Kadda and Messaoudi, C{\'{e}}dric and Marco, Sergio and Somogyi, Andrea", title = "{{\it MMX-I}: data-processing software for multimodal X-ray imaging and tomography}", diff --git a/docs/source/conf.py b/docs/source/conf.py index 479e9cd..3a9df80 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -14,6 +14,7 @@ import sys import os +from unittest.mock import MagicMock # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -23,7 +24,7 @@ # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' +# needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom @@ -40,6 +41,8 @@ 'sphinx.ext.viewcode', 'sphinx.ext.napoleon', 'sphinxcontrib.bibtex', + 'nbsphinx', + 'IPython.sphinxext.ipython_console_highlighting', ] # Napoleon settings @@ -63,7 +66,7 @@ source_suffix = '.rst' # The encoding of source files. -#source_encoding = 'utf-8-sig' +# source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' @@ -79,7 +82,7 @@ # # The short X.Y version. # The full version, including alpha/beta/rc tags. -release = '0.1' +release = '0.3' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -96,7 +99,7 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns = [] +exclude_patterns = ['_build', '**.ipynb_checkpoints'] # The reST default role (used for this markup: `text`) to use for all # documents. @@ -168,7 +171,7 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +# html_static_path = ['_static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied @@ -315,42 +318,24 @@ # texinfo_no_detailmenu = False # Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'https://docs.python.org/': None} +intersphinx_mapping = {'https://docs.python.org/3': None} -# picked from http://read-the-docs.readthedocs.org/en/latest/faq.html -class Mock(object): - __all__ = [] +# picked from http://read-the-docs.readthedocs.org/en/latest/faq.html +class Mock(MagicMock): + @classmethod + def __getattr__(cls, name): + return MagicMock() - def __init__(self, *args, **kwargs): - pass - def __call__(self, *args, **kwargs): - return Mock() +MOCK_MODULES = ['numpy', + 'matplotlib', 'matplotlib.pyplot', 'matplotlib.patches', + 'matplotlib.path', 'matplotlib.patheffects', 'matplotlib.axis', + 'polytope', + 'cached_property', + 'scipy', 'scipy.stats', 'scipy.ndimage', 'scipy.spatial', + 'cycler', + 'phasepack', + ] - @classmethod - def __getattr__(cls, name): - return Mock() - def __mul__(self, other): - return Mock() - def __rmul__(self, other): - return Mock() - def __pow__(self, other): - return Mock() - def __div__(self, other): - return Mock() - def __add__(self, other): - return Mock() - def __radd__(self, other): - return Mock() - -MOCK_MODULES = [ - 'cached_property', 'cycler', 'intertools', - 'matplotlib', 'matplotlib.pyplot', 'matplotlib.patches', - 'matplotlib.path', 'matplotlib.patheffects', 'matplotlib.axis', - 'math', 'numpy', 'numbers', 'phasepack', 'polytope', - 'scipy', 'scipy.stats', 'scipy.ndimage', 'scipy.spatial', - ] - -for mod_name in MOCK_MODULES: - sys.modules[mod_name] = Mock() +sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES) diff --git a/docs/demos/FullReferenceMetrics.ipynb b/docs/source/demos/FullReferenceMetrics.ipynb similarity index 100% rename from docs/demos/FullReferenceMetrics.ipynb rename to docs/source/demos/FullReferenceMetrics.ipynb diff --git a/docs/demos/NoReferenceMetrics.ipynb b/docs/source/demos/NoReferenceMetrics.ipynb similarity index 100% rename from docs/demos/NoReferenceMetrics.ipynb rename to docs/source/demos/NoReferenceMetrics.ipynb diff --git a/docs/demos/Parameterized.ipynb b/docs/source/demos/Parameterized.ipynb similarity index 100% rename from docs/demos/Parameterized.ipynb rename to docs/source/demos/Parameterized.ipynb diff --git a/docs/demos/Shepp.ipynb b/docs/source/demos/Shepp.ipynb similarity index 100% rename from docs/demos/Shepp.ipynb rename to docs/source/demos/Shepp.ipynb diff --git a/docs/demos/StandardPatterns.ipynb b/docs/source/demos/StandardPatterns.ipynb similarity index 100% rename from docs/demos/StandardPatterns.ipynb rename to docs/source/demos/StandardPatterns.ipynb diff --git a/docs/demos/WetCircles.ipynb b/docs/source/demos/WetCircles.ipynb similarity index 100% rename from docs/demos/WetCircles.ipynb rename to docs/source/demos/WetCircles.ipynb diff --git a/docs/source/examples.rst b/docs/source/examples.rst index 83854b8..993c3a0 100644 --- a/docs/source/examples.rst +++ b/docs/source/examples.rst @@ -2,26 +2,25 @@ Examples ======== -This section contains `Jupyter Notebooks `_ -examples for various XDesign functions. - -To `run `_ these examples in a -`notebooks `_ install -`Jupyter `_ or run the notebooks from -scripts from `here `_ +This section contains `Jupyter Notebooks `_ examples for various XDesign functions. + +To `run `_ these examples in a `notebook `_ install `Jupyter `_ and run the notebooks from their `source `_ .. toctree:: - :titlesonly: - - ipynb/FullReferenceMetrics.rst - ipynb/NoReferenceMetrics.rst - ipynb/Parameterized.rst - ipynb/Shepp.rst - ipynb/StandardPatterns.rst - ipynb/WetCircles.rst + :titlesonly: + :maxdepth: 1 + + demos/Shepp + demos/StandardPatterns + demos/Parameterized + demos/NoReferenceMetrics + demos/FullReferenceMetrics + demos/WetCircles + + .. automodule:: xdesign :members: :undoc-members: - :show-inheritance: + :show-inheritance: diff --git a/docs/source/index.rst b/docs/source/index.rst index 43e5a07..bf704b5 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -8,17 +8,15 @@ XDesign :alt: XDesign -**XDesign** is an open-source Python package for generating -configurable simulation phantoms for benchmarking tomographic -image reconstruction. +**XDesign** is an open-source Python package for creating x-ray imaging `phantoms `_, simulating `data acquisition `_, and benchmarking x-ray `tomographic image reconstruction `_. -.. toctree:: - :maxdepth: 1 +Goals +===== + +* Assist faster development of new generation tomographic reconstruction methods +* Allow quantitative comparison of different reconstruction methods +* Create a framework for designing x-ray imaging experiments - api - examples - zrefs - credits Features ======== @@ -27,6 +25,7 @@ Features * Various visualization tools for statistics. * Analytic projection operators. + Contribute ========== @@ -35,15 +34,25 @@ Contribute * Source Code: https://github.com/tomography/xdesign/tree/master/xdesign * Tests: https://github.com/tomography/xdesign/tree/master/test + License ======= The project is licensed under the `BSD-3 `_ license. + Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` + +.. toctree:: + :maxdepth: 1 + + api + examples + zrefs + credits diff --git a/docs/source/ipynb/FullReferenceMetrics.rst b/docs/source/ipynb/FullReferenceMetrics.rst deleted file mode 100644 index 665fd52..0000000 --- a/docs/source/ipynb/FullReferenceMetrics.rst +++ /dev/null @@ -1,155 +0,0 @@ - -Quality Metrics and Reconstruction Demo -======================================= - -Demonstrates the use of full reference metrics. - -.. code:: python - - import numpy as np - import matplotlib.pyplot as plt - from skimage.exposure import adjust_gamma, rescale_intensity - from xdesign import * - - - def rescale(reconstruction, hi): - I = rescale_intensity(reconstruction, out_range=(0., 1.)) - return adjust_gamma(I, 1, hi) - - -Generate a predetermined phantom that resembles soil. - -.. code:: python - - np.random.seed(0) - soil_like_phantom = Soil() - - -Generate a figure showing the phantom and save the discrete conversion -for later. - -.. code:: python - - discrete = sidebyside(soil_like_phantom, 100) - plt.savefig('Soil_sidebyside.png', dpi='figure', - orientation='landscape', papertype=None, format=None, - transparent=True, bbox_inches='tight', pad_inches=0.0, - frameon=False) - plt.show() - - - -.. image:: FullReferenceMetrics_files/FullReferenceMetrics_5_0.png - - -Simulate data acquisition for parallel beam around 180 degrees. - -.. code:: python - - sx, sy = 100, 100 - step = 1. / sy - prb = Probe(Point([step / 2., -10]), Point([step / 2., 10]), step) - theta = np.pi / sx - sino = np.zeros(sx * sy) - a = 0 - for m in range(sx): - for n in range(sy): - update_progress((m*sy + n)/(sx*sy)) - sino[a] = prb.measure(soil_like_phantom) - a += 1 - prb.translate(step) - prb.translate(-1) - prb.rotate(theta, Point([0.5, 0.5])) - update_progress(1) - - -.. code:: python - - plt.imshow(np.reshape(sino, (sx, sy)), cmap='gray', interpolation='nearest') - # plt.hist(sino) - plt.show(block=True) - - - -.. image:: FullReferenceMetrics_files/FullReferenceMetrics_8_0.png - - -Reconstruct the phantom using 3 different techniques: ART, SIRT, and -MLEM - -.. code:: python - - hi = 1 # highest expected value in reconstruction (for rescaling) - niter = 10 # number of iterations - - init = 1e-12 * np.ones((sx, sy)) - rec_art = art(prb, sino, init, niter) - rec_art = rescale(np.rot90(rec_art)[::-1], hi) - - init = 1e-12 * np.ones((sx, sy)) - rec_sirt = sirt(prb, sino, init, niter) - rec_sirt = rescale(np.rot90(rec_sirt)[::-1], hi) - - init = 1e-12 * np.ones((sx, sy)) - rec_mlem = mlem(prb, sino, init, niter) - rec_mlem = rescale(np.rot90(rec_mlem)[::-1], hi) - - -.. code:: python - - plt.figure(figsize=(12,4)) - plt.subplot(131) - plt.imshow(rec_art, cmap='gray', interpolation='none') - plt.title('ART') - plt.subplot(132) - plt.imshow(rec_sirt, cmap='gray', interpolation='none') - plt.title('SIRT') - plt.subplot(133) - plt.imshow(rec_mlem, cmap='gray', interpolation='none') - plt.title('MLEM') - plt.show() - - - -.. image:: FullReferenceMetrics_files/FullReferenceMetrics_11_0.png - - -Compute quality metrics using the MSSSIM method. - -.. code:: python - - metrics = compute_quality(discrete, [rec_art, rec_sirt, rec_mlem], method="MSSSIM") - -Plotting the results shows the average quality at each level for each -reconstruction in a line plot. Then it produces the local quality maps -for each reconstruction so we might see why certain reconstructions are -ranked higher than others. - -In this case, it's clear that ART is ranking higer than MLEM and SIRT at -smaller scales because the small dark particles are visible; whereas for -SIRT and MLEM they are unresolved. We can also see that the large yellow -circles have a more accurately rendered luminance for SIRT and MLEM -which is what causes these methods to be ranked higher at larger scales. - -.. code:: python - - plot_metrics(metrics) - plt.show() - - - -.. image:: FullReferenceMetrics_files/FullReferenceMetrics_15_0.png - - - -.. image:: FullReferenceMetrics_files/FullReferenceMetrics_15_1.png - - - -.. image:: FullReferenceMetrics_files/FullReferenceMetrics_15_2.png - - - -.. image:: FullReferenceMetrics_files/FullReferenceMetrics_15_3.png - - diff --git a/docs/source/ipynb/FullReferenceMetrics_files/FullReferenceMetrics_11_0.png b/docs/source/ipynb/FullReferenceMetrics_files/FullReferenceMetrics_11_0.png deleted file mode 100644 index 9338df6..0000000 Binary files a/docs/source/ipynb/FullReferenceMetrics_files/FullReferenceMetrics_11_0.png and /dev/null differ diff --git a/docs/source/ipynb/FullReferenceMetrics_files/FullReferenceMetrics_15_0.png b/docs/source/ipynb/FullReferenceMetrics_files/FullReferenceMetrics_15_0.png deleted file mode 100644 index 1c2f4ac..0000000 Binary files a/docs/source/ipynb/FullReferenceMetrics_files/FullReferenceMetrics_15_0.png and /dev/null differ diff --git a/docs/source/ipynb/FullReferenceMetrics_files/FullReferenceMetrics_15_1.png b/docs/source/ipynb/FullReferenceMetrics_files/FullReferenceMetrics_15_1.png deleted file mode 100644 index 5db4382..0000000 Binary files a/docs/source/ipynb/FullReferenceMetrics_files/FullReferenceMetrics_15_1.png and /dev/null differ diff --git a/docs/source/ipynb/FullReferenceMetrics_files/FullReferenceMetrics_15_2.png b/docs/source/ipynb/FullReferenceMetrics_files/FullReferenceMetrics_15_2.png deleted file mode 100644 index 2b0c979..0000000 Binary files a/docs/source/ipynb/FullReferenceMetrics_files/FullReferenceMetrics_15_2.png and /dev/null differ diff --git a/docs/source/ipynb/FullReferenceMetrics_files/FullReferenceMetrics_15_3.png b/docs/source/ipynb/FullReferenceMetrics_files/FullReferenceMetrics_15_3.png deleted file mode 100644 index 93199f9..0000000 Binary files a/docs/source/ipynb/FullReferenceMetrics_files/FullReferenceMetrics_15_3.png and /dev/null differ diff --git a/docs/source/ipynb/FullReferenceMetrics_files/FullReferenceMetrics_5_0.png b/docs/source/ipynb/FullReferenceMetrics_files/FullReferenceMetrics_5_0.png deleted file mode 100644 index 8091c7e..0000000 Binary files a/docs/source/ipynb/FullReferenceMetrics_files/FullReferenceMetrics_5_0.png and /dev/null differ diff --git a/docs/source/ipynb/FullReferenceMetrics_files/FullReferenceMetrics_8_0.png b/docs/source/ipynb/FullReferenceMetrics_files/FullReferenceMetrics_8_0.png deleted file mode 100644 index aab23ba..0000000 Binary files a/docs/source/ipynb/FullReferenceMetrics_files/FullReferenceMetrics_8_0.png and /dev/null differ diff --git a/docs/source/ipynb/NoReferenceMetrics.rst b/docs/source/ipynb/NoReferenceMetrics.rst deleted file mode 100644 index b853e81..0000000 --- a/docs/source/ipynb/NoReferenceMetrics.rst +++ /dev/null @@ -1,192 +0,0 @@ - -No Reference Metrics -==================== - -Demonstrates the use of the no-reference metrics: NPS, MTF, and NEQ. - -.. code:: python - - from xdesign import * - import tomopy - import numpy as np - import matplotlib.pylab as plt - - -Generate a UnitCircle test phantom. For the MTF, the radius must be less -than 0.5, otherwise the circle touches the edges of the field of view. - -.. code:: python - - p = UnitCircle(mass_atten=4, radius=0.35) - sidebyside(p, 100) - plt.show() - - - -.. image:: NoReferenceMetrics_files/NoReferenceMetrics_3_0.png - - -Generate two sinograms and reconstruct. Noise power spectrum and Noise -Equivalent Quanta are meaningless withouth noise so add some poisson -noise to the reconstruction process with the ``noise`` argument. -Collecting two sinograms allows us to isolate the noise by subtracting -out the circle. - -.. code:: python - - np.random.seed(0) - sinoA = sinogram(100, 100, p, noise=0.1) - sinoB = sinogram(100, 100, p, noise=0.1) - theta = np.arange(0, np.pi, np.pi / 100.) - - recA = tomopy.recon(np.expand_dims(sinoA, 1), theta, algorithm='gridrec', center=(sinoA.shape[1]-1)/2.) - recB = tomopy.recon(np.expand_dims(sinoB, 1), theta, algorithm='gridrec', center=(sinoB.shape[1]-1)/2.) - -Take a look at the two noisy reconstructions. - -.. code:: python - - plt.imshow(recA[0], cmap='inferno', interpolation="none") - plt.colorbar() - plt.savefig('UnitCircle_noise0.png', dpi=600, - orientation='landscape', papertype=None, format=None, - transparent=True, bbox_inches='tight', pad_inches=0.0, - frameon=False) - plt.show() - - - -.. image:: NoReferenceMetrics_files/NoReferenceMetrics_7_0.png - - -.. code:: python - - plt.imshow(recB[0], cmap='inferno', interpolation="none") - plt.colorbar() - plt.show() - - - -.. image:: NoReferenceMetrics_files/NoReferenceMetrics_8_0.png - - -Calculate MTF -------------- - -This metric is meaningful without noise. You can separate the MTF into -multiple directions or average them all together using the ``Ntheta`` -argument. - -.. code:: python - - mtf_freq, mtf_value, labels = compute_mtf(p, recA[0], Ntheta=4) - -The MTF is really a symmetric function around zero frequency, so usually -people just show the positive portion. Sometimes, there is a peak at the -higher spatial frequencies instead of the MTF approaching zero. This is -probably because of aliasing noise content with frequencies higher than -the Nyquist frequency. - -.. code:: python - - plot_mtf(mtf_freq, mtf_value, labels) - plt.gca().set_xlim([0,50]) # hide negative portion of MTF - plt.show() - - - -.. image:: NoReferenceMetrics_files/NoReferenceMetrics_12_0.png - - -You can also use a Siemens Star to calculate the MTF using a fitted -sinusoidal method instead of the slanted edges that the above method -uses. - -.. code:: python - - s = SiemensStar(n_sectors=32, center=Point([0.5, 0.5]), radius=0.5) - d = sidebyside(s, 100) - -.. code:: python - - plt.show() - - - -.. image:: NoReferenceMetrics_files/NoReferenceMetrics_15_0.png - - -Here we are using the discreet verison of the phantom (without noise), -so we are only limited by the resolution of the image. - -.. code:: python - - mtf_freq, mtf_value = compute_mtf_siemens(s, d) - -.. code:: python - - plot_mtf(mtf_freq, mtf_value, labels=None) - plt.gca().set_xlim([0,50]) # hide portion of MTF beyond Nyquist frequency - plt.show() - - - -.. image:: NoReferenceMetrics_files/NoReferenceMetrics_18_0.png - - -Calculate NPS -------------- - -You can also calculate the radial or 2D frequency plot of the NPS. - -.. code:: python - - X, Y, NPS = compute_nps(p, recA[0], plot_type='frequency',B=recB[0]) - -.. code:: python - - plot_nps(X, Y, NPS) - plt.show() - - - -.. image:: NoReferenceMetrics_files/NoReferenceMetrics_21_0.png - - -.. code:: python - - bins, counts = compute_nps(p, recA[0], plot_type='histogram',B=recB[0]) - -.. code:: python - - plt.figure() - plt.bar(bins, counts) - plt.xlabel('spatial frequency [cycles/length]') - plt.title('Noise Power Spectrum') - plt.show() - - - -.. image:: NoReferenceMetrics_files/NoReferenceMetrics_23_0.png - - -Calculate NEQ -------------- - -.. code:: python - - freq, NEQ = compute_neq(p, recA[0], recB[0]) - -.. code:: python - - plt.figure() - plt.plot(freq.flatten(), NEQ.flatten()) - plt.xlabel('spatial frequency [cycles/length]') - plt.title('Noise Equivalent Quanta') - plt.show() - - - -.. image:: NoReferenceMetrics_files/NoReferenceMetrics_26_0.png - - diff --git a/docs/source/ipynb/NoReferenceMetrics_files/NoReferenceMetrics_12_0.png b/docs/source/ipynb/NoReferenceMetrics_files/NoReferenceMetrics_12_0.png deleted file mode 100644 index e814f12..0000000 Binary files a/docs/source/ipynb/NoReferenceMetrics_files/NoReferenceMetrics_12_0.png and /dev/null differ diff --git a/docs/source/ipynb/NoReferenceMetrics_files/NoReferenceMetrics_15_0.png b/docs/source/ipynb/NoReferenceMetrics_files/NoReferenceMetrics_15_0.png deleted file mode 100644 index cfbab66..0000000 Binary files a/docs/source/ipynb/NoReferenceMetrics_files/NoReferenceMetrics_15_0.png and /dev/null differ diff --git a/docs/source/ipynb/NoReferenceMetrics_files/NoReferenceMetrics_18_0.png b/docs/source/ipynb/NoReferenceMetrics_files/NoReferenceMetrics_18_0.png deleted file mode 100644 index ffb35c3..0000000 Binary files a/docs/source/ipynb/NoReferenceMetrics_files/NoReferenceMetrics_18_0.png and /dev/null differ diff --git a/docs/source/ipynb/NoReferenceMetrics_files/NoReferenceMetrics_21_0.png b/docs/source/ipynb/NoReferenceMetrics_files/NoReferenceMetrics_21_0.png deleted file mode 100644 index 5cba729..0000000 Binary files a/docs/source/ipynb/NoReferenceMetrics_files/NoReferenceMetrics_21_0.png and /dev/null differ diff --git a/docs/source/ipynb/NoReferenceMetrics_files/NoReferenceMetrics_23_0.png b/docs/source/ipynb/NoReferenceMetrics_files/NoReferenceMetrics_23_0.png deleted file mode 100644 index 834c42e..0000000 Binary files a/docs/source/ipynb/NoReferenceMetrics_files/NoReferenceMetrics_23_0.png and /dev/null differ diff --git a/docs/source/ipynb/NoReferenceMetrics_files/NoReferenceMetrics_26_0.png b/docs/source/ipynb/NoReferenceMetrics_files/NoReferenceMetrics_26_0.png deleted file mode 100644 index 0e5e601..0000000 Binary files a/docs/source/ipynb/NoReferenceMetrics_files/NoReferenceMetrics_26_0.png and /dev/null differ diff --git a/docs/source/ipynb/NoReferenceMetrics_files/NoReferenceMetrics_3_0.png b/docs/source/ipynb/NoReferenceMetrics_files/NoReferenceMetrics_3_0.png deleted file mode 100644 index 1e764b9..0000000 Binary files a/docs/source/ipynb/NoReferenceMetrics_files/NoReferenceMetrics_3_0.png and /dev/null differ diff --git a/docs/source/ipynb/NoReferenceMetrics_files/NoReferenceMetrics_7_0.png b/docs/source/ipynb/NoReferenceMetrics_files/NoReferenceMetrics_7_0.png deleted file mode 100644 index a223c19..0000000 Binary files a/docs/source/ipynb/NoReferenceMetrics_files/NoReferenceMetrics_7_0.png and /dev/null differ diff --git a/docs/source/ipynb/NoReferenceMetrics_files/NoReferenceMetrics_8_0.png b/docs/source/ipynb/NoReferenceMetrics_files/NoReferenceMetrics_8_0.png deleted file mode 100644 index 852fb89..0000000 Binary files a/docs/source/ipynb/NoReferenceMetrics_files/NoReferenceMetrics_8_0.png and /dev/null differ diff --git a/docs/source/ipynb/Parameterized.rst b/docs/source/ipynb/Parameterized.rst deleted file mode 100644 index 351f025..0000000 --- a/docs/source/ipynb/Parameterized.rst +++ /dev/null @@ -1,102 +0,0 @@ - -Parameterized Phantom Generation -================================ - -Demonstrates how a parameterized function can generate 4 different -phantoms from the same parameterized class. - -.. code:: python - - from xdesign import * - import matplotlib.pyplot as plt - import numpy as np - import matplotlib.gridspec as gridspec - - SIZE = 600 - - -.. code:: python - - np.random.seed(0) # random seed for repeatability - p1 = Foam(size_range=[0.05, 0.01], gap=0, porosity=1) - d1 = discrete_phantom(p1, SIZE) - plt.imshow(d1, cmap='viridis') - plt.show() - - -.. image:: Parameterized_files/Parameterized_2_1.png - - -.. code:: python - - np.random.seed(0) # random seed for repeatability - p2 = Foam(size_range=[0.07, 0.01], gap=0, porosity=0.75) - d2 = discrete_phantom(p2, SIZE) - plt.imshow(d2, cmap='viridis') - plt.show() - - -.. image:: Parameterized_files/Parameterized_3_1.png - - -.. code:: python - - np.random.seed(0) # random seed for repeatability - p3 = Foam(size_range=[0.1, 0.01], gap=0, porosity=0.5) - d3 = discrete_phantom(p3, SIZE) - plt.imshow(d3, cmap='viridis') - plt.show() - - - -.. image:: Parameterized_files/Parameterized_4_0.png - - -.. code:: python - - np.random.seed(0) # random seed for repeatability - p4 = Foam(size_range=[0.1, 0.01], gap=0.015, porosity=0.5) - d4 = discrete_phantom(p4, SIZE) - plt.imshow(d4, cmap='viridis') - plt.show() - - -.. image:: Parameterized_files/Parameterized_5_1.png - - -Create a composite figure of all four discrete phantoms. - -.. code:: python - - fig = plt.figure(dpi=600) - gs1 = gridspec.GridSpec(2, 2) - gs1.update(wspace=0.1, hspace=0.1) # set the spacing between axes. - - plt.subplot(gs1[0]) - plt.title('(a)') - plt.axis('off') - plt.imshow(d1, interpolation='none', cmap=plt.cm.gray) - plt.subplot(gs1[1]) - plt.title('(b)') - plt.axis('off') - plt.imshow(d2, interpolation='none', cmap=plt.cm.gray) - plt.subplot(gs1[2]) - plt.title('(c)') - plt.axis('off') - plt.imshow(d3, interpolation='none', cmap=plt.cm.gray) - plt.subplot(gs1[3]) - plt.title('(d)') - plt.axis('off') - plt.imshow(d4, interpolation='none', cmap=plt.cm.gray) - fig.set_size_inches(6, 6) - plt.savefig('Foam_parameterized.png', dpi='figure', - orientation='landscape', papertype=None, format=None, - transparent=True, bbox_inches='tight', pad_inches=0.0, - frameon=False) - plt.show() - - - -.. image:: Parameterized_files/Parameterized_7_0.png - - diff --git a/docs/source/ipynb/Parameterized_files/Parameterized_2_1.png b/docs/source/ipynb/Parameterized_files/Parameterized_2_1.png deleted file mode 100644 index 85505be..0000000 Binary files a/docs/source/ipynb/Parameterized_files/Parameterized_2_1.png and /dev/null differ diff --git a/docs/source/ipynb/Parameterized_files/Parameterized_3_1.png b/docs/source/ipynb/Parameterized_files/Parameterized_3_1.png deleted file mode 100644 index 9e616b9..0000000 Binary files a/docs/source/ipynb/Parameterized_files/Parameterized_3_1.png and /dev/null differ diff --git a/docs/source/ipynb/Parameterized_files/Parameterized_4_0.png b/docs/source/ipynb/Parameterized_files/Parameterized_4_0.png deleted file mode 100644 index f408f2e..0000000 Binary files a/docs/source/ipynb/Parameterized_files/Parameterized_4_0.png and /dev/null differ diff --git a/docs/source/ipynb/Parameterized_files/Parameterized_5_1.png b/docs/source/ipynb/Parameterized_files/Parameterized_5_1.png deleted file mode 100644 index b4b4738..0000000 Binary files a/docs/source/ipynb/Parameterized_files/Parameterized_5_1.png and /dev/null differ diff --git a/docs/source/ipynb/Parameterized_files/Parameterized_7_0.png b/docs/source/ipynb/Parameterized_files/Parameterized_7_0.png deleted file mode 100644 index 8b34458..0000000 Binary files a/docs/source/ipynb/Parameterized_files/Parameterized_7_0.png and /dev/null differ diff --git a/docs/source/ipynb/Shepp.rst b/docs/source/ipynb/Shepp.rst deleted file mode 100644 index 7d81bb3..0000000 --- a/docs/source/ipynb/Shepp.rst +++ /dev/null @@ -1,109 +0,0 @@ - -Simple Phantom Construction Demo -================================ - -Demonstrates simple basic custom phantom and sinogram generation. - -.. code:: python - - import matplotlib.pyplot as plt - import numpy as np - from xdesign import * - - -Create various ``Features`` with geometries and assign attenuation -``values`` to each of the ``Features``. - -.. code:: python - - head = Feature(Circle(Point([0.5, 0.5]), radius=0.5)) - head.mass_atten = 1 - eyeL = Feature(Circle(Point([0.3, 0.5]), radius=0.1)) - eyeL.mass_atten = 1 - eyeR = Feature(Circle(Point([0.7, 0.5]), radius=0.1)) - eyeR.mass_atten = 1 - mouth = Feature(Triangle(Point([0.2, 0.7]), Point([0.5, 0.8]), Point([0.8, 0.7]))) - mouth.mass_atten = -1 - -Add 'Features' to 'Phantom'. - -.. code:: python - - Shepp = Phantom() - Shepp.append(head) - Shepp.append(eyeL) - Shepp.append(eyeR) - Shepp.append(mouth) - -Plot the ``Phantom`` geometry and properties with a colorbar. - -.. code:: python - - fig = plt.figure(figsize=(7, 3), dpi=600) - - # plot geometry - axis = fig.add_subplot(121, aspect='equal') - plt.grid('on') - plt.gca().invert_yaxis() - plot_phantom(Shepp, axis=axis, labels=False) - - # plot property - plt.subplot(1, 2, 2) - im = plt.imshow(discrete_phantom(Shepp, 100, prop='mass_atten'), interpolation='none', cmap=plt.cm.inferno) - - # plot colorbar - fig.subplots_adjust(right=0.8) - cbar_ax = fig.add_axes([0.85, 0.16, 0.05, 0.7]) - fig.colorbar(im, cax=cbar_ax) - - # save the figure - plt.savefig('Shepp_sidebyside.png', dpi=600, - orientation='landscape', papertype=None, format=None, - transparent=True, bbox_inches='tight', pad_inches=0.0, - frameon=False) - plt.show() - - - -.. image:: Shepp_files/Shepp_7_0.png - - -Simulate data acquisition for parallel beam around 180 degrees. - -.. code:: python - - sx, sy = 100, 100 - step = 1. / sy - prb = Probe(Point([step / 2., -10]), Point([step / 2., 10]), step) - theta = np.pi / sx - sino = np.zeros(sx * sy) - - a = 0 - for m in range(sx): - for n in range(sy): - update_progress((m*sy + n)/(sx*sy)) - sino[a] = prb.measure(Shepp) - a += 1 - prb.translate(step) - prb.translate(-1) - prb.rotate(theta, Point([0.5, 0.5])) - update_progress(1) - - -Plot the sinogram. - -.. code:: python - - plt.figure(figsize=(8, 8)) - plt.imshow(np.reshape(sino, (sx, sy)), cmap='inferno', interpolation='nearest') - plt.savefig('Shepp_sinogram.png', dpi=600, - orientation='landscape', papertype=None, format=None, - transparent=True, bbox_inches='tight', pad_inches=0.0, - frameon=False) - plt.show() - - - -.. image:: Shepp_files/Shepp_11_0.png - - diff --git a/docs/source/ipynb/Shepp_files/Shepp_11_0.png b/docs/source/ipynb/Shepp_files/Shepp_11_0.png deleted file mode 100644 index 059f703..0000000 Binary files a/docs/source/ipynb/Shepp_files/Shepp_11_0.png and /dev/null differ diff --git a/docs/source/ipynb/Shepp_files/Shepp_7_0.png b/docs/source/ipynb/Shepp_files/Shepp_7_0.png deleted file mode 100644 index f99d15b..0000000 Binary files a/docs/source/ipynb/Shepp_files/Shepp_7_0.png and /dev/null differ diff --git a/docs/source/ipynb/StandardPatterns.rst b/docs/source/ipynb/StandardPatterns.rst deleted file mode 100644 index be42174..0000000 --- a/docs/source/ipynb/StandardPatterns.rst +++ /dev/null @@ -1,132 +0,0 @@ - -Standard Test Patterns -====================== - -Generates sidebyside plots of all the standard test patterns in xdesign. - -.. code:: python - - from xdesign import * - import numpy as np - import matplotlib.pyplot as plt - import matplotlib.gridspec as gridspec - - -.. code:: python - - p = SlantedSquares(count=16, angle=5/360*2*np.pi, gap=0.01) - sidebyside(p) - plt.savefig('SlantedSquares_sidebyside.png', dpi='figure', - orientation='landscape', papertype=None, format=None, - transparent=True, bbox_inches='tight', pad_inches=0.0, - frameon=False) - plt.show() - - - -.. image:: StandardPatterns_files/StandardPatterns_2_0.png - - -.. code:: python - - h = HyperbolicConcentric() - sidebyside(h) - plt.savefig('HyperbolicConcentric_sidebyside.png', dpi='figure', - orientation='landscape', papertype=None, format=None, - transparent=True, bbox_inches='tight', pad_inches=0.0, - frameon=False) - plt.show() - - - -.. image:: StandardPatterns_files/StandardPatterns_3_0.png - - -.. code:: python - - u = UnitCircle(radius=0.4, mass_atten=1) - sidebyside(u) - plt.savefig('UnitCircle_sidebyside.png', dpi='figure', - orientation='landscape', papertype=None, format=None, - transparent=True, bbox_inches='tight', pad_inches=0.0, - frameon=False) - plt.show() - - - -.. image:: StandardPatterns_files/StandardPatterns_4_0.png - - -.. code:: python - - d = DynamicRange(steps=16, jitter=True, shape='square') - sidebyside(d) - plt.savefig('DynamicRange_sidebyside.png', dpi='figure', - orientation='landscape', papertype=None, format=None, - transparent=True, bbox_inches='tight', pad_inches=0.0, - frameon=False) - plt.show() - - - -.. image:: StandardPatterns_files/StandardPatterns_5_0.png - - -.. code:: python - - l = DogaCircles(n_sizes=8, size_ratio=0.5, n_shuffles=0) - l.rotate(np.pi/2, Point([0.5, 0.5])) - sidebyside(l) - plt.savefig('DogaCircles_sidebyside.png', dpi='figure', - orientation='landscape', papertype=None, format=None, - transparent=True, bbox_inches='tight', pad_inches=0.0, - frameon=False) - plt.show() - - - -.. image:: StandardPatterns_files/StandardPatterns_6_0.png - - -.. code:: python - - s = SiemensStar(32) - sidebyside(s) - plt.savefig('SiemensStar_sidebyside.png', dpi='figure', - orientation='landscape', papertype=None, format=None, - transparent=True, bbox_inches='tight', pad_inches=0.0, - frameon=False) - plt.show() - - - -.. image:: StandardPatterns_files/StandardPatterns_7_0.png - - -.. code:: python - - fig = plt.figure(figsize=(8, 6), dpi=600) - gs1 = gridspec.GridSpec(3, 4) - gs1.update(wspace=0.4, hspace=0.4) # set the spacing between axes. - phantoms = [l, d, u, h, p, s] - letters = ['a','b','c','d','e','f','g'] - for i in range(0, len(phantoms)): - axis = plt.subplot(gs1[2*i], aspect=1) - plt.grid('on') - plt.gca().invert_yaxis() - plot_phantom(phantoms[i], axis=axis) - plt.title('('+ letters[i] +')') - plt.subplot(gs1[2*i+1], aspect=1) - plt.imshow(discrete_phantom(phantoms[i], 200), cmap='inferno') - - plt.savefig('standard_patterns.png', dpi='figure', - orientation='landscape', papertype=None, format=None, - transparent=True, bbox_inches='tight', pad_inches=0.0, - frameon=False) - plt.show() - - - -.. image:: StandardPatterns_files/StandardPatterns_8_0.png - - diff --git a/docs/source/ipynb/StandardPatterns_files/StandardPatterns_2_0.png b/docs/source/ipynb/StandardPatterns_files/StandardPatterns_2_0.png deleted file mode 100644 index 2b550da..0000000 Binary files a/docs/source/ipynb/StandardPatterns_files/StandardPatterns_2_0.png and /dev/null differ diff --git a/docs/source/ipynb/StandardPatterns_files/StandardPatterns_3_0.png b/docs/source/ipynb/StandardPatterns_files/StandardPatterns_3_0.png deleted file mode 100644 index 38e8699..0000000 Binary files a/docs/source/ipynb/StandardPatterns_files/StandardPatterns_3_0.png and /dev/null differ diff --git a/docs/source/ipynb/StandardPatterns_files/StandardPatterns_4_0.png b/docs/source/ipynb/StandardPatterns_files/StandardPatterns_4_0.png deleted file mode 100644 index 1c5561a..0000000 Binary files a/docs/source/ipynb/StandardPatterns_files/StandardPatterns_4_0.png and /dev/null differ diff --git a/docs/source/ipynb/StandardPatterns_files/StandardPatterns_5_0.png b/docs/source/ipynb/StandardPatterns_files/StandardPatterns_5_0.png deleted file mode 100644 index b8a8e86..0000000 Binary files a/docs/source/ipynb/StandardPatterns_files/StandardPatterns_5_0.png and /dev/null differ diff --git a/docs/source/ipynb/StandardPatterns_files/StandardPatterns_6_0.png b/docs/source/ipynb/StandardPatterns_files/StandardPatterns_6_0.png deleted file mode 100644 index fc04ed5..0000000 Binary files a/docs/source/ipynb/StandardPatterns_files/StandardPatterns_6_0.png and /dev/null differ diff --git a/docs/source/ipynb/StandardPatterns_files/StandardPatterns_7_0.png b/docs/source/ipynb/StandardPatterns_files/StandardPatterns_7_0.png deleted file mode 100644 index cfbab66..0000000 Binary files a/docs/source/ipynb/StandardPatterns_files/StandardPatterns_7_0.png and /dev/null differ diff --git a/docs/source/ipynb/StandardPatterns_files/StandardPatterns_8_0.png b/docs/source/ipynb/StandardPatterns_files/StandardPatterns_8_0.png deleted file mode 100644 index ae16d36..0000000 Binary files a/docs/source/ipynb/StandardPatterns_files/StandardPatterns_8_0.png and /dev/null differ diff --git a/docs/source/ipynb/WetCircles.rst b/docs/source/ipynb/WetCircles.rst deleted file mode 100644 index 16a5c19..0000000 --- a/docs/source/ipynb/WetCircles.rst +++ /dev/null @@ -1,97 +0,0 @@ -Wet Circles -=========== - -.. code:: python - - import numpy as np - from scipy.spatial import Delaunay - import matplotlib.pyplot as plt - from xdesign import * - from skimage.exposure import adjust_gamma, rescale_intensity - - - def rescale(reconstruction, hi): - I = rescale_intensity(reconstruction, out_range=(0., 1.)) - return adjust_gamma(I, 1, hi) - -.. code:: python - - wet = WetCircles() - sidebyside(wet, size=200) - plt.savefig('Wet_sidebyside.png', dpi='figure', - orientation='landscape', papertype=None, format=None, - transparent=True, bbox_inches='tight', pad_inches=0.0, - frameon=False) - plt.show(block=True) - - - -.. image:: WetCircles_files/WetCircles_1_0.png - - -.. code:: python - - sx, sy = 100, 100 - step = 1. / sy - prb = Probe(Point([step / 2., -10]), Point([step / 2., 10]), step) - theta = np.pi / sx - sino = np.zeros(sx * sy) - a = 0 - for m in range(sx): - for n in range(sy): - update_progress((m*sy + n)/(sx*sy)) - sino[a] = prb.measure(wet) - a += 1 - prb.translate(step) - prb.translate(-1) - prb.rotate(theta, Point([0.5, 0.5])) - - - plt.figure(figsize=(8, 8)) - plt.imshow(np.reshape(sino, (sx, sy)), cmap='gray', interpolation='nearest') - plt.show(block=True) - - -.. image:: WetCircles_files/WetCircles_2_3.png - - -.. code:: python - - hi = 1 - niter = 20 - # Reconstruct object. - init = 1e-12 * np.ones((sx, sy)) - rec_art = art(prb, sino, init, niter) - rec_art = rescale(np.rot90(rec_art)[::-1], hi) - plt.figure(figsize=(8, 8)) - plt.imshow(rec_art, cmap='gray', interpolation='none') - plt.title('ART') - - init = 1e-12 * np.ones((sx, sy)) - rec_sirt = sirt(prb, sino, init, niter) - rec_sirt = rescale(np.rot90(rec_sirt)[::-1], hi) - plt.figure(figsize=(8, 8)) - plt.imshow(rec_sirt, cmap='gray', interpolation='none') - plt.title('SIRT') - - init = 1e-12 * np.ones((sx, sy)) - rec_mlem = mlem(prb, sino, init, niter) - rec_mlem = rescale(np.rot90(rec_mlem)[::-1], hi) - plt.figure(figsize=(8, 8)) - plt.imshow(rec_mlem, cmap='gray', interpolation='none') - plt.title('MLEM') - plt.show() - - - -.. image:: WetCircles_files/WetCircles_3_1.png - - - -.. image:: WetCircles_files/WetCircles_3_2.png - - - -.. image:: WetCircles_files/WetCircles_3_3.png - - diff --git a/docs/source/ipynb/WetCircles_files/WetCircles_1_0.png b/docs/source/ipynb/WetCircles_files/WetCircles_1_0.png deleted file mode 100644 index ad13984..0000000 Binary files a/docs/source/ipynb/WetCircles_files/WetCircles_1_0.png and /dev/null differ diff --git a/docs/source/ipynb/WetCircles_files/WetCircles_2_3.png b/docs/source/ipynb/WetCircles_files/WetCircles_2_3.png deleted file mode 100644 index db85e72..0000000 Binary files a/docs/source/ipynb/WetCircles_files/WetCircles_2_3.png and /dev/null differ diff --git a/docs/source/ipynb/WetCircles_files/WetCircles_3_1.png b/docs/source/ipynb/WetCircles_files/WetCircles_3_1.png deleted file mode 100644 index 1d21a56..0000000 Binary files a/docs/source/ipynb/WetCircles_files/WetCircles_3_1.png and /dev/null differ diff --git a/docs/source/ipynb/WetCircles_files/WetCircles_3_2.png b/docs/source/ipynb/WetCircles_files/WetCircles_3_2.png deleted file mode 100644 index f25b330..0000000 Binary files a/docs/source/ipynb/WetCircles_files/WetCircles_3_2.png and /dev/null differ diff --git a/docs/source/ipynb/WetCircles_files/WetCircles_3_3.png b/docs/source/ipynb/WetCircles_files/WetCircles_3_3.png deleted file mode 100644 index 4a4620f..0000000 Binary files a/docs/source/ipynb/WetCircles_files/WetCircles_3_3.png and /dev/null differ diff --git a/requirements-doc.txt b/requirements-doc.txt index 5067fcf..ee4cd69 100644 --- a/requirements-doc.txt +++ b/requirements-doc.txt @@ -1,3 +1,7 @@ sphinx sphinx_rtd_theme sphinxcontrib-bibtex +nbsphinx +pandoc +ipython +ipykernel diff --git a/xdesign/acquisition.py b/xdesign/acquisition.py index d4ca3f7..1741188 100644 --- a/xdesign/acquisition.py +++ b/xdesign/acquisition.py @@ -46,11 +46,21 @@ # POSSIBILITY OF SUCH DAMAGE. # # ######################################################################### +""" +Defines objects and methods for simulated data acquisition. + +The acquistion module contains the objects and procedures necessary to simulate +the operation of equipment used to collect tomographic data. This not only +includes physical things like Probes, detectors, turntables, and lenses, but +also non-physical things such as scanning patterns and programs. + +.. moduleauthor:: Doga Gursoy +""" + from __future__ import (absolute_import, division, print_function, unicode_literals) import numpy as np -from numbers import Number from xdesign.geometry import * from xdesign.geometry import halfspacecirc import logging @@ -71,14 +81,6 @@ 'raster_scan', 'angle_scan'] -"""Define objects and methods for simulated data acquisition. - -The acquistion module contains the objects and procedures necessary to simulate -the operation of equipment used to collect tomographic data. This not only -includes physical things like Probes, detectors, turntables, and lenses, but -also non-physical things such as scanning patterns and programs. -""" - class Beam(Line): """A thick line in 2-D cartesian space. @@ -97,8 +99,6 @@ class Beam(Line): # be merged with Probe. def __init__(self, p1, p2, size=0): """Return a new Beam from two given points and optional size.""" - if not isinstance(size, Number): - raise TypeError("Size must be scalar.") super(Beam, self).__init__(p1, p2) self.size = float(size) self.count = 0 diff --git a/xdesign/algorithms.py b/xdesign/algorithms.py index d54d452..c864cd9 100644 --- a/xdesign/algorithms.py +++ b/xdesign/algorithms.py @@ -46,6 +46,20 @@ # POSSIBILITY OF SUCH DAMAGE. # # ######################################################################### +"""Defines methods for reconstructing data from the :mod:`.acquisition` module. + +The algorithm module contains methods for reconstructing tomographic data +including gridrec, SIRT, ART, and MLEM. These methods can be used as benchmarks +for custom reconstruction methods or as an easy way to access reconstruction +algorithms for developing other methods such as noise correction. + +.. note:: + Using `tomopy ` is recommended instead + of these functions for heavy computation. + +.. moduleauthor:: Doga Gursoy +""" + from __future__ import (absolute_import, division, print_function, unicode_literals) @@ -60,14 +74,6 @@ __docformat__ = 'restructuredtext en' __all__ = ['art', 'sirt', 'mlem', 'stream', 'update_progress'] -"""Defines unoptimized implementations of popular reconstruction methods. - -The algorithm module contains methods for reconstructing tomographic data -including gridrec, SIRT, ART, and MLEM. These methods can be used as benchmarks -for custom reconstruction methods or as an easy way to access reconstruction -algorithms for developing other methods such as noise correction. -""" - def update_progress(progress): """Draw a process bar in the terminal. diff --git a/xdesign/geometry.py b/xdesign/geometry.py index fb41f2e..5e72a95 100644 --- a/xdesign/geometry.py +++ b/xdesign/geometry.py @@ -45,7 +45,12 @@ # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # # POSSIBILITY OF SUCH DAMAGE. # # ######################################################################### +"""Defines geometric objects to support :class:`.Phantom` definition and +perform compuational geometry for :mod:`.acquisition`. +.. moduleauthor:: Doga Gursoy +.. moduleauthor:: Daniel J Ching +""" from __future__ import (absolute_import, division, print_function, unicode_literals) @@ -62,7 +67,7 @@ logger = logging.getLogger(__name__) -__author__ = "Doga Gursoy" +__author__ = "Daniel Ching, Doga Gursoy" __copyright__ = "Copyright (c) 2016, UChicago Argonne, LLC." __docformat__ = 'restructuredtext en' __all__ = ['Entity', @@ -78,7 +83,40 @@ class Entity(object): """Base class for all geometric entities. All geometric entities should - have these attributes and methods.""" + have these attributes and methods. + + Example + ------- + Examples can be given using either the ``Example`` or ``Examples`` + sections. Sections support any reStructuredText formatting, including + literal blocks:: + + $ python example_numpy.py + + + Section breaks are created with two blank lines. Section breaks are also + implicitly created anytime a new section starts. Section bodies *may* be + indented: + + Parameters + ---------- + x : :class:`.ndarray`, :class:`.list` + ND coordinates of the point. + + Notes + ----- + This is an example of an indented section. It's like any other section, + but the body is indented to help it stand out from surrounding text. + + If a section is indented, then a section break is created by + resuming unindented text. + + + .. note:: + There are many other directives such as versionadded, versionchanged, + rubric, centered, ... See the sphinx documentation for more details. + + """ def __init__(self): self._dim = 0 @@ -168,12 +206,15 @@ def midpoint(self, other): class Point(Entity): """A point in ND cartesian space. - Takes either a 1D array-like object as the parameter for construction. - - Attributes + Parameters ---------- - _x : :class:`.ndarray` + x : :class:`.ndarray`, :class:`.list` ND coordinates of the point. + + Raises + ------ + TypeError + If x is not a list or ndarray. """ def __init__(self, x): if not isinstance(x, (list, np.ndarray)): diff --git a/xdesign/material.py b/xdesign/material.py index 977c91a..b45a932 100644 --- a/xdesign/material.py +++ b/xdesign/material.py @@ -45,6 +45,11 @@ # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # # POSSIBILITY OF SUCH DAMAGE. # # ######################################################################### +"""Defines objects which auto-generate a parameterized :class:`.Phantom`. + +.. moduleauthor:: Daniel J Ching +""" + from __future__ import (absolute_import, division, print_function, unicode_literals) @@ -152,11 +157,10 @@ def number_of_elements(self): class XDesignDefault(Phantom): """Generates a Phantom for internal testing of XDesign. - The default phantom is: - nested, it contains phantoms within phantoms; - geometrically simple, the sinogram can be verified visually; and - representative, it contains the three main geometric elements: circle, - polygon, and mesh. + The default phantom is: **nested**, it contains phantoms within phantoms; + **geometrically simple**, the sinogram can be verified visually; and + **representative**, it contains the three main geometric elements: circle, + polygon, and mesh. """ def __init__(self): diff --git a/xdesign/metrics.py b/xdesign/metrics.py index 99be338..929dfd3 100644 --- a/xdesign/metrics.py +++ b/xdesign/metrics.py @@ -45,7 +45,10 @@ # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # # POSSIBILITY OF SUCH DAMAGE. # # ######################################################################### +"""Objects and methods for computing the quality of reconstructions. +.. moduleauthor:: Daniel J Ching +""" from __future__ import (absolute_import, division, print_function, unicode_literals) @@ -269,7 +272,7 @@ def compute_mtf_ffst(phantom, image, Ntheta=4): def compute_mtf_lwkj(phantom, image): """Calculate the MTF using the modulated Siemens Star method in - Loebich et al. (2007). + :cite:`loebich2007digital`. parameters ---------- diff --git a/xdesign/phantom.py b/xdesign/phantom.py index b98aced..c4ac5ec 100644 --- a/xdesign/phantom.py +++ b/xdesign/phantom.py @@ -46,6 +46,11 @@ # POSSIBILITY OF SUCH DAMAGE. # # ######################################################################### +"""Defines an object for simulating X-ray phantoms. + +.. moduleauthor:: Daniel J Ching +""" + from __future__ import (absolute_import, division, print_function, unicode_literals) diff --git a/xdesign/plot.py b/xdesign/plot.py index 5c3cbf4..89569db 100644 --- a/xdesign/plot.py +++ b/xdesign/plot.py @@ -46,6 +46,12 @@ # POSSIBILITY OF SUCH DAMAGE. # # ######################################################################### +"""Contains functions for visualizing :class:`.Phantom` and +:class:`.ImageQuality` metrics. + +.. moduleauthor:: Daniel J Ching +""" + from __future__ import (absolute_import, division, print_function, unicode_literals) @@ -245,7 +251,7 @@ def plot_polygon(polygon, axis=None, alpha=None, c=None): def plot_curve(curve, axis=None, alpha=None, c=None): - """Plots a :class:`.Curve' to the given axis. + """Plots a :class:`.Curve` to the given axis. Parameters ----------