Closed sysiphus511 closed 4 months ago
Code to test:
%matplotlib qt
#%% DEMO 14: Playing with offsets
#
#
# In this demo we show how to change offsets to either the iamge or the
# detector, and the flexibility of 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
#%%Initialize
import tigre
import numpy as np
from tigre.utilities import sample_loader
import matplotlib.pyplot as plt
import tigre.algorithms as algs
#%% Geometry
geo = tigre.geometry_default(high_resolution=False)
# Offsets
## ####################################################################################
# Lets try simnple offset: The detector gets completelly displaced
geo.offOrigin = np.array([0, 0, 0]) # Offset of image from origin (mm)
geo.offDetector = np.array([200, 200]) # Offset of Detector (mm)
## ####################################################################################
# Auxiliary
geo.accuracy = 0.5
# Accuracy of FWD proj (vx/sample)
## Load data and generate projections
# see previous demo for explanation
angles = np.linspace(0, 2 * np.pi, 100)
# Load thorax phatom data
head = sample_loader.load_head_phantom(geo.nVoxel)
projections = tigre.Ax(head, geo, angles)
#%% lets see it
# tigre.plotproj(projections, angles)
## we will skip reconstruction of this tests because the image is outside the detector
## #####################################################################
#%% Second test: lets test variying offsets:
geo.nDetector = np.array([80,120]) # Number of detector pixels
geo.dDetector = np.array([4, 4]) # Detector element size (mm)
geo.sDetector = geo.nDetector * geo.dDetector # Detector size (mm)
geo.offDetector = np.array(
[0,-160]
) # Offset of Detector (mm)
projections2 = tigre.Ax(head, geo, angles)
## lets see it
# tigre.plotproj(projections2, angles)
## reconstruction
geo.offDetector = np.array(
[0,-160]
)
res = algs.fdk(projections2, geo, angles, dowang=True)
# tigre.plotimg(res, dim="z")
#%% Third test: lets vary everything
# plt.show()
Thanks!
Sorry, I left some print statements in there :\ maybe remove them on the next commit. And the matlab version had a geometry checking module that I didn't implement FYI
opps, missed them myself too! hehe
Yes, don't worry about the geo checking. Thanks again!
Adding wang weights! Seems to have worked but not tested that rigorously