log.info('Making '+str(N)+' frames') for i in tqdm(range(N)): # xp, yp, zp = phantoms.sphere_spiral(i/(N-1)) # print(xp,yp,zp) if i == 0: x, y, z = (0.5, 0, 0) xp, yp, zp = (1,0,1) else: x, y, z = (0, 0.5, 0) xp, yp, zp = (0,1,1) obj = R3S2toR.xyzj_list([[x,y,z]], [[xp,yp,zp]], shape=[10,10,4], title='Single dipole radiator') obj.build_actors() d1 = det.FourFLF(ulens_aperture='square', irrad_title='Lightfield detector irradiance') im1 = d1.xyzj_single_to_xy_det(obj) im1.data /= 100 d2 = det.FourF() im0 = d2.xyzj_single_to_xye_det(obj) im2 = d2.xyzj_single_to_xy_det(obj) im2.data /= 100 istr = '{:03d}'.format(i) im1.to_tiff('./out2/'+istr+'.tif') utilmpl.plot([[obj, im0, im2, im1]], './out/'+istr+'.png')
log = logging.getLogger('log') # Load object with open('guv-2um.pickle', 'rb') as handle: xyzJ_list = pickle.load(handle) # Load microscope with open('det.pickle', 'rb') as handle: det1 = pickle.load(handle) xyzJ_list.data_xyz += np.array([0, 0, -2.5]) N = 50 for i in range(N): # Shift up xyzJ_list.data_xyz += np.array([0, 0, 0.1]) # Put object on a grid input_shape = (101, 101, 50, 6) input_vox_dims = (6.5 / 60, 6.5 / 60, 0.2) xyzJ = xyzJ_list.to_xyzJ(input_shape, input_vox_dims) # Simulate microscope xy = det1.xyzJ_to_xy_det(xyzJ) # Plot xyzJ.skip_n = 2 xyzJ.rad_scale = 1.5 xyzJ.build_actors() obj_list = [xyzJ, xy] utilmpl.plot([obj_list], './out/' + str(i) + '.png', ss=2)
log = logging.getLogger('log') log.info('Generating phantom.') vox_dims = np.array([.1, .1, .1]) data = np.zeros((3, 3, 3, 6)) data[0, 0, 0, 0] = 1 data[1, 1, 1, 0] = 1 data[2, 2, 2, 0] = 1 data[2, 0, 0, 0] = 1 grid_obj = R3S2toR.xyzJ(data, vox_dims=vox_dims) grid_obj.to_tiff('./guv.tiff') grid_obj.rad_scale = 0.5 log.info('Calculating MIP') mip = grid_obj.to_R3toR_xyz() obj_list = [grid_obj, mip] for obj in obj_list: obj.build_actors() # Flyaround N = 80 log.info('Making ' + str(N) + ' frames') for i in tqdm(range(N)): for obj in obj_list: obj.increment_camera(360 / N) istr = '{:03d}'.format(i) utilmpl.plot([obj_list], './test/' + istr + '.png', ss=2)
for i in tqdm(range(N)): pos = np.array([0, 0, 0]) #phantoms.defocus_path(i/N) ss = phantoms.sphere_spiral(i / (N - 1)) jj = phantoms.uniaxial_ellipsoid(1, 0.0001, ss, N=2**14) obj = R3S2toR.xyzj_list([pos], [jj], shape=[10, 10, 4], title='Uniaxial distribution $a/b = 0.1$') obj2 = obj.to_xyzJ_list(Jmax=6) obj2.title = '$\ell = 2$ projection' print(obj2.data_J) obj.build_actors() obj2.build_actors() d1 = det.FourF() im1 = d1.xyzJ_list_to_xy_det(obj2) im1.data /= 100 d2 = det.FourFLF(irrad_title='Lightfield detector irradiance') im2 = d2.xyzJ_list_to_xy_det(obj2) im2.data /= 100 istr = '{:03d}'.format(i) utilmpl.plot([[obj, im1, im2]], './test/' + istr + '.png') # im1.to_tiff('./test1/'+istr+'.tif') # im2.to_tiff('./test2/'+istr+'.tif')
from tqdm import tqdm from polaris2.geomvis import R3S2toR, R2toR, S2toR, utilmpl from polaris2.micro.micro import det l2m_2 = S2toR.Jeven([0, 0, 1, 0], title='$Y_{2,-1}$') l2m_1 = S2toR.Jeven([0, 0, 0, 0, 0, 1], title='$Y_{2,2}$') l2m_2.precompute_tripling() l3 = l2m_2 * l2m_1 ell = [l2m_2, l2m_1, l3] # l2m_2.interact() for el in ell: el.build_actors() N = 100 for i in tqdm(range(N)): istr = '{:03d}'.format(i) utilmpl.plot([ell], './out/' + istr + '.png') for el in ell: el.increment_camera(360 / N)
# Threshold xyzJ_recon.threshold = 0.3*np.max(xyzJ_recon.data) # Convert to other visuals grid_peak_recon = xyzJ_recon.to_R3toR3_xyz() grid_int_recon = xyzJ_recon.to_R3toR_xyz() xyzJ_recon.build_actors() grid_peak_recon.rad_scale = 1 grid_peak_recon.build_actors() grid_int_recon.build_actors() # Calculate im3 # im3 = d2.xyzJ_to_xy_det(xyzJ_recon) im3 = d2.fwd(xyzJ_recon) # Titles xyzJ.title = '$\mathbf{f}$' grid_peak.title = 'Peaks$(\mathbf{f})$' grid_int.title = 'MIP$(\mathbf{f})$' im2.title = '$\mathcal{H}\mathbf{f}$' xyzJ_recon.title = '$\mathcal{H^+H}\mathbf{f}$' grid_peak_recon.title = 'Peaks$(\mathcal{H^+H}\mathbf{f})$' grid_int_recon.title = 'MIP$(\mathcal{H^+H}\mathbf{f})$' im3.title = '$\mathcal{HH^+H}\mathbf{f}$' # Plot obj_list = [xyzJ, grid_peak, grid_int, im2] res_list = [xyzJ_recon, grid_peak_recon, grid_int_recon, im3] utilmpl.plot([obj_list, res_list], './test-guv.png', ss=2)
# g = Hf g = lfdet.fwd(f) g.title = '$\mathbf{g} = \mathcal{H}\mathbf{f}$' # f_hat = H^+Hf f_hat = lfdet.pinv(g, out_vox_dims=input_vox_dims) f_hat.threshold = 0.3 * np.max(f_hat.data) f_hat.build_actors() f_hat.title = '$\hat{\mathbf{f}} = \mathcal{H^+H}\mathbf{f}$' # Peak(f_hat) peakf_hat = f_hat.to_R3toR3_xyz() peakf_hat.rad_scale = 1 peakf_hat.build_actors() peakf_hat.title = 'Peaks$(\hat{\mathbf{f}})$' # MIP(f) MIPf_hat = f_hat.to_R3toR_xyz() MIPf_hat.build_actors() MIPf_hat.title = 'MIP$(\hat{\mathbf{f}})$' # g_hat = Hf_hat g_hat = lfdet.fwd(f_hat) g_hat.title = '$\hat{\mathbf{g}} = \mathcal{H}\hat{\mathbf{f}}$' obj_list = [f_list, peakf, MIPf, g] res_list = [f_hat, peakf_hat, MIPf_hat, g_hat] nstr = '{:03d}'.format(n) utilmpl.plot([obj_list, res_list], './out/' + nstr + '.png', ss=2)
xyz_list, j_list = phantoms.guv(radius=2.0, ellip_ratio=0.2, M=2**13, dist_type='ellipsoid') ss_obj = R3S2toR.xyzj_list(xyz_list, j_list, title='Dense object', rad_scale=0.125) log.info('Converting phantom to grid.') vox_dims = np.array([6.5 / 60, 6.5 / 60, .2]) npx = np.array([45, 45, 25]) grid_obj = ss_obj.to_xyzJ(npx=npx, vox_dims=vox_dims, lmax=4) grid_obj.to_tiff('./guv-2um.tiff') grid_obj = R3S2toR.xyzJ(np.zeros((1, )), title='Dense object') grid_obj.from_tiff('./guv-2um.tiff') log.info('Calculating peaks') peaks = grid_obj.to_R3toR3_xyz() log.info('Calculating MIP') mip = grid_obj.to_R3toR_xyz() # Visualize obj_list = [grid_obj, peaks, mip] for obj in obj_list: obj.build_actors() utilmpl.plot([obj_list], './visuals.png', ss=2)