Note
Go to the end to download the full example code.
Detector rotation#
Describe a detector that is rotated or tilted.
Source: Python/demos/d17_DetectorRotation.py · MATLAB/Demos/d17_DetectorRotation.m
MATLAB version of this demo
%% DEMO 17: Detector Rotation
%
%
%
% Some systems have a slight rotation of the detector due to mechanical
% inaccuracies.
%
% According to the article "A geometric calibration method for cone beam
% CT systems" (DOI: 10.1118/1.2198187), only Roll needs to be corrected
% for in the algorithmic part, as the other 2 can be easily ignored if
% "sufficiently small". In TIGRE we decided to leave that to the users
% discretion and implemented the 3 possible detector rotation, per angle
% if needed.
%
% This demo shows how to use it.
%
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
% This file is part of the TIGRE Toolbox
%
% Copyright (c) 2015, University of Bath and
% CERN-European Organization for Nuclear Research
% All rights reserved.
%
% License: Open Source under BSD.
% See the full license at
% https://github.com/CERN/TIGRE/blob/master/LICENSE
%
% Contact: tigre.toolbox@gmail.com
% Codes: https://github.com/CERN/TIGRE/
% Coded by: Ander Biguri
%--------------------------------------------------------------------------
%% Initialize
clear;
close all;
%% Define Geometry
%
% VARIABLE DESCRIPTION UNITS
%-------------------------------------------------------------------------------------
geo.DSD = 1536; % Distance Source Detector (mm)
geo.DSO = 1000; % Distance Source Origin (mm)
% Detector parameters
geo.nDetector=[512; 512]; % number of pixels (px)
geo.dDetector=[0.8; 0.8]; % size of each pixel (mm)
geo.sDetector=geo.nDetector.*geo.dDetector; % total size of the detector (mm)
% Image parameters
geo.nVoxel=[128;128;128]; % number of voxels (vx)
% a bit smaller than usual because the demo includes a very big detector
% angle for showcase
geo.sVoxel=[256;256;256]/2; % total size of the image (mm)
geo.dVoxel=geo.sVoxel./geo.nVoxel; % size of each voxel (mm)
% Offsets
geo.offOrigin =[0;0;0]; % Offset of image from origin (mm)
geo.offDetector=[0; 0]; % Offset of Detector (mm)
% Auxiliary
geo.accuracy=0.5; % Accuracy of FWD proj (vx/sample)
%% Geometry has an additional field for the rotation.
%
%
angles=linspace(0,2*pi,100);
% lets define 3 angles, with big variability in each direction
roll=angles;
pitch=0.7*linspace(0,1,size(angles,2));
yaw=0.7*linspace(0,1,size(angles,2));
% Fill rotDetector. It can also be a 3x1, if its not angle dependent. e.g.
% geo.rotDetector=[pi/5; 0; pi/10];
geo.rotDetector=[roll;pitch;yaw];
%% Load data and generate projections
% define angles
% Load thorax phantom data
head=headPhantom(geo.nVoxel);
% generate projections
projections=Ax(head,geo,angles,'interpolated');
%% Lets plot the projections with a rotated detector
plotProj(projections,angles);
%% lets reconstruct with and without detector rotation
%
imgRotDet=OS_SART(projections,geo,angles,50);
% No rotation
geo.rotDetector=[0;0;0];
projections2=Ax(head,geo,angles,'interpolated');
imgnoRot=OS_SART(projections2,geo,angles,50);
% %% Plot to show that indeed the reconstruction is right
%
%
%
plotImg([imgRotDet imgnoRot] ,'dim',3)
Initialize#
import tigre
import numpy as np
from tigre.utilities import sample_loader
from tigre.utilities import CTnoise
import tigre.algorithms as algs
Geometry#
geo = tigre.geometry_default(high_resolution=False)
Load data and generate projections#
# 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
# 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)

recon#
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)
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
Plot to show that indeed the reconstruction is right#
tigre.plotimg(np.concatenate([imgRotDet, imgnoRot], axis=1), dim="z")

Total running time of the script: (0 minutes 20.327 seconds)