angles_spect = np.zeros((nRealizations,))
angles_clust = np.zeros((nRealizations,6))



for jj in range(nAngles,-1,-1): #range(nAngles + 1):

  #Generate signal
  rangle  =  np.arccos(1.0/2.0**0.25) + (np.pi/4.0)*(jj/(1.0*nAngles))   
  signal  =  np.zeros(n_sample_pnts)
  #angles_true[jj] = rangle * 180 / np.pi
  
  print('\n')
  print('Creating signal...')
  for i in range(n_sample_pnts):
    (angles_true[jj],signal[i]) = sph.rand_sig(sample_pnts[i, :3].T, b, n_fibers, rangle)


  s_energy = norm(signal,2)
  snr = 20.0
  tau = 10.0**(-snr/10.0) * s_energy
  print('Signal to noise ratio: %0.5g' % snr)


  #Start Monte Carlo simulations
  for kk in range(nRealizations):
    print('\n')
    print('Realization: %2g' % kk)

    # Make Rician noise
    noiseR = np.random.randn(*signal.shape)
Exemple #2
0
# Sample signal on lower degree quadrature
qsph1_16_132DP = np.loadtxt('data/qsph1-16-132DP.dat')
sample_pnts  = qsph1_16_132DP[:, :3]
n_sample_pnts = 132

# Create reproducing-kernel (sparse representation) matrix
A_new = sph.interp_matrix(quad_pnts, sample_pnts, n_qpnts, n_sample_pnts, N)

# Create signal
print('Creating signal...')
n_fibers = 1                      # number of Gaussian components (max n=3)
b        = 4000                   # s/mm^2
r_angle  = -np.pi/4
signal   =  np.zeros(n_sample_pnts)
for i in range(n_sample_pnts):
    signal[i] = sph.rand_sig(sample_pnts[i, :3].T, b, n_fibers, r_angle)[1]

SNR = []

nRealizations = 1
for kk in range(nRealizations):
    # Make Rician noise
    sigma  = 0.0                          # standard deviation
    noiseR = sigma * np.random.randn(*signal.shape)
    noiseI = sigma * np.random.randn(*signal.shape)
    noise  = noiseR + 1j*noiseI

    SNR.append(10 * np.log10(norm(signal,2)/norm(noise,2)))
    print('Signal to noise ratio: %0.5g' % SNR[kk])

    # Add noise to signal