Example #1
0
# Make volume:
vol_rec = numpy.zeros_like(vol)

# Backproject:
project.settings['block_number'] = 1
project.backproject(proj, vol_rec, geometry)

display.display_slice(vol_rec, title = 'Backprojection')

#%% Reconstruct

# Make volume:
vol_rec = numpy.zeros_like(vol)

# Use FDK:
project.FDK(proj, vol_rec, geometry)

display.display_slice(vol_rec, title = 'FDK')

#%% Use Expectation Maximization:

vol_rec = numpy.zeros_like(vol)

project.EM(proj, vol_rec, geometry, iterations = 10)

display.display_slice(vol_rec, title = 'EM')

#%% SIRT

vol = numpy.zeros([1, 512, 512], dtype = 'float32')
phase_ctf *= resolution.get_ctf(proj.shape[::2], 'gaussian',
                                [det_pixel, sigma * 1])

# Electro-magnetic field image:
proj_i = numpy.exp(-proj * n)

# Field intensity:
proj_i = resolution.apply_ctf(proj_i, phase_ctf)**2

display.display_slice(proj_i, title='Projections (phase contrast)')

#%% Reconstruct with phase contrast:

vol_rec = numpy.zeros_like(vol)

project.FDK(-numpy.log(proj_i), vol_rec, geometry)
display.display_slice(vol_rec, title='FDK')

#%% Invertion of phase contrast based on dual-CTF model:

# Propagator (Dual CTF):
alpha = numpy.imag(n) / numpy.real(n)
dual_ctf = resolution.get_ctf(proj.shape[::2], 'dual_ctf',
                              [det_pixel, energy, src2obj, det2obj, alpha])
dual_ctf *= resolution.get_ctf(proj.shape[::2], 'gaussian', [det_pixel, sigma])

# Use inverse convolution to solve for blurring and pci
proj_inv = resolution.deapply_ctf(proj_i, dual_ctf, epsilon=0.1)

# Depending on epsilon there is some lof frequency bias introduced...
proj_inv /= proj_inv.max()
meta = io.read_meta(path, 'flexray')

#%% Prepro:

proj = (proj - dark) / (flat.mean(0) - dark)
proj = -numpy.log(proj)

proj = array.raw2astra(proj)

display.display_slice(proj, title='Sinogram. What else?')

#%% FDK Recon

vol = project.init_volume(proj)
project.FDK(proj, vol, meta['geometry'])

display.display_slice(vol, bounds=[], title='FDK')

#%% EM

vol = numpy.ones([10, 2000, 2000], dtype='float32')

project.EM(proj, vol, meta['geometry'], iterations=3)

display.display_slice(vol, title='EM')

#%% SIRT with additional options

vol = numpy.zeros([1, 2000, 2000], dtype='float32')
Example #4
0
theta_range = [0, 360]
theta_count = 360

hrz_cntr = proj.shape[2] / 2
vrt_cntr = proj.shape[0] / 2

geometry = io.init_geometry(src2obj,
                            det2obj,
                            det_pixel,
                            theta_range,
                            geom_type='static_offsets')

# Source position:
geometry['src_hrz'] = (822 - hrz_cntr) * det_pixel
geometry['src_vrt'] = -(203 - vrt_cntr) * det_pixel

# Centre of rotation in mm:
geometry['axs_hrz'] = (1034.82 - hrz_cntr - geometry['src_hrz'] /
                       det_pixel) * img_pixel + geometry['src_hrz']

# Recon 10 slices:
vol = numpy.zeros([10, 1200, 1200], dtype='float32')

project.FDK(proj, vol, geometry)

display.display_projection(vol, dim=0, bounds=[], title='FDK')

#%% Save geometry:
import os

io.write_astra(os.path.join(path, 'projection.geom'), proj.shape, geometry)