diff --git a/docs/source/_static/api_objects/objects2d_notations.png b/docs/source/_static/api_objects/objects2d_notations.png new file mode 100644 index 0000000..4df668e Binary files /dev/null and b/docs/source/_static/api_objects/objects2d_notations.png differ diff --git a/docs/source/_static/api_objects/objects_notations.svg b/docs/source/_static/api_objects/objects_notations.svg new file mode 100644 index 0000000..4ddc279 --- /dev/null +++ b/docs/source/_static/api_objects/objects_notations.svg @@ -0,0 +1,326 @@ + + + + + + + + + + + + + + + + + + + + + + X + Y + + + + + 0 + -0.5 + -0.5 + 0.5 + 0.5 + (0,0) + (x0,y0) + a + C0 + b + + φ + + + + + diff --git a/docs/source/_static/tomophantom.png b/docs/source/_static/tomophantom.png deleted file mode 100644 index 77ce416..0000000 Binary files a/docs/source/_static/tomophantom.png and /dev/null differ diff --git a/docs/source/_static/tomophantom_logo.svg b/docs/source/_static/tomophantom_logo.svg index 24a494c..d60bee8 100644 --- a/docs/source/_static/tomophantom_logo.svg +++ b/docs/source/_static/tomophantom_logo.svg @@ -7,7 +7,7 @@ viewBox="0 0 297 210" version="1.1" id="SVGRoot" - inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)" + inkscape:version="1.2.2 (b0a8486541, 2022-12-01)" sodipodi:docname="tomophantom_logo.svg" inkscape:export-filename="/mnt/62ec4fe7-c838-4b3c-b11d-6d2fdf796bb1/algol/Documents/DEV/tomophantom3/docs/img/tomophantom_light.png" inkscape:export-xdpi="40" @@ -27,20 +27,23 @@ borderopacity="0" inkscape:pageopacity="0" inkscape:pageshadow="2" - inkscape:zoom="0.22627417" - inkscape:cx="-342.50485" - inkscape:cy="1005.4175" + inkscape:zoom="0.90509668" + inkscape:cx="712.63105" + inkscape:cy="382.2796" inkscape:document-units="mm" - inkscape:current-layer="g6451" + inkscape:current-layer="g6615" showgrid="false" - inkscape:window-width="1850" - inkscape:window-height="1016" - inkscape:window-x="70" - inkscape:window-y="27" + inkscape:window-width="1920" + inkscape:window-height="1011" + inkscape:window-x="0" + inkscape:window-y="32" inkscape:window-maximized="1" inkscape:snap-center="true" showguides="true" - inkscape:pagecheckerboard="false" /> + inkscape:pagecheckerboard="false" + inkscape:showpageshadow="2" + inkscape:deskcolor="#d1d1d1" + showborder="true" /> + id="feComposite2565" + k2="0" + k4="0" /> + id="feComposite2731" + k1="0" + k4="0" /> + gradientTransform="matrix(0.23113515,0,0,0.23113515,170.56748,60.643777)" /> + gradientTransform="matrix(0.1344286,0,0,0.13442859,59.133731,141.2209)" /> - + gradientTransform="matrix(0.12030485,0,0,0.12030485,92.590949,139.2881)" /> + gradientTransform="matrix(0.10455366,0,0,0.10455366,182.13365,27.331318)" /> + gradientTransform="matrix(0.10120422,0,0,0.10120422,202.78902,-20.878116)" /> + gradientTransform="matrix(0.1061106,0,0,0.10611059,196.67144,-59.571512)" /> + gradientTransform="matrix(0.1207191,0,0,0.1207191,202.39579,-92.162444)" /> + gradientTransform="matrix(0.11851464,0,0,0.11851465,186.83622,-119.2024)" /> + gradientTransform="matrix(0.11240678,0,0,0.11240678,155.25245,-161.53413)" /> + gradientTransform="matrix(0.1344286,0,0,0.1344286,139.48445,106.84342)" /> @@ -418,15 +415,15 @@ id="feBlend5797" /> + x="-0.17148412" + width="1.3429682"> - - + + + + + + + @@ -952,299 +964,302 @@ inkscape:export-filename="/mnt/62ec4fe7-c838-4b3c-b11d-6d2fdf796bb1/algol/Documents/DEV/tomophantom3/docs/source/_static/tomophantom_logo_light.png" inkscape:export-xdpi="49.992844" inkscape:export-ydpi="49.992844"> - - - - - - T - o - m - P - h - a - n - t - o - m - o - + + + + + + + o + m + h + a + n + t + o + m + o + T - P - T + m - m + o - o + m - m + h - h + a - a + n - n + t - t + o - o + o + style="font-style:normal;font-weight:normal;font-size:79.2008px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:url(#linearGradient6381);fill-opacity:1;stroke:none;stroke-width:0.412504;filter:url(#filter6057)" + xml:space="preserve">o + P + T + diff --git a/docs/source/_static/tomophantom_logo_dark.png b/docs/source/_static/tomophantom_logo_dark.png index 2956892..febcce0 100644 Binary files a/docs/source/_static/tomophantom_logo_dark.png and b/docs/source/_static/tomophantom_logo_dark.png differ diff --git a/docs/source/_static/tomophantom_logo_light.png b/docs/source/_static/tomophantom_logo_light.png index 2956892..fc4bfe8 100644 Binary files a/docs/source/_static/tomophantom_logo_light.png and b/docs/source/_static/tomophantom_logo_light.png differ diff --git a/docs/source/_static/tomophantom_logo_transp.png b/docs/source/_static/tomophantom_logo_transp.png deleted file mode 100644 index fcc7346..0000000 Binary files a/docs/source/_static/tomophantom_logo_transp.png and /dev/null differ diff --git a/docs/source/conf.py b/docs/source/conf.py index edd2329..7863bb8 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -5,8 +5,7 @@ import os import sys from datetime import date - -# from unittest import mock +from unittest import mock # If extensions (or modules to document with autodoc) are in another directory, @@ -16,25 +15,42 @@ sys.path.insert(0, os.path.abspath("../..")) # -- Mock imports ------------------------------------------------------------- +MOCK_MODULES = [ + "ctypes", + "tomophantom.ctypes", + "tomophantom.ctypes.dtype", + "tomophantom.ctypes.external", + "scipy.special", + "scipy.ndimage", + "tomophantom.supp.speckle_routines", +] + +for mod_name in MOCK_MODULES: + sys.modules[mod_name] = mock.Mock() + +autodoc_mock_imports = [ + "ctypes", + "tomophantom.ctypes", + "tomophantom.ctypes.dtype", + "tomophantom.ctypes.external", + "scipy.special", + "scipy.ndimage", + "tomophantom.supp.speckle_routines", +] -# Mock imports instead of full environment in readthedocs -# MOCK_MODULES = [ -# "numpy", -# "PIL", -# "skimage", -# "scipy", -# "scipy.fft", -# "scipy.ndimage", -# ] +class CustomMock(mock.Mock): + def __repr__(self): + return "" -# for mod_name in MOCK_MODULES: -# sys.modules[mod_name] = mock.Mock() + +sys.modules["numpy"] = CustomMock() # ------------------------------------------------------------------------------ project = "Tomophantom" -# copyright = f"{date.today().year}, Diamond Light Source" +author = "Daniil Kazantsev" +copyright = f"{date.today().year}, Diamond Light Source and Manchester University, UK" # Specify a base language to help assistive technology language = "en" @@ -57,9 +73,11 @@ # Add links to highlighted source code "sphinx.ext.viewcode", # Allows a grid layout and dropdown boxes - "sphinx_panels", + "sphinx_design", # copy to clipboard button "sphinx_copybutton", + # use jupyter notebooks + "nbsphinx", #'IPython.sphinxext.ipython_console_highlighting', "sphinx.ext.githubpages", # Generate .nojekyll file for git pages build @@ -83,13 +101,6 @@ html_static_path = ["_static"] html_use_smartypants = True -""" -html_theme_options = { - "logo_only": True, - "display_version": False, - "githuburl": "https://github.com/dkazanc/TomoPhantom", -} -""" html_theme_options = { "logo": { diff --git a/docs/source/doc-conda-requirements.yml b/docs/source/doc-conda-requirements.yml index d978ccb..bddc0c0 100644 --- a/docs/source/doc-conda-requirements.yml +++ b/docs/source/doc-conda-requirements.yml @@ -1,17 +1,15 @@ name: tomophantom-docs channels: - conda-forge - - defaults - - httomo dependencies: - - python=3.10 - - tomophantom + - python>=3.10 + - scipy - sphinx - sphinx-book-theme - nbsphinx - pandoc - jinja2 - - sphinx-panels + - sphinx-design - sphinx-copybutton - pyyaml - ipython diff --git a/docs/source/howto/build_phantoms.rst b/docs/source/howto/build_phantoms.rst new file mode 100644 index 0000000..196f812 --- /dev/null +++ b/docs/source/howto/build_phantoms.rst @@ -0,0 +1,10 @@ +.. _howto_buildphantoms: + +Build Phantoms +============== + +This sections explains how to build phantoms and also describes different ways of doing that. + +* 1. The easiest and quickest way to build a phantom is to use provided library files, see more in :ref:`howto_libraries`. For someone who is new to TomoPhantom, we recommend to play with already existing models, check this guide and also demos. + +* 2. blabla \ No newline at end of file diff --git a/docs/source/howto/libraries.rst b/docs/source/howto/libraries.rst new file mode 100644 index 0000000..fea1475 --- /dev/null +++ b/docs/source/howto/libraries.rst @@ -0,0 +1,38 @@ +.. _howto_libraries: + +Use Phantom Libraries +===================== + +TomoPhantom provides a number of phantoms for users that can be used `out-of-the-box`. +There are static (2D, 3D) or dynamic (2D+time, 3D+time) phantoms with the parameters for them stored in :ref:`ref_glossary_library`. + +The users can generate phantoms by specifying a :ref:`ref_glossary_model` number from the associated library file. +Alternatively, more experienced user can build a phantom using :ref:`ref_glossary_object` API. + + +.. _howto_2d_libs: + +Library file for 2D phantoms +---------------------------- + +.. dropdown:: The library file with 2D models + dynamic extensions + + .. literalinclude:: ../../../tomophantom/phantomlib/Phantom2DLibrary.dat + + +.. _howto_3d_libs: + +Library file for 3D phantoms +---------------------------- + +.. dropdown:: The library file with 3D models + dynamic extensions + + .. literalinclude:: ../../../tomophantom/phantomlib/Phantom3DLibrary.dat + + +See more on :ref:`ref_library_files_api` where library files syntax explained. It is also useful if one is interested in adding new or modifying the existing phantoms [#f1]_. + +.. rubric:: Footnotes + +.. [#f1] The generation of new phantoms is highly encouraged and the resulting models can be added to the repo. Please submit a pull requests for that through the Github page of the repository. + diff --git a/docs/source/howto/simulate.rst b/docs/source/howto/simulate.rst new file mode 100644 index 0000000..1eba2b2 --- /dev/null +++ b/docs/source/howto/simulate.rst @@ -0,0 +1,7 @@ +.. _howto_simulate: + +Use Artefacts Simulator +======================= + +TomoPhantom comes with an artefacts simulator that can add a variety of imaging inaccuracies and noise, therefore aiming to emulate real imaging artefacts. +While more detailed information needs to be added, please see the API for :func:`tomophantom.artefacts`. \ No newline at end of file diff --git a/docs/source/index.rst b/docs/source/index.rst index 9e8787a..335ec42 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -7,8 +7,7 @@ :maxdepth: 2 :glob: - introduction/about - introduction/libraries + introduction/about .. _how_to_content: @@ -16,7 +15,10 @@ :caption: How To's :maxdepth: 2 - howto/installation + howto/installation + howto/build_phantoms + howto/libraries + howto/simulate .. _reference_content: @@ -24,4 +26,7 @@ :caption: Reference guides :maxdepth: 2 + reference/library_files_api + reference/object_api + reference/glossary reference/api diff --git a/docs/source/introduction/libraries.rst b/docs/source/introduction/libraries.rst deleted file mode 100644 index f37141a..0000000 --- a/docs/source/introduction/libraries.rst +++ /dev/null @@ -1,15 +0,0 @@ -Phantom Libraries -******************* - -TomoPhantom provides a variety of phantoms that are static (2D,3D) and dynamic one (3D, 4D). -The users can start using them right away by specifying a **model** number from -the associated library file. Model is usually reffered to a combined phantom which -consists of simpler geometrical **objects**. Note that objects can be -also build independently, please see :ref:`ref_api`. - -`Phantom2DLibrary.dat` and `Phantom3DLibrary.dat` are editable -text files located in `tomophantom/phantomlib` folder with parametrised models. -For instance, 2D/3D versions of Shepp-Logan, Defrise, and QRM phantoms. - -The generation of new phantoms is highly encouraged, -please submit them through the pull requests to the repo. \ No newline at end of file diff --git a/docs/source/reference/api.rst b/docs/source/reference/api.rst index 9ae3a45..d74c211 100644 --- a/docs/source/reference/api.rst +++ b/docs/source/reference/api.rst @@ -4,12 +4,10 @@ API reference ========================== -This section contains the API reference and usage information for Tomophantom. +This section contains the references to Tomophantom's API. Tomophantom Modules -------------------- -v.3.0 -''''' .. toctree:: :glob: diff --git a/docs/source/reference/glossary.rst b/docs/source/reference/glossary.rst new file mode 100644 index 0000000..e57dd20 --- /dev/null +++ b/docs/source/reference/glossary.rst @@ -0,0 +1,40 @@ +.. _ref_glossary: + +Glossary +======== + +As some terms used in TomoPhantom can be ambiguous, we provide explanations on the terminology used. + +.. _ref_glossary_model: + +Model +----- + +The **model** term here describes a phantom and also associated projection data that can be generated for it. Normally model +consists of the number of elementary geometrical **objects**. Note that objects can be +also build independently, please see :ref:`ref_api`. For instance, 2D/3D versions of Shepp-Logan, Defrise, and QRM phantoms. +:mod:`tomophantom.TomoP2D.model`. + +.. _ref_glossary_dynamic_model: + +Dynamic model +------------- + +.. _ref_glossary_object: + +Object +------ + +Object blabla + + +.. _ref_glossary_library: + +Library files +------------- + +Library files are the text files which are provided to users with the downloaded repository or installation. Different phantoms are hardcoded using parameters +in the files. 2D phantoms and their dynamic extenstions are stored in the :data:`Phantom2DLibrary.dat` file, while 3D phantoms and their dynamic +extensions are stored in the :data:`Phantom3DLibrary.dat` file. The files are located in the `tomophantom/phantomlib` folder. + + diff --git a/docs/source/reference/library_files_api.rst b/docs/source/reference/library_files_api.rst new file mode 100644 index 0000000..5112759 --- /dev/null +++ b/docs/source/reference/library_files_api.rst @@ -0,0 +1,120 @@ +.. _ref_library_files_api: + +Library files API +================= + +There is a certain API protocol how the user should define objects in the :ref:`ref_glossary_library`. + + +.. _ref_library_files_api2d: + +Library files for 2D models +--------------------------- + +Let us consider a 2D model no. 1 (a classical Shepp-Logan phantom) as an example from the :data:`Phantom2DLibrary.dat` file. + +.. code-block:: text + + #---------------------------------------------------- + # Classical Shepp-Logan phantom (10 ellipses) + Model : 01; + Components : 10; + TimeSteps : 1; + Object : ellipse 1.0 0.0 0.0 0.69 0.92 0.0; + Object : ellipse -0.8 0.0184 0.0 0.6624 0.874 0.0; + Object : ellipse -0.2 0.0 0.22 0.11 0.31 18.0; + Object : ellipse -0.2 0.0 -0.22 0.16 0.41 -18.0; + Object : ellipse 0.1 -0.35 0.0 0.21 0.25 0.0; + Object : ellipse 0.1 -0.1 0.0 0.046 0.046 0.0; + Object : ellipse 0.1 0.1 0.0 0.046 0.046 0.0; + Object : ellipse 0.1 0.605 -0.08 0.046 0.023 0.0; + Object : ellipse 0.1 0.605 0.0 0.023 0.023 0.0; + Object : ellipse 0.1 0.605 0.06 0.023 0.046 0.0; + #---------------------------------------------------- + +.. note:: All the lines starting with the :code:`#` symbol will be parsed into comments. Also each line must end with the :code:`;` symbol. + +* 1. :code:`Model : 01;` this is how the unique model number should be specified. Please note that the numbers [0-99] are reserved for static phantoms while 100 and larger for dynamic extensions. +* 2. :code:`Components : 10;` Here one should specify the number of components present in that model. +* 3. :code:`TimeSteps : 1;` TimeSteps are only relevant for :ref:`ref_glossary_dynamic_model` and for a stationary object this should be set to 1. +* 4. :code:`Object : ellipse 1.0 0.0 0.0 0.69 0.92 0.0;` This is where the name of the elementary function and its parameters should be set. Here :code:`Object :` is a necessary syntax to initiate an object build. + +Let us look at this line in detail: + +.. code-block:: text + + Object : ellipse 1.0 0.0 0.0 0.69 0.92 0.0; + +TomoPhantom converts this string of 7 parameters [#f2]_ into the following behind the scenes: + +.. code-block:: text + + objects_name="ellipse" + C0=1.0 + x0=0.0 + y0=0.0 + a=0.69 + b=0.92 + angle=0.0 + +As we move here into the :ref:`ref_glossary_object` API territory, it is best to re-direct the reader to the :ref:`ref_object_2d` section. There the meaning of each parameter of a 2D object is explained in detail. + + +.. _ref_library_files_api3d: + +Library files for 3D models +--------------------------- + +3D models and the dynamic phantoms from the :data:`Phantom3DLibrary.dat` file are similar to 2D, but with the addition of few parameters. For instance, the 3D model 13 is given as: + +.. code-block:: text + + #---------------------------------------------------- + # 3D Shepp-Logan + Model : 13; + Components : 10; + TimeSteps : 1; + Object : ellipsoid 1.0 0.0 0.0 0.0 0.69 0.92 0.81 0.0 0.0 0.0 + Object : ellipsoid -0.8 0.0184 0.0 0.0 0.6624 0.874 0.78 0.0 0.0 0.0 + Object : ellipsoid -0.2 0.0 0.22 0.0 0.11 0.31 0.22 18.0 0.0 0.0 + Object : ellipsoid -0.2 0.0 -0.22 0.0 0.16 0.41 0.28 -18.0 0.0 0.0 + Object : ellipsoid 0.1 -0.35 0.0 -0.15 0.21 0.250 0.41 0.0 0.0 0.0 + Object : ellipsoid 0.1 -0.1 0.0 0.0 0.046 0.046 0.05 0.0 0.0 0.0 + Object : ellipsoid 0.1 0.1 0.0 0.0 0.046 0.046 0.05 0.0 0.0 0.0 + Object : ellipsoid 0.1 0.605 -0.08 0.0 0.046 0.023 0.05 0.0 0.0 0.0 + Object : ellipsoid 0.1 0.606 0.0 0.0 0.023 0.023 0.02 0.0 0.0 0.0 + Object : ellipsoid 0.1 0.605 0.06 0.0 0.023 0.046 0.02 0.0 0.0 0.0 + #---------------------------------------------------- + +and the objects definition is getting longer: + +.. code-block:: text + + Object : ellipsoid 1.0 0.0 0.0 0.0 0.69 0.92 0.81 0.0 0.0 0.0 + +Which is converted into the following: + +.. code-block:: text + + objects_name="ellipsoid" + C0=1.0 + x0=0.0 + y0=0.0 + z0=0.0 + a=0.69 + b=0.92 + c=0.81 + angle1=0.0 + angle2=0.0 + angle3=0.0 + +Again, for more in-depth read about parameters of 3D objects see :ref:`ref_object_api3d`. + +.. rubric:: Footnotes + +.. [#f2] The developers do understand that the choice of the text format to represent configuration files for libraries might not be the best choice. Potentially choosing YAML language instead would make parameters for objects more informative and readable. However, the choice of text file libraries was historically inherited from the initial implementation of software in C. Of course, it would be great to refactor it at some point. + + + + + diff --git a/docs/source/reference/object_api.rst b/docs/source/reference/object_api.rst new file mode 100644 index 0000000..ed9e006 --- /dev/null +++ b/docs/source/reference/object_api.rst @@ -0,0 +1,69 @@ +.. _ref_object_api: + +Object API +========== + +.. _ref_object_2d: + +Parameters of 2D objects explained +---------------------------------- + +There are 7 parameters in total to describe an object. + +.. dropdown:: 1. object's name, type: string + + For 2D phantoms the accepted objects names are :code:`gaussian`, :code:`parabola`, :code:`parabola1`, :code:`ellipse`, :code:`cone` and :code:`rectangle`. See more in the TomoPhantom paper [SX2018]_ for analytical formulae. + +.. dropdown:: 1. C0 - intensity level, type: float + + :math:`C_{0}` defines the grayscale intensity level (see :numref:`fig_objects2d_notations`), given as a floating point number. :math:`C_{0}` can be either negative or positive. Objects in the model are concatenated by summation, so one can do a subtraction of objects by defining negative intensities. + +.. _fig_objects2d_notations: +.. figure:: ../_static/api_objects/objects2d_notations.png + :scale: 50 % + :alt: Notation for a 2D object + + The coordinate system in which objects are defined. Note the location of :math:`X` and :math:`Y` axes and the ranges for the visible field of view. Parameters describing a 2D object are: object's name, :math:`C_{0}`, :math:`x_{0}`, :math:`y_{0}`, :math:`a`, :math:`b` and angle :math:`\phi`. + +.. _ref_object_api2d: + +Parameters of 2D object in library file +--------------------------------------- + +Let us look at this line in detail: + +.. code-block:: text + + Object : ellipse 1.0 0.0 0.0 0.69 0.92 0.0; + +TomoPhantom converts this string of 7 parameters for 2D model into the following behind the scenes: + +.. code-block:: text + + objects_name="ellipse" + C0=1.0 + x0=0.0 + y0=0.0 + a=0.69 + b=0.92 + angle=0.0 + + +.. _ref_object_api_python2d: + +Defining 2D object in Python +---------------------------- + + + +.. _ref_object_3d: + +Parameters of 3D objects explained +---------------------------------- + + +.. _ref_object_api3d: + +Parameters of 3D object in library file +--------------------------------------- + diff --git a/pyproject.toml b/pyproject.toml index 81f760a..a4c32cb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta" [tool.setuptools] include-package-data = true packages = ["tomophantom", - "tomophantom.ctypes", + "tomophantom.ctypes", "tomophantom.supp", ] @@ -27,9 +27,8 @@ classifiers = [ "Development Status :: 4 - Beta", "License :: OSI Approved :: BSD 3-clause", "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.9", ] -requires-python = ">=3.9" +requires-python = ">=3.10" dynamic = ["version"] dependencies = [ "numpy", diff --git a/tomophantom/TomoP2D.py b/tomophantom/TomoP2D.py index 9ad53e2..6ca452e 100644 --- a/tomophantom/TomoP2D.py +++ b/tomophantom/TomoP2D.py @@ -1,21 +1,15 @@ -""" -Copyright 2023 -The University of Manchester & Diamond Light Source -Licensed under the Apache License, Version 2.0. - - -These are modules for generation of 2D and 3D (dynamic extensions) -phantoms and their analytical data. +"""Modules for generating 2D synthetic phantoms and their analytical projection data. The dynamic extensions of 2D phantoms (resulting in 3D arrays) can also be generated. API Summary: -* Model - generates a 2D phantom from the Library (Phantom2DLibrary) -* ModelTemporal - generates a (2D+t) 3D model from the Library (Phantom2DLibrary) -* ModelSino - generates 2D sinogram for a model from the Library (Phantom2DLibrary) -* ModelSinoTemporal - generates (2D+t) sinogram for a temporal model from the Library (Phantom2DLibrary) -* Object - generates a 2D phantom from a given object described in the dictionary. +* :func:`Model` - generates a 2D phantom from :ref:`howto_2d_libs`. +* :func:`ModelTemporal` - generates a dynamic (2D+t) phantom from :ref:`howto_2d_libs`. +* :func:`ModelSino` - generates a 2D sinogram for a model from :ref:`howto_2d_libs`. +* :func:`ModelSinoTemporal` - generates a dynamic (2D+t) sinogram for a temporal model from :ref:`howto_2d_libs`. +* :func:`Object` - generates one elementary object from the provided parameters, see . * ObjectSino - generates a 2D sinogram from a given object described in the dictionary. * SinoNum - calculates a sinogram numerically from any given 2D array. + """ import ctypes @@ -232,15 +226,16 @@ def ModelSinoTemporal( def Object(phantom_size: int, obj_params: Union[list, dict]) -> np.ndarray: - """Generate a 2D analytical phantom for the standalone - geometrical object that is parametrised in the "obj_params" dictionary. + """Generates a 2D analytical phantom for the standalone + geometrical object that is parametrised in the "obj_params" dictionary. Multiple objects can be stacked together + by providing a list of dictionaries, where each dictionary associated with an object. See more in Args: phantom_size (int): A size of the phantom (squared). - obj_params (list of dict or a dict): A dictionary with parameters of an object, see Demos. + obj_params (a dict or a list of dict): A dictionary or a list of dictionaries with the parameters for object(s), see Demos. Returns: - np.ndarray: The generated 2D analytical object. + np.ndarray: The generated 2D analytical phantom. """ if type(obj_params) is dict: obj_params = [obj_params] diff --git a/tomophantom/__init__.py b/tomophantom/__init__.py index cb18e52..f7d14af 100644 --- a/tomophantom/__init__.py +++ b/tomophantom/__init__.py @@ -1,3 +1,4 @@ from tomophantom.artefacts import * +from tomophantom.flatsgen import * from tomophantom.TomoP2D import * from tomophantom.TomoP3D import * diff --git a/tomophantom/artefacts.py b/tomophantom/artefacts.py index 29b1eea..77d7020 100644 --- a/tomophantom/artefacts.py +++ b/tomophantom/artefacts.py @@ -1,9 +1,6 @@ -#!/usr/bin/env python3 -""" -Copyright 2023 -The University of Manchester & Diamond Light Source -Licensed under the Apache License, Version 2.0. +"""Modules to generate a variety of imaging artefacts. """ + import numpy as np import random from typing import Union, Any diff --git a/tomophantom/flatsgen.py b/tomophantom/flatsgen.py index 4599b1d..91ee278 100644 --- a/tomophantom/flatsgen.py +++ b/tomophantom/flatsgen.py @@ -1,14 +1,8 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -""" -Copyright 2023 -The University of Manchester & Diamond Light Source -Licensed under the Apache License, Version 2.0. +"""Modules to generate synthetic flats/darks and data. """ from scipy.special import spherical_yn -from scipy.ndimage import gaussian_filter -from scipy.ndimage import shift +from scipy.ndimage import gaussian_filter, shift import random import numpy as np from tomophantom.artefacts import noise @@ -28,7 +22,7 @@ def synth_flats( flatsnum: int = 20, ) -> list: """Function to generate synthetic flat field images and raw data for projection data normalisation. - This is more realistic modelling of stripes and various normalisation artefacts. + This is more realistic modelling of stripes and various artefacts rising after normalisation operation. Args: projData3D_clean (np.ndarray): 3D projection data of the following shape: (DetectorsVert, anglesDim, DetectorsHoriz).