Example #1
0
#
#                   Taken from "Few-view cone-beam CT reconstruction with
#                   deformed prior image" (doi: 10.1118/1.4901265)
#
#
#
#

## Define a cell array of image quality measures
qualmeas = ["RMSE", "CC", "MSSIM", "UQI"]

#%% Reconstruct image using SIRT, SART and OS-SART
# =========================================================================
imgSIRT, qualitySIRT = algs.sirt(projections,
                                 geo,
                                 angles,
                                 20,
                                 Quameasopts=qualmeas)
imgSART, qualitySART = algs.sart(projections,
                                 geo,
                                 angles,
                                 20,
                                 Quameasopts=qualmeas)
imgOSSART, qualityOSSART = algs.ossart(projections,
                                       geo,
                                       angles,
                                       20,
                                       Quameasopts=qualmeas)

#%% Plot the changes of image quality measures over iterations, i.e. how much each iteration looks like the previous iteration.
# (without the original image one can not compute the absolute image quality, of course)
Example #2
0
angles = np.linspace(0, 2 * np.pi, 100)
angles = np.hstack([angles, angles, angles])  # loop 3 times

# Load thorax phatom data
head = sample_loader.load_head_phantom(geo.nVoxel)

# This makes it helical
geo.offOrigin = np.zeros((angles.shape[0], 3))
geo.offOrigin[:, 2] = np.linspace(
    -1024 / 2 + 128, 1024 / 2 - 128,
    angles.shape[0])  # about 256^3 images fit int he detector with this size.

# project data
data = tigre.Ax(head, geo, angles)

# Uncomment if you want to see the data
# plotProj(data,angles);
## Reconstruct Helical

SIRTimg = algs.sirt(data, geo, angles, 30)
# SARTimg=SART(data,geo,angles,30); # takes time
CGLSimg = algs.cgls(data, geo, angles, 20)
## Plot results

# CGLS and SIRT
tigre.plotImg(np.concatenate([head, SIRTimg, CGLSimg], axis=1),
              dim="z",
              step=3,
              clims=[0, 1])
Example #3
0
verbose = True
# 'Quameasopts'  Asks the algorithm for a set of quality measurement
#                parameters. Input should contain a list of desired
#                quality measurement names. Example: ['CC','RMSE','MSSIM']
#                These will be computed in each iteration.
#                Note that this is the change in parameter value per iteration, not the quality of the result.
qualmeas = ["RMSE", "SSD"]

# SIRT and SART both have no extra input parameters.
# =========================================================================
imgSIRT, qualitySIRT = algs.sirt(
    projections,
    geo,
    angles,
    20,
    lmbda=lmbda,
    lmbda_red=lambdared,
    verbose=verbose,
    Quameasopts=qualmeas,
    computel2=True,
)
imgSART, qualitySART = algs.sart(
    projections,
    geo,
    angles,
    20,
    lmbda=lmbda,
    lmbda_red=lambdared,
    verbose=verbose,
    Quameasopts=qualmeas,
    computel2=True,
Example #4
0
#                            convergence is reached.
#             -  'image'    : Initialization using a user specified
#                            image. Not recomended unless you really
#                            know what you are doing.
#  'InitImg'    an image for the 'image' initialization. Avoid.

# use CGLS
imgCGLS, errL2CGLS = algs.cgls(noise_projections,
                               geo,
                               angles,
                               60,
                               computel2=True)
# SIRT for comparison.
imgSIRT, errL2SIRT = algs.sirt(noise_projections,
                               geo,
                               angles,
                               60,
                               computel2=True)

#%% plot results
#
# We can see that CGLS gets to the same L2 error in less amount of
# iterations.

plt.plot(np.vstack((errL2CGLS[0, :], errL2SIRT[0, :])).T)
plt.title("L2 error")
plt.xlabel("Iteration")
plt.ylabel("$ log_{10}(|Ax-b|) $")
plt.gca().legend(("CGLS", "SIRT"))
plt.show()
# plot images
#%% Load data and generate projections
# define angles
angles = np.linspace(0, 2 * np.pi, 100)
## Define angles
numProjs = 100

anglesY = np.linspace(0, 2 * np.pi, numProjs)
anglesZ2 = anglesY
anglesZ1 = np.pi * np.sin(np.linspace(0, 2 * np.pi, numProjs))
angles = np.vstack([anglesZ1, anglesY, anglesZ2]).T

## Get Image

head = sample_loader.load_head_phantom(geo.nVoxel)

## Project

projections = tigre.Ax(head, geo, angles)

tigre.plotproj(projections,
               anglesY)  # angle information not right in the title
## Reconstruct:

# Note, FDK will not work.

imgSIRT = algs.sirt(projections, geo, angles, 50)
imgCGLS = algs.cgls(projections, geo, angles, 10)

tigre.plotimg(np.concatenate([head, imgSIRT, imgCGLS], axis=1), dim="z")
Example #6
0
from __future__ import print_function
import tigre
import tigre.algorithms as algs
import numpy as np
from tigre.demos.Test_data import data_loader
from matplotlib import pyplot as plt

geo = tigre.geometry(mode='cone',
                     nVoxel=np.array([256, 256, 256]),
                     default_geo=True)
niter = 10
nangles = 100
angles = np.linspace(0, 2 * np.pi, nangles, dtype=np.float32)

head = data_loader.load_head_phantom(geo.nVoxel)
proj = tigre.Ax(head, geo, angles)
output = algs.sirt(proj, geo, angles, niter=50)

plt.imshow(output[geo.nVoxel[0] / 2])
plt.colorbar()
plt.show()