Example #1
0
 def setUp(self):
     self.im = binary_smiley(512)
Example #2
0
with the implementation...
'''

import numpy as np
import matplotlib.pyplot as plt
from skimage.measure import compare_mse

from mr_utils.recon.reordering import scr_reordering_adluru
from mr_utils.test_data.phantom import binary_smiley
from mr_utils.sim.traj import cartesian_pe

if __name__ == '__main__':

    N = 100
    reorder = True
    m = binary_smiley(N)
    k = np.sum(np.abs(np.diff(m)) > 0)
    np.random.seed(0)
    samp = cartesian_pe(m.shape, undersample=.2, reflines=5)

    # Take samples
    y = np.fft.fftshift(np.fft.fft2(m)) * samp

    # Do convex recon
    m_hat = scr_reordering_adluru(y,
                                  samp,
                                  prior=m,
                                  alpha0=1,
                                  alpha1=.001,
                                  beta2=np.finfo(float).eps,
                                  reorder=reorder,
Example #3
0
'''Try to leverage prexisting sorting strategies.'''

import numpy as np
from scipy import sparse
from scipy.sparse.csgraph import reverse_cuthill_mckee

from mr_utils.utils.orderings import inverse_permutation
from mr_utils.test_data.phantom import binary_smiley
from mr_utils import view

if __name__ == '__main__':

    # We want to find a sparse representation of X
    ax = 0  # Choosing ax=0 gives marginal improvement when reordering
    X = binary_smiley(512)
    Xinv = np.linalg.pinv(X.T)
    XX = X.dot(X.T)  # Do this to gaurantee symmetry

    # Try finite differences on XX'
    Y = np.diff(XX, axis=ax)
    print(np.sum(np.abs(Y) > 0))
    view(Y)
    recon = np.vstack((XX[:, 0][None, :], Y)).cumsum(axis=ax).dot(Xinv)
    view(recon)

    # Try finite differences on Cuthill-McKee reordered XX'
    Z = sparse.csr_matrix(XX)
    P = reverse_cuthill_mckee(Z, True)
    Z = Z[P, :].A
    A = np.diff(Z, axis=ax)
    print(np.sum(np.abs(A) > 0))