GridrecΒΆ

Here is an example on how to use the gridrec [Dowd:99] reconstruction algorithm with TomoPy [Gursoy:14a]. You can download the python script here or the Jupyter notebook here

%pylab inline

Install TomoPy then:

import tomopy

Tomographic data input in TomoPy is supported by DXchange.

import dxchange

matplotlib provide plotting of the result in this notebook. Paraview or other tools are available for more sophisticated 3D rendering.

import matplotlib.pyplot as plt

Set the path to the micro-CT data to reconstruct.

fname = '../../tomopy/data/tooth.h5'

Select the sinogram range to reconstruct.

start = 0
end = 2

tooth.h5 data set file format follows the APS beamline 2-BM and 32-ID data-exchange file format definition. Major synchrotron file format examples are available at DXchange.

proj, flat, dark, theta = dxchange.read_aps_32id(fname, sino=(start, end))

Plot the sinogram:

plt.imshow(proj[:, 0, :], cmap='Greys_r')
plt.show()
../_images/tomopy_15_0.png

If the angular information is not avaialable from the raw data you need to set the data collection angles. In this case theta is set as equally spaced between 0-180 degrees.

if (theta is None):
    theta = tomopy.angles(proj.shape[0])
else:
    pass

Perform the flat-field correction of raw data:

\[\frac{proj - dark} {flat - dark}\]
proj = tomopy.normalize(proj, flat, dark)

Tomopy provides various methods ([Donath:06], [Vo:14], [Guizar:08]) to find the rotation center.

rot_center = tomopy.find_center(proj, theta, init=290, ind=0, tol=0.5)
tomopy.rotation:Trying center: [ 290.]
tomopy.rotation:Trying center: [ 304.5]
tomopy.rotation:Trying center: [ 275.5]
tomopy.rotation:Trying center: [ 282.75]
tomopy.rotation:Trying center: [ 297.25]
tomopy.rotation:Trying center: [ 304.5]
tomopy.rotation:Trying center: [ 304.5]
tomopy.rotation:Trying center: [ 293.625]
tomopy.rotation:Trying center: [ 290.]
tomopy.rotation:Trying center: [ 295.4375]
tomopy.rotation:Trying center: [ 291.8125]
tomopy.rotation:Trying center: [ 294.53125]
tomopy.rotation:Trying center: [ 295.4375]
tomopy.rotation:Trying center: [ 294.078125]

Calculate

\[-log(proj)\]
proj = tomopy.minus_log(proj)

Reconstruction using Gridrec algorithm.Tomopy provides various reconstruction methods including the one part of the ASTRA toolbox.

recon = tomopy.recon(proj, theta, center=rot_center, algorithm='gridrec')

Mask each reconstructed slice with a circle.

recon = tomopy.circ_mask(recon, axis=0, ratio=0.95)
plt.imshow(recon[0, :,:], cmap='Greys_r')
plt.show()
../_images/tomopy_28_0.png