import tomopy
Tomographic data input in TomoPy is supported by DXchange.
import dxchange
Matplotlib provides plotting of the result in this notebook. Paraview or other tools are available for more sophisticated 3D rendering.
import matplotlib.pyplot as plt
Import and activate Python's built in logging module if desired. It may print something helpful.
import logging
logging.basicConfig(level=logging.INFO)
This data set file format follows the APS beamline 2-BM and 32-ID data-exchange definition. Other file format readers for other synchrotrons are also available with DXchange.
proj, flat, dark, theta = dxchange.read_aps_32id(
fname='../../../source/tomopy/data/tooth.h5',
sino=(0, 2), # Select the sinogram range to reconstruct.
)
Plot the sinogram
plt.imshow(proj[:, 0, :])
plt.show()
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])
Perform the flat-field correction of raw data: $$ \frac{proj - dark} {flat - dark} $$
proj = tomopy.normalize(proj, flat, dark)
Calculate $ -log(proj) $ to linearize transmission tomography data.
proj = tomopy.minus_log(proj)
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)
Reconstruct using the gridrec algorithm. Tomopy provides various reconstruction and provides wrappers for other libraries such as the ASTRA toolbox.
recon = tomopy.recon(proj, theta, center=rot_center, algorithm='gridrec', sinogram_order=False)
Mask each reconstructed slice with a circle.
recon = tomopy.circ_mask(recon, axis=0, ratio=0.95)
plt.imshow(recon[0, :, :])
plt.show()