.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "demos\02_algorithms\d20_Algorithms05.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_02_algorithms_d20_Algorithms05.py: FISTA with a TV proximal step ============================= FISTA, which reaches a TV-regularised solution faster than gradient methods. Source: `Python/demos/d20_Algorithms05.py `__ ยท `MATLAB/Demos/d20_Algorithms05.m `__ .. dropdown:: MATLAB version of this demo :icon: code .. literalinclude:: /../MATLAB/Demos/d20_Algorithms05.m :language: matlab .. GENERATED FROM PYTHON SOURCE LINES 17-19 Initialize ---------- .. GENERATED FROM PYTHON SOURCE LINES 19-27 .. 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 from matplotlib import pyplot as plt .. GENERATED FROM PYTHON SOURCE LINES 28-30 Geometry -------- .. GENERATED FROM PYTHON SOURCE LINES 30-33 .. code-block:: Python geo = tigre.geometry_default(high_resolution=False) .. GENERATED FROM PYTHON SOURCE LINES 34-36 Load data and generate projections ---------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 36-76 .. code-block:: Python # define angles angles = np.linspace(0, 2 * np.pi, 100, endpoint=False) # 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])) ## FISTA is a quadratically converging algorithm. # 'hyper': This parameter should approximate the largest # eigenvalue in the A matrix in the equation Ax-b and Atb. # Empirical tests show that for, the headphantom object: # # geo.nVoxel = [64,64,64]' , hyper (approx=) 2.e8 # geo.nVoxel = [512,512,512]' , hyper (approx=) 2.e4 # Default: 2.e8 # 'tviter': Number of iterations of Im3ddenoise to use. Default: 20 # 'lambda': Multiplier for the tvlambda used, which is proportional to # L (hyper). Default: 0.1 # 'verbose': get feedback or not. Default: 1 # -------------------------------------------------------------------------- imgFISTA_default = algs.fista(noise_projections, geo, angles, 100) ## Adding a different hyper parameter imgFISTA_hyper = algs.fista(noise_projections, geo, angles, 100, hyper=2.0e6) ## Recon more significant tv parameters imgFISTA_hightv = algs.fista( noise_projections, geo, angles, 100, hyper=2.0e6, tviter=100, tvlambda=20 ) ## Plot results tigre.plotimg( np.concatenate([imgFISTA_default, imgFISTA_hyper, imgFISTA_hightv], axis=1), dim="z", clims=[0, 1], ) .. image-sg:: /demos/02_algorithms/images/sphx_glr_d20_Algorithms05_001.gif :alt: d20 Algorithms05 :srcset: /demos/02_algorithms/images/sphx_glr_d20_Algorithms05_001.gif :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none using SVD power method to calculate Lipschitz const error for val is:inf error for val is:20.288054 error for val is:14.836177 error for val is:14.145595 error for val is:14.238516 error for val is:14.48735 error for val is:14.75272 error for val is:15.006372 error for val is:15.24479 error for val is:15.469367 FISTA: estimated hyper (Lipschitz constant) = 7.511e+05 (2 x sigma_max(A)^2 via svd_power_method) FISTA algorithm in progress. Estimated time until completion : 00:00:03 Algorithm will finish at : 16:51:07 FISTA algorithm in progress. Estimated time until completion : 00:00:02 Algorithm will finish at : 16:51:08 FISTA algorithm in progress. Estimated time until completion : 00:00:02 Algorithm will finish at : 16:51:11 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 15.916 seconds) .. _sphx_glr_download_demos_02_algorithms_d20_Algorithms05.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: d20_Algorithms05.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: d20_Algorithms05.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: d20_Algorithms05.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_