diff options
author | Edoardo Pasca <edo.paskino@gmail.com> | 2018-04-24 15:41:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-24 15:41:38 +0200 |
commit | f2979c7f41d6a7441a4bfdabbb3fd07fe3dd9a6a (patch) | |
tree | 6a3047647639bcaf85c3df6c8ef7d4f658a0a0dd /Wrappers | |
parent | 150bad45f5268dbc58b0c449d19d0dbb79b9ba30 (diff) | |
parent | 2a8138ed73c5a899886499016938ce8970e0ff6e (diff) | |
download | astra-wrapper-f2979c7f41d6a7441a4bfdabbb3fd07fe3dd9a6a.tar.gz astra-wrapper-f2979c7f41d6a7441a4bfdabbb3fd07fe3dd9a6a.tar.bz2 astra-wrapper-f2979c7f41d6a7441a4bfdabbb3fd07fe3dd9a6a.tar.xz astra-wrapper-f2979c7f41d6a7441a4bfdabbb3fd07fe3dd9a6a.zip |
Merge pull request #7 from vais-ral/demo_fix
Demo fix
Diffstat (limited to 'Wrappers')
-rwxr-xr-x | Wrappers/Python/wip/DemoRecIP.py | 110 | ||||
-rwxr-xr-x | Wrappers/Python/wip/demo_astra_mc.py (renamed from Wrappers/Python/wip/simple_mc_demo.py) | 0 | ||||
-rwxr-xr-x | Wrappers/Python/wip/demo_astra_simple.py (renamed from Wrappers/Python/wip/simple_demo_astra.py) | 0 | ||||
-rwxr-xr-x | Wrappers/Python/wip/demo_astra_sophiabeads.py (renamed from Wrappers/Python/wip/demo_sophiabeads.py) | 6 |
4 files changed, 3 insertions, 113 deletions
diff --git a/Wrappers/Python/wip/DemoRecIP.py b/Wrappers/Python/wip/DemoRecIP.py deleted file mode 100755 index 442e40e..0000000 --- a/Wrappers/Python/wip/DemoRecIP.py +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -""" -Reading multi-channel data and reconstruction using FISTA modular -""" - -import numpy as np -import matplotlib.pyplot as plt - -#import sys -#sys.path.append('../../../data/') -from read_IPdata import read_IPdata - -from ccpi.astra.astra_ops import AstraProjectorSimple, AstraProjectorMC -from ccpi.reconstruction.funcs import Norm2sq, Norm1, BaseFunction -from ccpi.reconstruction.algs import FISTA -#from ccpi.reconstruction.funcs import BaseFunction - -from ccpi.framework import ImageData, AcquisitionData, AcquisitionGeometry, ImageGeometry - -# read IP paper data into a dictionary -dataDICT = read_IPdata('..\..\..\data\IP_data70channels.mat') - -# Set ASTRA Projection-backprojection class (fan-beam geometry) -DetWidth = dataDICT.get('im_size')[0] * dataDICT.get('det_width')[0] / \ - dataDICT.get('detectors_numb')[0] -SourceOrig = dataDICT.get('im_size')[0] * dataDICT.get('src_to_rotc')[0] / \ - dataDICT.get('dom_width')[0] -OrigDetec = dataDICT.get('im_size')[0] * \ - (dataDICT.get('src_to_det')[0] - dataDICT.get('src_to_rotc')[0]) /\ - dataDICT.get('dom_width')[0] - -N = dataDICT.get('im_size')[0] - -vg = ImageGeometry(voxel_num_x=dataDICT.get('im_size')[0], - voxel_num_y=dataDICT.get('im_size')[0], - channels=1) - -pg = AcquisitionGeometry('cone', - '2D', - angles=(np.pi/180)*dataDICT.get('theta')[0], - pixel_num_h=dataDICT.get('detectors_numb')[0], - pixel_size_h=DetWidth, - dist_source_center=SourceOrig, - dist_center_detector=OrigDetec, - channels=1) - - -sino = dataDICT.get('data_norm')[0][:,:,34] # select mid-channel -b = AcquisitionData(sino,geometry=pg) - -# Initial guess -x_init = ImageData(np.zeros((N, N)),geometry=vg) - - - - - -Aop = AstraProjectorSimple(vg,pg,'gpu') -f = Norm2sq(Aop,b,c=0.5) - -# Run FISTA for least squares without regularization -opt = {'tol': 1e-4, 'iter': 10} -x_fista0, it0, timing0, criter0 = FISTA(x_init, f, None, opt) - -plt.imshow(x_fista0.array) -plt.show() - -# Now least squares plus 1-norm regularization -g1 = Norm1(10) - -# Run FISTA for least squares plus 1-norm function. -x_fista1, it1, timing1, criter1 = FISTA(x_init, f, g1, opt) - -plt.imshow(x_fista1.array) -plt.show() - -# Multiple channels -sino_mc = dataDICT.get('data_norm')[0][:,:,32:37] # select mid-channel - -vg_mc = ImageGeometry(voxel_num_x=dataDICT.get('im_size')[0], - voxel_num_y=dataDICT.get('im_size')[0], - channels=5) - -pg_mc = AcquisitionGeometry('cone', - '2D', - angles=(np.pi/180)*dataDICT.get('theta')[0], - pixel_num_h=dataDICT.get('detectors_numb')[0], - pixel_size_h=DetWidth, - dist_source_center=SourceOrig, - dist_center_detector=OrigDetec, - channels=5) - -b_mc = AcquisitionData(np.transpose(sino_mc,(2,0,1)), - geometry=pg_mc, - dimension_labels=("channel","angle","horizontal")) - -# ASTRA operator using volume and sinogram geometries -Aop_mc = AstraProjectorMC(vg_mc, pg_mc, 'gpu') - -f_mc = Norm2sq(Aop_mc,b_mc,c=0.5) - -# Initial guess -x_init_mc = ImageData(np.zeros((5, N, N)),geometry=vg_mc) - - -x_fista0_mc, it0_mc, timing0_mc, criter0_mc = FISTA(x_init_mc, f_mc, None, opt) - -plt.imshow(x_fista0_mc.as_array()[4,:,:]) -plt.show()
\ No newline at end of file diff --git a/Wrappers/Python/wip/simple_mc_demo.py b/Wrappers/Python/wip/demo_astra_mc.py index 3b78eb3..3b78eb3 100755 --- a/Wrappers/Python/wip/simple_mc_demo.py +++ b/Wrappers/Python/wip/demo_astra_mc.py diff --git a/Wrappers/Python/wip/simple_demo_astra.py b/Wrappers/Python/wip/demo_astra_simple.py index 8529c98..8529c98 100755 --- a/Wrappers/Python/wip/simple_demo_astra.py +++ b/Wrappers/Python/wip/demo_astra_simple.py diff --git a/Wrappers/Python/wip/demo_sophiabeads.py b/Wrappers/Python/wip/demo_astra_sophiabeads.py index 53a0bf8..d8100ea 100755 --- a/Wrappers/Python/wip/demo_sophiabeads.py +++ b/Wrappers/Python/wip/demo_astra_sophiabeads.py @@ -16,7 +16,7 @@ from ccpi.optimisation.algs import CGLS # Set up reader object and read the data datareader = XTEKReader("REPLACE_THIS_BY_PATH_TO_DATASET/SophiaBeads_256_averaged.xtekct") -data = datareader.getAcquisitionData() +data = datareader.get_acquisition_data() # Extract central slice, scale and negative-log transform sino = -np.log(data.as_array()[:,:,1000]/60000.0) @@ -65,8 +65,8 @@ Aop = AstraProjectorSimple(ig2d, ag2d,"gpu") x_init = ImageData(np.zeros((N,N)),geometry=ig2d) # Run 50-iteration CGLS reconstruction -num_iter = 50 -x, it, timing, criter = CGLS(Aop,data2d,num_iter,x_init) +opt = {'tol': 1e-4, 'iter': 100} +x, it, timing, criter = CGLS(x_init,Aop,data2d,opt=opt) # Display reconstruction plt.figure() |