X-radia XRMΒΆ

This section contains a script to read the X-radia XRM tomography dataset and reconstruct it with tomoPy.

Download file: rec_xradia_xrm.py

 1#!/usr/bin/env python
 2# -*- coding: utf-8 -*-
 3
 4"""
 5TomoPy example script to reconstruct the xrm tomography data from
 6the original stack of xrm. To use rename the xrm data as 
 7radios/image_00000.xrm and flats/ref_00000.xrm
 8"""
 9
10from __future__ import print_function
11import tomopy
12import dxchange
13
14if __name__ == '__main__':
15    # Set path to the micro-CT data to reconstruct.
16    fname = 'data_dir/'
17
18    proj_start = 0
19    proj_end = 1800
20    flat_start = 0
21    flat_end = 100
22
23    ind_tomo = range(proj_start, proj_end)
24    ind_flat = range(flat_start, flat_end)
25
26    # Select the sinogram range to reconstruct.
27    start = 0
28    end = 16
29
30    # APS 26-ID has an x-radia system collecting raw data as xrm.
31    proj, flat, metadata = dxchange.read_aps_26id(fname, ind_tomo, ind_flat,
32                                                 sino=(start, end))
33
34    # make the darks
35    dark = np.zeros((1, proj.shape[1], proj.shape[2]))    
36
37    # Set data collection angles as equally spaced between 0-180 degrees.
38    theta = tomopy.angles(proj.shape[0])
39
40    # Flat-field correction of raw data.
41    proj = tomopy.normalize(proj, flat, dark)
42
43    # Find rotation center.
44    rot_center = tomopy.find_center(proj, theta, init=1024,
45                                    ind=0, tol=0.5)
46    print("Center of rotation: ", rot_center)
47
48    proj = tomopy.minus_log(proj)
49
50    # Reconstruct object using Gridrec algorithm.
51    rec = tomopy.recon(proj, theta, center=rot_center, algorithm='gridrec')
52
53    # Mask each reconstructed slice with a circle.
54    rec = tomopy.circ_mask(rec, axis=0, ratio=0.95)
55
56    # Write data as stack of TIFs.
57    dxchange.write_tiff_stack(rec, fname='recon_dir/recon')