Source_PolState = np.zeros((len(Source), 2), complex) for i in range(len(Source)): Source_PolState[i, 0] = E_in[0] Source_PolState[i, 1] = E_in[1] # Reconstruct parameters setup = wo.waveorder_microscopy((Ns, Ms), lambda_illu, ps, NA_obj, NA_illu, z_defocus, n_media=n_media, cali=cali, bg_option=bg_option, A_matrix=A_matrix, phase_deconv='3D', inc_recon='3D', illu_mode='Arbitrary', Source=Source, Source_PolState=Source_PolState, use_gpu=use_gpu, gpu_id=gpu_id) # ### Writer setup uPTI_file_name = 'uPTI_subFOVs.zarr' writer = WaveorderWriter(output_path, hcs=False, hcs_meta=None, verbose=True) writer.create_zarr_root(uPTI_file_name) data_shape = (1, 9, N_defocus, int(Ns), int(Ms))
# ### Load data # Load simulations file_name = '/data_sm/home/lihao/project/Polscope/Simulation/3D_Pol_Phase/uPTI_repo_demo/3D_PODT_simulation.npz' array_loaded = np.load(file_name) list_of_array_names = sorted(array_loaded) for array_name in list_of_array_names: globals()[array_name] = array_loaded[array_name] print(list_of_array_names) N, M, L = I_meas.shape # ### Refractive index reconstruction z_defocus = (np.r_[:L]-L//2)*psz chi = 0.1*2*np.pi setup = wo.waveorder_microscopy((N,M), lambda_illu, ps, NA_obj, NA_illu, z_defocus, chi, n_media = n_media, phase_deconv='3D', pad_z=10) H_re_vis = fftshift(setup.H_re) wo.plot_multicolumn([np.real(H_re_vis)[:,:,L//2], np.transpose(np.real(H_re_vis)[N//2,:,:]), np.imag(H_re_vis)[:,:,L//2], np.transpose(np.imag(H_re_vis)[N//2,:,:])], num_col=2, size=8, set_title=True, titles=['$xy$-slice of Re{$H_{re}$} at $u_z=0$', '$xz$-slice of Re{$H_{re}$} at $u_y=0$', '$xy$-slice of Im{$H_{re}$} at $u_z=0$', '$xz$-slice of Im{$H_{re}$} at $u_y=0$'], colormap='jet') plt.show() H_im_vis = fftshift(setup.H_im) wo.plot_multicolumn([np.real(H_im_vis)[:,:,L//2], np.transpose(np.real(H_im_vis)[N//2,:,:]), np.imag(H_im_vis)[:,:,L//2], np.transpose(np.imag(H_im_vis)[N//2,:,:])], num_col=2, size=8, set_title=True, titles=['$xy$-slice of Re{$H_{im}$} at $u_z=0$', '$xz$-slice of Re{$H_{im}$} at $u_y=0$', '$xy$-slice of Im{$H_{im}$} at $u_z=0$', '$xz$-slice of Im{$H_{im}$} at $u_y=0$'], colormap='jet')
lambda_illu * fxx, lambda_illu * fyy, subsampled_NA=0.1) plt.figure(figsize=(10, 10)) plt.imshow(fftshift(Source_discrete), cmap='gray') plt.show() print(np.sum(Source_discrete)) z_defocus = (np.r_[:L] - L // 2) * psz chi = 0.1 * 2 * np.pi setup = wo.waveorder_microscopy((N, M), lambda_illu, ps, NA_obj, NA_illu, z_defocus, chi, n_media=n_media, phase_deconv='3D', illu_mode='Arbitrary', Source=Source_cont) simulator = wo.waveorder_microscopy_simulator((N, M), lambda_illu, ps, NA_obj, NA_illu, z_defocus, chi, n_media=n_media, illu_mode='Arbitrary',
for array_name in list_of_array_names: globals()[array_name] = array_loaded[array_name] print(list_of_array_names) # ### Reconstruction of Stokes parameters and anisotropy _, N, M, L = I_meas.shape cali = False bg_option = 'global' setup = wo.waveorder_microscopy((N, M), lambda_illu, ps, NA_obj, NA_illu, z_defocus, chi, n_media=n_media, phase_deconv='2D', bire_in_plane_deconv='2D', illu_mode='BF') S_image_recon = setup.Stokes_recon(I_meas) S_image_tm = setup.Stokes_transform(S_image_recon) Recon_para = setup.Polarization_recon( S_image_tm) # Without accounting for diffraction wo.plot_multicolumn( np.array([ Recon_para[0, :, :, L // 2], Recon_para[1, :, :, L // 2], Recon_para[2, :, :, L // 2], Recon_para[3, :, :, L // 2] ]),
_, _, N, M, L = I_meas.shape cali = False bg_option = 'global' use_gpu = True gpu_id = 0 A_matrix = 0.5*np.array([[1, 1, 0], \ [1, 0, 1], \ [1, -1, 0], \ [1, 0, -1]]) setup = wo.waveorder_microscopy((N,M), lambda_illu, ps, NA_obj, NA_illu, z_defocus, chi, \ n_media=n_media, cali=cali, \ A_matrix=A_matrix, inc_recon='3D', \ illu_mode='Arbitrary', Source = Source_cont, Source_PolState=Source_PolState,\ pad_z=5, use_gpu=use_gpu, gpu_id=gpu_id) ### Illumination patterns used wo.plot_multicolumn(fftshift(Source_cont, axes=(1, 2)), origin='lower', num_col=5, size=5) plt.show() ## Reconstruct Stokes images and visualize them as a function of illumination pattern S_image_recon = setup.Stokes_recon(I_meas) S_bg_mean_0 = np.mean(S_image_recon[0, :, :, :, :], axis=(1, 2, 3))[:, np.newaxis, np.newaxis, np.newaxis]