In [1]:
%pylab inline
import numpy as np
import sys
sys.path.append('../src')
import PatternEvaluator as pe
import SamplingPattern as sp
In [2]:
# instance PatternEvaluator
mype = pe.PatternEvaluator()
#load numpy array of coil sensitivities. (nchannels x nx x ny)
mype.load_sens('../data/sens_6ch_128x128.npz')
#mype.load_sens('../data/sens_31ch_128x128.npz')
In [9]:
# make sampling pat
mypat = sp.SamplingPattern()
# set up vectors for r= 2x2
mypat.yvec[::2,:]=0
mypat.xvec[:,::2]=0
#tell sampling pattern to calculate its 'sampling' parameter by taking outer product of x and y sampling vectors
mypat.calc_pattern()
#alternativley, you can set mypat.sampling to an array of 1/0 of the correct k-space size
Out[9]:
In [4]:
pat = np.random.sample((128,128))>0.75
sum(pat)
mypat.sampling = pat
In [5]:
#evaluate pattern
mype.eval_pattern(mypat)
In [5]:
#can change simulation params in mypat
mypat.hitol=1e-2
mypat.tol=1e-5
In [6]:
mype.eval_pattern(mypat)
In [8]:
# We can opt to use a single coil, in which case the system is not solvable
#mype.set_single_coil()
#mype.eval_pattern(mypat)
Demonstration: fill in centre block of sampling pattern and re-evaluate. Note the change in the maximum eigenvalue.
In [7]:
mypat.sampling[61:67, 61:67]=1
In [8]:
mype.eval_pattern(mypat)
In [10]:
mypat.sampling[61:68,122:127]=1
mype.eval_pattern(mypat)