from GaussDictCode import standardGaussTomo RECORD = 'store/5_atoms_3D_OT_+I' RECORD = None from GaussDictCode.dictionary_def import AtomElement from numpy import sqrt, pi from GaussDictCode.bin.manager import myManager with myManager(device='cpu', order='C', fType='float32', cType='complex64') as c: Radon, fidelity, _, ASpace, PSpace, params = standardGaussTomo( dim=3, device='GPU', isotropic=False, angle_range=(0, pi), angle_num=50, vol_box=[-1, 1], vol_size=32, det_box=[-1.4, 1.4], det_size=64, fidelity='l2_squared', reg=None, solver='Newton') reg, GD = params vol = Radon.embedding # Initiate Data: ##### # # These lines initiate the 2 atom demo, seed=200 is a good one # gt = AtomElement(ASpace, x=[[-.5, 0, 0], [.5, 0, 0]], r=[30, 10], I=1) gt = AtomElement(ASpace, x=[[0.24, 0.48, 0], [-0.2, -0.52, -0.1]],
# if smallVid is None: # plt.show(block=False) # plt.pause(.2) # else: # __makeVid(writer, plt, stage=2) # if smallVid is not None: # __makeVid(writer, plt, stage=3) # exit() if True: Radon, fidelity, data, ASpace, PSpace, params = standardGaussTomo( data=data / data.max(), dim=3, device='GPU', isotropic=False, vol_box=[-1, 1], vol_size=(data.shape[1], data.shape[1], data.shape[2]), angles=angles, det_box=[-1, 1], fidelity='l2_squared', reg=None, solver='Newton') reg, GD = params # Initiate Recon: ##### def newAtoms(n, seed=None): tmp = ASpace.random(n, seed=seed) c.set(tmp.r, 10, (slice(None), slice(None, 3))) c.set(tmp.r, 0, (slice(None), slice(3, None))) c.set(tmp.x[:], c.mul(tmp.x, .5)) c.set(tmp.I[:], 4 / n)
# # print(j) # # plt.pause(.01) # # plt.show(block=False) # # plt.show() # exit() with myManager(device='cpu', order='C', fType='float32', cType='complex64') as c: Radon, fidelity, data, ASpace, PSpace, params = standardGaussTomo( gt=gt, dim=3, device='GPU', isotropic=False, angle_range=([-pi / 3, 0], [pi / 3, pi / 2]), angle_num=[61, 1], vol_box=[-1, 1], det_box=[-sqrt(3), sqrt(3)], noise=0 * 0.1, fidelity='l2_squared', reg=None, solver='Newton') # Radon, fidelity, data, ASpace, PSpace, params = standardGaussTomo( # gt=gt, dim=3, device='GPU', isotropic=False, # angle_range=([-pi / 3, 0], [pi / 3, pi / 2]), angle_num=[61 * 4, 1], # vol_box=[-1, 1], det_box=[-sqrt(3), sqrt(3)], det_size=int(40 / 2), # fidelity='l2_squared', reg=None, solver='Newton' # ) reg, GD = params # recon = loadmat(join('store', 'polyII_recon')) # x, recon = recon['view'], AtomElement(
# _get3DvolPlot(f.add_subplot(222, projection='3d'), gt, (100, 90), 1.5) # plt.title('GT, view from orientation: ' + str((100, 90))) # _get3DvolPlot(f.add_subplot(223, projection='3d'), x, (20, 45), 1.5) # plt.title('TV recon, view from orientation: ' + str((20, 45))) # _get3DvolPlot(f.add_subplot(224, projection='3d'), x, (100, 90), 1.5) # plt.title('TV recon, view from orientation: ' + str((100, 90))) # plt.show() # exit() Radon, _, fidelity, data, vol, PSpace, params = standardGaussTomo( gt=gt, dim=3, solver='odl', fidelity='l2_squared', reg=['TV', 3e-6], vol_box=([-v / sqrt(128) for v in vol], [v / sqrt(128) for v in vol]), vol_size=vol, angle_range=[-60 * pi / 180, 60 * pi / 180], angle_num=61, noise=0.1, det_box=([-v / sqrt(128) for v in vol[1:]], [v / sqrt(128) for v in vol[1:]]), det_size=vol[1:]) # n = 4 # Radon, _, fidelity, data, vol, PSpace, params = standardGaussTomo( # gt=gt, dim=3, solver='odl', fidelity='l2_squared', reg=['TV', 1e-5], # vol_box=([-v / n for v in vol], [v / n for v in vol]), vol_size=vol, # angle_range=[-pi / 3, pi / 3], angle_num=61 * 4, # det_box=([-v / n for v in vol[1:]], [v / n for v in vol[1:]]), det_size=int(40 / 2) # )
# # plt.show() # # exit() # for i in range(0, 71): # plt.gca().clear() # plt.imshow(data[i].T) # plt.title(str(i)) # plt.pause(.1) # plt.show() # exit() Radon, fidelity, data, ASpace, PSpace, params = standardGaussTomo( data=(data - data.min()) / 151786, dim=3, device='GPU', isotropic=False, vol_box=[-1, 1], vol_size=(data.shape[1], data.shape[1], data.shape[2]), angles=angles, det_box=[-1, 1], fidelity='l2_squared', reg=None, solver='Newton') reg, GD = params # Initiate Recon: ##### def newAtoms(n, seed=None): tmp = ASpace.random(n, seed=seed) c.set(tmp.r, 1, (slice(None), slice(None, 3))) c.set(tmp.r, 0, (slice(None), slice(3, None))) c.set(tmp.I[:], 1e-2) # c.set(tmp.x, 0, (slice(None), [2]))