APS 13-BMΒΆ

This section contains a script to read the APS 13-BM tomography dataset and reconstruct it with tomoPy.

Download file: rec_aps_13bm.py

 1#!/usr/bin/env python
 2# -*- coding: utf-8 -*-
 3
 4"""
 5TomoPy example script to reconstruct the APS 13-BM tomography
 6data as original netcdf files. To use, change fname to just
 7the file name (e.g. 'sample[2].nc' would be 'sample'.
 8Reconstructed dataset will be saved as float32 netcdf3.
 9"""
10import glob
11import numpy as np
12import tomopy as tp
13import dxchange as dx
14
15from netCDF4 import Dataset
16
17if __name__ == '__main__':
18    ## Set path (without file suffix) to the micro-CT data to reconstruct.
19    fname = 'data_dir/sample'
20
21    ## Import Data.
22    proj, flat, dark, theta = dx.exchange.read_aps_13bm(fname, format = 'netcdf4')
23
24    ## Flat-field correction of raw data.
25    proj = tp.normalize(proj, flat = flat, dark = dark)
26
27    ## Additional flat-field correction of raw data to negate need to mask.
28    proj = tp.normalize_bg(proj, air = 10)
29
30    ## Set rotation center.
31    rot_center = tp.find_center_vo(proj)
32    print('Center of rotation: ', rot_center)
33
34    tp.minus_log(proj, out = proj)
35
36    # Reconstruct object using Gridrec algorith.
37    rec = tp.recon(proj, theta, center = rot_center, sinogram_order = False, algorithm = 'gridrec', filter_name = 'hann')
38    rec = tp.remove_nan(rec)
39
40    ## Writing data in netCDF3 .volume.
41    ncfile = Dataset('filename.volume', 'w', format = 'NETCDF3_64BIT', clobber = True)
42    NX = ncfile.createDimension('NX', rec.shape[2])
43    NY = ncfile.createDimension('NY', rec.shape[1])
44    NZ = ncfile.createDimension('NZ', rec.shape[0])
45    volume = ncfile.createVariable('VOLUME', 'f4', ('NZ','NY','NX'))
46    volume[:] = rec
47    ncfile.close()