# Temporary replacement of bad projections if params["correct_bad"]: stack_phasecorr = replace_bad( stack_phasecorr, list_bad=params["bad_projs"], temporary=True ) # find the residues and choose region to be unwrapped rx, ry, airpix = chooseregiontounwrap(stack_phasecorr) ansunw = input("Do you want to continue with the unwrapping?([y]/n)").lower() if str(ansunw) == "" or str(ansunw) == "y": stack_unwrap = unwrapping_phase(stack_phasecorr, rx, ry, airpix, **params) else: stack_unwrap = stack_phasecorr print("The phases have not been unwrapped").lower() # display the projections after the unwrapping showmovie = input( "Do you want to show all the unwrapped projections?([y]/n): " ).lower() if str(showmovie) == "" or str(showmovie) == "y": iterative_show(stack_unwrap, ry, rx, airpix, onlyroi=False) # Save the unwrapped phase projections SaveData.save("unwrapped_phases.h5", stack_unwrap, theta, **params) # next step print('You should run "vertical_alignment.py" now') # =============================================================================#
# initializing params params = dict() ### Edit section ### # ========================= params["account"] = "ma3495" params["samplename"] = "H2int_15000h_outlet" params[ "pathfilename" ] = "/data/id16a/inhouse5/visitor/ma3495/id16a/H2int_15000h_outlet/H2int_15000h_outlet_25nm_holo_/H2int_15000h_outlet_25nm_holo_rec_0000.edf" params["regime"] = "holoct" params["showrecons"] = False params["autosave"] = True # ========================= # =============================================================================# # Don't edit below this line, please # # =============================================================================# if __name__ == "__main__": # loading the projections from files stack_objs, theta, pixelsize, params = LoadProjections.loadedf(**params) # Save reconstructed phase projections SaveData.save("reconstructed_projections.h5", stack_objs, theta, **params) # next step print('You should run "vertical_alignment_holo.py" for phase tomogram') # =============================================================================#
print("Tomo consistency on multiples slices not done") # Shift projections (Only shift the horizontal) print("Shifting the projections (only shifts in the horizontal direction)") aligned_projections = compute_aligned_horizontal( aligned_diff, shiftstack, shift_method=params["shiftmeth"] ) # correcting bad projections after the alignment if needed if params["correct_bad"]: aligned_projections = replace_bad( aligned_projections, list_bad=params["bad_projs"], temporary=False ) a = input("Do you want to display the aligned projections? (y/[n]) :").lower() if str(a) == "y": iterative_show( aligned_projections, vmin=-0.2, vmax=0.2 ) # Show aligned projections derivatives # calculate one slice for display aligned_sinogram = np.transpose(aligned_projections[:, params["slicenum"], :]) oneslicefordisplay(aligned_sinogram, theta, **params) # save horizontally aligned_projections SaveData.save( "aligned_projections.h5", aligned_projections, theta, shiftstack, **params ) # next step print('You should run "tomographic_reconstruction.py" now') # =============================================================================#
normfreqs, T, FSC2Dcurve = FSC2D.plot() print("The pixelsize of the data is {:.02f} nm".format(voxelsize[0] * 1e9)) a = input("\nPlease, input the value of the intersection: ") params["resolution2D"] = voxelsize[0] * 1e9 / float(a) print("------------------------------------------") print("| Resolution is estimated to be {:.2f} nm |".format( params["resolution2D"])) print("------------------------------------------") input("\n<Hit Return to close images>") plt.close("all") # save the 2D FSC data SaveData.saveFSC("FSC2D.h5", normfreqs, T, FSC2Dcurve, tomogram1, tomogram2, theta, voxelsize, **params) # ========================= # 3D FSC calculation # ========================= a = str(input("Do you want to calculate the 3D FSC?(y/n)")).lower() if a == "" or a == "y": # del tomo1, tomo2, image1, image2, sinogram_align, sinogram_align1, sinogram_align2#, sagital_slice1, sagital_slice2 limsyFSC = params["limsyFSC"] nslices = limsyFSC[-1] - limsyFSC[0] # initializing variables tomogram1 = np.empty((nslices, nr, nc)) tomogram2 = np.empty((nslices, nr, nc)) sinogram1 = np.empty((nslices, sino1nr, sino1nc))
"reconstructed_projections.h5", **params) # initializing shiftstack if params["load_previous_shiftstack"]: shiftstack = LoadData.loadshiftstack("vertical_alignment.h5", **params) print("Using previous estimate of shiftstack") else: # initializing shiftstack with zeros shiftstack[0] = np.zeros(stack_unwrap.shape[0]) # Vertical alignment shiftstack, aligned = alignprojections_vertical(stack_unwrap, shiftstack, **params) a = input("Do you want to refine further the alignment? (y/[n]): ").lower() if str(a) == "y": shiftstack, aligned = alignprojections_vertical( stack_unwrap, shiftstack, **params) a = input( "Do you want to display the aligned projections? (y/[n]) :").lower() if str(a) == "y": iterative_show(aligned) # Show aligned projections # save vertically aligned_projections SaveData.save("vertical_alignment.h5", aligned, theta, shiftstack, **params) # next step print('You should run "projections_derivatives.py" now') # =============================================================================#
params = dict() ### Edit section ### # ========================= params["samplename"] = "v97_v_nfptomo2_15nm" params["crop_reg"] = None # [20,0,20,0] # left, bottom, right, top params["autosave"] = False params["vmin"] = -1.6 params["vmax"] = 1.6 params["amponly"] = True # ensuring that we are loading only amplitude # ========================= # =============================================================================# # Don't edit below this line, please # # =============================================================================# if __name__ == "__main__": # loading the data stack_objs, theta, shiftstack, params = LoadData.load( "reconstructed_projections.h5", **params ) # correcting phase ramp stack_phasecorr = gui_plotamp(stack_objs, **params) # Save the corrected phase projections SaveData.save("air_corrected_amplitude.h5", stack_phasecorr, theta, **params) # next step print('You should run "phase_unwrapping.py" now') # =============================================================================#
params = dict() ### Edit section ### # ========================= params["samplename"] = "v97_v_nfptomo2_15nm" params["crop_reg"] = None # [20,0,20,0] # left, bottom, right, top params["autosave"] = False params["vmin"] = -1.6 params["vmax"] = 1.6 params["phaseonly"] = True # ensuring that we are loading only phase # ========================= # =============================================================================# # Don't edit below this line, please # # =============================================================================# if __name__ == "__main__": # loading the data stack_objs, theta, shiftstack, params = LoadData.load( "reconstructed_projections.h5", **params) # correcting phase ramp stack_phasecorr = gui_plotphase(stack_objs, **params) # Save the corrected phase projections SaveData.save("linear_phase_corrected.h5", stack_phasecorr, theta, **params) # next step print('You should run "phase_unwrapping.py" now') # =============================================================================#
# =============================================================================# if __name__ == "__main__": # loading the data aligned, theta, shiftstack, params = LoadData.load("vertical_alignment.h5", **params) # chosse the region to apply the derivatives roix, roiy = chooseregiontoderivatives(aligned, **params) # calculating the projection derivatives aligned_diff = calculate_derivatives(aligned, roiy, roix, shift_method=params["shift_method"]) # display the projections after the unwrapping showmovie = input( "Do you want to show all the projection derivatives?([y]/n): ").lower( ) if str(showmovie) == "" or str(showmovie) == "y": iterative_show(aligned_diff, onlyroi=False, vmin=-0.2, vmax=0.2) # Save the projection derivatives SaveData.save("aligned_derivatives.h5", aligned_diff, theta, shiftstack, **params) # next step print('You should run "sinogram_inspection.py" now') # =============================================================================#
# local packages from toupy.io import LoadData, SaveData, load_paramsh5 # initializing dictionaries params = dict() # Edit section # ========================= params["samplename"] = "v97_v_nfptomo2_15nm" # ========================= # =============================================================================# # Don't edit below this line, please # # =============================================================================# if __name__ == "__main__": # update params paramsh5 = load_paramsh5(**params) params.update(paramsh5) # loading theta and shiftstack for the saving shiftstack = LoadData.loadshiftstack("aligned_projections.h5", **params) theta = LoadData.loadtheta("aligned_projections.h5", **params) # actual saving SaveData.save_vol_to_h5("tomogramVOL.h5", theta, **params) # next step print('You can now run "tiff_convertion.py" if needed') # =============================================================================#