selective=None, x=x, ignore_residual=ignore, disp=disp, maxiter=maxiter) x_ri = proximal_GD(y, forward_fun=uft.forward_ortho, inverse_fun=uft.inverse_ortho, sparsify=sparsify, unsparsify=unsparsify, reorder_fun=None, alpha=alpha, thresh_sep=True, selective=None, x=x, ignore_residual=ignore, disp=disp, maxiter=maxiter) xabs = np.abs(x) x_cabs = np.abs(x_c) x_riabs = np.abs(x_ri) print('Thresholding complex:') print(' MSE: %g' % compare_mse(xabs, x_cabs)) print(' SSIM: %g' % compare_ssim(xabs, x_cabs)) print('Thresholding real/imag separately:') print(' MSE: %g' % compare_mse(xabs, x_riabs)) print(' SSIM: %g' % compare_ssim(xabs, x_riabs)) view(np.stack((x, uft.inverse_ortho(y), x_c, x_ri)))
if __name__ == '__main__': # Same binary smiley face example do_reordering = True N = 1000 x = binary_smiley(N) k = np.sum(np.abs(np.diff(x)) > 0) np.random.seed(5) samp = cartesian_pe(x.shape, undersample=.2, reflines=5) uft = UFT(samp) # Make the complex measurement in kspace # Note this is different than uft.forward, as fftshift must be performed y = uft.forward_ortho(x) # Solve inverse problem using gradient descent with TV sparsity constraint x_hat = GD_TV(y, forward_fun=uft.forward_ortho, inverse_fun=uft.inverse_ortho, alpha=.5, lam=.022, do_reordering=do_reordering, x=x, ignore_residual=True, disp=True, maxiter=50) # Look at the before/after shots view(np.stack((uft.inverse_ortho(y), x_hat)))
do_reordering = True N = 1000 x = binary_smiley(N) k = np.sum(np.abs(np.diff(x)) > 0) np.random.seed(5) samp = cartesian_pe(x.shape, undersample=.01, reflines=5) uft = UFT(samp) # acquisiton model # Show sampling pattern plt.imshow(samp, cmap='gray') plt.title('Sampling Pattern') plt.show() # Simulate acquisiton kspace_u = uft.forward_ortho(x) imspace_u = uft.inverse_ortho(kspace_u) # Look at the aliased acquired signal plt.imshow(np.abs(imspace_u), cmap='gray') plt.title('Acquired') plt.show() # Do IHT, enforcing sparsity in finite differences domain x_hat = IHT_TV(kspace_u, forward_fun=uft.forward_ortho, inverse_fun=lambda x: np.abs(uft.inverse_ortho(x)), k=k, mu=1, tol=1e-8, do_reordering=do_reordering, x=x,