Example #1
0
def qtest_pocs(st_rec, st_orginal, alpharange, irange):
	"""
	Runs the selected method in a certain range of parameters (iterations and alpha), returns a table of Q values ,defined as:

	Q = 10 * log( || d_org || ^2 _2  / ||  d_org - d_rec || ^2 _2 )

	The highest Q value is the one to be chosen.
	"""
	Qall = []
	dmethod  = 'reconstruct'
	method	= 'linear'

	st_org  = st_orginal.copy()
	data_org= stream2array(st_org, normalize=True)

	for alpha in alpharange:
		
		print("##################### CURRENT ALPHA %f  #####################\n" % alpha )
		for i in irange:

			print('POCS RECON WITH %i ITERATIONS' % i, end="\r")
			sys.stdout.flush()
			srs = st_rec.copy()
			st_pocsrec = pocs_recon(srs, maxiter=int(i), method=method, dmethod=dmethod, alpha=alpha)
			drec = stream2array(st_pocsrec, normalize=True)
			Q_tmp = np.linalg.norm(data_org,2)**2. / np.linalg.norm(data_org - drec,2)**2.
			Q = 10.*np.log(Q_tmp)	
			Qall.append([alpha, i, Q])

	Qmax = [0,0,0]
	for i in Qall:
		if i[2] > Qmax[2]: Qmax = i


	return Qall
Example #2
0
	            DOMETHOD = 'recon'

	    for alpha in alphalist:

	        name1 = 'pocs_' + str(noiselevellist[i]) + '-noise_' + '{:01.2}'.format(alpha) + '-alpha_' + 'linear' + '.png'
	        name2 = 'pocs_' + str(noiselevellist[i]) + '-noise_' + '{:01.2}'.format(alpha) + '-alpha_' + 'exp' + '.png'             
	        picpath1 = PICPATH + name1
	        picpath2 = PICPATH + name2
	        plotnameQall = PICPATH + 'pocs_' + str(noiselevellist[i]) + '{:01.2}'.format(alpha) + '-alpha' + DOMETHOD + 'lin'
	        plotnameQmbwall = PICPATH + 'pocs_' + str(noiselevellist[i]) + '{:01.2}'.format(alpha) + '-alpha' + DOMETHOD + 'mask_bw'
	        plotnameQmtaperall = PICPATH + 'pocs_' + str(noiselevellist[i]) + '{:01.2}'.format(alpha) + '-alpha' + DOMETHOD + 'mask_taper'
	        plotnameQSSAall = PICPATH + 'pocs_' + str(noiselevellist[i]) + '{:01.2}'.format(alpha) + '-alpha' + DOMETHOD + 'SSA'

	        
	        print("##################### CURRENT ALPHA %f  #####################\n" % alpha )
	        for maxiter in maxiterlist:

	            print('POCS RECON WITH %i ITERATIONS' % maxiter, end="\r")
	            sys.stdout.flush()
	            data_org = d0.copy()
	            srs = array2stream(data.copy())
	            st_rec = pocs_recon(srs, maxiter, dmethod='recon', method='linear', alpha=alpha)
	            drec = stream2array(st_rec, normalize=True)
	            Q = np.linalg.norm(data_org,2)**2. / np.linalg.norm(data_org - drec,2)**2.                  
	            Qlinall.append([alpha, maxiter, 10.*np.log(Q)])


                savepath = plotnameQall + '.dat'
                np.savetxt(savepath, Qlinall)

Example #3
0
			picpath2 = PICPATH + name2
			plotnameQall = PICPATH + 'pocs_' + str(noiselevellist[i]) + '{:01.2}'.format(alpha) + '-alpha' + DOMETHOD + 'lin'
			plotnameQmbwall = PICPATH + 'pocs_' + str(noiselevellist[i]) + '{:01.2}'.format(alpha) + '-alpha' + DOMETHOD + 'mask_bw'
			plotnameQmtaperall = PICPATH + 'pocs_' + str(noiselevellist[i]) + '{:01.2}'.format(alpha) + '-alpha' + DOMETHOD + 'mask_taper'
			plotnameQmvaryall = PICPATH + 'pocs_' + str(noiselevellist[i]) + '{:01.2}'.format(alpha) + '-alpha' + 'norm' + 'mask_vary'

			
			print("##################### CURRENT ALPHA %f  #####################\n" % alpha )
			for maxiter in maxiterlist:

				print('POCS RECON WITH %i ITERATIONS' % maxiter, end="\r")
				sys.stdout.flush()
				print('LINEAR\n')
				data_org = d0.copy()
				srs = array2stream(data.copy())
				st_rec = pocs_recon(srs, maxiter, method=DOMETHOD, dmethod='linear', alpha=alpha)
				drec = stream2array(st_rec, normalize=True)
				Q = np.linalg.norm(data_org,2)**2. / np.linalg.norm(data_org - drec,2)**2.
				Qlin = 10.*np.log(Q)	
				Qlinall.append([alpha, maxiter, Qlin])

				for bws in bwlist:
					print('USING BW, %i, MASK' % int(bws), end="\r")
					sys.stdout.flush()
					data_org = d0.copy()
					srs = array2stream(data.copy())
					st_rec = pocs_recon(srs, maxiter, method=DOMETHOD, dmethod='linear', alpha=alpha, beta=None, peaks=peaks)
					drecmask = stream2array(st_rec, normalize=True)
					Q = np.linalg.norm(data_org,2)**2. / np.linalg.norm(data_org - drecmask,2)**2.
					
					Qbwmaskall.append([alpha, maxiter, 10.*np.log(Q), bws])