biref_map = ne_map_copy -  no_map_copy
## assign material on the top to be reverse optic sign ##
# no_map[:,:,L//2:] = ne_map_copy[:,:,L//2:].copy()
# ne_map[:,:,L//2:] = no_map_copy[:,:,L//2:].copy()
#########################################################

## assign material on the right to be reverse optic sign ##
# no_map[:,M//2:,:] = ne_map_copy[:,M//2:,:].copy()
# ne_map[:,M//2:,:] = no_map_copy[:,M//2:,:].copy()
###########################################################

### Visualize sample properties

#### XY sections
wo.plot_multicolumn([target[:,:,z_layer], azimuth[:,:,z_layer]%(2*np.pi), inclination[:,:,z_layer]], origin='lower', size=5, num_col=3, titles=[f'target, z={z_layer}', 'azimuth', 'inclination'], set_title = True)
#### XZ sections
wo.plot_multicolumn([np.transpose(target[y_layer,:,:]), np.transpose(azimuth[y_layer,:,:])%(2*np.pi), np.transpose(inclination[y_layer,:,:])], origin='lower', size=5, num_col=3, titles=['retardance', 'azimuth', 'inclination'], set_title = True)
plt.show()

#### Principal retardance and 3D orientation in color

orientation_3D_image = np.transpose(np.array([azimuth%(2*np.pi)/2/np.pi, inclination,  np.clip((ne_map-no_map)*psz*2*np.pi/lambda_illu/np.pi/2*lambda_illu*1e3,0, 1.5)/1.5]),(3,1,2,0))
orientation_3D_image_RGB = wo.orientation_3D_to_rgb(orientation_3D_image, interp_belt = 20/180*np.pi, sat_factor = 1)

plt.figure(figsize=(10,10))
plt.imshow(orientation_3D_image_RGB[z_layer], origin='lower')
plt.figure(figsize=(10,10))
plt.imshow(orientation_3D_image_RGB[:,y_layer], origin='lower')
plt.figure(figsize=(3,3))
wo.orientation_3D_colorwheel(wheelsize=128, circ_size=50, interp_belt=20/180*np.pi, sat_factor=1,  discretize=True)
Exemplo n.º 2
0
    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')
plt.show()

plt.figure(figsize=(10,10))
plt.imshow(I_meas[:,:,L//2], cmap='gray', origin='lower')
plt.figure(figsize=(10,10))
sector_angle = 45

Source_BF = wo.gen_Pupil(fxx, fyy, NA_obj / n_media / 2, lambda_illu / n_media)
Source = wo.gen_sector_Pupil(fxx, fyy, NA_obj / n_media, lambda_illu / n_media,
                             sector_angle, rotation_angle)
Source.append(Source_BF)
Source = np.array(Source)

# setup polarization state of the illumination
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]

wo.plot_multicolumn(fftshift(Source, axes=(1, 2)), origin='lower', num_col=5)
plt.show()

# Initiate reconstruction with experimental 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',
Exemplo n.º 4
0
                                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]
    ]),
    num_col=2,
    size=5,
    set_title=True,
    titles=['Retardance', '2D orientation', 'Brightfield', 'Depolarization'],
    origin='lower')

wo.plot_hsv([Recon_para[1, :, :, L // 2], Recon_para[0, :, :, L // 2]],
            max_val=1,
            origin='lower',
            size=10)
plt.show()

# ## 2D retardance and orientation reconstruction with $S_1$ and $S_2$
# Diffraction aware reconstruction assuming slowly varying transmission.
S1_stack = S_image_recon[1].copy() / S_image_recon[0].mean()
S2_stack = S_image_recon[2].copy() / S_image_recon[0].mean()
Exemplo n.º 5
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, phase_deconv='2D', \
                                A_matrix=A_matrix, inc_recon='2D-vec-WOTF', \
                                illu_mode='Arbitrary', Source = Source_cont, Source_PolState=Source_PolState, \
                                use_gpu=use_gpu, gpu_id=gpu_id)

## Visualize 2D transfer functions as a function of illumination pattern

# 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_image_tm = np.zeros_like(S_image_recon)

S_bg_mean_0 = np.mean(S_image_recon[0,:,:,:], axis=(0,1))[np.newaxis,np.newaxis,:]
S_bg_mean_1 = np.mean(S_image_recon[1,:,:,:], axis=(0,1))[np.newaxis,np.newaxis,:]
S_bg_mean_2 = np.mean(S_image_recon[2,:,:,:], axis=(0,1))[np.newaxis,np.newaxis,:]


S_image_tm[0] = S_image_recon[0]/S_bg_mean_0-1
S_image_tm[1] = S_image_recon[1]/S_bg_mean_0 - S_bg_mean_1*S_image_recon[0]/S_bg_mean_0**2
Exemplo n.º 6
0
N           = 256                 # number of pixel in y dimension
M           = 256                 # number of pixel in x dimension
mag         = 40                  # magnification
ps          = 6.5/mag             # effective pixel size
lambda_illu = 0.532               # wavelength
n_media     = 1                   # refractive index in the media
NA_obj      = 0.55                # objective NA
NA_illu     = 0.4                 # illumination NA (condenser)
NA_illu_in  = 0.4                 # illumination NA (phase contrast inner ring)
z_defocus   = (np.r_[:5]-2)*1.757 # a set of defocus plane
chi         = 0.03*2*np.pi           # swing of Polscope analyzer

# ## Sample : star with uniform phase, uniform retardance, and radial orientation
# generate Siemens star pattern
star, theta, _ = wo.genStarTarget(N,M)
wo.plot_multicolumn(np.array([star, theta]), num_col=2, size=5)

# Assign uniform phase, uniform retardance, and radial slow axes to the star pattern
phase_value = 1 # average phase in radians (optical path length)
phi_s = star*(phase_value + 0.15) # slower OPL across target
phi_f = star*(phase_value - 0.15) # faster OPL across target
mu_s = np.zeros((N,M)) # absorption
mu_f = mu_s.copy()
t_eigen = np.zeros((2, N, M), complex) # complex specimen transmission
t_eigen[0] = np.exp(-mu_s + 1j*phi_s) 
t_eigen[1] = np.exp(-mu_f + 1j*phi_f)
sa = theta%np.pi #slow axes.
wo.plot_multicolumn(np.array([phi_s, phi_f, mu_s, sa]),
                    num_col=2, size=5, set_title=True,
                    titles=['Phase (slow)', 'Phase (fast)', 'absorption', 'slow axis'], origin='lower')
plt.show()