Function documentation¶
+core¶
-
core.
append_engine
()¶ - APPEND_ENGINE appends engine specified in new_eng to pAdds engines with index, starting at 01st engine: p.engines.engine0
-
core.
check_omny_queue
()¶ - CHECK_OMNY_QUEUE Check for file queue for omny
-
core.
check_prepared_data
()¶ - CHECK_PREPARED_DATA compares prepared data file with currentreconstruction parameters. If force_update == true, data preparation willbe forced (see core.ptycho_prepare_scans)
-
core.
engine_status
()¶ - ENGINE_STATUS use persisten variables to store error messagesError code: 0 for ‘everything OK’ and ~=0 for ‘error’ (return values of matlab’s system function)usage:engine_status(status) to set persisten variable engine_stat tostatusengine_status to read persisten variables
-
core.
errorplot
()¶ - Build an errormetric plot vs iteration numbere = errorplot Clears the persistent variablee = errorplot(x) Appends x to the persistent variablee = errorplot([]) Only reads the persistent variable
-
core.
extract4saving
()¶ - EXTRACT4SAVING extracts datasets and parameters from p and creates HDF5 structure
-
core.
get_projections
()¶ - GET_PROJECTIONS
-
core.
hermite_like
()¶ - %%%%%%%%%%%%%%%%.. function:: core.initialize_ptychoINITIALIZE_PTYCHO
-
core.
prep_h5data
()¶ - PREP_H5DATA prepare data and save it to diskprep_h5data expects that fmask and fmag already exist, prepares themfor the C++ code and saves everything to disk.It uses the old h5 file format, i.e. each measurement is saved in its owngroup and with its own fmask. This allows for more flexibilty, at thecost of reading and writing speed.If this flexibility is not needed, procPtycho (python data preparation)is highly recommended!
-
core.
prep_initial_conditions
()¶ - PREP_INITIAL_CONDITIONS prepares the initial_conditions file for thereconstruction with external C++ codesave2hdf5 saves a structure to an h5 file
-
core.
prepare_data_matlab
()¶ - PREPARE_DATA_MATLAB prepares and normalizes data for matlab engines
-
core.
prepare_probes
()¶ - Prepare probe - Only single file supported, either the file has a 3D matrixof many probes or the probe will be repeated for the number of probesneeded for reconstruction
-
core.
probe_modes_ortho
()¶ - ORTHO Orthogonalize the given list of modes using SVD.[pr, I_n, eval] = probe_modes_ortho(modes)pr Orthogonalized (eigen) modesI_n Normalized intensity of the mode (relative contribution to total intensity)eval SVD eigenvalues
-
core.
ptycho_adjust_positions
()¶ - PTYCHO_ADJUST_POSITIONS
-
core.
ptycho_artificial_scans
()¶ - PTYCHO_ARTIFICIAL_SCANSDetailed explanation goes here
-
core.
ptycho_model_probe
()¶ - pout = ptycho_model_probe(p)
-
core.
ptycho_plot_ptycho
()¶ - .. function:: core.ptycho_prepare_pathsPTYCHO_PREPARE_PATHS Prepare paths and check defaults
-
core.
ptycho_prepare_scans
()¶ - PTYCHO_PREPARE_SCANS Load data from disk and prepare the scan for theptychographic reconstruction.
-
core.
ptycho_recons
()¶ - OUT = PTYCHO_RECONS(P)Runs the reconstruction using parameters in the structure P.Returns a structure OUT containing all necessary information.Publications most relevant to the Difference-Map implementation+ P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer,“High-Resolution Scanning X-ray Diffraction Microscopy,” Science 321, 379-382 (2008)+ P. Thibault, M. Dierolf, O. Bunk, A. Menzel, F. Pfeiffer,“Probe retrieval in ptychographic coherent diffractive imaging,”Ultramicroscopy 109, 338–343 (2009)Publications most relevant to the Maximum Likelihood refinement+ M. Guizar-Sicairos and J. R. Fienup, “Phase retrieval with transversetranslation diversity: a nonlinear optimization approach,” Opt. Express 16, 7264-7278 (2008)+ P. Thibault and M. Guizar-Sicairos, “Maximum-likelihood refinement forcoherent diffractive imaging,” New J. Phys. 14, 063004 (2012).
-
core.
python_prep_data
()¶ - PYTHON_PREP_DATA prepares and exports data for json/ptyhon datapreparation.
-
core.
run_engine
()¶ - RUN_ENGINE calls engine ‘eng’
-
core.
save_fig_ext
()¶ - SAVE_FIG_EXT Subsection of ptycho_show_recons to load reconstruction fileand save figures.
-
core.
save_results
()¶ - %%%%%%%%%%%%%%%%%%%%%%%%%.. function:: core.set_projectionsobject = set_projections(p, object, obj_update, scan_id)
-
core.
update_omny_queue
()¶ - UPDATE_OMNY_QUEUE
+detector¶
-
detector.
initialize_detector
()¶ - INITIALIZE_DETECTOR run some checks and load the detector settings
-
detector.
load_detector
()¶ - LOAD_DETECTORload detector files as specified in p
-
detector.
prepare_data
()¶ - PREPARE_DATA prepare the raw data for the ptychographic reconstructionNote:All (default) functions are located in +detector/private. If You wantto add a new detector, please create a new package directory(+detector_name) with a parameter file detector_name.m. Functions in apackage detectory directory will overload similar functions inprivate.
+engines¶
-
engines.
DM
()¶ - DM Difference-Map algorithmPublications most relevant to the Difference-Map implementation+ P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer,“High-Resolution Scanning X-ray Diffraction Microscopy,” Science 321, 379-382 (2008)+ P. Thibault, M. Dierolf, O. Bunk, A. Menzel, F. Pfeiffer,“Probe retrieval in ptychographic coherent diffractive imaging,”Ultramicroscopy 109, 338–343 (2009)
-
engines.
DM_MS
()¶ - [ p, fdb ] = DM_MS( p )
-
engines.
GPU
()¶ - engines.GPU is a function.[p_out, fdb] = GPU(p)
-
engines.
ML
()¶ - ML Maximum Likelihood refinementPublications most relevant to the Maximum Likelihood refinement+ M. Guizar-Sicairos and J. R. Fienup, “Phase retrieval with transversetranslation diversity: a nonlinear optimization approach,” Opt. Express 16, 7264-7278 (2008)+ P. Thibault and M. Guizar-Sicairos, “Maximum-likelihood refinement forcoherent diffractive imaging,” New J. Phys. 14, 063004 (2012).
-
engines.
ML_MS
()¶ - [ p, fdb ] = ML_MS( p )
-
engines.
c_solver
()¶ - C_SOLVER external C++ code for DM and MLPublications most relevant to the Difference-Map implementation+ P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer,“High-Resolution Scanning X-ray Diffraction Microscopy,” Science 321, 379-382 (2008)+ P. Thibault, M. Dierolf, O. Bunk, A. Menzel, F. Pfeiffer,“Probe retrieval in ptychographic coherent diffractive imaging,”Ultramicroscopy 109, 338–343 (2009)Publications most relevant to the Maximum Likelihood refinement+ M. Guizar-Sicairos and J. R. Fienup, “Phase retrieval with transversetranslation diversity: a nonlinear optimization approach,” Opt. Express 16, 7264-7278 (2008)+ P. Thibault and M. Guizar-Sicairos, “Maximum-likelihood refinement forcoherent diffractive imaging,” New J. Phys. 14, 063004 (2012).
-
engines.
c_solver_MS
()¶ - C_SOLVER external C++ code for DM and MLPublications most relevant to the Difference-Map implementation+ P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer,“High-Resolution Scanning X-ray Diffraction Microscopy,” Science 321, 379-382 (2008)+ P. Thibault, M. Dierolf, O. Bunk, A. Menzel, F. Pfeiffer,“Probe retrieval in ptychographic coherent diffractive imaging,”Ultramicroscopy 109, 338–343 (2009)Publications most relevant to the Maximum Likelihood refinement+ M. Guizar-Sicairos and J. R. Fienup, “Phase retrieval with transversetranslation diversity: a nonlinear optimization approach,” Opt. Express 16, 7264-7278 (2008)+ P. Thibault and M. Guizar-Sicairos, “Maximum-likelihood refinement forcoherent diffractive imaging,” New J. Phys. 14, 063004 (2012).
-
engines.
presolver
()¶ - C_SOLVER external C++ code for DM in lower resolution
+scans¶
-
scans.
get_queue
()¶ - GET_QUEUE call queue functions in package directories
-
scans.
read_metadata
()¶ - READ_METADATA load meta data and overwrite previous settings
-
scans.
read_positions
()¶ - READ_POSITIONS load positions
cSAXS_python_env¶
utils¶
-
utils/aligned_FSC
- [resolution stat] = aligned_FSC(file1,file2,params)Receives two filenames with path for ptychography reconstructions and astructure with parameters. The routine reads the reconstructions, matchesthe linear phase between them, registers the images, and returns theresolution estimates based on first and last crossing of the FSC with thethreshold.References relevant to this code:For using this FSC code with ptychography: J. Vila-Comamala, et al., “Characterization of high-resolution diffractive X-ray optics by ptychographic coherent diffractive imaging,” Opt. Express 19, 21333-21344 (2011).For subpixel alignment: M. Guizar-Sicairos, et al., “Efficient subpixel image registration algorithms,” Opt. Lett. 33, 156 (2008).For matching of phase ramp by approximate least squared error: M. Guizar-Sicairos, et al., “Phase tomography from x-ray coherent diffractive imaging projections,” Opt. Express 19, 21345-21357 (2011).Outputs:resolution A two element variable that contains the resolutionobtained from first and last crossing of the FSC curve withthe threshold curve.stat structure containing other statistics such asspectral signal to noise ratio (SSNR), average SNR and area under FSC curveInputs:file1 Filename with path of reconstruction 1file2 Filename with path of reconstruction 2params Structure with parameters as described belowparams.flipped_images Flip one input image horizontally (= true or false).Useful when comparing 0 and 180 degree projectionsin tomography (default = false).params.crop = ‘’; for using the default half size of the probe= ‘manual’ for using GUI to select region. This will display the range, e.g. {600:800, 600:800}= {600:800, 600:800} for custom vertical and horizontal cropping, respectivelyparams.GUIguess To click for an initial alignment guess, if used it ignoresthe values of params.guessx and params.guessy (default= false)params.guessxparams.guessy An intial guess for x and y alignment (default = [])params.remove_ramp Try to remove linear phase from whole image before initialalignment (default = true)params.image_prop = ‘complex’= ‘phasor’ (phase with unit amplitude, default)= ‘phase’ (Note: phase should not be used if there is phase wrapping)params.taper = 20 (default) Pixels to taper images - Increase until the FSC does not change anymoreparams.plotting Display plots (default = false)params.dispfsc Display FSC plot (default = true)params.SNRt SNR for FSC threshold curveSNRt = 0.2071 for 1/2 bit threshold for resolution of the average of the 2 imagesSNRt = 0.5 for 1 bit threshold for resolution of each individual image (default)params.thickring Thickness of Fourier domain ring for FSC in pixels (default = 1)params.freq_thr To ignore the crossings before freq_thr for determining resolution (default 0.02)params.out_fn Filename of output of jpeg for FSC
-
utils/break_check
- [] = break_check(filename)
-
utils/calculate_round_roi
- Data path info
-
utils/change_file_names
- change_file_names.msmall script to remove lock files from certain scans
-
utils/check_option
- CHECK_OPTIONcheck if required option exists and is equal to the given value,otherwise return false
-
utils/check_scan_interruption
- Detect an interruption of the scan in the Log fileFrom spec compile post_scan.mac= 1, if the scan is ready for processing= 0, if the scan was interrupted and is not yet repeated, or if the scanis being repeated now
-
utils/find_file_names
- change_file_names.msmall script to remove lock files from certain scans
-
utils/find_ptycho_filename
- filename_with_path = find_ptycho_filename(base_analysis_path,scan_number,fileprefix,filesuffix)Looks for a ptychography reconstruction name inside the path given asinitial argument. I will look in the folder given and also try withadding analysis. If the scan_number is given it will compile an analysisfolder and look for it. e.g. find_ptycho_filename(‘~/Data10’,235);Use verbose(2) in order to see all directories and names attempted.Inputsbase_analysis_path .. function:: utils/integrate_frames14-11-2012Integrates frames from a loopscanSyntax:[int] = integrate_frames(base_path,scan_num,plotfigure,det_num,savedata,maskfilename)Needed parameters: base_path (e.g. ‘~/Data10/’)scan_num (scan number)Optional parameters: plotfigure (figure number for fial plot, 0 for no plotting, by default is 0)det_num (detector number, default 1)savedata (=1 to save data in ‘analysis/integrated_frames/’, default 0)maskfilename (valid mask file name. If empty [], no mask used)
-
utils/loopregerror
- Evaluate registration error in an angle series. Returns the error betweensubsequent images. The last image is evaluated against the first butflipped in x. Recieves image FT with DC in (1,1), the image should havehad the center in center of array.filt_stackFT FT of stack of images, previously filtered if neededdeltastack Estimates of positionsxmax Vector with positions of horizontal edges of rectangularwindow for registrationymax Same as xmax but vertical edges of window
-
utils/make_lock_files
- make_lock_files is a script.
-
utils/phase_from_dpc
- Integrates the phase from a combination of x and y gradients.phase_from_dpc(dpcx,dpcy,’fourier’) uses the Fourier method (default),phase_from_dpc(dpcx,dpcy,’finitdiff’) uses a finite difference method.
-
utils/propagate_probe
- propagate_probe.mWarning: Currently working only for square pixels
-
utils/remove_lock_files
- remove_lock_files.msmall script to remove lock files from certain scans
-
utils/remove_lock_files_select
- remove_lock_files.msmall script to remove lock files from certain scans
-
utils/round_roi_new_stxm
- Another script for STXM evaluation of round roi scansDoes not use Gaussians centered on grid points which leads to inaccuaratevalues at the center positions (due to adding up all the Gaussians)but rather uses the Matlab’s “griddata” function.
-
utils/round_roi_numpts
- Usage:function numpts = round_roi_numpts(lx,ly,dr,nth)Description:Calculates the number of points of a round roi scanfor a set of parameters used in a Spec call.Parameters:lx = horizontal field of view in meterly = vertical field of view in meterdr = radial shell step size in meterdth = angluar intervals in first shellChangelog:2010-12-04, First version.
-
utils/set_all_engines
- function p = set_all_engines(p, parameter, value)set given parameter to all engines
-
utils/show_recons
- show recons.mWarning: Currently working only for square pixelsclose all .. function:: utils/show_recons_ms%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%.. function:: utils/unwrap_pilatus_weird[frame_unwrapped, frame_replaced_from_lowcount] = unwrap_pilatus(frame_low, frame_high, numbad, slope)unwraps the pilatus pixels that had too high intensity.slope and numbad are optional.slope should be (high exposure time / low exposure time), but can beevaluated from the data.numbad is the rough number of bad pixels - it should be greater than the actualvalue. It is used only if the slope needs to be evaluated.The first output is the result of unwrapping the high intensity counts.The second is equal to the high intensity frame with all wrapped valuesreplaced with scaled counts from the low exposure frame. These two shouldbe equal, but the first output is biased by the intensity correction doneby the pilatus.