diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..ecb56223bc06270f2f41c0346fd78f3eefab66e7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +_data/ \ No newline at end of file diff --git a/README.md b/README.md index d22628c66fbad3b6525578a606931cafd5655e21..41c0b596362a9752eedd1e5c799ef01c1bb5c936 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ ## Tomopy + + ### Gridrec * parallel beam diff --git a/gridrec.py b/gridrec.py new file mode 100644 index 0000000000000000000000000000000000000000..5d5bc71cb21c9418b489e459adc4b204ad1ec659 --- /dev/null +++ b/gridrec.py @@ -0,0 +1,82 @@ + +# coding: utf-8 + +# ## Gridrec +# +# Here is an example on how to use [TomoPy](http://tomopy.readthedocs.io/en/latest/) with the gridrec algorithm. +# +# [user manual](https://media.readthedocs.org/pdf/tomopy/latest/tomopy.pdf) + +# In[3]: + + +# get_ipython().run_line_magic('pylab', 'inline') + + +# In[4]: + + +import tomopy +import dxchange +import numpy as np +import matplotlib.pyplot as plt +import ipyvolume as ipv + + +if __name__ == '__main__': + + haveLoaded = False + + if (haveLoaded): + print("loading projection data...") + proj = np.load("projection_data.npy") + else: + print("loading angle data...") + ctdata = np.loadtxt("test_scan_250/_ctdata.txt",skiprows=3) + theta = np.deg2rad(ctdata[:,1]) + + fname = '_data/test_scan_250/test scan 250_0001.tif' + + print("loading tiff stack...") + indices = [i for i in range(1,752)] + data = dxchange.read_tiff_stack(fname, indices) + print(np.shape(data)) + + # downsample and minus log + print("downsampling and taking minus log...") + proj = tomopy.minus_log(data[::1,::8,::8]) + print(np.shape(proj)) + + print("saving projection data...") + np.save('projection_data',proj) + + rot_center = proj.shape[2]/2 + + # gridrec + print("running reconstruction...") + rec = tomopy.recon(proj,theta,sinogram_order=False, + center=rot_center,algorithm='art') + + # LPrec (not working) + # rec = tomopy.recon(proj, theta, center=rot_center, + # algorithm=tomopy.lprec, lpmethod='lpfbp', + # filter_name='parzen') + + # ASTRA (not working) + options = {'proj_type':'linear', 'method':'FBP'} + rec = tomopy.recon(proj, theta, center=rot_center, + algorithm=tomopy.astra, options=options) + + print("applying circular mask...") + rec = tomopy.circ_mask(rec, axis=0, ratio=0.75) + + print("saving data to reconstruction_data.npy...") + np.save('reconstruction_data',rec) + + # use jupyter notebook to visualize results + + # print("visualizing...") + # ipv.figure() + # vol = ipv.volshow(rec) + # ipv.show() + diff --git a/images/coil_tomopy_recon.gif b/images/coil_tomopy_recon.gif new file mode 100644 index 0000000000000000000000000000000000000000..8993caf2e4d055027335579b89dad8b82ceae5d8 Binary files /dev/null and b/images/coil_tomopy_recon.gif differ