.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "demos\03_geometry\d17_DetectorRotation.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_demos_03_geometry_d17_DetectorRotation.py: Detector rotation ================= Describe a detector that is rotated or tilted. Source: `Python/demos/d17_DetectorRotation.py `__ ยท `MATLAB/Demos/d17_DetectorRotation.m `__ .. dropdown:: MATLAB version of this demo :icon: code .. literalinclude:: /../MATLAB/Demos/d17_DetectorRotation.m :language: matlab .. GENERATED FROM PYTHON SOURCE LINES 17-19 Initialize ---------- .. GENERATED FROM PYTHON SOURCE LINES 19-26 .. code-block:: Python import tigre import numpy as np from tigre.utilities import sample_loader from tigre.utilities import CTnoise import tigre.algorithms as algs .. GENERATED FROM PYTHON SOURCE LINES 27-29 Geometry -------- .. GENERATED FROM PYTHON SOURCE LINES 29-32 .. code-block:: Python geo = tigre.geometry_default(high_resolution=False) .. GENERATED FROM PYTHON SOURCE LINES 33-35 Load data and generate projections ---------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 35-45 .. code-block:: Python # define angles angles = np.linspace(0, 2 * np.pi, 100, endpoint=False) roll = angles pitch = 0.7 * np.linspace(0, 1, len(angles)) yaw = 0.7 * np.linspace(0, 1, len(angles)) geo.rotDetector = np.array(np.vstack([roll, pitch, yaw])).T .. GENERATED FROM PYTHON SOURCE LINES 46-56 .. code-block:: Python # Load thorax phantom data head = sample_loader.load_head_phantom(geo.nVoxel) # generate projections projections = tigre.Ax(head, geo, angles) # add noise noise_projections = CTnoise.add(projections, Poisson=1e5, Gaussian=np.array([0, 10])) tigre.plotproj(projections, angles) .. image-sg:: /demos/03_geometry/images/sphx_glr_d17_DetectorRotation_001.gif :alt: d17 DetectorRotation :srcset: /demos/03_geometry/images/sphx_glr_d17_DetectorRotation_001.gif :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 57-59 recon ----- .. GENERATED FROM PYTHON SOURCE LINES 59-68 .. code-block:: Python imgRotDet = algs.ossart(projections, geo, angles, 50) #% No rotation geo.rotDetector = np.array([0, 0, 0]) projections2 = tigre.Ax(head, geo, angles) imgnoRot = algs.ossart(projections2, geo, angles, 50) .. rst-class:: sphx-glr-script-out .. code-block:: none OSSART algorithm in progress. Estimated time until completion : 00:00:03 Algorithm will finish at : 16:55:44 OSSART algorithm in progress. Estimated time until completion : 00:00:02 Algorithm will finish at : 16:55:46 .. GENERATED FROM PYTHON SOURCE LINES 69-71 Plot to show that indeed the reconstruction is right ---------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 71-73 .. code-block:: Python tigre.plotimg(np.concatenate([imgRotDet, imgnoRot], axis=1), dim="z") .. image-sg:: /demos/03_geometry/images/sphx_glr_d17_DetectorRotation_002.gif :alt: d17 DetectorRotation :srcset: /demos/03_geometry/images/sphx_glr_d17_DetectorRotation_002.gif :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 20.327 seconds) .. _sphx_glr_download_demos_03_geometry_d17_DetectorRotation.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: d17_DetectorRotation.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: d17_DetectorRotation.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: d17_DetectorRotation.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_