RTK/Scripts/3DCG: Difference between revisions

From Openrtk
Jump to navigation Jump to search
(Created page with "<div class="floatcenter">200px 200px</div> This script uses the file [http://midas3.kitware.com/midas/download?items=27326 SheppLog...")
 
No edit summary
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
<div class="floatcenter">[[File:sinogram.png|200px]] [[File:overlay.png|200px]]</div>
<div class="floatcenter">[[File:sinogram.png|200px]] [[File:overlay.png|200px]]</div>


This script uses the file [http://midas3.kitware.com/midas/download?items=27326 SheppLogan.txt] as input.
This script uses the file [https://data.kitware.com/api/v1/item/5b179c938d777f15ebe2020b/download SheppLogan.txt] as input.


<source lang="bash" enclose="div">
<source lang="bash" enclose="div">
Line 16: Line 16:
  # Create a reference volume for comparison
  # Create a reference volume for comparison
  rtkdrawgeometricphantom --spacing 2 --dimension 256 --phantomfile SheppLogan.txt -o ref.mha
  rtkdrawgeometricphantom --spacing 2 --dimension 256 --phantomfile SheppLogan.txt -o ref.mha
</source>
In the presence of noise, all projection data may not be equally reliable. The conjugate gradient algorithm can be modified to take this into account, and each pixel of the projections can be associated with a weight. The higher the weight, the more reliable the pixel data. Download [https://data.kitware.com/api/v1/item/5be99cdf8d777f2179a2e63d/download noisy projections] and [https://data.kitware.com/api/v1/item/5be99d268d777f2179a2e6f8/download the associated weights], as well as [https://data.kitware.com/api/v1/item/5be99d268d777f2179a2e700/download the geometry], and run the following to compare the regular least squares reconstruction (without weights) and the weighted least squares reconstruction.
<source lang="bash" enclose="div">
# Perform least squares reconstruction
rtkconjugategradient -p . -r noisyLineIntegrals.mha -o LeastSquares.mha -g geom.xml -n 20
# Perform weighted least squares reconstruction
rtkconjugategradient -p . -r noisyLineIntegrals.mha -o WeightedLeastSquares.mha -g geom.xml -w weightsmap.mha -n 20
</source>
Taking the weights into account slows down convergence. This can be corrected by using a preconditioner in the conjugate gradient algorithm. The preconditioner is computed automatically from the weights map, you just need to activate the flag :
<source lang="bash" enclose="div">
# Perform preconditioned conjugate gradient reconstruction with weighted least squares cost function
rtkconjugategradient -p . -r noisyLineIntegrals.mha -o WeightedLeastSquares.mha -g geom.xml -w weightsmap.mha -n 20 --preconditioned
</source>
</source>

Latest revision as of 11:14, 12 November 2018

Error creating thumbnail: File missing
Error creating thumbnail: File missing

This script uses the file SheppLogan.txt as input.

 # Create a simulated geometry
 rtksimulatedgeometry -n 180 -o geometry.xml
 # You may add "--arc 200" to make the scan short or "--proj_iso_x 200" to offset the detector

 # Create projections of the phantom file
 rtkprojectgeometricphantom -g geometry.xml -o projections.mha --spacing 2 --dimension 256 --phantomfile SheppLogan.txt

 # Reconstruct
 rtkconjugategradient -p . -r projections.mha -o 3dcg.mha -g geometry.xml --spacing 2 --dimension 256 -n 20

 # Create a reference volume for comparison
 rtkdrawgeometricphantom --spacing 2 --dimension 256 --phantomfile SheppLogan.txt -o ref.mha

In the presence of noise, all projection data may not be equally reliable. The conjugate gradient algorithm can be modified to take this into account, and each pixel of the projections can be associated with a weight. The higher the weight, the more reliable the pixel data. Download noisy projections and the associated weights, as well as the geometry, and run the following to compare the regular least squares reconstruction (without weights) and the weighted least squares reconstruction.

 # Perform least squares reconstruction
 rtkconjugategradient -p . -r noisyLineIntegrals.mha -o LeastSquares.mha -g geom.xml -n 20

 # Perform weighted least squares reconstruction
 rtkconjugategradient -p . -r noisyLineIntegrals.mha -o WeightedLeastSquares.mha -g geom.xml -w weightsmap.mha -n 20

Taking the weights into account slows down convergence. This can be corrected by using a preconditioner in the conjugate gradient algorithm. The preconditioner is computed automatically from the weights map, you just need to activate the flag :

 # Perform preconditioned conjugate gradient reconstruction with weighted least squares cost function
 rtkconjugategradient -p . -r noisyLineIntegrals.mha -o WeightedLeastSquares.mha -g geom.xml -w weightsmap.mha -n 20 --preconditioned