del UBornCplxR, UBornCplxG, UBornCplxB start_time = time.time() ft.SAVtiffRGBCube( f"{PROCESSINGFOLDER}/IntensiteRheinSpec_{DIMTOMO}x{DIMTOMO}x{DIMTOMO}.tiff", IntensiteRhein, 2 * PIXTHEO * 1e6) print( f"Data saving: {np.round(time.time() - start_time,decimals=2)} seconds" ) # Darkfield processing if "DARKFIELD" == MethodUsed: DarkF = abs(UBornCplxDark)**2 start_time = time.time() ft.SAVtiffCube( f"{PROCESSINGFOLDER}/Darkfield_{DIMTOMO}x{DIMTOMO}x{DIMTOMO}.tiff", DarkF, 2 * PIXTHEO * 1e6) print( f"Data saving: {np.round(time.time() - start_time,decimals=2)} seconds" ) if "BASE" == MethodUsed: Base = np.abs(Refraction + 1j * Absorption)**2 start_time = time.time() ft.SAVtiffCube( f"{PROCESSINGFOLDER}/Brightfield_{DIMTOMO}x{DIMTOMO}x{DIMTOMO}.tiff", Base, 2 * PIXTHEO * 1e6) print( f"Data saving: {np.round(time.time() - start_time,decimals=2)} seconds" )
CPT += 1 if "RHEINBERG" == MethodUsed: StackRGB[:,:,int((Z+1200)/80),0] = SumHoloR StackRGB[:,:,int((Z+1200)/80),1] = SumHoloG StackRGB[:,:,int((Z+1200)/80),2] = SumHoloB else : Stack[:,:,int((Z+1200)/80)] = SumHolo CPTSUM += 1 print(f"Slice {CPTSUM} out of {Stack.shape[2]}") print(f"Pre-Processing time for {CPTSUM} Slices: " f"{np.round(time.time() - start_time,decimals=2)} seconds") if "RHEINBERG" == MethodUsed: ft.SAVtiffRGBCube(f"{PROCESSINGFOLDER}/{MethodUsed}_{2*dimHolo}x{2*dimHolo}x{StackRGB.shape[2]}.tiff", StackRGB, 2*M.PIX*1e6) else: ft.SAVtiffCube(f"{PROCESSINGFOLDER}/{MethodUsed}_{2*dimHolo}x{2*dimHolo}x{Stack.shape[2]}.tiff", Stack, 2*M.PIX*1e6) # Center recording and file closing fidParams.write(f"nb_angle {CPT_EXIST-1}\n") fidParams.write(f"fmaxHolo {fmaxHolo}\n") fidParams.write(f"dimHolo {dimHolo}\n") fidParams.write(f"pixTheo {M.PIX/Gtot}\n") tf.imwrite(CHEMINSAV_CENTRES, np.float32(np.int32(Centres))) fidCentrestxt.close() fidParams.close()
NMAX = 0.05 KAPPAMIN = 0 KAPPAMAX = 0 # Gerchberg reconstruction del Absorption, Refraction start_time = time.time() FilteredObj = rp.Gerchberg(Rec_Object, OTF, NMIN, NMAX, KAPPAMIN, KAPPAMAX, NBITER) print("") print(f"Reconstruction time for {NBITER} iterations: " f"{np.round(time.time() - start_time,decimals=2)} seconds") print("") # plt.imshow(Rec_Object[:, :, DIMHOLO].real, cmap="gray") # plt.show() # plt.imshow(Rec_Object[:, :, DIMHOLO].imag, cmap="gray") # plt.show() # Data saving start_time = time.time() ft.SAVtiffCube( f"{GERCHBERGFOLDER}/RefractionGerch_{DIMTOMO}x{DIMTOMO}x{DIMTOMO}.tiff", Rec_Object.real.transpose(1, 0, -1), 2 * PIXTHEO * 1e6) print(f"Data saving: {np.round(time.time() - start_time,decimals=2)} seconds") # Visualization viewer = napari.view_image(Rec_Object.real.transpose(-1, 1, 0), name='Refraction', colormap='magma', axis_labels=["z", "y", "x"])
print( f"3D-FFT computation time : {np.round(time.time() - start_time, decimals=2)} seconds" ) fdm, sdzm, dxm, dym = rp.Calc_fd(FMAXHOLO, REWALD) HOLO = np.zeros((DIMHOLO, DIMHOLO, NB_HOLO), dtype=np.complex128) start_time = time.time() for cpt in range(NB_HOLO): if cpt % 100 == 0: print(f"Hologram = {cpt} out of {NB_HOLO}") TF_Holo = np.zeros((DIMHOLO, DIMHOLO), dtype=np.complex128) k_inc = np.array([fi[0, cpt], fi[1, cpt]]) TF_Holo = st.Calc_TF_Holo(TomoSpectrum, TF_Holo, fdm, sdzm, dxm, dym, FMAXHOLO, k_inc, REWALD, 632.8e-9, nimm) decal = np.array([-k_inc[0] + DIMHOLO / 2, -k_inc[1] + DIMHOLO / 2]).astype(int) TF_Holo_r = rp.decal_TF_holo(TF_Holo, decal, TF_Holo.shape[0], roll=True) HOLO[:, :, cpt] = (ifftn(TF_Holo_r)) / (UBornPitch**2 * FMAXHOLO**2) # plt.imshow(np.abs(HOLO), cmap="gray") # plt.show() print( f"Simulation time for {NB_HOLO} holograms: {np.round(time.time() - start_time, decimals=2)} seconds" ) print("") # ft.SAVtiffCube(CHEMIN_RE_UBORN, HOLO, PIXTHEO*1e6) ft.SAVtiffCube(CHEMIN_RE_UBORN, HOLO.real, PIXTHEO * 1e6) ft.SAVtiffCube(CHEMIN_IM_UBORN, HOLO.imag, PIXTHEO * 1e6) print( f"Execution time: {np.round(time.time() - total_time, decimals=2)} seconds" )
print("") Refraction = f_recon.real Absorption = f_recon.imag OTF = np.zeros_like(mask_sum) OTF[mask_sum != 0] = 1 # TFVolfilt = np.zeros_like(OTF) # TFVolfilt[TFVol != 0] = 1 viewer = napari.Viewer() viewer.add_image(Absorption.transpose(-1, 1, 0), name='Absorption', colormap='magma') viewer.add_image(Refraction.transpose(-1, 1, 0), name='Refraction', colormap='magma') # Writting results start_time = time.time() ft.SAVtiffCube( f"{PROCESSINGFOLDER}/Refraction_{DIMTOMO}x{DIMTOMO}x{DIMTOMO}.tiff", Refraction, 2 * PIXTHEO * 1e6) ft.SAVtiffCube( f"{PROCESSINGFOLDER}/Absorption_{DIMTOMO}x{DIMTOMO}x{DIMTOMO}.tiff", Absorption, 2 * PIXTHEO * 1e6) ft.SAVtiffCube(f"{PROCESSINGFOLDER}/OTF_{DIMTOMO}x{DIMTOMO}x{DIMTOMO}.tiff", OTF, 1. / (Refraction.shape[0] * 2 * PIXTHEO * 1e6)) # ft.SAVtiffCube(f"{PROCESSINGFOLDER}/Spectrum_{DIMTOMO}x{DIMTOMO}x{DIMTOMO}.tiff", # fftshift(np.log10(abs(TFVol*1e17+1e-10)**2)), 1./(Refraction.shape[0]*2*PIXTHEO*1e6)) print(f"Data saving: {np.round(time.time() - start_time,decimals=2)} seconds")