mirror of
https://github.com/c-sooyoung/fold_slice.git
synced 2026-09-17 19:39:08 +09:00
initial commit
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
%% TEST TEMPLATE FOR FUNTIONALITY CHECK OF CPU ENGINES
|
||||
% 1) call standard template to get fresh settings defaults
|
||||
% 2) generate artificial data that should serve as a standart test "sample"
|
||||
% 3) call GPU engine with different basic functionalities and test if all still works
|
||||
% !! THESE TEST ARE ONLY USEFUL TO FIND CRASHES IN THE CODE, QUALITY OF THE RECONSTRUCTION IS NOT EVALUATED !!
|
||||
|
||||
%% set shared parameters for all test scripts
|
||||
run(fullfile( fileparts(mfilename('fullpath')), 'init_test.m'))
|
||||
|
||||
%% general settings
|
||||
p. artificial_data_file = 'tests/test_data.m'; % artificial data parameters
|
||||
p. asize = [192 192]; % size of the reconstruction probe
|
||||
p. binning = 1; % binning will be 2^p.binning
|
||||
|
||||
|
||||
%% ENGINES
|
||||
|
||||
eng = struct();
|
||||
eng. name = 'DM';
|
||||
eng. method = 'DM';
|
||||
eng. number_iterations = 5; % Total number of iterations
|
||||
eng. probe_change_start = 1; % Start updating probe at this iteration number
|
||||
eng. average_start = 300; % Start averaging at this iteration number
|
||||
eng. average_interval = 5; % Number of iterations between reconstruction estimates for average
|
||||
eng. count_bound = 4e-2; % Relaxed Fourier projection parameter - average photons of change per pixel (= 0 no relaxation)
|
||||
eng. pfft_relaxation = 0.05 ; % Relaxation in the Fourier domain projection, = 0 for full projection
|
||||
eng. probe_regularization = .1; % Weigth factor for the probe update
|
||||
eng. probe_mask_bool = true; % If true, impose a support constraint to the probe
|
||||
eng. probe_mask_area = .9; % Area ratio of the mask
|
||||
eng. probe_mask_use_auto = false; % Use autocorrelation for probe_mask (if false: circular circle)
|
||||
eng. object_flat_region = []; % Mask for enforcing a flat region in the object (to reduce artifacts)
|
||||
eng. remove_scaling_ambiguity = true; % Remove ambiguity of the probe times object scalling by probe normalization
|
||||
eng. clip_object = true; % Clip the object transmission function
|
||||
eng. clip_max = 1.0; % Upper bound
|
||||
eng. clip_min = 0.0; % Lower bound
|
||||
eng. compute_rfact = false; % If set to true, R-factor is computed at every iteration (large overhead!!!)
|
||||
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
|
||||
|
||||
|
||||
run(fullfile( fileparts(mfilename('fullpath')), 'run_test.m'))
|
||||
|
||||
|
||||
|
||||
% Academic License Agreement
|
||||
%
|
||||
% Source Code
|
||||
%
|
||||
% Introduction
|
||||
% • This license agreement sets forth the terms and conditions under which the PAUL SCHERRER INSTITUT (PSI), CH-5232 Villigen-PSI, Switzerland (hereafter "LICENSOR")
|
||||
% will grant you (hereafter "LICENSEE") a royalty-free, non-exclusive license for academic, non-commercial purposes only (hereafter "LICENSE") to use the cSAXS
|
||||
% ptychography MATLAB package computer software program and associated documentation furnished hereunder (hereafter "PROGRAM").
|
||||
%
|
||||
% Terms and Conditions of the LICENSE
|
||||
% 1. LICENSOR grants to LICENSEE a royalty-free, non-exclusive license to use the PROGRAM for academic, non-commercial purposes, upon the terms and conditions
|
||||
% hereinafter set out and until termination of this license as set forth below.
|
||||
% 2. LICENSEE acknowledges that the PROGRAM is a research tool still in the development stage. The PROGRAM is provided without any related services, improvements
|
||||
% or warranties from LICENSOR and that the LICENSE is entered into in order to enable others to utilize the PROGRAM in their academic activities. It is the
|
||||
% LICENSEE’s responsibility to ensure its proper use and the correctness of the results.”
|
||||
% 3. THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
% A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE LICENSOR, THE AUTHORS OR THE COPYRIGHT
|
||||
% HOLDERS BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE
|
||||
% OF THE PROGRAM OR OTHER DEALINGS IN THE PROGRAM.
|
||||
% 4. LICENSEE agrees that it will use the PROGRAM and any modifications, improvements, or derivatives of PROGRAM that LICENSEE may create (collectively,
|
||||
% "IMPROVEMENTS") solely for academic, non-commercial purposes and that any copy of PROGRAM or derivatives thereof shall be distributed only under the same
|
||||
% license as PROGRAM. The terms "academic, non-commercial", as used in this Agreement, mean academic or other scholarly research which (a) is not undertaken for
|
||||
% profit, or (b) is not intended to produce works, services, or data for commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged
|
||||
% in the commercial use, application or exploitation of works similar to the PROGRAM.
|
||||
% 5. LICENSEE agrees that it shall make the following acknowledgement in any publication resulting from the use of the PROGRAM or any translation of the code into
|
||||
% another computing language:
|
||||
% "Data processing was carried out using the cSAXS ptychography MATLAB package developed by the Science IT and the coherent X-ray scattering (CXS) groups, Paul
|
||||
% Scherrer Institut, Switzerland."
|
||||
%
|
||||
% Additionally, any publication using the package, or any translation of the code into another computing language should cite for difference map:
|
||||
% P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer, High-resolution scanning X-ray diffraction microscopy, Science 321, 379–382 (2008).
|
||||
% (doi: 10.1126/science.1158573),
|
||||
% for maximum likelihood:
|
||||
% P. Thibault and M. Guizar-Sicairos, Maximum-likelihood refinement for coherent diffractive imaging, New J. Phys. 14, 063004 (2012).
|
||||
% (doi: 10.1088/1367-2630/14/6/063004),
|
||||
% for mixed coherent modes:
|
||||
% P. Thibault and A. Menzel, Reconstructing state mixtures from diffraction measurements, Nature 494, 68–71 (2013). (doi: 10.1038/nature11806),
|
||||
% and/or for multislice:
|
||||
% E. H. R. Tsai, I. Usov, A. Diaz, A. Menzel, and M. Guizar-Sicairos, X-ray ptychography with extended depth of field, Opt. Express 24, 29089–29108 (2016).
|
||||
% (doi: 10.1364/OE.24.029089).
|
||||
% 6. Except for the above-mentioned acknowledgment, LICENSEE shall not use the PROGRAM title or the names or logos of LICENSOR, nor any adaptation thereof, nor the
|
||||
% names of any of its employees or laboratories, in any advertising, promotional or sales material without prior written consent obtained from LICENSOR in each case.
|
||||
% 7. Ownership of all rights, including copyright in the PROGRAM and in any material associated therewith, shall at all times remain with LICENSOR, and LICENSEE
|
||||
% agrees to preserve same. LICENSEE agrees not to use any portion of the PROGRAM or of any IMPROVEMENTS in any machine-readable form outside the PROGRAM, nor to
|
||||
% make any copies except for its internal use, without prior written consent of LICENSOR. LICENSEE agrees to place the following copyright notice on any such copies:
|
||||
% © All rights reserved. PAUL SCHERRER INSTITUT, Switzerland, Laboratory for Macromolecules and Bioimaging, 2017.
|
||||
% 8. The LICENSE shall not be construed to confer any rights upon LICENSEE by implication or otherwise except as specifically set forth herein.
|
||||
% 9. DISCLAIMER: LICENSEE shall be aware that Phase Focus Limited of Sheffield, UK has an international portfolio of patents and pending applications which relate
|
||||
% to ptychography and that the PROGRAM may be capable of being used in circumstances which may fall within the claims of one or more of the Phase Focus patents,
|
||||
% in particular of patent with international application number PCT/GB2005/001464. The LICENSOR explicitly declares not to indemnify the users of the software
|
||||
% in case Phase Focus or any other third party will open a legal action against the LICENSEE due to the use of the program.
|
||||
% 10. This Agreement shall be governed by the material laws of Switzerland and any dispute arising out of this Agreement or use of the PROGRAM shall be brought before
|
||||
% the courts of Zürich, Switzerland.
|
||||
@@ -0,0 +1,302 @@
|
||||
%% TEST TEMPLATE FOR FUNTIONALITY CHECK OF CPU ENGINES
|
||||
% 1) call standard template to get fresh settings defaults
|
||||
% 2) generate artificial data that should serve as a standart test "sample"
|
||||
% 3) call GPU engine with different basic functionalities and test if all still works
|
||||
% !! THESE TEST ARE ONLY USEFUL TO FIND CRASHES IN THE CODE, QUALITY OF THE RECONSTRUCTION IS NOT EVALUATED !!
|
||||
|
||||
|
||||
%% set shared parameters for all test scripts
|
||||
run(fullfile( fileparts(mfilename('fullpath')), 'init_test.m'))
|
||||
|
||||
%% general settings
|
||||
p. artificial_data_file = 'tests/test_data.m'; % artificial data parameters
|
||||
p. asize = [192 192]; % size of the reconstruction probe
|
||||
|
||||
|
||||
|
||||
%% ENGINES
|
||||
% External C++ code
|
||||
if isunix
|
||||
% Please notice that you have to force data preparation (force_prepare_h5_files=true) if you have made any changes to
|
||||
% the already prepared data (fmag, fmask, positions, sharing ...).
|
||||
eng = struct();
|
||||
eng. name = 'presolver';
|
||||
eng. method = 'DM';
|
||||
eng. asize_presolve = [192 192];
|
||||
eng. number_iterations = 10; % Total number of iterations
|
||||
eng. probe_regularization = .1; % Weigth factor for the probe update;
|
||||
eng. probe_change_start = 1; % Start updating probe at this iteration number
|
||||
eng. probe_support_radius = 0.8; % Normalized radius of circular support, = 1 for radius touching the window
|
||||
eng. pfft_relaxation = .05; % Relaxation in the Fourier domain projection, = 0 for full projection
|
||||
eng. single_prec = true; % single or double precision
|
||||
eng. threads = 20; % number of threads for OMP
|
||||
eng. beamline_nodes = []; % beamline nodes for the MPI/OMP hybrid, e.g. ['x12sa-cn-2'; 'x12sa-cn-3'];
|
||||
eng. ra_nodes = 0; % number of nodes on ra cluster for the MPI/OMP hybrid; set to 0 for current node
|
||||
eng. caller_suffix = ''; % suffix for the external reconstruction program
|
||||
eng. reconstruction_program = ''; % specify external reconstruction program that overwrites previous settings, e.g. 'OMP_NUM_THREADS=20 ./ptycho_single_OMP';
|
||||
eng. check_cpu_load = false; % check if specified nodes are already in use (only x12sa). Disable check if you are sure that the nodes are free.
|
||||
eng. initial_conditions_path = ''; % path of the initial conditions file; default if empty (== prepare_data_path)
|
||||
eng. initial_conditions_file = ''; % Name of the initial conditions file, default if empty. Do not use ~ in the path
|
||||
eng. measurements_file = ''; % Name of the measurements file, default if empty. Do not use ~ in the path
|
||||
eng. solution_file = ''; % Name of the solution file, default if empty. Do not use ~ in the path
|
||||
eng. force_prepare_h5_files = 0; % If true before running the C-code the data h5 file is created and the h5 file with initial object and probe too, regardless of whether it exists. It will use the matlab data preparator.
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
if isunix
|
||||
% Please notice that you have to force data preparation (force_prepare_h5_files=true) if you have made any changes to
|
||||
% the already prepared data (fmag, fmask, positions, sharing ...).
|
||||
eng = struct();
|
||||
eng. name = 'c_solver';
|
||||
eng. method = 'DM+ML';
|
||||
eng. number_iterations = 10; % Total number of iterations
|
||||
eng. opt_iter = 10; % Iterations for optimization
|
||||
eng. probe_regularization = .1; % Weigth factor for the probe update;
|
||||
eng. probe_change_start = 1; % Start updating probe at this iteration number
|
||||
eng. probe_support_radius = 0.8; % Normalized radius of circular support, = 1 for radius touching the window
|
||||
eng. pfft_relaxation = .05; % Relaxation in the Fourier domain projection, = 0 for full projection
|
||||
eng. background = 0; % [PARTIALLY IMPLEMENTED (not fully optimized)] Add background to the ML model in form: |Psi|^2+B, B is in average counts per frame and pixel
|
||||
eng. probe_support_fft = false; % [PARTIALLY IMPLEMENTED (not fully optimized)] Apply probe support in Fourier space, ! uses model zoneplate settings to estimate support size
|
||||
|
||||
eng. N_layer = 1; % Number of virtual object layers (slices)
|
||||
eng. delta_z = 0e-6 * ones(1, eng.N_layer-1); % Separation between object slices
|
||||
%eng. ms_init_ob_fraction = [1 0];
|
||||
if eng. N_layer>1
|
||||
p.suffix = [p.suffix '_N' num2str(eng. N_layer)];
|
||||
eng. number_iterations = 0; % highly recommended
|
||||
end
|
||||
|
||||
eng. single_prec = true; % single or double precision
|
||||
eng. threads = 20; % number of threads for OMP
|
||||
eng. beamline_nodes = []; % beamline nodes for the MPI/OMP hybrid, e.g. ['x12sa-cn-2'; 'x12sa-cn-3'];
|
||||
eng. ra_nodes = 0; % number of nodes on ra cluster for the MPI/OMP hybrid; set to 0 for current node
|
||||
eng. caller_suffix = ''; % suffix for the external reconstruction program
|
||||
eng. reconstruction_program = ''; % specify external reconstruction program that overwrites previous settings, e.g. 'OMP_NUM_THREADS=20 ./ptycho_single_OMP';
|
||||
eng. check_cpu_load = true; % check if specified nodes are already in use (only x12sa). Disable check if you are sure that the nodes are free.
|
||||
eng. initial_conditions_path = ''; % path of the initial conditions file; default if empty (== prepare_data_path)
|
||||
eng. initial_conditions_file = ''; % Name of the initial conditions file, default if empty. Do not use ~ in the path
|
||||
eng. measurements_file = ''; % Name of the measurements file, default if empty. Do not use ~ in the path
|
||||
eng. solution_file = ''; % Name of the solution file, default if empty. Do not use ~ in the path
|
||||
eng. force_prepare_h5_files = 1; % If true before running the C-code the data h5 file is created and the h5 file with initial object and probe too, regardless of whether it exists. It will use the matlab data preparator.
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
% --------- Matlab engines -------------
|
||||
if 1
|
||||
eng = struct(); % reset settings for this engine
|
||||
eng. name = 'GPU';
|
||||
eng. use_gpu = false; % if false, run CPU code, but it will get very slow
|
||||
eng. keep_on_gpu = true; % keep data + projections on GPU, false is useful for large data if DM is used
|
||||
eng. compress_data = true; % use automatic online memory compression to limit meed of GPU memory
|
||||
eng. gpu_id = []; % default GPU id, [] means choosen by matlab
|
||||
eng. check_gpu_load = true; % check available GPU memory before starting GPU engines
|
||||
|
||||
% general
|
||||
eng. number_iterations = 10; % number of iterations for selected method
|
||||
%eng. asize_presolve = [196 196]; % crop data to "asize_presolve" size to get low resolution estimate
|
||||
%eng. share_probe = 1; % Share probe between scans. Can be either a number/boolean or a list of numbers, specifying the probe index; e.g. [1 2 2] to share the probes between the second and third scan.
|
||||
%eng. share_object = 0; % Share object between scans. Can be either a number/boolean or a list of numbers, specifying the object index; e.g. [1 2 2] to share the objects between the second and third scan.
|
||||
eng. method = ''; % choose GPU solver: DM, ePIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng. opt_errmetric = 'L1' ; % optimization likelihood - poisson, L1
|
||||
eng. grouping = 100; % size of processed blocks, larger blocks need more memory but they use GPU more effeciently
|
||||
% for hPIE, ePIE, MLs methods smaller blocks lead to faster convergence,
|
||||
% for MLc the convergence is similar
|
||||
% for DM, RAAR is has no effect on convergence
|
||||
%eng. probe_modes = 1; % Number of coherent modes for probe
|
||||
eng. object_change_start = 1; % Start updating object at this iteration number
|
||||
eng. probe_change_start = 1; % Start updating probe at this iteration number
|
||||
|
||||
% regularizations
|
||||
eng. reg_mu = 0; % Regularization constant ( = 0 for no regularization)
|
||||
eng. delta = 0; % press values to zero out of the illumination area, usually 1e-2 is enough
|
||||
eng. positivity_constraint_object = 0; % enforce weak positivity in object, usually 1e-2 is already enough
|
||||
|
||||
eng. apply_multimodal_update = false; % apply all incoherent modes to object, it can cause isses if the modes collect some crap
|
||||
eng. probe_backpropagate = 0; % backpropagate the probe mask, inf == farfield
|
||||
eng. probe_support_radius = []; % Normalized radius of circular support, = 1 for radius touching the window
|
||||
eng. probe_support_fft = false; % assume that there is not illumination intensity out of the central FZP cone
|
||||
|
||||
% basic recontruction parameters
|
||||
% PIE / ML methods
|
||||
eng. beta_object = 1; % object step size, larger == faster convergence, smaller == more robust, should not exceed 1
|
||||
eng. beta_probe = 1; % probe step size, larger == faster convergence, smaller == more robust, should not exceed 1
|
||||
eng. delta_p = 0.1; % LSQ dumping constant, 0 == no preconditioner, 0.1 is usually safe,
|
||||
eng. momentum = 0.5; % add momentum term to the MLc method, eng.momentum = multiplication gain for velocity
|
||||
% eng. delta_z = [50e-6, 50e-6]; % multilayer ptycho extension
|
||||
|
||||
% DM
|
||||
eng. pfft_relaxation = 0.05; % Relaxation in the Fourier domain projection, = 0 for full projection
|
||||
eng. probe_regularization = 0.1; % Weight factor for the probe update (inertia)
|
||||
|
||||
|
||||
% ADVANCED OPTIONS
|
||||
% position refinement
|
||||
eng. apply_subpix_shift = false; % apply FFT-based subpixel shift, important for good position refinement but it is slow
|
||||
eng. probe_position_search = inf; % reconstruct probe positions, from iteration == probe_position_search, assume they have to match geometry model with error less than probe_position_error_max
|
||||
eng. probe_position_error_max = 20e-9; % max expected random position error of the stages
|
||||
|
||||
% other extensions
|
||||
eng. background = 0.001; % average background scattering level, for OMNI values around 0.3 for 100ms, for flOMNI <0.1 per 100ms exposure
|
||||
eng. clean_residua = false; % remove residua from reconstruction by iterative unwrapping, may result in low spatial freq. artefacts
|
||||
eng. regularize_layers = 0.01; % 0<R<<1 -> apply regularization on the reconstructed object layers, 0 == no regularization
|
||||
|
||||
% wavefront refinement
|
||||
eng. probe_fourier_shift_search = inf; % refine farfield position of the beam (ie angle) from iteration == probe_fourier_shift_search
|
||||
eng. estimate_NF_distance = inf; % try to estimate the nearfield propagation distance
|
||||
eng. variable_probe = false; % Use SVD to account for variable illumination during a single (coupled) scan
|
||||
eng. variable_probe_modes = 3; % OPRP settings , number of SVD modes, apply only for PIE methods
|
||||
eng. variable_probe_smooth = 1; % OPRP settings , apply assumption of smooth evolution of the OPRP modes -> N is order of polynomial fit used for smoothing, 0 == n
|
||||
eng. variable_intensity = false; % account to changes in probe intensity
|
||||
|
||||
% extra analysis
|
||||
eng. get_fsc_score = false; % measure evolution of the Fourier ring correlation during convergence
|
||||
eng. mirror_objects = false; % mirror objects, useful for 0/180deg scan sharing
|
||||
|
||||
eng. method = 'DM'; % choose GPU solver: DM, ePIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
eng. method = 'MLc'; % choose GPU solver: DM, ePIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
eng. method = 'MLs'; % choose GPU solver: DM, ePIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
eng. method = 'hPIE'; % choose GPU solver: DM, ePIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
eng. method = 'ePIE'; % choose GPU solver: DM, ePIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
|
||||
end
|
||||
|
||||
|
||||
% Difference Map (Matlab and MEX)
|
||||
|
||||
|
||||
if false
|
||||
eng = struct();
|
||||
eng. name = 'DM';
|
||||
eng. method = 'mex';
|
||||
eng. number_iterations = 10; % Total number of iterations
|
||||
eng. probe_change_start = 1; % Start updating probe at this iteration number
|
||||
eng. average_start = 300; % Start averaging at this iteration number
|
||||
eng. average_interval = 5; % Number of iterations between reconstruction estimates for average
|
||||
eng. count_bound = 4e-2; % Relaxed Fourier projection parameter - average photons of change per pixel (= 0 no relaxation)
|
||||
eng. pfft_relaxation = 0.05 ; % Relaxation in the Fourier domain projection, = 0 for full projection
|
||||
eng. probe_regularization = .1; % Weigth factor for the probe update
|
||||
eng. probe_mask_bool = true; % If true, impose a support constraint to the probe
|
||||
eng. probe_mask_area = .9; % Area ratio of the mask
|
||||
eng. probe_mask_use_auto = false; % Use autocorrelation for probe_mask (if false: circular circle)
|
||||
eng. object_flat_region = []; % Mask for enforcing a flat region in the object (to reduce artifacts)
|
||||
eng. remove_scaling_ambiguity = true; % Remove ambiguity of the probe times object scalling by probe normalization
|
||||
eng. clip_object = true; % Clip the object transmission function
|
||||
eng. clip_max = 1.0; % Upper bound
|
||||
eng. clip_min = 0.0; % Lower bound
|
||||
eng. compute_rfact = false; % If set to true, R-factor is computed at every iteration (large overhead!!!)
|
||||
|
||||
eng. use_mex = [1,1,1];
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
if 1
|
||||
eng = struct();
|
||||
eng. name = 'DM';
|
||||
eng. method = 'matlab';
|
||||
eng. number_iterations = 10; % Total number of iterations
|
||||
eng. probe_change_start = 1; % Start updating probe at this iteration number
|
||||
eng. average_start = 300; % Start averaging at this iteration number
|
||||
eng. average_interval = 5; % Number of iterations between reconstruction estimates for average
|
||||
eng. count_bound = 4e-2; % Relaxed Fourier projection parameter - average photons of change per pixel (= 0 no relaxation)
|
||||
eng. pfft_relaxation = 0.05 ; % Relaxation in the Fourier domain projection, = 0 for full projection
|
||||
eng. probe_regularization = .1; % Weigth factor for the probe update
|
||||
eng. probe_mask_bool = true; % If true, impose a support constraint to the probe
|
||||
eng. probe_mask_area = .9; % Area ratio of the mask
|
||||
eng. probe_mask_use_auto = false; % Use autocorrelation for probe_mask (if false: circular circle)
|
||||
eng. object_flat_region = []; % Mask for enforcing a flat region in the object (to reduce artifacts)
|
||||
eng. remove_scaling_ambiguity = true; % Remove ambiguity of the probe times object scalling by probe normalization
|
||||
eng. clip_object = true; % Clip the object transmission function
|
||||
eng. clip_max = 1.0; % Upper bound
|
||||
eng. clip_min = 0.0; % Lower bound
|
||||
eng. compute_rfact = false; % If set to true, R-factor is computed at every iteration (large overhead!!!)
|
||||
eng. use_mex = [0,0,0];
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
% Maximum Likelihood (Matlab)
|
||||
if 1
|
||||
eng = struct();
|
||||
eng. name = 'ML';
|
||||
eng. method = 'matlab';
|
||||
eng. opt_errmetric = 'L1'; % Error metric for max likelihood = 'poisson', 'L1' (approx poisson), 'L2' (uniform gaussian noise)
|
||||
eng. opt_flags = [1 1]; % Optimize [object probe]
|
||||
eng. opt_iter = 5; % Iterations for optimization
|
||||
eng. opt_ftol = 1e-10; % Tolerance on error metric for optimization
|
||||
eng. opt_xtol = 1e-7; % Tolerance on optimizable parameters
|
||||
eng. probe_mask_bool = true; % If true, impose a support constraint to the probe
|
||||
eng. probe_mask_area = .9; % Area ratio of the mask
|
||||
eng. probe_mask_use_auto = false; % Use autocorrelation for probe_mask (if false: circular circle)
|
||||
eng. scale_gradient = false; % Preconditioning by scaling probe gradient - Reported useful for weak objects
|
||||
eng. inv_intensity = false; % Make error metric insensitive to intensity fluctuations
|
||||
eng. use_probe_support = false; % Use the support on the probe that was used in the difference-map
|
||||
eng. reg_mu = 0.01; %0.01 % Regularization constant ( = 0 for no regularization)
|
||||
eng. smooth_gradient = true; % Sieves preconditioning, =false no smoothing, = true uses Hanning, otherwise specify a small matrix making sure its sum = 1
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
|
||||
run(fullfile( ptycho_path, 'tests/run_test.m'))
|
||||
|
||||
|
||||
|
||||
% Academic License Agreement
|
||||
%
|
||||
% Source Code
|
||||
%
|
||||
% Introduction
|
||||
% • This license agreement sets forth the terms and conditions under which the PAUL SCHERRER INSTITUT (PSI), CH-5232 Villigen-PSI, Switzerland (hereafter "LICENSOR")
|
||||
% will grant you (hereafter "LICENSEE") a royalty-free, non-exclusive license for academic, non-commercial purposes only (hereafter "LICENSE") to use the cSAXS
|
||||
% ptychography MATLAB package computer software program and associated documentation furnished hereunder (hereafter "PROGRAM").
|
||||
%
|
||||
% Terms and Conditions of the LICENSE
|
||||
% 1. LICENSOR grants to LICENSEE a royalty-free, non-exclusive license to use the PROGRAM for academic, non-commercial purposes, upon the terms and conditions
|
||||
% hereinafter set out and until termination of this license as set forth below.
|
||||
% 2. LICENSEE acknowledges that the PROGRAM is a research tool still in the development stage. The PROGRAM is provided without any related services, improvements
|
||||
% or warranties from LICENSOR and that the LICENSE is entered into in order to enable others to utilize the PROGRAM in their academic activities. It is the
|
||||
% LICENSEE’s responsibility to ensure its proper use and the correctness of the results.”
|
||||
% 3. THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
% A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE LICENSOR, THE AUTHORS OR THE COPYRIGHT
|
||||
% HOLDERS BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE
|
||||
% OF THE PROGRAM OR OTHER DEALINGS IN THE PROGRAM.
|
||||
% 4. LICENSEE agrees that it will use the PROGRAM and any modifications, improvements, or derivatives of PROGRAM that LICENSEE may create (collectively,
|
||||
% "IMPROVEMENTS") solely for academic, non-commercial purposes and that any copy of PROGRAM or derivatives thereof shall be distributed only under the same
|
||||
% license as PROGRAM. The terms "academic, non-commercial", as used in this Agreement, mean academic or other scholarly research which (a) is not undertaken for
|
||||
% profit, or (b) is not intended to produce works, services, or data for commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged
|
||||
% in the commercial use, application or exploitation of works similar to the PROGRAM.
|
||||
% 5. LICENSEE agrees that it shall make the following acknowledgement in any publication resulting from the use of the PROGRAM or any translation of the code into
|
||||
% another computing language:
|
||||
% "Data processing was carried out using the cSAXS ptychography MATLAB package developed by the Science IT and the coherent X-ray scattering (CXS) groups, Paul
|
||||
% Scherrer Institut, Switzerland."
|
||||
%
|
||||
% Additionally, any publication using the package, or any translation of the code into another computing language should cite for difference map:
|
||||
% P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer, High-resolution scanning X-ray diffraction microscopy, Science 321, 379–382 (2008).
|
||||
% (doi: 10.1126/science.1158573),
|
||||
% for maximum likelihood:
|
||||
% P. Thibault and M. Guizar-Sicairos, Maximum-likelihood refinement for coherent diffractive imaging, New J. Phys. 14, 063004 (2012).
|
||||
% (doi: 10.1088/1367-2630/14/6/063004),
|
||||
% for mixed coherent modes:
|
||||
% P. Thibault and A. Menzel, Reconstructing state mixtures from diffraction measurements, Nature 494, 68–71 (2013). (doi: 10.1038/nature11806),
|
||||
% and/or for multislice:
|
||||
% E. H. R. Tsai, I. Usov, A. Diaz, A. Menzel, and M. Guizar-Sicairos, X-ray ptychography with extended depth of field, Opt. Express 24, 29089–29108 (2016).
|
||||
% (doi: 10.1364/OE.24.029089).
|
||||
% 6. Except for the above-mentioned acknowledgment, LICENSEE shall not use the PROGRAM title or the names or logos of LICENSOR, nor any adaptation thereof, nor the
|
||||
% names of any of its employees or laboratories, in any advertising, promotional or sales material without prior written consent obtained from LICENSOR in each case.
|
||||
% 7. Ownership of all rights, including copyright in the PROGRAM and in any material associated therewith, shall at all times remain with LICENSOR, and LICENSEE
|
||||
% agrees to preserve same. LICENSEE agrees not to use any portion of the PROGRAM or of any IMPROVEMENTS in any machine-readable form outside the PROGRAM, nor to
|
||||
% make any copies except for its internal use, without prior written consent of LICENSOR. LICENSEE agrees to place the following copyright notice on any such copies:
|
||||
% © All rights reserved. PAUL SCHERRER INSTITUT, Switzerland, Laboratory for Macromolecules and Bioimaging, 2017.
|
||||
% 8. The LICENSE shall not be construed to confer any rights upon LICENSEE by implication or otherwise except as specifically set forth herein.
|
||||
% 9. DISCLAIMER: LICENSEE shall be aware that Phase Focus Limited of Sheffield, UK has an international portfolio of patents and pending applications which relate
|
||||
% to ptychography and that the PROGRAM may be capable of being used in circumstances which may fall within the claims of one or more of the Phase Focus patents,
|
||||
% in particular of patent with international application number PCT/GB2005/001464. The LICENSOR explicitly declares not to indemnify the users of the software
|
||||
% in case Phase Focus or any other third party will open a legal action against the LICENSEE due to the use of the program.
|
||||
% 10. This Agreement shall be governed by the material laws of Switzerland and any dispute arising out of this Agreement or use of the PROGRAM shall be brought before
|
||||
% the courts of Zürich, Switzerland.
|
||||
@@ -0,0 +1,149 @@
|
||||
%% TEST TEMPLATE FOR FUNTIONALITY CHECK OF CPU ENGINES
|
||||
% 1) call standard template to get fresh settings defaults
|
||||
% 2) generate artificial data that should serve as a standart test "sample"
|
||||
% 3) call GPU engine with different basic functionalities and test if all still works
|
||||
% !! THESE TEST ARE ONLY USEFUL TO FIND CRASHES IN THE CODE, QUALITY OF THE RECONSTRUCTION IS NOT EVALUATED !!
|
||||
|
||||
|
||||
%% set shared parameters for all test scripts
|
||||
run(fullfile( fileparts(mfilename('fullpath')), 'init_test.m'))
|
||||
|
||||
%% general settings
|
||||
p. verbose_level = -1; % level -1 -> keep it totally quiet
|
||||
p. artificial_data_file = 'tests/test_data_low_coherence.m'; % artificial data parameters
|
||||
p. asize = [128 128]; % size of the reconstruction probe
|
||||
|
||||
% Modes
|
||||
p. probe_modes = 4; % Number of coherent modes for probe
|
||||
p. object_modes = 1; % Number of coherent modes for object
|
||||
% Mode starting guess
|
||||
p. mode_start_pow = [0.02]; % Normalized intensity on probe modes > 1. Can be a number (all higher modes equal) or a vector
|
||||
p. mode_start = 'herm'; % (for probe) = 'rand', = 'herm' (Hermitian-like base), = 'hermver' (vertical modes only), = 'hermhor' (horizontal modes only)
|
||||
p. ortho_probes = true; % orthogonalize probes after each engine
|
||||
|
||||
|
||||
% p. use_display = false;
|
||||
|
||||
|
||||
%% ENGINES
|
||||
|
||||
if isunix
|
||||
% Please notice that you have to force data preparation (force_prepare_h5_files=true) if you have made any changes to
|
||||
% the already prepared data (fmag, fmask, positions, sharing ...).
|
||||
eng = struct();
|
||||
eng. name = 'c_solver';
|
||||
eng. method = 'DM+ML';
|
||||
eng. number_iterations = 20; % Total number of iterations
|
||||
eng. opt_iter = 10; % Iterations for optimization
|
||||
eng. probe_regularization = .1; % Weigth factor for the probe update;
|
||||
eng. probe_change_start = 1; % Start updating probe at this iteration number
|
||||
eng. probe_support_radius = 0.8; % Normalized radius of circular support, = 1 for radius touching the window
|
||||
eng. pfft_relaxation = .05; % Relaxation in the Fourier domain projection, = 0 for full projection
|
||||
eng. background = 0; % [PARTIALLY IMPLEMENTED (not fully optimized)] Add background to the ML model in form: |Psi|^2+B, B is in average counts per frame and pixel
|
||||
eng. probe_support_fft = false; % [PARTIALLY IMPLEMENTED (not fully optimized)] Apply probe support in Fourier space, ! uses model zoneplate settings to estimate support size
|
||||
|
||||
eng. N_layer = 1; % Number of virtual object layers (slices)
|
||||
eng. delta_z = 0e-6 * ones(1, eng.N_layer-1); % Separation between object slices
|
||||
%eng. ms_init_ob_fraction = [1 0];
|
||||
if eng. N_layer>1
|
||||
p.sufix = [p.sufix '_N' num2str(eng. N_layer)];
|
||||
eng. number_iterations = 0; % highly recommended
|
||||
end
|
||||
|
||||
eng. single_prec = true; % single or double precision
|
||||
eng. threads = 20; % number of threads for OMP
|
||||
eng. beamline_nodes = []; % beamline nodes for the MPI/OMP hybrid, e.g. ['x12sa-cn-2'; 'x12sa-cn-3'];
|
||||
eng. ra_nodes = 0; % number of nodes on ra cluster for the MPI/OMP hybrid; set to 0 for current node
|
||||
eng. caller_suffix = ''; % suffix for the external reconstruction program
|
||||
eng. reconstruction_program = ''; % specify external reconstruction program that overwrites previous settings, e.g. 'OMP_NUM_THREADS=20 ./ptycho_single_OMP';
|
||||
eng. check_cpu_load = true; % check if specified nodes are already in use (only x12sa). Disable check if you are sure that the nodes are free.
|
||||
eng. initial_conditions_path = ''; % path of the initial conditions file; default if empty (== prepare_data_path)
|
||||
eng. initial_conditions_file = ''; % Name of the initial conditions file, default if empty. Do not use ~ in the path
|
||||
eng. measurements_file = ''; % Name of the measurements file, default if empty. Do not use ~ in the path
|
||||
eng. solution_file = ''; % Name of the solution file, default if empty. Do not use ~ in the path
|
||||
eng. force_prepare_h5_files = 1; % If true before running the C-code the data h5 file is created and the h5 file with initial object and probe too, regardless of whether it exists. It will use the matlab data preparator.
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
if 1
|
||||
eng = struct();
|
||||
eng. name = 'DM';
|
||||
eng. method = 'matlab';
|
||||
eng. number_iterations = 20; % Total number of iterations
|
||||
eng. probe_change_start = 1; % Start updating probe at this iteration number
|
||||
eng. average_start = 300; % Start averaging at this iteration number
|
||||
eng. average_interval = 5; % Number of iterations between reconstruction estimates for average
|
||||
eng. count_bound = 4e-2; % Relaxed Fourier projection parameter - average photons of change per pixel (= 0 no relaxation)
|
||||
eng. pfft_relaxation = 0.05 ; % Relaxation in the Fourier domain projection, = 0 for full projection
|
||||
eng. probe_regularization = .1; % Weigth factor for the probe update
|
||||
eng. probe_mask_bool = true; % If true, impose a support constraint to the probe
|
||||
eng. probe_mask_area = .9; % Area ratio of the mask
|
||||
eng. probe_mask_use_auto = false; % Use autocorrelation for probe_mask (if false: circular circle)
|
||||
eng. object_flat_region = []; % Mask for enforcing a flat region in the object (to reduce artifacts)
|
||||
eng. remove_scaling_ambiguity = true; % Remove ambiguity of the probe times object scalling by probe normalization
|
||||
eng. clip_object = true; % Clip the object transmission function
|
||||
eng. clip_max = 1.0; % Upper bound
|
||||
eng. clip_min = 0.0; % Lower bound
|
||||
eng. compute_rfact = false; % If set to true, R-factor is computed at every iteration (large overhead!!!)
|
||||
eng. use_mex = [0,0,0];
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
|
||||
run(fullfile( ptycho_path, 'tests/run_test.m'))
|
||||
|
||||
|
||||
|
||||
% Academic License Agreement
|
||||
%
|
||||
% Source Code
|
||||
%
|
||||
% Introduction
|
||||
% • This license agreement sets forth the terms and conditions under which the PAUL SCHERRER INSTITUT (PSI), CH-5232 Villigen-PSI, Switzerland (hereafter "LICENSOR")
|
||||
% will grant you (hereafter "LICENSEE") a royalty-free, non-exclusive license for academic, non-commercial purposes only (hereafter "LICENSE") to use the cSAXS
|
||||
% ptychography MATLAB package computer software program and associated documentation furnished hereunder (hereafter "PROGRAM").
|
||||
%
|
||||
% Terms and Conditions of the LICENSE
|
||||
% 1. LICENSOR grants to LICENSEE a royalty-free, non-exclusive license to use the PROGRAM for academic, non-commercial purposes, upon the terms and conditions
|
||||
% hereinafter set out and until termination of this license as set forth below.
|
||||
% 2. LICENSEE acknowledges that the PROGRAM is a research tool still in the development stage. The PROGRAM is provided without any related services, improvements
|
||||
% or warranties from LICENSOR and that the LICENSE is entered into in order to enable others to utilize the PROGRAM in their academic activities. It is the
|
||||
% LICENSEE’s responsibility to ensure its proper use and the correctness of the results.”
|
||||
% 3. THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
% A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE LICENSOR, THE AUTHORS OR THE COPYRIGHT
|
||||
% HOLDERS BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE
|
||||
% OF THE PROGRAM OR OTHER DEALINGS IN THE PROGRAM.
|
||||
% 4. LICENSEE agrees that it will use the PROGRAM and any modifications, improvements, or derivatives of PROGRAM that LICENSEE may create (collectively,
|
||||
% "IMPROVEMENTS") solely for academic, non-commercial purposes and that any copy of PROGRAM or derivatives thereof shall be distributed only under the same
|
||||
% license as PROGRAM. The terms "academic, non-commercial", as used in this Agreement, mean academic or other scholarly research which (a) is not undertaken for
|
||||
% profit, or (b) is not intended to produce works, services, or data for commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged
|
||||
% in the commercial use, application or exploitation of works similar to the PROGRAM.
|
||||
% 5. LICENSEE agrees that it shall make the following acknowledgement in any publication resulting from the use of the PROGRAM or any translation of the code into
|
||||
% another computing language:
|
||||
% "Data processing was carried out using the cSAXS ptychography MATLAB package developed by the Science IT and the coherent X-ray scattering (CXS) groups, Paul
|
||||
% Scherrer Institut, Switzerland."
|
||||
%
|
||||
% Additionally, any publication using the package, or any translation of the code into another computing language should cite for difference map:
|
||||
% P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer, High-resolution scanning X-ray diffraction microscopy, Science 321, 379–382 (2008).
|
||||
% (doi: 10.1126/science.1158573),
|
||||
% for maximum likelihood:
|
||||
% P. Thibault and M. Guizar-Sicairos, Maximum-likelihood refinement for coherent diffractive imaging, New J. Phys. 14, 063004 (2012).
|
||||
% (doi: 10.1088/1367-2630/14/6/063004),
|
||||
% for mixed coherent modes:
|
||||
% P. Thibault and A. Menzel, Reconstructing state mixtures from diffraction measurements, Nature 494, 68–71 (2013). (doi: 10.1038/nature11806),
|
||||
% and/or for multislice:
|
||||
% E. H. R. Tsai, I. Usov, A. Diaz, A. Menzel, and M. Guizar-Sicairos, X-ray ptychography with extended depth of field, Opt. Express 24, 29089–29108 (2016).
|
||||
% (doi: 10.1364/OE.24.029089).
|
||||
% 6. Except for the above-mentioned acknowledgment, LICENSEE shall not use the PROGRAM title or the names or logos of LICENSOR, nor any adaptation thereof, nor the
|
||||
% names of any of its employees or laboratories, in any advertising, promotional or sales material without prior written consent obtained from LICENSOR in each case.
|
||||
% 7. Ownership of all rights, including copyright in the PROGRAM and in any material associated therewith, shall at all times remain with LICENSOR, and LICENSEE
|
||||
% agrees to preserve same. LICENSEE agrees not to use any portion of the PROGRAM or of any IMPROVEMENTS in any machine-readable form outside the PROGRAM, nor to
|
||||
% make any copies except for its internal use, without prior written consent of LICENSOR. LICENSEE agrees to place the following copyright notice on any such copies:
|
||||
% © All rights reserved. PAUL SCHERRER INSTITUT, Switzerland, Laboratory for Macromolecules and Bioimaging, 2017.
|
||||
% 8. The LICENSE shall not be construed to confer any rights upon LICENSEE by implication or otherwise except as specifically set forth herein.
|
||||
% 9. DISCLAIMER: LICENSEE shall be aware that Phase Focus Limited of Sheffield, UK has an international portfolio of patents and pending applications which relate
|
||||
% to ptychography and that the PROGRAM may be capable of being used in circumstances which may fall within the claims of one or more of the Phase Focus patents,
|
||||
% in particular of patent with international application number PCT/GB2005/001464. The LICENSOR explicitly declares not to indemnify the users of the software
|
||||
% in case Phase Focus or any other third party will open a legal action against the LICENSEE due to the use of the program.
|
||||
% 10. This Agreement shall be governed by the material laws of Switzerland and any dispute arising out of this Agreement or use of the PROGRAM shall be brought before
|
||||
% the courts of Zürich, Switzerland.
|
||||
@@ -0,0 +1,145 @@
|
||||
%% TEST TEMPLATE FOR FUNTIONALITY CHECK OF MULTILAYER EXTENSION IN CPU ENGINES
|
||||
% 1) call standard template to get fresh settings defaults
|
||||
% 2) generate artificial data that should serve as a standart test "sample"
|
||||
% 3) call GPU engine with different basic functionalities and test if all still works
|
||||
% !! THESE TEST ARE ONLY USEFUL TO FIND CRASHES IN THE CODE, QUALITY OF THE RECONSTRUCTION IS NOT EVALUATED !!
|
||||
|
||||
|
||||
%% set shared parameters for all test scripts
|
||||
run(fullfile( fileparts(mfilename('test_ML_data')), 'init_test.m'))
|
||||
|
||||
|
||||
%% general settings
|
||||
p. artificial_data_file = 'tests/test_ML_data.m'; % artificial data parameters
|
||||
p. asize = [192 192]; % size of the reconstruction probe
|
||||
|
||||
%% load simulation parameters
|
||||
run(fullfile( ptycho_path, p.artificial_data_file))
|
||||
Nlayers = length(p.simulation.dataset{1});
|
||||
|
||||
%% ENGINES
|
||||
% External C++ code
|
||||
if isunix
|
||||
% Please notice that you have to force data preparation (force_prepare_h5_files=true) if you have made any changes to
|
||||
% the already prepared data (fmag, fmask, positions, sharing ...).
|
||||
eng. name = 'c_solver';
|
||||
eng. method = 'DM+ML';
|
||||
eng. number_iterations = 0; % Total number of iterations
|
||||
eng. opt_iter = 50; % Iterations for optimization
|
||||
eng. probe_regularization = .1; % Weigth factor for the probe update;
|
||||
eng. probe_change_start = 1; % Start updating probe at this iteration number
|
||||
eng. probe_support_radius = 0.8; % Normalized radius of circular support, = 1 for radius touching the window
|
||||
eng. pfft_relaxation = .05; % Relaxation in the Fourier domain projection, = 0 for full projection
|
||||
eng. background = 0; % [PARTIALLY IMPLEMENTED (not fully optimized)] Add background to the ML model in form: |Psi|^2+B, B is in average counts per frame and pixel
|
||||
eng. probe_support_fft = false; % [PARTIALLY IMPLEMENTED (not fully optimized)] Apply probe support in Fourier space, ! uses model zoneplate settings to estimate support size
|
||||
|
||||
eng.delta_z = p.simulation.thickness / (Nlayers-1) * ones(Nlayers-1,1);
|
||||
|
||||
|
||||
eng. single_prec = true; % single or double precision
|
||||
eng. threads = 20; % number of threads for OMP
|
||||
eng. beamline_nodes = []; % beamline nodes for the MPI/OMP hybrid, e.g. ['x12sa-cn-2'; 'x12sa-cn-3'];
|
||||
eng. ra_nodes = 0; % number of nodes on ra cluster for the MPI/OMP hybrid; set to 0 for current node
|
||||
eng. caller_suffix = ''; % suffix for the external reconstruction program
|
||||
eng. reconstruction_program = ''; % specify external reconstruction program that overwrites previous settings, e.g. 'OMP_NUM_THREADS=20 ./ptycho_single_OMP';
|
||||
eng. check_cpu_load = true; % check if specified nodes are already in use (only x12sa). Disable check if you are sure that the nodes are free.
|
||||
eng. initial_conditions_path = ''; % path of the initial conditions file; default if empty (== prepare_data_path)
|
||||
eng. initial_conditions_file = ''; % Name of the initial conditions file, default if empty. Do not use ~ in the path
|
||||
eng. measurements_file = ''; % Name of the measurements file, default if empty. Do not use ~ in the path
|
||||
eng. solution_file = ''; % Name of the solution file, default if empty. Do not use ~ in the path
|
||||
eng. force_prepare_h5_files = 1; % If true before running the C-code the data h5 file is created and the h5 file with initial object and probe too, regardless of whether it exists. It will use the matlab data preparator.
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
% 3D Maximum Likelihood (Matlab) See for more details: Tsai EH, et al, Optics express. 2016 Dec 12;24(25):29089-108.
|
||||
if 0 % MEX functions not compatible with Matlab 2018
|
||||
eng. name = 'ML_MS';
|
||||
eng. ms_opt_iter = 100;
|
||||
eng. N_layer = Nlayers;
|
||||
eng.delta_z = p.simulation.thickness / (Nlayers-1) * ones(Nlayers-1,1);
|
||||
|
||||
eng. ms_init_ob_fraction = []; % Default: 1/N_layer
|
||||
eng. ms_opt_flags = [1 1 0]; % Optimize [object, probe, and separation (delat_z)]
|
||||
eng. ms_opt_z_param = [200 50]; % [Every this iteratsion, run this many iterations to optimize z (likely to converge earlier anyway)]
|
||||
eng. ms_grado_roi = []; % Consider using scan_roi
|
||||
|
||||
|
||||
eng. opt_errmetric = 'L1'; % Error metric for max likelihood = 'poisson', 'L1' (approx poisson), 'L2' (uniform gaussian noise)
|
||||
eng. opt_ftol = 1e-10; % Tolerance on error metric for optimization
|
||||
eng. opt_xtol = 1e-7; % Tolerance on optimizable parameters
|
||||
eng. probe_mask_bool = true; % If true, impose a support constraint to the probe
|
||||
eng. probe_mask_area = .9; % Area ratio of the mask
|
||||
eng. probe_mask_use_auto = false; % Use autocorrelation for probe_mask (if false: circular circle)
|
||||
eng. scale_gradient = false; % Preconditioning by scaling probe gradient - Reported useful for weak objects
|
||||
eng. inv_intensity = false; % Make error metric insensitive to intensity fluctuations
|
||||
eng. use_probe_support = false; % Use the support on the probe that was used in the difference-map
|
||||
eng. reg_mu = 0.01; %0.01 % Regularization constant ( = 0 for no regularization)
|
||||
eng. smooth_gradient = true; % Sieves preconditioning, =false no smoothing, = true uses Hanning, otherwise specify a small matrix making sure its sum = 1
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
run(fullfile( fileparts(mfilename('fullpath')), 'run_test.m'))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
% Academic License Agreement
|
||||
%
|
||||
% Source Code
|
||||
%
|
||||
% Introduction
|
||||
% • This license agreement sets forth the terms and conditions under which the PAUL SCHERRER INSTITUT (PSI), CH-5232 Villigen-PSI, Switzerland (hereafter "LICENSOR")
|
||||
% will grant you (hereafter "LICENSEE") a royalty-free, non-exclusive license for academic, non-commercial purposes only (hereafter "LICENSE") to use the cSAXS
|
||||
% ptychography MATLAB package computer software program and associated documentation furnished hereunder (hereafter "PROGRAM").
|
||||
%
|
||||
% Terms and Conditions of the LICENSE
|
||||
% 1. LICENSOR grants to LICENSEE a royalty-free, non-exclusive license to use the PROGRAM for academic, non-commercial purposes, upon the terms and conditions
|
||||
% hereinafter set out and until termination of this license as set forth below.
|
||||
% 2. LICENSEE acknowledges that the PROGRAM is a research tool still in the development stage. The PROGRAM is provided without any related services, improvements
|
||||
% or warranties from LICENSOR and that the LICENSE is entered into in order to enable others to utilize the PROGRAM in their academic activities. It is the
|
||||
% LICENSEE’s responsibility to ensure its proper use and the correctness of the results.”
|
||||
% 3. THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
% A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE LICENSOR, THE AUTHORS OR THE COPYRIGHT
|
||||
% HOLDERS BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE
|
||||
% OF THE PROGRAM OR OTHER DEALINGS IN THE PROGRAM.
|
||||
% 4. LICENSEE agrees that it will use the PROGRAM and any modifications, improvements, or derivatives of PROGRAM that LICENSEE may create (collectively,
|
||||
% "IMPROVEMENTS") solely for academic, non-commercial purposes and that any copy of PROGRAM or derivatives thereof shall be distributed only under the same
|
||||
% license as PROGRAM. The terms "academic, non-commercial", as used in this Agreement, mean academic or other scholarly research which (a) is not undertaken for
|
||||
% profit, or (b) is not intended to produce works, services, or data for commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged
|
||||
% in the commercial use, application or exploitation of works similar to the PROGRAM.
|
||||
% 5. LICENSEE agrees that it shall make the following acknowledgement in any publication resulting from the use of the PROGRAM or any translation of the code into
|
||||
% another computing language:
|
||||
% "Data processing was carried out using the cSAXS ptychography MATLAB package developed by the Science IT and the coherent X-ray scattering (CXS) groups, Paul
|
||||
% Scherrer Institut, Switzerland."
|
||||
%
|
||||
% Additionally, any publication using the package, or any translation of the code into another computing language should cite for difference map:
|
||||
% P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer, High-resolution scanning X-ray diffraction microscopy, Science 321, 379–382 (2008).
|
||||
% (doi: 10.1126/science.1158573),
|
||||
% for maximum likelihood:
|
||||
% P. Thibault and M. Guizar-Sicairos, Maximum-likelihood refinement for coherent diffractive imaging, New J. Phys. 14, 063004 (2012).
|
||||
% (doi: 10.1088/1367-2630/14/6/063004),
|
||||
% for mixed coherent modes:
|
||||
% P. Thibault and A. Menzel, Reconstructing state mixtures from diffraction measurements, Nature 494, 68–71 (2013). (doi: 10.1038/nature11806),
|
||||
% and/or for multislice:
|
||||
% E. H. R. Tsai, I. Usov, A. Diaz, A. Menzel, and M. Guizar-Sicairos, X-ray ptychography with extended depth of field, Opt. Express 24, 29089–29108 (2016).
|
||||
% (doi: 10.1364/OE.24.029089).
|
||||
% 6. Except for the above-mentioned acknowledgment, LICENSEE shall not use the PROGRAM title or the names or logos of LICENSOR, nor any adaptation thereof, nor the
|
||||
% names of any of its employees or laboratories, in any advertising, promotional or sales material without prior written consent obtained from LICENSOR in each case.
|
||||
% 7. Ownership of all rights, including copyright in the PROGRAM and in any material associated therewith, shall at all times remain with LICENSOR, and LICENSEE
|
||||
% agrees to preserve same. LICENSEE agrees not to use any portion of the PROGRAM or of any IMPROVEMENTS in any machine-readable form outside the PROGRAM, nor to
|
||||
% make any copies except for its internal use, without prior written consent of LICENSOR. LICENSEE agrees to place the following copyright notice on any such copies:
|
||||
% © All rights reserved. PAUL SCHERRER INSTITUT, Switzerland, Laboratory for Macromolecules and Bioimaging, 2017.
|
||||
% 8. The LICENSE shall not be construed to confer any rights upon LICENSEE by implication or otherwise except as specifically set forth herein.
|
||||
% 9. DISCLAIMER: LICENSEE shall be aware that Phase Focus Limited of Sheffield, UK has an international portfolio of patents and pending applications which relate
|
||||
% to ptychography and that the PROGRAM may be capable of being used in circumstances which may fall within the claims of one or more of the Phase Focus patents,
|
||||
% in particular of patent with international application number PCT/GB2005/001464. The LICENSOR explicitly declares not to indemnify the users of the software
|
||||
% in case Phase Focus or any other third party will open a legal action against the LICENSEE due to the use of the program.
|
||||
% 10. This Agreement shall be governed by the material laws of Switzerland and any dispute arising out of this Agreement or use of the PROGRAM shall be brought before
|
||||
% the courts of Zürich, Switzerland.
|
||||
@@ -0,0 +1,308 @@
|
||||
%% TEST TEMPLATE FOR FUNTIONALITY OF RECONSTRUCTION ON REAL DATA
|
||||
% 1) call standard template to get fresh settings defaults
|
||||
% 2) load example of measured data
|
||||
% 3) all c_solver engine to test quality
|
||||
|
||||
|
||||
%% set shared parameters for all test scripts
|
||||
run(fullfile( fileparts(mfilename('fullpath')), 'init_test.m'))
|
||||
|
||||
|
||||
%% General
|
||||
|
||||
p. z = 5.213; % Distance from object to detector
|
||||
p. src_metadata = 'spec';
|
||||
|
||||
% Scan queue
|
||||
p. scan_number = [1717 1718]; % Multiple scan numbers for shared scans
|
||||
|
||||
|
||||
% Data preparation
|
||||
p. asize = [400 400]; % Diffr. patt. array size
|
||||
p. ctr = [460 801]; % Diffr. patt. center coordinates (y,x) (empty means middle of the array); e.g. [100 207;100+20 207+10];
|
||||
p. detector.check_2_detpos = []; % = []; (ignores) = 270; compares to dettrx to see if p.ctr should be reversed (for OMNY shared scans 1221122), make equal to the middle point of dettrx between the 2 detector positions
|
||||
p. prepare.data_preparator = 'python'; % data preparator; 'python' or 'matlab'
|
||||
p. src_metadata = 'spec'; % load meta data from file; currently only 'spec' is supported;
|
||||
|
||||
% Scan positions
|
||||
p. src_positions = 'orchestra'; % 'spec', 'orchestra', 'load_from_file', 'matlab_pos' (scan params are defined below)
|
||||
p. angular_correction_setup = 'omny'; % if src_positions=='orchestra', choose angular correction for specific cSAXS experiment: 'flomni', 'omny', 'lamni', 'none',
|
||||
p. positions_file = ['/das/work/p16/p16812/data/eiger1p5_h5/specES1/scan_positions/scan_%05d.dat']; % Filename pattern for position files, Example: ['../../specES1/scan_positions/scan_%05d.dat']; (the scan number will be automatically filled in)
|
||||
p. detector.name = 'Eiger1p5m';
|
||||
|
||||
p. affine_matrix = [1 0;tan(0.4*pi/180) 1]; % Applies affine transformation (e.g. rotation, stretching) to the positions (ignore by = []). Convention [yn;xn] = M*[y;x]. For flOMNI we found in September 2018: = [1 0;tan(0.36*pi/180) 1]; for OMNY we found in October 2018: = [1 0;tan(0.4*pi/180) 1]; laMNI in June 2018 [1,0.0154;-0.0017,1.01]; laMNI in August [1.01 0.0031; -0.0018 1.00]
|
||||
|
||||
p. prepare.force_preparation_data = true;
|
||||
|
||||
% I/O
|
||||
p. base_path = fullfile(ptycho_path, 'tests');
|
||||
p. specfile = '/das/work/p16/p16812/data/eiger1p5_h5/'; % Name of spec file to get motor positions and check end of scan, defaut is p.spec_file == p.base_path;
|
||||
p. detector.name = 'eiger1p5M'; % 'pilatus' or 'eiger'
|
||||
p. raw_data_path{1} = '/das/work/p16/p16812/data/eiger1p5_h5/'; % Default using compile_x12sa_filename, used only if data should be prepared automatically
|
||||
|
||||
%% Reconstruction
|
||||
|
||||
% Initial iterate object
|
||||
p. model_object = true; % Use model object
|
||||
p. model_object_type = 'rand'; % specify how the object shall be created; use 'rand' for a random initial guess; use 'amplitude' for an initial guess based on the prepared data
|
||||
|
||||
p. initial_iterate_object_file{1} = ''; % use this mat-file as initial guess of object, it is possible to use wild characters and pattern filling, example: '../analysis/S%05i/wrap_*_1024x1024_1_recons*'
|
||||
|
||||
% Initial iterate probe
|
||||
p. model_probe = false; % Use model probe
|
||||
p. initial_probe_file = '/das/work/p16/p16812/data/eiger1p5_h5/tests/S01717_S01718_400x400_b0_run_1_recons_06.h5';% Use probe from this mat-file (not used if model_probe is true)
|
||||
|
||||
% Shared scans - Currently working only for sharing probe and object
|
||||
p. share_probe = 0; % Share probe between scans. Can be either a number/boolean or a list of numbers, specifying the probe index; e.g. [1 2 2] to share the probes between the second and third scan.
|
||||
p. share_object = 0; % Share object between scans. Can be either a number/boolean or a list of numbers, specifying the object index; e.g. [1 2 2] to share the objects between the second and third scan.
|
||||
|
||||
% Modes
|
||||
p. probe_modes = 1; % Number of coherent modes for probe
|
||||
p. object_modes = 1; % Number of coherent modes for object
|
||||
% Mode starting guess
|
||||
p. mode_start_pow = [0.02]; % Normalized intensity on probe modes > 1. Can be a number (all higher modes equal) or a vector
|
||||
p. mode_start = 'herm'; % (for probe) = 'rand', = 'herm' (Hermitian-like base), = 'hermver' (vertical modes only), = 'hermhor' (horizontal modes only)
|
||||
p. ortho_probes = true; % orthogonalize probes after each engine
|
||||
|
||||
%% Plot and save
|
||||
p. plot.prepared_data = false; % plot prepared data
|
||||
p. plot.calc_FSC = true; % Calculate the Fourier Shell correlation for 2 scans
|
||||
p. plot.show_FSC = false; % Show the FSC plots, including the cropped FOV
|
||||
p. save.store_images = 0; % Write nice jpegs in [p.base_path,'analysis/online/ptycho/'] if p.use_display = 0 then the figures are opened invisible in order to create the nice layout. It writes images in analysis/online/ptycho
|
||||
p. plot.plot_interval = inf; % Write nice jpegs in [p.base_path,'analysis/online/ptycho/'] if p.use_display = 0 then the figures are opened invisible in order to create the nice layout. It writes images in analysis/online/ptycho
|
||||
|
||||
|
||||
|
||||
%% ENGINES
|
||||
% External C++ code
|
||||
|
||||
% Please notice that you have to force data preparation (force_prepare_h5_files=true) if you have made any changes to
|
||||
% the already prepared data (fmag, fmask, positions, sharing ...).
|
||||
eng. name = 'c_solver';
|
||||
eng. number_iterations = 300; % Total number of iterations
|
||||
eng. opt_iter = 300; % Iterations for optimization
|
||||
eng. probe_regularization = .1; % Weigth factor for the probe update;
|
||||
eng. probe_change_start = 1; % Start updating probe at this iteration number
|
||||
eng. probe_support_radius = 0.8; % Normalized radius of circular support, = 1 for radius touching the window
|
||||
eng. pfft_relaxation = .08; % Relaxation in the Fourier domain projection, = 0 for full projection
|
||||
eng. background = 0; % [PARTIALLY IMPLEMENTED (not fully optimized)] Add background to the ML model in form: |Psi|^2+B, B is in average counts per frame and pixel
|
||||
eng. probe_support_fft = false; % [PARTIALLY IMPLEMENTED (not fully optimized)] Apply probe support in Fourier space, ! uses model zoneplate settings to estimate support size
|
||||
|
||||
eng. N_layer = 1; % Number of virtual object layers (slices)
|
||||
eng. delta_z = 0e-6 * ones(1, eng.N_layer-1); % Separation between object slices
|
||||
%eng. ms_init_ob_fraction = [1 0];
|
||||
if eng. N_layer>1
|
||||
p.sufix = [p.sufix '_N' num2str(eng. N_layer)];
|
||||
eng. number_iterations = 0; % highly recommended
|
||||
end
|
||||
|
||||
eng. single_prec = true; % single or double precision
|
||||
eng. threads = 20; % number of threads for OMP
|
||||
eng. beamline_nodes = []; % beamline nodes for the MPI/OMP hybrid, e.g. ['x12sa-cn-2'; 'x12sa-cn-3'];
|
||||
eng. ra_nodes = 2; % number of nodes on ra cluster for the MPI/OMP hybrid; set to 0 for current node
|
||||
eng. caller_suffix = ''; % suffix for the external reconstruction program
|
||||
eng. reconstruction_program = ''; % specify external reconstruction program that overwrites previous settings, e.g. 'OMP_NUM_THREADS=20 ./ptycho_single_OMP';
|
||||
eng. check_cpu_load = true; % check if specified nodes are already in use (only x12sa). Disable check if you are sure that the nodes are free.
|
||||
eng. initial_conditions_path = ''; % path of the initial conditions file; default if empty (== prepare_data_path)
|
||||
eng. initial_conditions_file = ''; % Name of the initial conditions file, default if empty. Do not use ~ in the path
|
||||
eng. measurements_file = ''; % Name of the measurements file, default if empty. Do not use ~ in the path
|
||||
eng. solution_file = ''; % Name of the solution file, default if empty. Do not use ~ in the path
|
||||
eng. force_prepare_h5_files = 0; % If true before running the C-code the data h5 file is created and the h5 file with initial object and probe too, regardless of whether it exists. It will use the matlab data preparator.
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
|
||||
|
||||
if gpuDeviceCount
|
||||
% % --------- GPU engines ------------- See for more details: Odstrčil M, et al., Optics express. 2018 Feb 5;26(3):3108-23.
|
||||
eng = struct(); % reset settings for this engine
|
||||
eng. name = 'GPU';
|
||||
eng. gpu_id = []; % default GPU id, [] means choosen by matlab
|
||||
eng. probe_modes = 1;
|
||||
eng. probe_support_radius = 0.9; % Normalized radius of circular support, = 1 for radius touching the window
|
||||
eng. probe_support_fft = false; % assume that there is not illumination intensity out of the central FZP cone
|
||||
|
||||
% basic recontruction parameters
|
||||
% PIE / ML methods % See for more details: Odstrčil M, et al., Optics express. 2018 Feb 5;26(3):3108-23.
|
||||
eng. beta_object = 1; % object step size, larger == faster convergence, smaller == more robust, should not exceed 1
|
||||
eng. beta_probe = 1; % probe step size, larger == faster convergence, smaller == more robust, should not exceed 1
|
||||
eng. delta_p = 0.1; % LSQ dumping constant, 0 == no preconditioner, 0.1 is usually safe,
|
||||
eng. momentum = 0.5; % add momentum term to the MLc method, eng.momentum = multiplication gain for velocity
|
||||
eng. accelerated_gradients_start = 2; % iteration number from which the Nesterov gradient acceleration should be applied, this option is supposted only for MLc method
|
||||
|
||||
% DM
|
||||
eng. pfft_relaxation = 0.05; % Relaxation in the Fourier domain projection, = 0 for full projection
|
||||
eng. probe_regularization = 0.1; % Weight factor for the probe update (inertia)
|
||||
|
||||
% other extensions
|
||||
eng. background = 0.001; % average background scattering level, for OMNI values around 0.3 for 100ms, for flOMNI <0.1 per 100ms exposure, see for more details: Odstrcil, M., et al., Optics letters 40.23 (2015): 5574-5577.
|
||||
|
||||
eng. method = 'DM'; % choose GPU solver: DM, ePIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng. number_iterations = 300; % number of iterations for selected method
|
||||
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
|
||||
eng. method = 'MLc'; % choose GPU solver: DM, ePIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng. number_iterations = 500; % number of iterations for selected method
|
||||
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
|
||||
%% Run the reconstruction
|
||||
% python data prep
|
||||
p.prepare.data_preparator = 'python';
|
||||
run_recons_test(p, 'libDetXR', 1);
|
||||
|
||||
% matlab data prep
|
||||
p.prepare.data_preparator = 'matlab';
|
||||
run_recons_test(p, 'matlab_ps', 1);
|
||||
|
||||
% matlab data prep WITH BINNING
|
||||
p.prepare.data_preparator = 'matlab';
|
||||
p.detector.binning = true;
|
||||
run_recons_test(p, 'matlab_ps', 1);
|
||||
|
||||
|
||||
|
||||
if gpuDeviceCount
|
||||
% matlab data prep
|
||||
p.detector.binning = false;
|
||||
p.prepare.data_preparator = 'matlab';
|
||||
run_recons_test(p, 'matlab_ps', 2:3);
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
function run_recons_test(p, arg, engine_ids )
|
||||
|
||||
% run only preselected engines
|
||||
p.engines = p.engines(engine_ids);
|
||||
% reconstruct
|
||||
out = core.ptycho_recons(p);
|
||||
|
||||
if p.detector.binning
|
||||
fprintf('Testing BINNED dataset "EIGER1p5M - OMNY - %s engine %s" .... resolution %3.2f\n', arg, p.engines{1}.name, out.FSC.resolution(end))
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
cmp = load('/das/work/p16/p16812/data/eiger1p5_h5/tests/reference.mat');
|
||||
if all(cmp.ref.resolution-out.FSC.resolution>=1)
|
||||
fprintf('Testing real dataset "EIGER1p5M - OMNY - %s engine %s" .... OK\n', arg, p.engines{1}.name)
|
||||
fprintf('The resolution improved from [%3.2f %3.2f] to [%3.2f %3.2f]. Please consider updating the reference!\n', cmp.ref.resolution, out.FSC.resolution)
|
||||
elseif all(cmp.ref.resolution-out.FSC.resolution<=-1)
|
||||
fprintf('Testing real dataset "EIGER1p5M - OMNY - %s engine %s" .... failed\n', arg, p.engines{1}.name)
|
||||
warning('The resolution dropped from %3.2f to %3.2f!\n', cmp.ref.resolution(1), out.FSC.resolution(1))
|
||||
else
|
||||
fprintf('Testing real dataset "EIGER1p5M - OMNY - %s engine %s" .... OK\n', arg, p.engines{1}.name)
|
||||
end
|
||||
|
||||
% delete temporal data
|
||||
for path = out.save_path
|
||||
rmdir(path{1}, 's')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
%end
|
||||
% 2011-11-24
|
||||
% Parameter to autoposition windows on first display - p.windowautopos
|
||||
% Replaced powerbound with countbound. countbound represents the mean
|
||||
% number of photons in a change below which no projection is taken. It
|
||||
% scales automatically with exposure time (number of photons in
|
||||
% measurement)
|
||||
% Real axes option to show plots in microns
|
||||
% Read parameters from spec
|
||||
% Implement user suplied object_flat_region
|
||||
% Implemented option for reconstructing when having 2 repeated scans in the prepared data file
|
||||
|
||||
% 2011-11-29
|
||||
% Template seemed extracted from an AFS run, I modified directories for
|
||||
% direct use on ../../
|
||||
% Implemented test mode
|
||||
% Added cutoff value at beginning
|
||||
% Added auto settings for prepare data, scan numbers
|
||||
% Implemented reading from spec. Note it will use the values from the first
|
||||
% scan
|
||||
% Added option for repeated scan, should be enabled for 2 detector positions
|
||||
|
||||
% 2012-08-23
|
||||
% Replaced default prepare data function to prepare_data_2d
|
||||
% In I/O section: added option for a sufix
|
||||
% Added default option for raw data path based on compile_x12sa_filename
|
||||
% Added options to autoprepare data, with cutoff and burstmode detected if
|
||||
% the file does not exist. Also added the possiblity to override and
|
||||
% force a repreparation of data
|
||||
% Added a data prefix option (for eaccount_1_) and defaults using
|
||||
% identify_eaccount
|
||||
|
||||
% 2012-10-29
|
||||
% Added option for binning and some checks for OMNY detector position scans
|
||||
|
||||
% 2012-10-31
|
||||
% Added options to use the external C-code for testing
|
||||
|
||||
% 2015-05-13
|
||||
% Added option to queue file tasks from OMNI.
|
||||
% For this I moved the default checks and generation of default names and
|
||||
% paths to ptycho_recons. Que Dios se apiade de nosotros.
|
||||
|
||||
% 2016-02-11
|
||||
% Removed old option for dump files
|
||||
% Added p.store_images, if this flag is on and p.use_display it will open
|
||||
% figures in the background and write nice jpegs of the reconstruction and error metric anyway
|
||||
|
||||
% Academic License Agreement
|
||||
%
|
||||
% Source Code
|
||||
%
|
||||
% Introduction
|
||||
% • This license agreement sets forth the terms and conditions under which the PAUL SCHERRER INSTITUT (PSI), CH-5232 Villigen-PSI, Switzerland (hereafter "LICENSOR")
|
||||
% will grant you (hereafter "LICENSEE") a royalty-free, non-exclusive license for academic, non-commercial purposes only (hereafter "LICENSE") to use the cSAXS
|
||||
% ptychography MATLAB package computer software program and associated documentation furnished hereunder (hereafter "PROGRAM").
|
||||
%
|
||||
% Terms and Conditions of the LICENSE
|
||||
% 1. LICENSOR grants to LICENSEE a royalty-free, non-exclusive license to use the PROGRAM for academic, non-commercial purposes, upon the terms and conditions
|
||||
% hereinafter set out and until termination of this license as set forth below.
|
||||
% 2. LICENSEE acknowledges that the PROGRAM is a research tool still in the development stage. The PROGRAM is provided without any related services, improvements
|
||||
% or warranties from LICENSOR and that the LICENSE is entered into in order to enable others to utilize the PROGRAM in their academic activities. It is the
|
||||
% LICENSEE’s responsibility to ensure its proper use and the correctness of the results.”
|
||||
% 3. THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
% A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE LICENSOR, THE AUTHORS OR THE COPYRIGHT
|
||||
% HOLDERS BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE
|
||||
% OF THE PROGRAM OR OTHER DEALINGS IN THE PROGRAM.
|
||||
% 4. LICENSEE agrees that it will use the PROGRAM and any modifications, improvements, or derivatives of PROGRAM that LICENSEE may create (collectively,
|
||||
% "IMPROVEMENTS") solely for academic, non-commercial purposes and that any copy of PROGRAM or derivatives thereof shall be distributed only under the same
|
||||
% license as PROGRAM. The terms "academic, non-commercial", as used in this Agreement, mean academic or other scholarly research which (a) is not undertaken for
|
||||
% profit, or (b) is not intended to produce works, services, or data for commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged
|
||||
% in the commercial use, application or exploitation of works similar to the PROGRAM.
|
||||
% 5. LICENSEE agrees that it shall make the following acknowledgement in any publication resulting from the use of the PROGRAM or any translation of the code into
|
||||
% another computing language:
|
||||
% "Data processing was carried out using the cSAXS ptychography MATLAB package developed by the Science IT and the coherent X-ray scattering (CXS) groups, Paul
|
||||
% Scherrer Institut, Switzerland."
|
||||
%
|
||||
% Additionally, any publication using the package, or any translation of the code into another computing language should cite for difference map:
|
||||
% P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer, High-resolution scanning X-ray diffraction microscopy, Science 321, 379–382 (2008).
|
||||
% (doi: 10.1126/science.1158573),
|
||||
% for maximum likelihood:
|
||||
% P. Thibault and M. Guizar-Sicairos, Maximum-likelihood refinement for coherent diffractive imaging, New J. Phys. 14, 063004 (2012).
|
||||
% (doi: 10.1088/1367-2630/14/6/063004),
|
||||
% for mixed coherent modes:
|
||||
% P. Thibault and A. Menzel, Reconstructing state mixtures from diffraction measurements, Nature 494, 68–71 (2013). (doi: 10.1038/nature11806),
|
||||
% and/or for multislice:
|
||||
% E. H. R. Tsai, I. Usov, A. Diaz, A. Menzel, and M. Guizar-Sicairos, X-ray ptychography with extended depth of field, Opt. Express 24, 29089–29108 (2016).
|
||||
% (doi: 10.1364/OE.24.029089).
|
||||
% 6. Except for the above-mentioned acknowledgment, LICENSEE shall not use the PROGRAM title or the names or logos of LICENSOR, nor any adaptation thereof, nor the
|
||||
% names of any of its employees or laboratories, in any advertising, promotional or sales material without prior written consent obtained from LICENSOR in each case.
|
||||
% 7. Ownership of all rights, including copyright in the PROGRAM and in any material associated therewith, shall at all times remain with LICENSOR, and LICENSEE
|
||||
% agrees to preserve same. LICENSEE agrees not to use any portion of the PROGRAM or of any IMPROVEMENTS in any machine-readable form outside the PROGRAM, nor to
|
||||
% make any copies except for its internal use, without prior written consent of LICENSOR. LICENSEE agrees to place the following copyright notice on any such copies:
|
||||
% © All rights reserved. PAUL SCHERRER INSTITUT, Switzerland, Laboratory for Macromolecules and Bioimaging, 2017.
|
||||
% 8. The LICENSE shall not be construed to confer any rights upon LICENSEE by implication or otherwise except as specifically set forth herein.
|
||||
% 9. DISCLAIMER: LICENSEE shall be aware that Phase Focus Limited of Sheffield, UK has an international portfolio of patents and pending applications which relate
|
||||
% to ptychography and that the PROGRAM may be capable of being used in circumstances which may fall within the claims of one or more of the Phase Focus patents,
|
||||
% in particular of patent with international application number PCT/GB2005/001464. The LICENSOR explicitly declares not to indemnify the users of the software
|
||||
% in case Phase Focus or any other third party will open a legal action against the LICENSEE due to the use of the program.
|
||||
% 10. This Agreement shall be governed by the material laws of Switzerland and any dispute arising out of this Agreement or use of the PROGRAM shall be brought before
|
||||
% the courts of Zürich, Switzerland.
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
%% TEST TEMPLATE FOR FUNTIONALITY CHECK IN GPU ENGINES
|
||||
% 1) call standard template to get fresh settings defaults
|
||||
% 2) generate artificial data that should serve as a standart test "sample"
|
||||
% 3) call GPU engine with different basic functionalities and test if all still works
|
||||
% !! THESE TEST ARE ONLY USEFUL TO FIND CRASHES IN THE CODE, QUALITY OF THE RECONSTRUCTION IS NOT EVALUATED !!
|
||||
|
||||
|
||||
%% set shared parameters for all test scripts
|
||||
run(fullfile( fileparts(mfilename('fullpath')), 'init_test.m'))
|
||||
|
||||
|
||||
%% general settings
|
||||
p. artificial_data_file = 'tests/test_data_camera_geometry.m'; % artificial data parameters
|
||||
p. asize = [128 128]; % size of the reconstruction probe
|
||||
p. preserve_previous_results = true;
|
||||
plot_results = true;
|
||||
|
||||
|
||||
%% ENGINES
|
||||
% --------- GPU engines -------------
|
||||
eng = struct();
|
||||
eng. name = 'GPU';
|
||||
eng. use_gpu = true; % if false, run CPU code, but it will get very slow
|
||||
eng. gpu_id = []; % default GPU id, [] means choosen by matlab
|
||||
|
||||
%% general
|
||||
eng. share_probe = 0; % Share probe between scans. Can be either a number/boolean or a list of numbers, specifying the probe index; e.g. [1 2 2] to share the probes between the second and third scan.
|
||||
eng. grouping = inf; % size of processed blocks, larger blocks need more memory but they use GPU more effeciently
|
||||
% for hPIE, ePIE, MLs methods smaller blocks lead to faster convergence,
|
||||
|
||||
eng_0 = eng;
|
||||
|
||||
if 1
|
||||
%% presolve by DM solver
|
||||
eng = eng_0;
|
||||
eng. method = 'DM'; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng. number_iterations = 50; % number of iterations for selected method
|
||||
eng.probe_change_start = 5;
|
||||
eng. pfft_relaxation = 0.1; % Relaxation in the Fourier domain projection, = 0 for full projection
|
||||
eng. probe_regularization = 0.1;% Weight factor for the probe update (inertia)
|
||||
|
||||
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
|
||||
|
||||
if 1
|
||||
%% presolve by MLc solver
|
||||
eng = eng_0;
|
||||
eng. method = 'MLc'; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng. number_iterations = 50; % number of iterations for selected method
|
||||
eng.probe_change_start = 1;
|
||||
eng. mirror_objects = true; % mirror objects, useful for 0/180deg scan sharing -> geometry refinement for tomography
|
||||
eng. share_object = false;
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
|
||||
if 1
|
||||
%% test geometry refinement with MLc solver
|
||||
eng = eng_0;
|
||||
eng. number_iterations =200; % number of iterations for selected method
|
||||
eng.probe_modes = 1;
|
||||
eng. method = 'MLc'; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng.grouping = inf;
|
||||
|
||||
eng. mirror_objects = true; % mirror objects, useful for 0/180deg scan sharing -> geometry refinement for tomography
|
||||
eng. share_object = true;
|
||||
eng. detector_rotation_search = 10;
|
||||
eng. detector_scale_search = 10;
|
||||
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
|
||||
run(fullfile( fileparts(mfilename('fullpath')), 'run_test.m'))
|
||||
|
||||
|
||||
|
||||
% Academic License Agreement
|
||||
%
|
||||
% Source Code
|
||||
%
|
||||
% Introduction
|
||||
% • This license agreement sets forth the terms and conditions under which the PAUL SCHERRER INSTITUT (PSI), CH-5232 Villigen-PSI, Switzerland (hereafter "LICENSOR")
|
||||
% will grant you (hereafter "LICENSEE") a royalty-free, non-exclusive license for academic, non-commercial purposes only (hereafter "LICENSE") to use the cSAXS
|
||||
% ptychography MATLAB package computer software program and associated documentation furnished hereunder (hereafter "PROGRAM").
|
||||
%
|
||||
% Terms and Conditions of the LICENSE
|
||||
% 1. LICENSOR grants to LICENSEE a royalty-free, non-exclusive license to use the PROGRAM for academic, non-commercial purposes, upon the terms and conditions
|
||||
% hereinafter set out and until termination of this license as set forth below.
|
||||
% 2. LICENSEE acknowledges that the PROGRAM is a research tool still in the development stage. The PROGRAM is provided without any related services, improvements
|
||||
% or warranties from LICENSOR and that the LICENSE is entered into in order to enable others to utilize the PROGRAM in their academic activities. It is the
|
||||
% LICENSEE’s responsibility to ensure its proper use and the correctness of the results.”
|
||||
% 3. THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
% A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE LICENSOR, THE AUTHORS OR THE COPYRIGHT
|
||||
% HOLDERS BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE
|
||||
% OF THE PROGRAM OR OTHER DEALINGS IN THE PROGRAM.
|
||||
% 4. LICENSEE agrees that it will use the PROGRAM and any modifications, improvements, or derivatives of PROGRAM that LICENSEE may create (collectively,
|
||||
% "IMPROVEMENTS") solely for academic, non-commercial purposes and that any copy of PROGRAM or derivatives thereof shall be distributed only under the same
|
||||
% license as PROGRAM. The terms "academic, non-commercial", as used in this Agreement, mean academic or other scholarly research which (a) is not undertaken for
|
||||
% profit, or (b) is not intended to produce works, services, or data for commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged
|
||||
% in the commercial use, application or exploitation of works similar to the PROGRAM.
|
||||
% 5. LICENSEE agrees that it shall make the following acknowledgement in any publication resulting from the use of the PROGRAM or any translation of the code into
|
||||
% another computing language:
|
||||
% "Data processing was carried out using the cSAXS ptychography MATLAB package developed by the Science IT and the coherent X-ray scattering (CXS) groups, Paul
|
||||
% Scherrer Institut, Switzerland."
|
||||
%
|
||||
% Additionally, any publication using the package, or any translation of the code into another computing language should cite for difference map:
|
||||
% P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer, High-resolution scanning X-ray diffraction microscopy, Science 321, 379–382 (2008).
|
||||
% (doi: 10.1126/science.1158573),
|
||||
% for maximum likelihood:
|
||||
% P. Thibault and M. Guizar-Sicairos, Maximum-likelihood refinement for coherent diffractive imaging, New J. Phys. 14, 063004 (2012).
|
||||
% (doi: 10.1088/1367-2630/14/6/063004),
|
||||
% for mixed coherent modes:
|
||||
% P. Thibault and A. Menzel, Reconstructing state mixtures from diffraction measurements, Nature 494, 68–71 (2013). (doi: 10.1038/nature11806),
|
||||
% and/or for multislice:
|
||||
% E. H. R. Tsai, I. Usov, A. Diaz, A. Menzel, and M. Guizar-Sicairos, X-ray ptychography with extended depth of field, Opt. Express 24, 29089–29108 (2016).
|
||||
% (doi: 10.1364/OE.24.029089).
|
||||
% 6. Except for the above-mentioned acknowledgment, LICENSEE shall not use the PROGRAM title or the names or logos of LICENSOR, nor any adaptation thereof, nor the
|
||||
% names of any of its employees or laboratories, in any advertising, promotional or sales material without prior written consent obtained from LICENSOR in each case.
|
||||
% 7. Ownership of all rights, including copyright in the PROGRAM and in any material associated therewith, shall at all times remain with LICENSOR, and LICENSEE
|
||||
% agrees to preserve same. LICENSEE agrees not to use any portion of the PROGRAM or of any IMPROVEMENTS in any machine-readable form outside the PROGRAM, nor to
|
||||
% make any copies except for its internal use, without prior written consent of LICENSOR. LICENSEE agrees to place the following copyright notice on any such copies:
|
||||
% © All rights reserved. PAUL SCHERRER INSTITUT, Switzerland, Laboratory for Macromolecules and Bioimaging, 2017.
|
||||
% 8. The LICENSE shall not be construed to confer any rights upon LICENSEE by implication or otherwise except as specifically set forth herein.
|
||||
% 9. DISCLAIMER: LICENSEE shall be aware that Phase Focus Limited of Sheffield, UK has an international portfolio of patents and pending applications which relate
|
||||
% to ptychography and that the PROGRAM may be capable of being used in circumstances which may fall within the claims of one or more of the Phase Focus patents,
|
||||
% in particular of patent with international application number PCT/GB2005/001464. The LICENSOR explicitly declares not to indemnify the users of the software
|
||||
% in case Phase Focus or any other third party will open a legal action against the LICENSEE due to the use of the program.
|
||||
% 10. This Agreement shall be governed by the material laws of Switzerland and any dispute arising out of this Agreement or use of the PROGRAM shall be brought before
|
||||
% the courts of Zürich, Switzerland.
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
%% TEST TEMPLATE FOR FUNTIONALITY CHECK IN GPU ENGINES
|
||||
% 1) call standard template to get fresh settings defaults
|
||||
% 2) generate artificial data that should serve as a standart test "sample"
|
||||
% 3) call GPU engine with different basic functionalities and test if all still works
|
||||
% !! THESE TEST ARE ONLY USEFUL TO FIND CRASHES IN THE CODE, QUALITY OF THE RECONSTRUCTION IS NOT EVALUATED !!
|
||||
|
||||
|
||||
%% set shared parameters for all test scripts
|
||||
run(fullfile( fileparts(mfilename('fullpath')), 'init_test.m'))
|
||||
|
||||
|
||||
%% general settings
|
||||
p. artificial_data_file = 'tests/test_data_geometry.m'; % artificial data parameters
|
||||
p. asize = [128 128]; % size of the reconstruction probe
|
||||
p. preserve_previous_results = true;
|
||||
plot_results = true;
|
||||
|
||||
%% ENGINES
|
||||
% --------- GPU engines -------------
|
||||
if 1
|
||||
eng = struct();
|
||||
eng. name = 'GPU';
|
||||
eng. use_gpu = true; % if false, run CPU code, but it will get very slow
|
||||
eng. gpu_id = []; % default GPU id, [] means choosen by matlab
|
||||
|
||||
%% general
|
||||
eng. share_probe = 0; % Share probe between scans. Can be either a number/boolean or a list of numbers, specifying the probe index; e.g. [1 2 2] to share the probes between the second and third scan.
|
||||
eng. grouping = inf; % size of processed blocks, larger blocks need more memory but they use GPU more effeciently
|
||||
% for hPIE, ePIE, MLs methods smaller blocks lead to faster convergence,
|
||||
end
|
||||
|
||||
eng_0 = eng;
|
||||
|
||||
if 1
|
||||
%% presolve by DM solver
|
||||
eng = eng_0;
|
||||
eng. method = 'DM'; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng. number_iterations = 50; % number of iterations for selected method
|
||||
eng.probe_change_start = 5;
|
||||
eng. pfft_relaxation = 0.1; % Relaxation in the Fourier domain projection, = 0 for full projection
|
||||
eng. probe_regularization = 0.1;% Weight factor for the probe update (inertia)
|
||||
|
||||
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
|
||||
|
||||
if 1
|
||||
%% presolve by MLc solver
|
||||
eng = eng_0;
|
||||
eng. method = 'MLc'; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng. number_iterations = 50; % number of iterations for selected method
|
||||
eng.probe_change_start = 1;
|
||||
eng. mirror_objects = true; % mirror objects, useful for 0/180deg scan sharing -> geometry refinement for tomography
|
||||
eng. share_object = false;
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
|
||||
if 1
|
||||
%% test geometry refinement by MLc
|
||||
eng = eng_0;
|
||||
eng. number_iterations = 100; % number of iterations for selected method
|
||||
eng.probe_modes = 1;
|
||||
eng. method = 'MLc'; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng.grouping = inf;
|
||||
|
||||
eng. probe_position_search = 20; % reconstruct probe positions, from iteration == probe_pos_search, assume they are independed
|
||||
eng. probe_position_error_max = 20e-9; % max expected random position error of the stages
|
||||
eng. probe_geometry_model = {'scale', 'asymmetry', 'rotation', 'shear'}; % list of free parameters in the geometry model, choose from: {'scale', 'asymmetry', 'rotation', 'shear'}
|
||||
eng. mirror_objects = true; % mirror objects, useful for 0/180deg scan sharing -> geometry refinement for tomography
|
||||
eng. share_object = true;
|
||||
eng. detector_rotation_search = inf;
|
||||
eng. detector_scale_search = inf;
|
||||
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
|
||||
|
||||
%% use two shared scans flipped by 180 degrees for geometry refinement
|
||||
p0 = p;
|
||||
|
||||
p.flip_objects_180deg = [false, true]; % Simulated 0 vs 180 deg projection
|
||||
|
||||
run(fullfile( fileparts(mfilename('fullpath')), 'run_test.m'))
|
||||
|
||||
|
||||
%% use two shared scans without flipping for geometry refinement
|
||||
p = p0;
|
||||
p.flip_objects_180deg = [false, false]; % Simulated 0 vs 180 deg projection
|
||||
p.engines(2) = []; % delete MLc presolver
|
||||
p.engines{end}.mirror_objects = false;
|
||||
p.engines{end}.share_object = false;
|
||||
|
||||
run(fullfile( fileparts(mfilename('fullpath')), 'run_test.m'))
|
||||
|
||||
|
||||
% Academic License Agreement
|
||||
%
|
||||
% Source Code
|
||||
%
|
||||
% Introduction
|
||||
% • This license agreement sets forth the terms and conditions under which the PAUL SCHERRER INSTITUT (PSI), CH-5232 Villigen-PSI, Switzerland (hereafter "LICENSOR")
|
||||
% will grant you (hereafter "LICENSEE") a royalty-free, non-exclusive license for academic, non-commercial purposes only (hereafter "LICENSE") to use the cSAXS
|
||||
% ptychography MATLAB package computer software program and associated documentation furnished hereunder (hereafter "PROGRAM").
|
||||
%
|
||||
% Terms and Conditions of the LICENSE
|
||||
% 1. LICENSOR grants to LICENSEE a royalty-free, non-exclusive license to use the PROGRAM for academic, non-commercial purposes, upon the terms and conditions
|
||||
% hereinafter set out and until termination of this license as set forth below.
|
||||
% 2. LICENSEE acknowledges that the PROGRAM is a research tool still in the development stage. The PROGRAM is provided without any related services, improvements
|
||||
% or warranties from LICENSOR and that the LICENSE is entered into in order to enable others to utilize the PROGRAM in their academic activities. It is the
|
||||
% LICENSEE’s responsibility to ensure its proper use and the correctness of the results.”
|
||||
% 3. THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
% A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE LICENSOR, THE AUTHORS OR THE COPYRIGHT
|
||||
% HOLDERS BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE
|
||||
% OF THE PROGRAM OR OTHER DEALINGS IN THE PROGRAM.
|
||||
% 4. LICENSEE agrees that it will use the PROGRAM and any modifications, improvements, or derivatives of PROGRAM that LICENSEE may create (collectively,
|
||||
% "IMPROVEMENTS") solely for academic, non-commercial purposes and that any copy of PROGRAM or derivatives thereof shall be distributed only under the same
|
||||
% license as PROGRAM. The terms "academic, non-commercial", as used in this Agreement, mean academic or other scholarly research which (a) is not undertaken for
|
||||
% profit, or (b) is not intended to produce works, services, or data for commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged
|
||||
% in the commercial use, application or exploitation of works similar to the PROGRAM.
|
||||
% 5. LICENSEE agrees that it shall make the following acknowledgement in any publication resulting from the use of the PROGRAM or any translation of the code into
|
||||
% another computing language:
|
||||
% "Data processing was carried out using the cSAXS ptychography MATLAB package developed by the Science IT and the coherent X-ray scattering (CXS) groups, Paul
|
||||
% Scherrer Institut, Switzerland."
|
||||
%
|
||||
% Additionally, any publication using the package, or any translation of the code into another computing language should cite for difference map:
|
||||
% P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer, High-resolution scanning X-ray diffraction microscopy, Science 321, 379–382 (2008).
|
||||
% (doi: 10.1126/science.1158573),
|
||||
% for maximum likelihood:
|
||||
% P. Thibault and M. Guizar-Sicairos, Maximum-likelihood refinement for coherent diffractive imaging, New J. Phys. 14, 063004 (2012).
|
||||
% (doi: 10.1088/1367-2630/14/6/063004),
|
||||
% for mixed coherent modes:
|
||||
% P. Thibault and A. Menzel, Reconstructing state mixtures from diffraction measurements, Nature 494, 68–71 (2013). (doi: 10.1038/nature11806),
|
||||
% and/or for multislice:
|
||||
% E. H. R. Tsai, I. Usov, A. Diaz, A. Menzel, and M. Guizar-Sicairos, X-ray ptychography with extended depth of field, Opt. Express 24, 29089–29108 (2016).
|
||||
% (doi: 10.1364/OE.24.029089).
|
||||
% 6. Except for the above-mentioned acknowledgment, LICENSEE shall not use the PROGRAM title or the names or logos of LICENSOR, nor any adaptation thereof, nor the
|
||||
% names of any of its employees or laboratories, in any advertising, promotional or sales material without prior written consent obtained from LICENSOR in each case.
|
||||
% 7. Ownership of all rights, including copyright in the PROGRAM and in any material associated therewith, shall at all times remain with LICENSOR, and LICENSEE
|
||||
% agrees to preserve same. LICENSEE agrees not to use any portion of the PROGRAM or of any IMPROVEMENTS in any machine-readable form outside the PROGRAM, nor to
|
||||
% make any copies except for its internal use, without prior written consent of LICENSOR. LICENSEE agrees to place the following copyright notice on any such copies:
|
||||
% © All rights reserved. PAUL SCHERRER INSTITUT, Switzerland, Laboratory for Macromolecules and Bioimaging, 2017.
|
||||
% 8. The LICENSE shall not be construed to confer any rights upon LICENSEE by implication or otherwise except as specifically set forth herein.
|
||||
% 9. DISCLAIMER: LICENSEE shall be aware that Phase Focus Limited of Sheffield, UK has an international portfolio of patents and pending applications which relate
|
||||
% to ptychography and that the PROGRAM may be capable of being used in circumstances which may fall within the claims of one or more of the Phase Focus patents,
|
||||
% in particular of patent with international application number PCT/GB2005/001464. The LICENSOR explicitly declares not to indemnify the users of the software
|
||||
% in case Phase Focus or any other third party will open a legal action against the LICENSEE due to the use of the program.
|
||||
% 10. This Agreement shall be governed by the material laws of Switzerland and any dispute arising out of this Agreement or use of the PROGRAM shall be brought before
|
||||
% the courts of Zürich, Switzerland.
|
||||
|
||||
@@ -0,0 +1,231 @@
|
||||
%% TEST TEMPLATE FOR FUNTIONALITY CHECK IN GPU ENGINES
|
||||
% 1) call standard template to get fresh settings defaults
|
||||
% 2) generate artificial data that should serve as a standart test "sample"
|
||||
% 3) call GPU engine with different basic functionalities and test if all still works
|
||||
% !! THESE TEST ARE ONLY USEFUL TO FIND CRASHES IN THE CODE, QUALITY OF THE RECONSTRUCTION IS NOT EVALUATED !!
|
||||
|
||||
|
||||
%% set shared parameters for all test scripts
|
||||
run(fullfile( fileparts(mfilename('fullpath')), 'init_test.m'))
|
||||
|
||||
|
||||
%% general settings
|
||||
p. artificial_data_file = 'tests/test_data.m'; % artificial data parameters
|
||||
p. asize = [128 128]; % size of the reconstruction probe
|
||||
|
||||
%% ENGINES
|
||||
|
||||
% --------- GPU engines -------------
|
||||
if 1
|
||||
eng = struct();
|
||||
eng. name = 'GPU';
|
||||
eng. use_gpu = true; % if false, run CPU code, but it will get very slow
|
||||
eng. keep_on_gpu = true; % keep data + projections on GPU, false is useful for large data if DM is used
|
||||
eng. compress_data = true; % use automatic online memory compression to limit meed of GPU memory
|
||||
eng. gpu_id = []; % default GPU id, [] means choosen by matlab
|
||||
eng. check_gpu_load = true; % check available GPU memory before starting GPU engines
|
||||
|
||||
%% general
|
||||
eng. number_iterations = 20; % number of iterations for selected method
|
||||
eng. share_probe = 0; % Share probe between scans. Can be either a number/boolean or a list of numbers, specifying the probe index; e.g. [1 2 2] to share the probes between the second and third scan.
|
||||
%eng. share_object = 0; % Share object between scans. Can be either a number/boolean or a list of numbers, specifying the object index; e.g. [1 2 2] to share the objects between the second and third scan.
|
||||
eng. method = 'MLs'; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng. opt_errmetric = 'L1' ; % optimization likelihood - poisson, L1
|
||||
eng. grouping = 50; % size of processed blocks, larger blocks need more memory but they use GPU more effeciently
|
||||
% for hPIE, ePIE, MLs methods smaller blocks lead to faster convergence,
|
||||
% for pPIE, MLc the convergence is similar
|
||||
% for DM, RAAR is has no effect on convergence
|
||||
%eng. probe_modes = 1; % Number of coherent modes for probe
|
||||
eng. object_change_start = 1; % Start updating object at this iteration number
|
||||
eng. probe_change_start = 1; % Start updating probe at this iteration number
|
||||
eng.probe_support_fft = true;
|
||||
eng. probe_modes = 1; % Number of coherent modes for probe
|
||||
|
||||
% regularizations
|
||||
eng. reg_mu = 0; % Regularization constant ( = 0 for no regularization)
|
||||
eng. delta = 0; % press values to zero out of the illumination area, usually 1e-2 is enough
|
||||
eng. positivity_constraint_object = 0; % enforce weak positivity in object, usually 1e-2 is already enough
|
||||
|
||||
eng. apply_multimodal_update = false; % apply all incoherent modes to object, it can cause isses if the modes collect some crap
|
||||
eng. probe_backpropagate = 0; % backpropagate the probe mask, inf == farfield
|
||||
|
||||
% basic recontruction parameters
|
||||
% PIE / ML methods
|
||||
eng. beta_object = 1; % object step size, larger == faster convergence, smaller == more robust, should not exceed 1
|
||||
eng. beta_probe = 1; % probe step size, larger == faster convergence, smaller == more robust, should not exceed 1
|
||||
eng. delta_p = 0.1; % LSQ dumping constant, 0 == no preconditioner, 0.1 is usually safe,
|
||||
% DM
|
||||
eng. pfft_relaxation = 0.1; % Relaxation in the Fourier domain projection, = 0 for full projection
|
||||
eng. probe_regularization = 0.1;% Weigth factor for the probe update (inertia)
|
||||
|
||||
|
||||
% ADVANCED OPTIONS
|
||||
% position refinement
|
||||
eng. apply_subpix_shift = false; % apply FFT-based subpixel shift, important for good position refinement but it is slow
|
||||
eng. probe_position_search = inf; % reconstruct probe positions, from iteration == probe_position_search, assume they have to match geometry model with error less than probe_position_error_max
|
||||
eng. probe_position_error_max = 10e-9; % max expected random position error of the stages
|
||||
|
||||
% wavefront refinement
|
||||
eng. probe_fourier_shift_search = inf; % refine farfield position of the beam (ie angle) from iteration == probe_fourier_shift_search
|
||||
eng. estimate_NF_distance = inf; % try to estimate the nearfield propagation distance
|
||||
eng. variable_probe = false; % Use SVD to account for variable illumination during a single (coupled) scan
|
||||
eng. variable_SVD_modes = 3; % OPRP settings , number of SVD modes, apply only for PIE methods
|
||||
eng. variable_probe_smooth = 0; % OPRP settings , apply assumption of smooth evolution of the OPRP modes (ie slow drifts)
|
||||
eng. variable_intensity = false; % account to changes in probe intensity
|
||||
|
||||
end
|
||||
|
||||
eng_0 = eng;
|
||||
%
|
||||
|
||||
if 1
|
||||
%% test DM solver
|
||||
eng = eng_0;
|
||||
eng. method = 'DM'; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng.grouping = inf;
|
||||
eng.probe_support_radius = 0.9;
|
||||
eng. number_iterations = 50; % number of iterations for selected method
|
||||
eng.probe_change_start = 5;
|
||||
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
|
||||
if 1
|
||||
%% test MLc/s codes
|
||||
eng = eng_0;
|
||||
eng. method = 'MLs'; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng.grouping = 50;
|
||||
eng.probe_support_radius = [];
|
||||
eng. background = 0.1;
|
||||
eng. background_width = 20;
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
if 1
|
||||
eng = eng_0;
|
||||
eng. method = 'MLc'; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng.grouping = inf;
|
||||
eng.probe_support_radius = 0.9;
|
||||
eng. number_iterations = 50; % number of iterations for selected method
|
||||
eng.probe_change_start = 1;
|
||||
eng. accelerated_gradients_start = 5; % use accelerated gradients to speed up the convergence
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
|
||||
if 1
|
||||
%% test position refinement and variable modes
|
||||
eng = eng_0;
|
||||
eng. method = 'MLc'; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng. probe_position_search = 100; % reconstruct probe positions, from iteration == probe_pos_search, assume they are independed
|
||||
eng. variable_probe = true; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng. variable_probe_modes = 2; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng. accelerated_gradients_start = 5; % use accelerated gradients to speed up the convergence
|
||||
eng. probe_fourier_shift_search = 3; % reconstruct probe positions, from iteration == probe_pos_search, assume they are independed
|
||||
eng. probe_geometry_model = {'scale', 'asymmetry', 'rotation', 'shear'}; % list of free parameters in the geometry model, choose from: {'scale', 'asymmetry', 'rotation', 'shear'}
|
||||
|
||||
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
if 1
|
||||
%% test variable probe extension
|
||||
eng = eng_0;
|
||||
eng. method = 'hPIE'; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng. variable_probe = false; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng. variable_intensity = true; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng. variable_probe_modes = 1; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng. probe_modes = 1; % Number of coherent modes for probe
|
||||
eng. beta_probe = 0.1; % slower convergence of the probe in order to prevent diverging
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
if 1
|
||||
%% test variable probe extension
|
||||
eng = eng_0;
|
||||
eng. method = 'MLs'; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng. likelihood = 'poisson';
|
||||
|
||||
eng.probe_modes = 2;
|
||||
eng. momentum = 0.5; % momentum acceleration
|
||||
eng.variable_probe = true;
|
||||
eng.variable_probe_modes = 3;
|
||||
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
|
||||
if 1
|
||||
%% test variable probe extension
|
||||
eng = eng_0;
|
||||
eng. method = 'hPIE'; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng. variable_probe = true; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng. variable_probe_modes = 3; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng. beta_probe = 0.2;
|
||||
eng. beta_object = 0.5;
|
||||
eng. delta_p = 0.1;
|
||||
eng. probe_reconstruct = 1;
|
||||
eng.probe_modes = 1;
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
|
||||
run(fullfile( fileparts(mfilename('fullpath')), 'run_test.m'))
|
||||
|
||||
|
||||
|
||||
% Academic License Agreement
|
||||
%
|
||||
% Source Code
|
||||
%
|
||||
% Introduction
|
||||
% • This license agreement sets forth the terms and conditions under which the PAUL SCHERRER INSTITUT (PSI), CH-5232 Villigen-PSI, Switzerland (hereafter "LICENSOR")
|
||||
% will grant you (hereafter "LICENSEE") a royalty-free, non-exclusive license for academic, non-commercial purposes only (hereafter "LICENSE") to use the cSAXS
|
||||
% ptychography MATLAB package computer software program and associated documentation furnished hereunder (hereafter "PROGRAM").
|
||||
%
|
||||
% Terms and Conditions of the LICENSE
|
||||
% 1. LICENSOR grants to LICENSEE a royalty-free, non-exclusive license to use the PROGRAM for academic, non-commercial purposes, upon the terms and conditions
|
||||
% hereinafter set out and until termination of this license as set forth below.
|
||||
% 2. LICENSEE acknowledges that the PROGRAM is a research tool still in the development stage. The PROGRAM is provided without any related services, improvements
|
||||
% or warranties from LICENSOR and that the LICENSE is entered into in order to enable others to utilize the PROGRAM in their academic activities. It is the
|
||||
% LICENSEE’s responsibility to ensure its proper use and the correctness of the results.”
|
||||
% 3. THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
% A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE LICENSOR, THE AUTHORS OR THE COPYRIGHT
|
||||
% HOLDERS BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE
|
||||
% OF THE PROGRAM OR OTHER DEALINGS IN THE PROGRAM.
|
||||
% 4. LICENSEE agrees that it will use the PROGRAM and any modifications, improvements, or derivatives of PROGRAM that LICENSEE may create (collectively,
|
||||
% "IMPROVEMENTS") solely for academic, non-commercial purposes and that any copy of PROGRAM or derivatives thereof shall be distributed only under the same
|
||||
% license as PROGRAM. The terms "academic, non-commercial", as used in this Agreement, mean academic or other scholarly research which (a) is not undertaken for
|
||||
% profit, or (b) is not intended to produce works, services, or data for commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged
|
||||
% in the commercial use, application or exploitation of works similar to the PROGRAM.
|
||||
% 5. LICENSEE agrees that it shall make the following acknowledgement in any publication resulting from the use of the PROGRAM or any translation of the code into
|
||||
% another computing language:
|
||||
% "Data processing was carried out using the cSAXS ptychography MATLAB package developed by the Science IT and the coherent X-ray scattering (CXS) groups, Paul
|
||||
% Scherrer Institut, Switzerland."
|
||||
%
|
||||
% Additionally, any publication using the package, or any translation of the code into another computing language should cite for difference map:
|
||||
% P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer, High-resolution scanning X-ray diffraction microscopy, Science 321, 379–382 (2008).
|
||||
% (doi: 10.1126/science.1158573),
|
||||
% for maximum likelihood:
|
||||
% P. Thibault and M. Guizar-Sicairos, Maximum-likelihood refinement for coherent diffractive imaging, New J. Phys. 14, 063004 (2012).
|
||||
% (doi: 10.1088/1367-2630/14/6/063004),
|
||||
% for mixed coherent modes:
|
||||
% P. Thibault and A. Menzel, Reconstructing state mixtures from diffraction measurements, Nature 494, 68–71 (2013). (doi: 10.1038/nature11806),
|
||||
% and/or for multislice:
|
||||
% E. H. R. Tsai, I. Usov, A. Diaz, A. Menzel, and M. Guizar-Sicairos, X-ray ptychography with extended depth of field, Opt. Express 24, 29089–29108 (2016).
|
||||
% (doi: 10.1364/OE.24.029089).
|
||||
% 6. Except for the above-mentioned acknowledgment, LICENSEE shall not use the PROGRAM title or the names or logos of LICENSOR, nor any adaptation thereof, nor the
|
||||
% names of any of its employees or laboratories, in any advertising, promotional or sales material without prior written consent obtained from LICENSOR in each case.
|
||||
% 7. Ownership of all rights, including copyright in the PROGRAM and in any material associated therewith, shall at all times remain with LICENSOR, and LICENSEE
|
||||
% agrees to preserve same. LICENSEE agrees not to use any portion of the PROGRAM or of any IMPROVEMENTS in any machine-readable form outside the PROGRAM, nor to
|
||||
% make any copies except for its internal use, without prior written consent of LICENSOR. LICENSEE agrees to place the following copyright notice on any such copies:
|
||||
% © All rights reserved. PAUL SCHERRER INSTITUT, Switzerland, Laboratory for Macromolecules and Bioimaging, 2017.
|
||||
% 8. The LICENSE shall not be construed to confer any rights upon LICENSEE by implication or otherwise except as specifically set forth herein.
|
||||
% 9. DISCLAIMER: LICENSEE shall be aware that Phase Focus Limited of Sheffield, UK has an international portfolio of patents and pending applications which relate
|
||||
% to ptychography and that the PROGRAM may be capable of being used in circumstances which may fall within the claims of one or more of the Phase Focus patents,
|
||||
% in particular of patent with international application number PCT/GB2005/001464. The LICENSOR explicitly declares not to indemnify the users of the software
|
||||
% in case Phase Focus or any other third party will open a legal action against the LICENSEE due to the use of the program.
|
||||
% 10. This Agreement shall be governed by the material laws of Switzerland and any dispute arising out of this Agreement or use of the PROGRAM shall be brought before
|
||||
% the courts of Zürich, Switzerland.
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
%% TEST TEMPLATE FOR FUNTIONALITY CHECK OF CPU ENGINES
|
||||
% 1) call standard template to get fresh settings defaults
|
||||
% 2) generate artificial data that should serve as a standart test "sample"
|
||||
% 3) call GPU engine with different basic functionalities and test if all still works
|
||||
% !! THESE TEST ARE ONLY USEFUL TO FIND CRASHES IN THE CODE, QUALITY OF THE RECONSTRUCTION IS NOT EVALUATED !!
|
||||
|
||||
|
||||
%% set shared parameters for all test scripts
|
||||
run(fullfile( fileparts(mfilename('fullpath')), 'init_test.m'))
|
||||
|
||||
%% general settings
|
||||
p. verbose_level = -1; % level -1 -> keep it totally quiet
|
||||
p. artificial_data_file = 'tests/test_data_low_coherence.m'; % artificial data parameters
|
||||
p. asize = [192 192]; % size of the reconstruction probe
|
||||
|
||||
% Modes
|
||||
p. probe_modes = 4; % Number of coherent modes for probe
|
||||
p. object_modes = 1; % Number of coherent modes for object
|
||||
% Mode starting guess
|
||||
p. mode_start_pow = [0.02]; % Normalized intensity on probe modes > 1. Can be a number (all higher modes equal) or a vector
|
||||
p. mode_start = 'herm'; % (for probe) = 'rand', = 'herm' (Hermitian-like base), = 'hermver' (vertical modes only), = 'hermhor' (horizontal modes only)
|
||||
p. ortho_probes = true; % orthogonalize probes after each engine
|
||||
|
||||
|
||||
%% ENGINES
|
||||
|
||||
% --------- GPU engines -------------
|
||||
if 1
|
||||
eng = struct();
|
||||
eng. name = 'GPU';
|
||||
eng. use_gpu = true; % if false, run CPU code, but it will get very slow
|
||||
eng. keep_on_gpu = true; % keep data + projections on GPU, false is useful for large data if DM is used
|
||||
eng. compress_data = true; % use automatic online memory compression to limit meed of GPU memory
|
||||
eng. gpu_id = []; % default GPU id, [] means choosen by matlab
|
||||
eng. check_gpu_load = true; % check available GPU memory before starting GPU engines
|
||||
|
||||
%% general
|
||||
eng. number_iterations = 100; % number of iterations for selected method
|
||||
eng. opt_errmetric = 'L1' ; % optimization likelihood - poisson, L1
|
||||
eng. grouping = 50; % size of processed blocks, larger blocks need more memory but they use GPU more effeciently
|
||||
% for hPIE, ePIE, MLs methods smaller blocks lead to faster convergence,
|
||||
% for pPIE, MLc the convergence is similar
|
||||
% for DM, RAAR is has no effect on convergence
|
||||
%eng. probe_modes = 1; % Number of coherent modes for probe
|
||||
eng. object_change_start = 1; % Start updating object at this iteration number
|
||||
eng. probe_change_start = 1; % Start updating probe at this iteration number
|
||||
eng.probe_support_fft = true;
|
||||
|
||||
% regularizations
|
||||
eng. reg_mu = 0; % Regularization constant ( = 0 for no regularization)
|
||||
eng. delta = 0; % press values to zero out of the illumination area, usually 1e-2 is enough
|
||||
eng. positivity_constraint_object = 0; % enforce weak positivity in object, usually 1e-2 is already enough
|
||||
|
||||
eng. apply_multimodal_update = false; % apply all incoherent modes to object, it can cause isses if the modes collect some crap
|
||||
eng. probe_backpropagate = 0; % backpropagate the probe mask, inf == farfield
|
||||
|
||||
% basic recontruction parameters
|
||||
% PIE / ML methods
|
||||
eng. beta_object = 1; % object step size, larger == faster convergence, smaller == more robust, should not exceed 1
|
||||
eng. beta_probe = 1; % probe step size, larger == faster convergence, smaller == more robust, should not exceed 1
|
||||
eng. delta_p = 0.1; % LSQ dumping constant, 0 == no preconditioner, 0.1 is usually safe,
|
||||
|
||||
% DM
|
||||
eng. pfft_relaxation = 0.1; % Relaxation in the Fourier domain projection, = 0 for full projection
|
||||
eng. probe_regularization = 0.1;% Weigth factor for the probe update (inertia)
|
||||
|
||||
|
||||
% ADVANCED OPTIONS
|
||||
% position refinement
|
||||
eng. apply_subpix_shift = false; % apply FFT-based subpixel shift, important for good position refinement but it is slow
|
||||
eng. probe_position_search = inf; % reconstruct probe positions, from iteration == probe_pos_search, assume they are independed
|
||||
eng. probe_position_error_max = 10e-9; % max expected random position error of the stages
|
||||
|
||||
% wavefront refinement
|
||||
eng. probe_fourier_shift_search = inf; % refine farfield position of the beam (ie angle) from iteration == probe_fourier_shift_search
|
||||
eng. estimate_NF_distance = inf; % try to estimate the nearfield propagation distance
|
||||
eng. variable_probe = false; % Use SVD to account for variable illumination during a single (coupled) scan
|
||||
eng. variable_SVD_modes = 3; % OPRP settings , number of SVD modes, apply only for PIE methods
|
||||
eng. variable_probe_smooth = 0; % OPRP settings , apply assumption of smooth evolution of the OPRP modes (ie slow drifts)
|
||||
eng. variable_intensity = false; % account to changes in probe intensity
|
||||
|
||||
end
|
||||
|
||||
eng_0 = eng;
|
||||
|
||||
if 1
|
||||
%% test DM solver
|
||||
eng = eng_0;
|
||||
eng. method = 'DM'; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng.grouping = 50;
|
||||
eng.probe_support_radius = 0.9;
|
||||
eng. number_iterations = 50; % number of iterations for selected method
|
||||
eng.probe_change_start = 5;
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
if 1
|
||||
%% test MLc/s codes
|
||||
eng = eng_0;
|
||||
eng. method = 'MLs'; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng.grouping = 50;
|
||||
eng.probe_support_radius = [];
|
||||
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
if 1
|
||||
%% test MLc/s codes
|
||||
eng = eng_0;
|
||||
eng. method = 'MLc'; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng.grouping = 50;
|
||||
eng.probe_support_radius = [];
|
||||
eng.accelerated_gradients_start = inf;
|
||||
eng. momentum = 0; % add momentum term to the MLc method, eng.momentum = multiplication gain for velocity
|
||||
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
run(fullfile( ptycho_path, 'tests/run_test.m'))
|
||||
|
||||
|
||||
|
||||
% Academic License Agreement
|
||||
%
|
||||
% Source Code
|
||||
%
|
||||
% Introduction
|
||||
% • This license agreement sets forth the terms and conditions under which the PAUL SCHERRER INSTITUT (PSI), CH-5232 Villigen-PSI, Switzerland (hereafter "LICENSOR")
|
||||
% will grant you (hereafter "LICENSEE") a royalty-free, non-exclusive license for academic, non-commercial purposes only (hereafter "LICENSE") to use the cSAXS
|
||||
% ptychography MATLAB package computer software program and associated documentation furnished hereunder (hereafter "PROGRAM").
|
||||
%
|
||||
% Terms and Conditions of the LICENSE
|
||||
% 1. LICENSOR grants to LICENSEE a royalty-free, non-exclusive license to use the PROGRAM for academic, non-commercial purposes, upon the terms and conditions
|
||||
% hereinafter set out and until termination of this license as set forth below.
|
||||
% 2. LICENSEE acknowledges that the PROGRAM is a research tool still in the development stage. The PROGRAM is provided without any related services, improvements
|
||||
% or warranties from LICENSOR and that the LICENSE is entered into in order to enable others to utilize the PROGRAM in their academic activities. It is the
|
||||
% LICENSEE’s responsibility to ensure its proper use and the correctness of the results.”
|
||||
% 3. THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
% A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE LICENSOR, THE AUTHORS OR THE COPYRIGHT
|
||||
% HOLDERS BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE
|
||||
% OF THE PROGRAM OR OTHER DEALINGS IN THE PROGRAM.
|
||||
% 4. LICENSEE agrees that it will use the PROGRAM and any modifications, improvements, or derivatives of PROGRAM that LICENSEE may create (collectively,
|
||||
% "IMPROVEMENTS") solely for academic, non-commercial purposes and that any copy of PROGRAM or derivatives thereof shall be distributed only under the same
|
||||
% license as PROGRAM. The terms "academic, non-commercial", as used in this Agreement, mean academic or other scholarly research which (a) is not undertaken for
|
||||
% profit, or (b) is not intended to produce works, services, or data for commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged
|
||||
% in the commercial use, application or exploitation of works similar to the PROGRAM.
|
||||
% 5. LICENSEE agrees that it shall make the following acknowledgement in any publication resulting from the use of the PROGRAM or any translation of the code into
|
||||
% another computing language:
|
||||
% "Data processing was carried out using the cSAXS ptychography MATLAB package developed by the Science IT and the coherent X-ray scattering (CXS) groups, Paul
|
||||
% Scherrer Institut, Switzerland."
|
||||
%
|
||||
% Additionally, any publication using the package, or any translation of the code into another computing language should cite for difference map:
|
||||
% P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer, High-resolution scanning X-ray diffraction microscopy, Science 321, 379–382 (2008).
|
||||
% (doi: 10.1126/science.1158573),
|
||||
% for maximum likelihood:
|
||||
% P. Thibault and M. Guizar-Sicairos, Maximum-likelihood refinement for coherent diffractive imaging, New J. Phys. 14, 063004 (2012).
|
||||
% (doi: 10.1088/1367-2630/14/6/063004),
|
||||
% for mixed coherent modes:
|
||||
% P. Thibault and A. Menzel, Reconstructing state mixtures from diffraction measurements, Nature 494, 68–71 (2013). (doi: 10.1038/nature11806),
|
||||
% and/or for multislice:
|
||||
% E. H. R. Tsai, I. Usov, A. Diaz, A. Menzel, and M. Guizar-Sicairos, X-ray ptychography with extended depth of field, Opt. Express 24, 29089–29108 (2016).
|
||||
% (doi: 10.1364/OE.24.029089).
|
||||
% 6. Except for the above-mentioned acknowledgment, LICENSEE shall not use the PROGRAM title or the names or logos of LICENSOR, nor any adaptation thereof, nor the
|
||||
% names of any of its employees or laboratories, in any advertising, promotional or sales material without prior written consent obtained from LICENSOR in each case.
|
||||
% 7. Ownership of all rights, including copyright in the PROGRAM and in any material associated therewith, shall at all times remain with LICENSOR, and LICENSEE
|
||||
% agrees to preserve same. LICENSEE agrees not to use any portion of the PROGRAM or of any IMPROVEMENTS in any machine-readable form outside the PROGRAM, nor to
|
||||
% make any copies except for its internal use, without prior written consent of LICENSOR. LICENSEE agrees to place the following copyright notice on any such copies:
|
||||
% © All rights reserved. PAUL SCHERRER INSTITUT, Switzerland, Laboratory for Macromolecules and Bioimaging, 2017.
|
||||
% 8. The LICENSE shall not be construed to confer any rights upon LICENSEE by implication or otherwise except as specifically set forth herein.
|
||||
% 9. DISCLAIMER: LICENSEE shall be aware that Phase Focus Limited of Sheffield, UK has an international portfolio of patents and pending applications which relate
|
||||
% to ptychography and that the PROGRAM may be capable of being used in circumstances which may fall within the claims of one or more of the Phase Focus patents,
|
||||
% in particular of patent with international application number PCT/GB2005/001464. The LICENSOR explicitly declares not to indemnify the users of the software
|
||||
% in case Phase Focus or any other third party will open a legal action against the LICENSEE due to the use of the program.
|
||||
% 10. This Agreement shall be governed by the material laws of Switzerland and any dispute arising out of this Agreement or use of the PROGRAM shall be brought before
|
||||
% the courts of Zürich, Switzerland.
|
||||
@@ -0,0 +1,163 @@
|
||||
%% TEST TEMPLATE FOR FUNTIONALITY CHECK IN GPU ENGINES
|
||||
% 1) call standard template to get fresh settings defaults
|
||||
% 2) generate artificial data that should serve as a standart test "sample"
|
||||
% 3) call GPU engine with different basic functionalities and test if all still works
|
||||
% !! THESE TEST ARE ONLY USEFUL TO FIND CRASHES IN THE CODE, QUALITY OF THE RECONSTRUCTION IS NOT EVALUATED !!
|
||||
|
||||
%% set shared parameters for all test scripts
|
||||
run(fullfile( fileparts(mfilename('fullpath')), 'init_test.m'))
|
||||
|
||||
plot_results = true;
|
||||
|
||||
%% general settings
|
||||
p. artificial_data_file = 'tests/test_data_mirror_objects.m'; % artificial data parameters
|
||||
p. asize = [256 256]; % size of the reconstruction probe
|
||||
|
||||
p. scan.lx = 10e-6; % round_roi scan: width of the roi
|
||||
p. scan.ly = 10e-6;
|
||||
p. preserve_previous_results = true; % do not reset p-struct after the first reconstruction
|
||||
|
||||
|
||||
%% ENGINES
|
||||
% External C++ code
|
||||
|
||||
% --------- GPU engines -------------
|
||||
if 1
|
||||
eng = struct();
|
||||
eng. name = 'GPU';
|
||||
eng. use_gpu = true; % if false, run CPU code, but it will get very slow
|
||||
eng. keep_on_gpu = true; % keep data + projections on GPU, false is useful for large data if DM is used
|
||||
eng. compress_data = true; % use automatic online memory compression to limit meed of GPU memory
|
||||
eng. gpu_id = []; % default GPU id, [] means choosen by matlab
|
||||
eng. check_gpu_load = true; % check available GPU memory before starting GPU engines
|
||||
|
||||
%% general
|
||||
eng. number_iterations = 20; % number of iterations for selected method
|
||||
%eng. share_probe = 1; % Share probe between scans. Can be either a number/boolean or a list of numbers, specifying the probe index; e.g. [1 2 2] to share the probes between the second and third scan.
|
||||
%eng. share_object = 0; % Share object between scans. Can be either a number/boolean or a list of numbers, specifying the object index; e.g. [1 2 2] to share the objects between the second and third scan.
|
||||
eng. method = 'MLs'; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng. opt_errmetric = 'L1' ; % optimization likelihood - poisson, L1
|
||||
eng. grouping = 50; % size of processed blocks, larger blocks need more memory but they use GPU more effeciently
|
||||
% for hPIE, ePIE, MLs methods smaller blocks lead to faster convergence,
|
||||
% for pPIE, MLc the convergence is similar
|
||||
% for DM, RAAR is has no effect on convergence
|
||||
%eng. probe_modes = 1; % Number of coherent modes for probe
|
||||
eng. object_change_start = 1; % Start updating object at this iteration number
|
||||
eng. probe_change_start = 1; % Start updating probe at this iteration number
|
||||
eng.probe_support_fft = false;
|
||||
|
||||
% regularizations
|
||||
eng. reg_mu = 0; % Regularization constant ( = 0 for no regularization)
|
||||
eng. delta = 0; % press values to zero out of the illumination area, usually 1e-2 is enough
|
||||
eng. positivity_constraint_object = 0; % enforce weak positivity in object, usually 1e-2 is already enough
|
||||
|
||||
eng. apply_multimodal_update = false; % apply all incoherent modes to object, it can cause isses if the modes collect some crap
|
||||
eng. probe_backpropagate = 0; % backpropagate the probe mask, inf == farfield
|
||||
|
||||
% basic recontruction parameters
|
||||
% PIE / ML methods
|
||||
eng. beta_object = 1; % object step size, larger == faster convergence, smaller == more robust, should not exceed 1
|
||||
eng. beta_probe = 1; % probe step size, larger == faster convergence, smaller == more robust, should not exceed 1
|
||||
eng. delta_p = 0.1; % LSQ dumping constant, 0 == no preconditioner, 0.1 is usually safe,
|
||||
% DM
|
||||
eng. pfft_relaxation = 0.1; % Relaxation in the Fourier domain projection, = 0 for full projection
|
||||
eng. probe_regularization = 0.1;% Weigth factor for the probe update (inertia)
|
||||
|
||||
|
||||
% ADVANCED OPTIONS
|
||||
% position refinement
|
||||
eng. apply_subpix_shift = false; % apply FFT-based subpixel shift, important for good position refinement but it is slow
|
||||
eng. probe_position_search = inf; % reconstruct probe positions, from iteration == probe_pos_search, assume they are independed
|
||||
eng. probe_position_error_max = 10e-9; % max expected random position error of the stages
|
||||
|
||||
% wavefront refinement
|
||||
eng. probe_fourier_shift_search = inf; % refine farfield position of the beam (ie angle) from iteration == probe_fourier_shift_search
|
||||
eng. estimate_NF_distance = inf; % try to estimate the nearfield propagation distance
|
||||
eng. variable_probe = false; % Use SVD to account for variable illumination during a single (coupled) scan
|
||||
eng. variable_SVD_modes = 3; % OPRP settings , number of SVD modes, apply only for PIE methods
|
||||
eng. variable_probe_smooth = 0; % OPRP settings , apply assumption of smooth evolution of the OPRP modes (ie slow drifts)
|
||||
eng. variable_intensity = false; % account to changes in probe intensity
|
||||
|
||||
|
||||
|
||||
%% test MLc/s codes
|
||||
eng. method = 'MLs'; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng.grouping = 50;
|
||||
eng.probe_support_radius = [];
|
||||
eng.number_iterations = 50;
|
||||
eng.accelerated_gradients_start = inf;
|
||||
|
||||
eng.mirror_objects = false;
|
||||
eng.share_object = false;
|
||||
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
|
||||
eng.number_iterations = 50;
|
||||
|
||||
eng.mirror_objects = true;
|
||||
eng.share_object = true;
|
||||
eng.share_probe = false;
|
||||
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
run(fullfile( fileparts(mfilename('fullpath')), 'run_test.m'))
|
||||
|
||||
|
||||
% Academic License Agreement
|
||||
%
|
||||
% Source Code
|
||||
%
|
||||
% Introduction
|
||||
% • This license agreement sets forth the terms and conditions under which the PAUL SCHERRER INSTITUT (PSI), CH-5232 Villigen-PSI, Switzerland (hereafter "LICENSOR")
|
||||
% will grant you (hereafter "LICENSEE") a royalty-free, non-exclusive license for academic, non-commercial purposes only (hereafter "LICENSE") to use the cSAXS
|
||||
% ptychography MATLAB package computer software program and associated documentation furnished hereunder (hereafter "PROGRAM").
|
||||
%
|
||||
% Terms and Conditions of the LICENSE
|
||||
% 1. LICENSOR grants to LICENSEE a royalty-free, non-exclusive license to use the PROGRAM for academic, non-commercial purposes, upon the terms and conditions
|
||||
% hereinafter set out and until termination of this license as set forth below.
|
||||
% 2. LICENSEE acknowledges that the PROGRAM is a research tool still in the development stage. The PROGRAM is provided without any related services, improvements
|
||||
% or warranties from LICENSOR and that the LICENSE is entered into in order to enable others to utilize the PROGRAM in their academic activities. It is the
|
||||
% LICENSEE’s responsibility to ensure its proper use and the correctness of the results.”
|
||||
% 3. THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
% A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE LICENSOR, THE AUTHORS OR THE COPYRIGHT
|
||||
% HOLDERS BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE
|
||||
% OF THE PROGRAM OR OTHER DEALINGS IN THE PROGRAM.
|
||||
% 4. LICENSEE agrees that it will use the PROGRAM and any modifications, improvements, or derivatives of PROGRAM that LICENSEE may create (collectively,
|
||||
% "IMPROVEMENTS") solely for academic, non-commercial purposes and that any copy of PROGRAM or derivatives thereof shall be distributed only under the same
|
||||
% license as PROGRAM. The terms "academic, non-commercial", as used in this Agreement, mean academic or other scholarly research which (a) is not undertaken for
|
||||
% profit, or (b) is not intended to produce works, services, or data for commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged
|
||||
% in the commercial use, application or exploitation of works similar to the PROGRAM.
|
||||
% 5. LICENSEE agrees that it shall make the following acknowledgement in any publication resulting from the use of the PROGRAM or any translation of the code into
|
||||
% another computing language:
|
||||
% "Data processing was carried out using the cSAXS ptychography MATLAB package developed by the Science IT and the coherent X-ray scattering (CXS) groups, Paul
|
||||
% Scherrer Institut, Switzerland."
|
||||
%
|
||||
% Additionally, any publication using the package, or any translation of the code into another computing language should cite for difference map:
|
||||
% P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer, High-resolution scanning X-ray diffraction microscopy, Science 321, 379–382 (2008).
|
||||
% (doi: 10.1126/science.1158573),
|
||||
% for maximum likelihood:
|
||||
% P. Thibault and M. Guizar-Sicairos, Maximum-likelihood refinement for coherent diffractive imaging, New J. Phys. 14, 063004 (2012).
|
||||
% (doi: 10.1088/1367-2630/14/6/063004),
|
||||
% for mixed coherent modes:
|
||||
% P. Thibault and A. Menzel, Reconstructing state mixtures from diffraction measurements, Nature 494, 68–71 (2013). (doi: 10.1038/nature11806),
|
||||
% and/or for multislice:
|
||||
% E. H. R. Tsai, I. Usov, A. Diaz, A. Menzel, and M. Guizar-Sicairos, X-ray ptychography with extended depth of field, Opt. Express 24, 29089–29108 (2016).
|
||||
% (doi: 10.1364/OE.24.029089).
|
||||
% 6. Except for the above-mentioned acknowledgment, LICENSEE shall not use the PROGRAM title or the names or logos of LICENSOR, nor any adaptation thereof, nor the
|
||||
% names of any of its employees or laboratories, in any advertising, promotional or sales material without prior written consent obtained from LICENSOR in each case.
|
||||
% 7. Ownership of all rights, including copyright in the PROGRAM and in any material associated therewith, shall at all times remain with LICENSOR, and LICENSEE
|
||||
% agrees to preserve same. LICENSEE agrees not to use any portion of the PROGRAM or of any IMPROVEMENTS in any machine-readable form outside the PROGRAM, nor to
|
||||
% make any copies except for its internal use, without prior written consent of LICENSOR. LICENSEE agrees to place the following copyright notice on any such copies:
|
||||
% © All rights reserved. PAUL SCHERRER INSTITUT, Switzerland, Laboratory for Macromolecules and Bioimaging, 2017.
|
||||
% 8. The LICENSE shall not be construed to confer any rights upon LICENSEE by implication or otherwise except as specifically set forth herein.
|
||||
% 9. DISCLAIMER: LICENSEE shall be aware that Phase Focus Limited of Sheffield, UK has an international portfolio of patents and pending applications which relate
|
||||
% to ptychography and that the PROGRAM may be capable of being used in circumstances which may fall within the claims of one or more of the Phase Focus patents,
|
||||
% in particular of patent with international application number PCT/GB2005/001464. The LICENSOR explicitly declares not to indemnify the users of the software
|
||||
% in case Phase Focus or any other third party will open a legal action against the LICENSEE due to the use of the program.
|
||||
% 10. This Agreement shall be governed by the material laws of Switzerland and any dispute arising out of this Agreement or use of the PROGRAM shall be brought before
|
||||
% the courts of Zürich, Switzerland.
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
%% TEST TEMPLATE FOR FUNTIONALITY CHECK IN GPU ENGINES
|
||||
% 1) call standard template to get fresh settings defaults
|
||||
% 2) generate artificial data that should serve as a standart test "sample"
|
||||
% 3) call GPU engine with different basic functionalities and test if all still works
|
||||
% !! THESE TEST ARE ONLY USEFUL TO FIND CRASHES IN THE CODE, QUALITY OF THE RECONSTRUCTION IS NOT EVALUATED !!
|
||||
|
||||
%% set shared parameters for all test scripts
|
||||
run(fullfile( fileparts(mfilename('fullpath')), 'init_test.m'))
|
||||
|
||||
plot_results = true;
|
||||
|
||||
%% general settings
|
||||
p. artificial_data_file = 'tests/test_data_shifted_objects.m'; % artificial data parameters
|
||||
p. asize = [128 128]; % size of the reconstruction probe
|
||||
|
||||
p. scan.lx = 10e-6; % round_roi scan: width of the roi
|
||||
p. scan.ly = 10e-6;
|
||||
p. preserve_previous_results = true; % do not reset p-struct after the first reconstruction
|
||||
|
||||
|
||||
%% ENGINES
|
||||
% External C++ code
|
||||
|
||||
% --------- GPU engines -------------
|
||||
if 1
|
||||
eng = struct();
|
||||
eng. name = 'GPU';
|
||||
eng. use_gpu = true; % if false, run CPU code, but it will get very slow
|
||||
eng. keep_on_gpu = true; % keep data + projections on GPU, false is useful for large data if DM is used
|
||||
eng. compress_data = true; % use automatic online memory compression to limit meed of GPU memory
|
||||
eng. gpu_id = []; % default GPU id, [] means choosen by matlab
|
||||
eng. check_gpu_load = true; % check available GPU memory before starting GPU engines
|
||||
|
||||
%% general
|
||||
eng. number_iterations = 20; % number of iterations for selected method
|
||||
%eng. share_probe = 1; % Share probe between scans. Can be either a number/boolean or a list of numbers, specifying the probe index; e.g. [1 2 2] to share the probes between the second and third scan.
|
||||
%eng. share_object = 0; % Share object between scans. Can be either a number/boolean or a list of numbers, specifying the object index; e.g. [1 2 2] to share the objects between the second and third scan.
|
||||
eng. method = 'MLs'; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng. opt_errmetric = 'L1' ; % optimization likelihood - poisson, L1
|
||||
eng. grouping = 50; % size of processed blocks, larger blocks need more memory but they use GPU more effeciently
|
||||
% for hPIE, ePIE, MLs methods smaller blocks lead to faster convergence,
|
||||
% for pPIE, MLc the convergence is similar
|
||||
% for DM, RAAR is has no effect on convergence
|
||||
%eng. probe_modes = 1; % Number of coherent modes for probe
|
||||
eng. object_change_start = 1; % Start updating object at this iteration number
|
||||
eng. probe_change_start = 1; % Start updating probe at this iteration number
|
||||
eng.probe_support_fft = false;
|
||||
|
||||
% regularizations
|
||||
eng. reg_mu = 0; % Regularization constant ( = 0 for no regularization)
|
||||
eng. delta = 0; % press values to zero out of the illumination area, usually 1e-2 is enough
|
||||
eng. positivity_constraint_object = 0; % enforce weak positivity in object, usually 1e-2 is already enough
|
||||
|
||||
eng. apply_multimodal_update = false; % apply all incoherent modes to object, it can cause isses if the modes collect some crap
|
||||
eng. probe_backpropagate = 0; % backpropagate the probe mask, inf == farfield
|
||||
|
||||
% basic recontruction parameters
|
||||
% PIE / ML methods
|
||||
eng. beta_object = 1; % object step size, larger == faster convergence, smaller == more robust, should not exceed 1
|
||||
eng. beta_probe = 1; % probe step size, larger == faster convergence, smaller == more robust, should not exceed 1
|
||||
eng. delta_p = 0.1; % LSQ dumping constant, 0 == no preconditioner, 0.1 is usually safe,
|
||||
% DM
|
||||
eng. pfft_relaxation = 0.1; % Relaxation in the Fourier domain projection, = 0 for full projection
|
||||
eng. probe_regularization = 0.1;% Weigth factor for the probe update (inertia)
|
||||
|
||||
|
||||
% ADVANCED OPTIONS
|
||||
% position refinement
|
||||
eng. apply_subpix_shift = false; % apply FFT-based subpixel shift, important for good position refinement but it is slow
|
||||
eng. probe_position_search = inf; % reconstruct probe positions, from iteration == probe_pos_search, assume they are independed
|
||||
eng. probe_position_error_max = 10e-9; % max expected random position error of the stages
|
||||
|
||||
% wavefront refinement
|
||||
eng. probe_fourier_shift_search = inf; % refine farfield position of the beam (ie angle) from iteration == probe_fourier_shift_search
|
||||
eng. estimate_NF_distance = inf; % try to estimate the nearfield propagation distance
|
||||
eng. variable_probe = false; % Use SVD to account for variable illumination during a single (coupled) scan
|
||||
eng. variable_SVD_modes = 3; % OPRP settings , number of SVD modes, apply only for PIE methods
|
||||
eng. variable_probe_smooth = 0; % OPRP settings , apply assumption of smooth evolution of the OPRP modes (ie slow drifts)
|
||||
eng. variable_intensity = false; % account to changes in probe intensity
|
||||
|
||||
|
||||
|
||||
%% test MLc/s codes
|
||||
eng. method = 'MLs'; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng.grouping = 50;
|
||||
eng.probe_support_radius = [];
|
||||
eng.number_iterations = 50;
|
||||
eng.accelerated_gradients_start = inf;
|
||||
|
||||
eng.mirror_objects = false;
|
||||
eng.share_object = false;
|
||||
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
|
||||
eng.number_iterations = 50;
|
||||
|
||||
eng.share_object = true;
|
||||
eng.share_probe = false;
|
||||
eng. align_shared_objects = true; % before merging multiple unshared objects into one shared, the object will be aligned and the probes shifted by the same distance -> use for alignement and shared reconstruction of drifting scans
|
||||
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
run(fullfile( fileparts(mfilename('fullpath')), 'run_test.m'))
|
||||
|
||||
|
||||
% Academic License Agreement
|
||||
%
|
||||
% Source Code
|
||||
%
|
||||
% Introduction
|
||||
% • This license agreement sets forth the terms and conditions under which the PAUL SCHERRER INSTITUT (PSI), CH-5232 Villigen-PSI, Switzerland (hereafter "LICENSOR")
|
||||
% will grant you (hereafter "LICENSEE") a royalty-free, non-exclusive license for academic, non-commercial purposes only (hereafter "LICENSE") to use the cSAXS
|
||||
% ptychography MATLAB package computer software program and associated documentation furnished hereunder (hereafter "PROGRAM").
|
||||
%
|
||||
% Terms and Conditions of the LICENSE
|
||||
% 1. LICENSOR grants to LICENSEE a royalty-free, non-exclusive license to use the PROGRAM for academic, non-commercial purposes, upon the terms and conditions
|
||||
% hereinafter set out and until termination of this license as set forth below.
|
||||
% 2. LICENSEE acknowledges that the PROGRAM is a research tool still in the development stage. The PROGRAM is provided without any related services, improvements
|
||||
% or warranties from LICENSOR and that the LICENSE is entered into in order to enable others to utilize the PROGRAM in their academic activities. It is the
|
||||
% LICENSEE’s responsibility to ensure its proper use and the correctness of the results.”
|
||||
% 3. THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
% A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE LICENSOR, THE AUTHORS OR THE COPYRIGHT
|
||||
% HOLDERS BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE
|
||||
% OF THE PROGRAM OR OTHER DEALINGS IN THE PROGRAM.
|
||||
% 4. LICENSEE agrees that it will use the PROGRAM and any modifications, improvements, or derivatives of PROGRAM that LICENSEE may create (collectively,
|
||||
% "IMPROVEMENTS") solely for academic, non-commercial purposes and that any copy of PROGRAM or derivatives thereof shall be distributed only under the same
|
||||
% license as PROGRAM. The terms "academic, non-commercial", as used in this Agreement, mean academic or other scholarly research which (a) is not undertaken for
|
||||
% profit, or (b) is not intended to produce works, services, or data for commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged
|
||||
% in the commercial use, application or exploitation of works similar to the PROGRAM.
|
||||
% 5. LICENSEE agrees that it shall make the following acknowledgement in any publication resulting from the use of the PROGRAM or any translation of the code into
|
||||
% another computing language:
|
||||
% "Data processing was carried out using the cSAXS ptychography MATLAB package developed by the Science IT and the coherent X-ray scattering (CXS) groups, Paul
|
||||
% Scherrer Institut, Switzerland."
|
||||
%
|
||||
% Additionally, any publication using the package, or any translation of the code into another computing language should cite for difference map:
|
||||
% P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer, High-resolution scanning X-ray diffraction microscopy, Science 321, 379–382 (2008).
|
||||
% (doi: 10.1126/science.1158573),
|
||||
% for maximum likelihood:
|
||||
% P. Thibault and M. Guizar-Sicairos, Maximum-likelihood refinement for coherent diffractive imaging, New J. Phys. 14, 063004 (2012).
|
||||
% (doi: 10.1088/1367-2630/14/6/063004),
|
||||
% for mixed coherent modes:
|
||||
% P. Thibault and A. Menzel, Reconstructing state mixtures from diffraction measurements, Nature 494, 68–71 (2013). (doi: 10.1038/nature11806),
|
||||
% and/or for multislice:
|
||||
% E. H. R. Tsai, I. Usov, A. Diaz, A. Menzel, and M. Guizar-Sicairos, X-ray ptychography with extended depth of field, Opt. Express 24, 29089–29108 (2016).
|
||||
% (doi: 10.1364/OE.24.029089).
|
||||
% 6. Except for the above-mentioned acknowledgment, LICENSEE shall not use the PROGRAM title or the names or logos of LICENSOR, nor any adaptation thereof, nor the
|
||||
% names of any of its employees or laboratories, in any advertising, promotional or sales material without prior written consent obtained from LICENSOR in each case.
|
||||
% 7. Ownership of all rights, including copyright in the PROGRAM and in any material associated therewith, shall at all times remain with LICENSOR, and LICENSEE
|
||||
% agrees to preserve same. LICENSEE agrees not to use any portion of the PROGRAM or of any IMPROVEMENTS in any machine-readable form outside the PROGRAM, nor to
|
||||
% make any copies except for its internal use, without prior written consent of LICENSOR. LICENSEE agrees to place the following copyright notice on any such copies:
|
||||
% © All rights reserved. PAUL SCHERRER INSTITUT, Switzerland, Laboratory for Macromolecules and Bioimaging, 2017.
|
||||
% 8. The LICENSE shall not be construed to confer any rights upon LICENSEE by implication or otherwise except as specifically set forth herein.
|
||||
% 9. DISCLAIMER: LICENSEE shall be aware that Phase Focus Limited of Sheffield, UK has an international portfolio of patents and pending applications which relate
|
||||
% to ptychography and that the PROGRAM may be capable of being used in circumstances which may fall within the claims of one or more of the Phase Focus patents,
|
||||
% in particular of patent with international application number PCT/GB2005/001464. The LICENSOR explicitly declares not to indemnify the users of the software
|
||||
% in case Phase Focus or any other third party will open a legal action against the LICENSEE due to the use of the program.
|
||||
% 10. This Agreement shall be governed by the material laws of Switzerland and any dispute arising out of this Agreement or use of the PROGRAM shall be brought before
|
||||
% the courts of Zürich, Switzerland.
|
||||
|
||||
@@ -0,0 +1,687 @@
|
||||
%% TEST TEMPLATE FOR FUNTIONALITY CHECK OF MULTILAYER EXTENSION IN GPU ENGINES
|
||||
% 1) call standard template to get fresh settings defaults
|
||||
% 2) generate artificial data that should serve as a standart test "sample"
|
||||
% 3) call GPU engine with different basic functionalities and test if all still works
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%%%%%%%%%%%%% IDEA BEHIND THE ITERATIVE PTYCHO TOMOGRAPHY %%%%%%%%%%%%%%%%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Why is it useful ?
|
||||
% ==================
|
||||
% 1) resolution improvement for ideal noise-limited datasets
|
||||
% Ptychotomography is gaining information from overlap of the projection in
|
||||
% the 3D Fourier space of the sample volume. So theoretically, the provided
|
||||
% constrait s better than for simple 2D overlap in ptychography.
|
||||
% But if the collected anglular sampling is following the Crowther criterion,
|
||||
% there is no overlap between the projection for the highest spatial
|
||||
% frequencies !!!
|
||||
%
|
||||
% Conclusion: Iterative ptychotomo should not improve resolution for ideal
|
||||
% noise-limited datasets. It can theoretically improve SNR for the middle
|
||||
% and low spatial frequencies, but since the error in the low spatial
|
||||
% frequencies provided by ptychography is anyway rather limited by
|
||||
% systematic errors, there is not much to expect.
|
||||
%
|
||||
% 2) position refinement
|
||||
% =======================
|
||||
% Position errors in the projection, e.g. from drifts, will result in
|
||||
% errors that are effecting also lower spatial frequencies. Conventional
|
||||
% ptychography can refine the positions and geometry errors, but it is very
|
||||
% slow and not too reliable. Much better is to use information from
|
||||
% neighbouring projections or 180 deg mirrored projections
|
||||
%
|
||||
% Conclusion:
|
||||
% Iterative ptychotomo should help with position refinement and improve
|
||||
% reconstrution of samples, where this could be limitting, e.g. large catalyst
|
||||
% particles.
|
||||
%
|
||||
% 3) extended depth of focus
|
||||
% ===========================
|
||||
% Extended depth of focus can be achieve via ptychography but
|
||||
% reconstruction of N layers is opening N-times more degrees of freedom
|
||||
% that reconstruction of single layer. This means that eDOF ptychography
|
||||
% requires much more signal (imaging dose) than conventional ptychography
|
||||
% But the final tomography has still the same number of voxels -> if we search
|
||||
% for the voxel values in the tomogram instead of the projections, there
|
||||
% should be no loss in the signal to noise ratio -> resolution identical to
|
||||
% the single layer ptychography can be reached.
|
||||
% Additionally, if the illumination angle (NA) or the collected NA is larger than
|
||||
% the tomographic angular sampling angle according to the Crowther criterion
|
||||
% It is possible to reconstruct angularly undersampled tomogram and fill
|
||||
% the gaps by information provided by multilayer ptychography.
|
||||
% Of course, the total imaging dose has to be preserved, so the
|
||||
% ptychography scanning step or exposure would have to be increased
|
||||
%
|
||||
% Conclusion: eDOF ptychography can benefit from the iterative
|
||||
% ptycho-tomography
|
||||
%
|
||||
% ================
|
||||
% Implementation
|
||||
% ================
|
||||
% 1) diffraction from a 3D phantom are created using ptychography code,
|
||||
% using the simulated sample thickness and other parameters
|
||||
% 2) Provide initial 2D reconstructions -> use the fact that computing
|
||||
% initial guess is cheap -> use conventional ptychtomography as initial
|
||||
% guess before any iterative ptycho-tomo is started
|
||||
% Also and maybe even more importantly, the real measured projections have
|
||||
% to be aligned first
|
||||
% 3) Start to refine the initial guess using the ptycho projections
|
||||
%
|
||||
% P0_i = model complex-valued projection at angle 'i'
|
||||
% P0c_i = model log complex projection, ie P0 = exp(POc)
|
||||
% P_i = projection after ptychography update
|
||||
% Pc_i = log complex projection after ptychography update
|
||||
% Vol = 3D tomographic volume
|
||||
% step = step size in the gradient descent method
|
||||
%
|
||||
% Pseudo code for the iterative ptycho tomo
|
||||
% ==========================================
|
||||
% for i = 1:Nangles
|
||||
% Vol_rot = rotate(Vol, theta(i))
|
||||
% P0c_i = sum(Vol_rot) % only in case of single layer, see fwd_proj.m
|
||||
% P0 = exp(P0c_i) % see prepare_distributed_data.m
|
||||
% P_i = ptychography(P0_i) % see ptycho_solver_distributed.m
|
||||
% Pc_i = log(Pc_i) % see prepare_projections.m , note that log is calculated from complex number -> some unwrapping is needed
|
||||
% Vol_upd = repmat(P_i - P_0, N) % only in case of single layer ptycho, see back_proj.m
|
||||
% Vol = Vol + step * rotate(Vol_upd, -theta(i)) % see update_volume.m
|
||||
% end
|
||||
%
|
||||
% In case of multilayer, the sum and repmat are replace the centered
|
||||
% Fourier interpolation. This allows to optimally up/down sample the
|
||||
% information from different sample layers into a few ptychography layers
|
||||
% Therefore, there is no need of propagation between all layers (ie. size(volData,1))
|
||||
% of the sample.
|
||||
%
|
||||
%
|
||||
% Important notes:
|
||||
% a) ptychography should run only single iteration and return results back
|
||||
% to tomography. But the overhead would be huge -> running a few iterations
|
||||
% is better deal. But too many iteration will lead to deterioration of the
|
||||
% achievable quality
|
||||
%
|
||||
% b) the volume is kept complex values but logarithmized, ie. projection
|
||||
% through the volume is exp(sum(volume)) or prod(exp(volume))
|
||||
% This is critical for rotation of the volume where some interpolation needs
|
||||
% to be used, for example bilinear interpolation. Without the logarithmized
|
||||
% values, only nearest neighbours interpolation would be valid
|
||||
%
|
||||
% c) Convergence of the gradient descent scheme is slow. Best results are
|
||||
% achieved when just a small groups of close to orthogonal angles are applied
|
||||
% in parallel like the SART tomo method. Applying all in parallel like SIRT
|
||||
% would be too slow.
|
||||
% In order to further accelerate the convergence, Nesterov acceleration method
|
||||
% is applied in each iteration to update the tomography volume
|
||||
%
|
||||
% d) major issues are GPU memory limitations. Ptychotomography needs to keep
|
||||
% entire tomographic volume in memory, otherwise the data transfer overhead
|
||||
% would significanlty reduce the performance. This limits the maximal size of
|
||||
% the volume and some compression schemes, ie store the volume in uint8 or uint16
|
||||
% will be required for datasets large than ~10GB
|
||||
%
|
||||
% e) ptychography solvers needs to run asynchronously and in parallel with the
|
||||
% tomography solver for maximal performance. Also they have to run on different
|
||||
% GPUs to avoid memory collisions. This asynchronity introduces some noise into the
|
||||
% reconstruction convergence, so the size of the blocks should be kept small.
|
||||
% On the other hand, larger groups uses the resources more efficient.
|
||||
%
|
||||
%
|
||||
|
||||
|
||||
|
||||
%% set shared parameters for all test scripts
|
||||
cd(fullfile(fileparts(mfilename('fullpath')), '../'))
|
||||
|
||||
|
||||
addpath('./')
|
||||
addpath(core.find_base_package)
|
||||
addpath('./utils')
|
||||
addpath('../cSAXS_matlab_tomo/')
|
||||
addpath('../cSAXS_matlab_tomo/utils/')
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%%%% user settings %%%%%%%%%%%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
undersampling = 4;
|
||||
Nangles = ceil(300*pi/2 / max(1,undersampling)); % number tomo angles
|
||||
asize = [192 192];
|
||||
base_path = '../';
|
||||
GPU_id = 1;
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
if undersampling > 1
|
||||
warning('Tomogram may be angularly undersampled')
|
||||
end
|
||||
|
||||
%% run common template for initalization
|
||||
ptycho_path = fileparts(mfilename('fullpath'));
|
||||
ptycho_path = replace(ptycho_path, 'tests', '');
|
||||
run(fullfile( ptycho_path, 'template_ptycho.m'))
|
||||
if ~exist('temporal_data_path', 'var'); temporal_data_path = './temp/'; end
|
||||
gpuDevice(GPU_id);
|
||||
utils.verbose(0)
|
||||
utils.verbose(struct('prefix', 'ptychotomo'))
|
||||
utils.report_GPU_usage()
|
||||
|
||||
%% general settings
|
||||
p = rmfield(p, 'engines');
|
||||
p. scan_number = [];
|
||||
p. asize = asize;
|
||||
p. verbose_level = 2;
|
||||
p. src_metadata = 'artificial'; % load meta data from file; currently only 'spec' is supported;
|
||||
p. artificial_data_file = 'tests/test_ML3D_data.m'; % artificial data parameters
|
||||
p. data_prep = 'matlab'; % data preparator; 'python' or 'matlab'
|
||||
p. base_path = base_path;
|
||||
p. gpu_id = GPU_id;
|
||||
%% plotting
|
||||
p. save.external = false; % Use a new Matlab session to run save final figures (saves ~6s per reconstruction). Please be aware that this might lead to an accumulation of Matlab sessions if your single reconstruction is very fast.
|
||||
p. plot.prepared_data = false; % plot prepared data
|
||||
p. save.store_images = 1; % Write nice jpegs in [p.base_path,'analysis/online/ptycho/'] if p.use_display = 0 then the figures are opened invisible in order to create the nice layout. It writes images in analysis/online/ptycho
|
||||
p. plot.fov_box = 1; % Plot the scanning FOV box on the object (both phase and amplitude)
|
||||
p. plot.log_scal = [1 1]; % Plot on log scale for x and y
|
||||
p. plot.positions = 1; % Plot the scanning positions
|
||||
p. plot.interval = 50;
|
||||
|
||||
p. io.data_compression = 0; % file compression for HDF5 files; 0 for no compression
|
||||
p. io.file_compression = 0; % file compression for HDF5 files; 0 for no compression
|
||||
|
||||
|
||||
%% SHARE MULTIPLE OBJECTS
|
||||
p. share_object = 0; % Share object between scans. Can be either a number/boolean or a list of numbers, specifying the object index; e.g. [1 2 2] to share the objects between the second and third scan.
|
||||
|
||||
|
||||
run(fullfile( ptycho_path,p.artificial_data_file))
|
||||
|
||||
|
||||
%% io
|
||||
p. ptycho_matlab_path = ''; % cSAXS ptycho package path
|
||||
p. cSAXS_matlab_path = fullfile(ptycho_path, '../cSAXS_matlab_base'); % cSAXS package path
|
||||
p. prepare_data_path = temporal_data_path;
|
||||
p. use_display = false;
|
||||
|
||||
|
||||
%% ENGINES
|
||||
% --------- GPU engines -------------
|
||||
|
||||
eng = struct();
|
||||
eng. name = 'GPU';
|
||||
eng. use_gpu = true; % if false, run CPU code, but it will get very slow
|
||||
eng. keep_on_gpu = true; % keep data + projections on GPU, false is useful for large data if DM is used
|
||||
eng. compress_data = true; % use automatic online memory compression to limit meed of GPU memory
|
||||
eng. gpu_id = []; % default GPU id, [] means choosen by matlab
|
||||
eng. check_gpu_load = true; % check available GPU memory before starting GPU engines
|
||||
|
||||
%% general
|
||||
eng. number_iterations = 100; % number of iterations for selected method
|
||||
eng. downscale = 1; % Ntimes downsize data to make low res. fast guess, similar to presolver engine
|
||||
%eng. share_probe = 1; % Share probe between scans. Can be either a number/boolean or a list of numbers, specifying the probe index; e.g. [1 2 2] to share the probes between the second and third scan.
|
||||
eng. method = 'MLs'; % choose GPU solver: DM, RAAR, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng. opt_errmetric = 'L1' ; % optimization likelihood - poisson, L1
|
||||
eng. grouping = 200; % size of processed blocks, larger blocks need more memory but they use GPU more effeciently
|
||||
% for hPIE, ePIE, MLs methods smaller blocks lead to faster convergence,
|
||||
% for pPIE, MLc the convergence is similar
|
||||
% for DM, RAAR is has no effect on convergence
|
||||
%eng. probe_modes = 1; % Number of coherent modes for probe
|
||||
eng. object_change_start = 1; % Start updating object at this iteration number
|
||||
eng. probe_change_start = inf; % Start updating probe at this iteration number
|
||||
|
||||
|
||||
% regularizations
|
||||
eng. reg_mu = 0; % Regularization constant ( = 0 for no regularization)
|
||||
eng. background = 1e-3;
|
||||
eng. delta = 0; % press values to zero out of the illumination area, usually 1e-2 is enough
|
||||
eng. positivity_constraint_object = 0; % enforce weak positivity in object, usually 1e-2 is already enough
|
||||
eng. regularize_layers = 0.01; % 0<R<<1 -> apply regularization on the reconstructed object layers, 0 == no regularization
|
||||
|
||||
eng. apply_multimodal_update = false; % apply all incoherent modes to object, it can cause isses if the modes collect some crap
|
||||
eng. probe_backpropagate = 0; % backpropagate the probe mask, inf == farfield
|
||||
|
||||
% basic recontruction parameters
|
||||
% PIE / ML methods
|
||||
eng. beta_object = 1; % object step size, larger == faster convergence, smaller == more robust, should not exceed 1
|
||||
eng. beta_probe = 1; % probe step size, larger == faster convergence, smaller == more robust, should not exceed 1
|
||||
eng. delta_p = 0.1; % LSQ dumping constant, 0 == no preconditioner, 0.1 is usually safe,
|
||||
% DM
|
||||
eng. pfft_relaxation = 0.1; % Relaxation in the Fourier domain projection, = 0 for full projection
|
||||
eng. probe_regularization = 0.1;% Weigth factor for the probe update (inertia)
|
||||
|
||||
|
||||
% ADVANCED OPTIONS
|
||||
% position refinement
|
||||
eng. apply_subpix_shift = false; % apply FFT-based subpixel shift, important for good position refinement but it is slow
|
||||
eng. probe_pos_search = inf; % reconstruct probe positions, from iteration == probe_pos_search, assume they are independed
|
||||
eng. probe_geometry_search = inf; % reconstruct probe positions, from iteration == probe_geometry_search, assume they have to match geometry model with error less than probe_position_error_max
|
||||
eng. probe_position_error_max = 10e-9; % max expected random position error of the stages
|
||||
|
||||
% wavefront refinement
|
||||
eng. probe_fourier_shift_search = inf; % refine farfield position of the beam (ie angle) from iteration == probe_fourier_shift_search
|
||||
eng. estimate_NF_distance = inf; % try to estimate the nearfield propagation distance
|
||||
eng. variable_probe = false; % Use SVD to account for variable illumination during a single (coupled) scan
|
||||
eng. variable_SVD_modes = 3; % OPRP settings , number of SVD modes, apply only for PIE methods
|
||||
eng. variable_probe_smooth = 0; % OPRP settings , apply assumption of smooth evolution of the OPRP modes (ie slow drifts)
|
||||
eng. variable_intensity = false; % account to changes in probe intensity
|
||||
|
||||
|
||||
eng_0 = eng;
|
||||
|
||||
addpath(p. cSAXS_matlab_path)
|
||||
|
||||
|
||||
|
||||
if 1
|
||||
eng = eng_0;
|
||||
eng. method = 'DM'; % choose GPU solver: DM, RAAR, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng. grouping = inf;
|
||||
eng. probe_support_radius = inf;
|
||||
eng. number_iterations = 50;
|
||||
eng. probe_change_start = inf;
|
||||
|
||||
eng. use_display = true;
|
||||
eng. probe_change_start = 10;
|
||||
eng. plot_results_every = inf;
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
|
||||
eng. method = 'MLc'; % choose GPU solver: DM, RAAR, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng. grouping = inf;
|
||||
eng. probe_support_radius = inf;
|
||||
eng. number_iterations = 50;
|
||||
eng. accelerated_gradients_start = 2;
|
||||
eng. use_display = true;
|
||||
eng. probe_change_start = inf;
|
||||
eng. plot_results_every = inf;
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%% GENERATE DATA AND INITIAL GUESS %%%%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
p.prepare.force_preparation_data = true;
|
||||
p.use_display = 0;
|
||||
angles = 1+ linspace(0,360-1/Nangles, Nangles);
|
||||
utils.verbose(-1)
|
||||
disp('GENERATE DATA')
|
||||
objects_prepared = {};
|
||||
for ii = 1:Nangles
|
||||
% reset(gpuDevice)
|
||||
utils.progressbar(ii, Nangles, 30)
|
||||
rng(ii)
|
||||
p_tmp = p;
|
||||
p_tmp. use_gpu = true;
|
||||
p_tmp. verbose_level = -1;
|
||||
p_tmp. positions_pad = round(rand(1,2)*10);
|
||||
p_tmp. scan_number = ii;
|
||||
p_tmp. rotation_angle = angles(ii);
|
||||
p_tmp. prepare_data_path = fullfile(ptycho_path,'temp');
|
||||
|
||||
[pout] = core.initialize_ptycho(p_tmp);
|
||||
|
||||
|
||||
core.prep_h5data(pout);
|
||||
position_offset(ii,:) = pout.positions_pad;
|
||||
assert(~core.check_prepared_data( pout ), 'Generated data checked')
|
||||
|
||||
|
||||
|
||||
objects_ideal{ii} = prod(pout.simulation.obj{1},4);
|
||||
|
||||
p_tmp = pout;
|
||||
% get all engines
|
||||
|
||||
utils.verbose(struct('prefix', {'ptycho'}))
|
||||
for ieng=1:length(p_tmp.engines)
|
||||
% engine call
|
||||
utils.verbose(1, 'Calling engine %s', p_tmp.engines{ieng}.name)
|
||||
utils.verbose(struct('prefix', {p_tmp.engines{ieng}.name}))
|
||||
[p_tmp, fdb] = core.run_engine(p_tmp,ieng);
|
||||
|
||||
utils.verbose(struct('prefix', {'ptycho'}))
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
objects_prepared{ii} = struct('object', p_tmp.object{1},...
|
||||
'probe', p_tmp.probes, ...
|
||||
'positions', p_tmp.positions, ...
|
||||
'illum_sum', p_tmp.illum_sum{1}, ...
|
||||
'angle', angles(ii), ...
|
||||
'position_offset', position_offset(ii,:));
|
||||
|
||||
%% plot current projection
|
||||
objects{ii} = p_tmp.object{1};
|
||||
o = utils.crop_pad(utils.imshift_fft(p_tmp.object{1}, p_tmp.positions_pad) ,[300,500]);
|
||||
subplot(1,2,1)
|
||||
plotting.imagesc3D( abs( o ))
|
||||
title('Amplitude')
|
||||
colorbar
|
||||
caxis([0.4,1.2])
|
||||
colormap bone
|
||||
axis image
|
||||
subplot(1,2,2)
|
||||
plotting.imagesc3D( angle( o ))
|
||||
colorbar
|
||||
caxis([-1,2])
|
||||
title('Phase')
|
||||
colormap bone
|
||||
axis image
|
||||
plotting.suptitle(sprintf('Showing initial guess for projection %i', ii))
|
||||
drawnow
|
||||
|
||||
|
||||
end
|
||||
Npix_simulated_obj = size(pout.simulation.obj{1});
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%% TEST FILTERED BACKPROPAGATION %%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
addpath('../cSAXS_matlab_tomo/')
|
||||
|
||||
obj_size_max = [0, 0];
|
||||
for ii = 1:Nangles
|
||||
obj_size_max = max(obj_size_max, size(objects_prepared{ii}.object));
|
||||
end
|
||||
|
||||
sino = zeros([obj_size_max,Nangles], 'single');
|
||||
theta = zeros(Nangles,1);
|
||||
for ii = 1:Nangles
|
||||
utils.progressbar(ii, Nangles);
|
||||
sino(:,:,ii) = utils.crop_pad(utils.imshift_fft(objects_ideal{ii},objects_prepared{ii}.position_offset), obj_size_max);
|
||||
theta(ii) = objects_prepared{ii}.angle;
|
||||
end
|
||||
%
|
||||
sino = utils.crop_pad(sino, floor((obj_size_max - p.asize)/2)*2);
|
||||
|
||||
sino = sino(end/2 + [-20:20],:,:); % take only a few layers
|
||||
|
||||
par_tomo.pixel_size = pout.dx_spec(1);
|
||||
par_tomo.lambda = pout.lambda;
|
||||
par_tomo.GPU_list = 1;
|
||||
par_tomo.thickness = p_tmp.simulation.thickness ;
|
||||
|
||||
sino = gpuArray(sino);
|
||||
[rec] = tomo.FBP_propagation(sino, theta, 'phase', par_tomo, 0, par_tomo.thickness);
|
||||
|
||||
plotting.smart_figure(2322)
|
||||
% plotting.imagesc3D(rec, 'init_frame', ceil(size(rec,3)/2));
|
||||
plotting.imagesc3D(max(0,rec), 'init_frame', ceil(size(rec,3)/2));
|
||||
colormap bone
|
||||
caxis([0,0.1])
|
||||
title('Filtered backpropagation reconstruction')
|
||||
axis image
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%% test iterative ptychotomo %%%%%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
p0 = p;
|
||||
p0.object_size = pout.object_size;
|
||||
p0.asize = p.asize;
|
||||
p0.simulation.thickness = pout.simulation.thickness;
|
||||
p0.probes = pout.probes;
|
||||
|
||||
|
||||
|
||||
|
||||
% Make initial object guess
|
||||
disp('Store ideal reconstructions')
|
||||
volData_c = single(squeeze(pout.simulation.obj{1}));
|
||||
volData_c = utils.imshift_fft(volData_c,pout.positions_pad);
|
||||
volData_c = permute(volData_c,[3,2,1]);
|
||||
volData_c = rot90(volData_c,-1); % get the same orientation as seen by this code ;
|
||||
volData_c = complex(log(abs(volData_c)) , angle(volData_c)); % store in log space instead of complex space
|
||||
%%%%%%%%%
|
||||
Npx_vol = size(volData_c)-100; % keep only the relevant volume
|
||||
volData_c = utils.crop_pad(volData_c, max(Npx_vol(1:2))*ones(1,2));
|
||||
%%%%%%%%%
|
||||
|
||||
% rotate back to the initial angle
|
||||
volData_c = gather(utils.imrotate_ax(gpuArray(volData_c), -p_tmp.rotation_angle, 3));
|
||||
|
||||
|
||||
plotting.smart_figure(232)
|
||||
plotting.imagesc3D(max(0,-imag(volData_c)), 'init_frame', ceil(size(volData_c,3)/2));
|
||||
colormap bone
|
||||
colorbar
|
||||
axis image
|
||||
title('Ideal reconstruction')
|
||||
|
||||
|
||||
%% unwrap data
|
||||
|
||||
addpath('../cSAXS_matlab_tomo/')
|
||||
objects = objects(1:Nangles);
|
||||
position_offset = position_offset(1:Nangles, :);
|
||||
obj_size_max = [0, 0];
|
||||
for ii = 1:Nangles
|
||||
obj_size_max = max(obj_size_max, size(objects{ii}));
|
||||
end
|
||||
for ii = 1:Nangles
|
||||
objects{ii} = utils.crop_pad(objects{ii}, obj_size_max);
|
||||
end
|
||||
|
||||
|
||||
disp('Unwrapping ... ')
|
||||
Npx_proj = [obj_size_max,1];
|
||||
for ii = 1:Nangles
|
||||
utils.progressbar(ii, Nangles,30);
|
||||
objects_prepared{ii}.object = utils.stabilize_phase( objects{ii}, 'weights', abs(objects{ii}).^2 ,'fourier_guess', false);
|
||||
objects_prepared{ii}.illum_sum = utils.crop_pad(objects_prepared{ii}.illum_sum, Npx_proj);
|
||||
delta = 0.01*max(objects_prepared{ii}.illum_sum(:));
|
||||
W = sqrt(objects_prepared{ii}.illum_sum.^2 ./ (objects_prepared{ii}.illum_sum.^2 + delta^2));
|
||||
[object_c] = ptychotomo.prepare_projections(objects_prepared{ii}.object, Npx_proj, p0.asize,false,[], W);
|
||||
|
||||
objects_prepared{ii}.object_c = gather(object_c);
|
||||
objects_prepared{ii}.weight = W;
|
||||
|
||||
% plotting.smart_figure(2454)
|
||||
% subplot(1,2,1)
|
||||
% plotting.imagesc3D(exp(object_c)); axis off image
|
||||
% title('exp(object_c) - linearized reconstruction', 'interpreter', 'none')
|
||||
% subplot(1,2,2)
|
||||
% plotting.imagesc3D(objects_prepared{ii}.object); axis off image
|
||||
% title('Original reconstruction')
|
||||
% plotting.suptitle('Compare complex projections after unwrapping')
|
||||
% drawnow
|
||||
|
||||
|
||||
end
|
||||
clear object_c
|
||||
|
||||
|
||||
%%
|
||||
|
||||
disp('Removing phase offset from initial projection guess')
|
||||
volData_c = gpuArray(volData_c);
|
||||
probe_size = p.asize;
|
||||
win = tukeywin(Npx_proj(2), probe_size(2)/Npx_proj(2)/2)'.*tukeywin(Npx_proj(1), probe_size(1)/Npx_proj(1)/2);
|
||||
|
||||
for ii = 1:Nangles
|
||||
utils.progressbar(ii, Nangles);
|
||||
|
||||
|
||||
[~,objects_prepared{ii}] = ptychotomo.prepare_distributed_data(pout, volData_c, objects_prepared{ii}, [], struct(), -1, false);
|
||||
objects_prepared{ii}.object_c = gather(objects_prepared{ii}.object_c);
|
||||
|
||||
% plotting.smart_figure(2455)
|
||||
% subplot(1,2,1)
|
||||
% plotting.imagesc3D(exp( objects_prepared{ii}.object_c)); axis off image
|
||||
% subplot(1,2,2)
|
||||
% plotting.imagesc3D(objects_prepared{ii}.object); axis off image
|
||||
% drawnow
|
||||
|
||||
|
||||
end
|
||||
|
||||
scan_ids = 1:Nangles;
|
||||
for ii = 1:Nangles
|
||||
objects_prepared{ii}.scan_id = scan_ids(ii);
|
||||
objects_prepared{ii}.proj_id = ii;
|
||||
% shift by 1 pixel is needed get the right center of rotation in the projection
|
||||
objects_prepared{ii}.position_offset = objects_prepared{ii}.position_offset - 1;
|
||||
end
|
||||
|
||||
|
||||
volData_c = gather(volData_c);
|
||||
|
||||
|
||||
|
||||
pout.fmag = [];
|
||||
pout.fmask = [];
|
||||
pout.simulation.obj = [];
|
||||
volData0_c = volData_c;
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%% RUN ITERATIVE PTYCHO-TOMO RECONSTRUCTION %%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
par.queue_path = 'reconstruction';
|
||||
|
||||
% reconstruct the data
|
||||
addpath('../cSAXS_matlab_tomo/')
|
||||
addpath('../cSAXS_matlab_base/')
|
||||
|
||||
% smooth volData_c -> make a poor initial guess
|
||||
volData_c = utils.imgaussfilt3_fft(volData0_c, 10);
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%%% BASIC SETTINGS %%%%%%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
par.debug = false;
|
||||
par.downsample_angles = 1;
|
||||
par.Niter = 10;
|
||||
par.Niter_inner = 1;
|
||||
|
||||
%% set starting iteration for different actions
|
||||
par.start_3D_reconstruction = 1; % start reconstructing the 3D volume
|
||||
par.ptycho_interval = 1; % solver ptycho each N-th call
|
||||
par.ptycho_reconstruct_start = 2; % start ptychography reconstructiom
|
||||
par.ptycho_ML_reconstruct_start = par.ptycho_reconstruct_start; % start multilayer solver
|
||||
par.ptycho_accel_start = par.ptycho_ML_reconstruct_start+1 ; % start momemntum acceleration
|
||||
par.plot_every = 10; % seconds
|
||||
|
||||
|
||||
par.Nlayers_max = 32; % maximal number of reconstructed layers
|
||||
par.apply_support = true; % apply support constraint around the reconstructed volume
|
||||
par.smooth_reconstruction = false; % apply smoothing filter on the reconstruction, helps agains artefacts fom the rotation
|
||||
par.wait_time_solver = 10; % how long should the code wait for a projection before giving up
|
||||
par.max_queue_length = 5; % how many projection should be kept in the processing queue. More == better parallelism but more unstable solver
|
||||
|
||||
par.lambda = 0.5; % relative update step length in gradient descent
|
||||
|
||||
par.prepare_data_path = './temp/S%05i/';
|
||||
|
||||
|
||||
%% set constraints for the 3D reconstruction, it makes solver more stable
|
||||
par.max_value = 0 + 0i;
|
||||
par.min_value = -4.0e-3 -10e-2i;
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% set ptychography %
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
p0.verbose_level = 0;
|
||||
|
||||
% set data preparation
|
||||
p0.queue.name = 'filelist';
|
||||
p0.queue.file_queue_timeout = 0.1;
|
||||
p0.queue.recon_latest_first = false;
|
||||
|
||||
p0.prepare.auto_prepare_data = true;
|
||||
p0.prepare.force_preparation_data = false;
|
||||
|
||||
% set reconstruction engines
|
||||
p0.number_iterations = 5;
|
||||
p0.plot.interval = inf;
|
||||
p0.probe_change_start = 1;
|
||||
p0.object_change_start = 2;
|
||||
|
||||
|
||||
% engine settings
|
||||
p0.engines = {struct()};
|
||||
p0.engines{1}. name = 'GPU';
|
||||
p0.engines{1}. method = 'MLc';
|
||||
|
||||
p0.engines{1}.verbose_level = 0;
|
||||
p0.engines{1}.mirror_objects = false;
|
||||
p0.engines{1}.share_object = false;
|
||||
p0.engines{1}.probe_support_fft = true; % Apply probe support in Fourier space, ! uses model zoneplate settings to estimate support size
|
||||
p0.engines{1}.probe_support_radius = [];
|
||||
p0.engines{1}.grouping = inf; % group size
|
||||
p0.engines{1}.regularize_layers = 0;
|
||||
p0.engines{1}.use_display = false;
|
||||
p0.engines{1}.momentum = 0;
|
||||
p0.engines{1}.probe_support_fft = false;
|
||||
p0.engines{1}.delta = 0;
|
||||
p0.engines{1}.beta_LSQ = 0.9;
|
||||
p0.engines{1}.delta_p = 0.1;
|
||||
p0.engines{1}.remove_object_ambiguity = false;
|
||||
p0.engines{1}.accelerated_gradients_start = 2;
|
||||
|
||||
p0.prepare_data_filename = '';
|
||||
p0.scan = '';
|
||||
p0.fmag = [];
|
||||
p0.fmask = [];
|
||||
p0.simulation.obj = [];
|
||||
p0.object_size = size(objects_prepared{1}.object);
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
p0.engines{1}.probe_pos_search = inf;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Npx_vol = size(volData_c);
|
||||
|
||||
volData_c = utils.crop_pad(volData_c, ceil(Npx_vol / 64) * 64);
|
||||
|
||||
% correct for updated volume size -> keep thicnkness per pixel constant
|
||||
p0.thickness = pout.simulation.thickness * size(volData_c,1) / Npix_simulated_obj(4);
|
||||
|
||||
utils.verbose(0)
|
||||
utils.verbose(0, 'p0.simulation.thickness %g microns', p0.simulation.thickness*1e6)
|
||||
|
||||
|
||||
|
||||
|
||||
par.force_initialization = true;
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%% START PTYCHO SOLVERS %%%%%%%%%%%%%%%%%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
% run asynchronous solver in background , there can be many of them
|
||||
% started, they will automatically use different GPUs
|
||||
|
||||
|
||||
Nsolver = 1; % how many solvers should be started
|
||||
for ii = 1:Nsolver
|
||||
system('matlab -nodisplay -r ptychotomo.call_tomo_solver_asynchronous & ');
|
||||
end
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%% START TOMO SOLVER %%%%%%%%%%%%%%%%%%%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
% run tomo solver in foreground
|
||||
volData_rec = ptychotomo.tomo_solver_distributed(par, volData_c, objects_prepared, p0, angles,scan_ids);
|
||||
|
||||
|
||||
% clear temporal data
|
||||
rmdir('./temp/', 's')
|
||||
rmdir('./reconstruction/', 's')
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
%% TEST TEMPLATE FOR FUNTIONALITY CHECK OF MULTILAYER EXTENSION IN GPU ENGINES
|
||||
% 1) call standard template to get fresh settings defaults
|
||||
% 2) generate artificial data that should serve as a standart test "sample"
|
||||
% 3) call GPU engine with different basic functionalities and test if all still works
|
||||
% !! THESE TEST ARE ONLY USEFUL TO FIND CRASHES IN THE CODE, QUALITY DETERIORATION STILL NEED TO BE MEASURED !!
|
||||
|
||||
|
||||
%% set shared parameters for all test scripts
|
||||
run(fullfile( fileparts(mfilename('test_ML_data')), 'init_test.m'))
|
||||
|
||||
%% general settings
|
||||
p. artificial_data_file = 'tests/test_ML_data.m'; % artificial data parameters
|
||||
p. asize = [192 192]; % size of the reconstruction probe
|
||||
|
||||
%% load simulation parameters
|
||||
run(fullfile( ptycho_path, p.artificial_data_file))
|
||||
Nlayers = length(p.simulation.dataset{1});
|
||||
|
||||
|
||||
%% ENGINES
|
||||
% --------- GPU engines -------------
|
||||
|
||||
eng = struct();
|
||||
eng. name = 'GPU';
|
||||
eng. use_gpu = true; % if false, run CPU code, but it will get very slow
|
||||
eng. keep_on_gpu = true; % keep data + projections on GPU, false is useful for large data if DM is used
|
||||
eng. compress_data = true; % use automatic online memory compression to limit meed of GPU memory
|
||||
eng. gpu_id = []; % default GPU id, [] means choosen by matlab
|
||||
eng. check_gpu_load = true; % check available GPU memory before starting GPU engines
|
||||
|
||||
%% general
|
||||
% eng. number_iterations = 50; % number of iterations for selected method
|
||||
%eng. share_probe = 1; % Share probe between scans. Can be either a number/boolean or a list of numbers, specifying the probe index; e.g. [1 2 2] to share the probes between the second and third scan.
|
||||
%eng. share_object = 0; % Share object between scans. Can be either a number/boolean or a list of numbers, specifying the object index; e.g. [1 2 2] to share the objects between the second and third scan.
|
||||
% eng. method = 'MLs'; % choose GPU solver: DM, RAAR, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng. opt_errmetric = 'L1' ; % optimization likelihood - poisson, L1
|
||||
eng. grouping = 50; % size of processed blocks, larger blocks need more memory but they use GPU more effeciently
|
||||
% for hPIE, ePIE, MLs methods smaller blocks lead to faster convergence,
|
||||
% for pPIE, MLc the convergence is similar
|
||||
% for DM, RAAR is has no effect on convergence
|
||||
%eng. probe_modes = 1; % Number of coherent modes for probe
|
||||
eng. object_change_start = 1; % Start updating object at this iteration number
|
||||
eng. probe_change_start = 1; % Start updating probe at this iteration number
|
||||
|
||||
|
||||
% regularizations
|
||||
eng. reg_mu = 0; % Regularization constant ( = 0 for no regularization)
|
||||
eng. background = 1e-3;
|
||||
eng. delta = 0; % press values to zero out of the illumination area, usually 1e-2 is enough
|
||||
eng. positivity_constraint_object = 0; % enforce weak positivity in object, usually 1e-2 is already enough
|
||||
eng. regularize_layers = 0.01; % 0<R<<1 -> apply regularization on the reconstructed object layers, 0 == no regularization
|
||||
|
||||
eng. apply_multimodal_update = false; % apply all incoherent modes to object, it can cause isses if the modes collect some crap
|
||||
eng. probe_backpropagate = 0; % backpropagate the probe mask, inf == farfield
|
||||
|
||||
% basic recontruction parameters
|
||||
% PIE / ML methods
|
||||
eng. beta_object = 1; % object step size, larger == faster convergence, smaller == more robust, should not exceed 1
|
||||
eng. beta_probe = 1; % probe step size, larger == faster convergence, smaller == more robust, should not exceed 1
|
||||
eng. delta_p = 0.1; % LSQ dumping constant, 0 == no preconditioner, 0.1 is usually safe,
|
||||
% DM
|
||||
eng. pfft_relaxation = 0.1; % Relaxation in the Fourier domain projection, = 0 for full projection
|
||||
eng. probe_regularization = 0.1;% Weigth factor for the probe update (inertia)
|
||||
|
||||
|
||||
% ADVANCED OPTIONS
|
||||
% position refinement
|
||||
eng. apply_subpix_shift = false; % apply FFT-based subpixel shift, important for good position refinement but it is slow
|
||||
eng. probe_position_search = inf; % reconstruct probe positions, from iteration == probe_position_search, assume they have to match geometry model with error less than probe_position_error_max
|
||||
eng. probe_position_error_max = 10e-9; % max expected random position error of the stages
|
||||
|
||||
% wavefront refinement
|
||||
eng. probe_fourier_shift_search = inf; % refine farfield position of the beam (ie angle) from iteration == probe_fourier_shift_search
|
||||
eng. estimate_NF_distance = inf; % try to estimate the nearfield propagation distance
|
||||
eng. variable_probe = false; % Use SVD to account for variable illumination during a single (coupled) scan
|
||||
eng. variable_SVD_modes = 3; % OPRP settings , number of SVD modes, apply only for PIE methods
|
||||
eng. variable_probe_smooth = 0; % OPRP settings , apply assumption of smooth evolution of the OPRP modes (ie slow drifts)
|
||||
eng. variable_intensity = false; % account to changes in probe intensity
|
||||
|
||||
|
||||
eng_0 = eng;
|
||||
|
||||
|
||||
if 1
|
||||
%% test multilayer extension
|
||||
eng = eng_0;
|
||||
eng.delta_z = p.simulation.thickness / (Nlayers-1) * ones(Nlayers-1,1);
|
||||
eng.mirror_objects = false;
|
||||
eng.share_object = false;
|
||||
eng.probe_support_radius = [];
|
||||
eng.get_fsc_score = false;
|
||||
%eng.plot.interval = 50;
|
||||
eng.number_iterations = 100; % number of iterations for selected method
|
||||
eng.grouping = 100; % number of iterations for selected method
|
||||
eng. method = 'MLc'; % choose GPU solver: DM, RAAR, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng.momentum = true;
|
||||
eng.regularize_layers = 0;
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
|
||||
|
||||
run(fullfile( fileparts(mfilename('fullpath')), 'run_test.m'))
|
||||
|
||||
|
||||
|
||||
|
||||
% Academic License Agreement
|
||||
%
|
||||
% Source Code
|
||||
%
|
||||
% Introduction
|
||||
% • This license agreement sets forth the terms and conditions under which the PAUL SCHERRER INSTITUT (PSI), CH-5232 Villigen-PSI, Switzerland (hereafter "LICENSOR")
|
||||
% will grant you (hereafter "LICENSEE") a royalty-free, non-exclusive license for academic, non-commercial purposes only (hereafter "LICENSE") to use the cSAXS
|
||||
% ptychography MATLAB package computer software program and associated documentation furnished hereunder (hereafter "PROGRAM").
|
||||
%
|
||||
% Terms and Conditions of the LICENSE
|
||||
% 1. LICENSOR grants to LICENSEE a royalty-free, non-exclusive license to use the PROGRAM for academic, non-commercial purposes, upon the terms and conditions
|
||||
% hereinafter set out and until termination of this license as set forth below.
|
||||
% 2. LICENSEE acknowledges that the PROGRAM is a research tool still in the development stage. The PROGRAM is provided without any related services, improvements
|
||||
% or warranties from LICENSOR and that the LICENSE is entered into in order to enable others to utilize the PROGRAM in their academic activities. It is the
|
||||
% LICENSEE’s responsibility to ensure its proper use and the correctness of the results.”
|
||||
% 3. THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
% A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE LICENSOR, THE AUTHORS OR THE COPYRIGHT
|
||||
% HOLDERS BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE
|
||||
% OF THE PROGRAM OR OTHER DEALINGS IN THE PROGRAM.
|
||||
% 4. LICENSEE agrees that it will use the PROGRAM and any modifications, improvements, or derivatives of PROGRAM that LICENSEE may create (collectively,
|
||||
% "IMPROVEMENTS") solely for academic, non-commercial purposes and that any copy of PROGRAM or derivatives thereof shall be distributed only under the same
|
||||
% license as PROGRAM. The terms "academic, non-commercial", as used in this Agreement, mean academic or other scholarly research which (a) is not undertaken for
|
||||
% profit, or (b) is not intended to produce works, services, or data for commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged
|
||||
% in the commercial use, application or exploitation of works similar to the PROGRAM.
|
||||
% 5. LICENSEE agrees that it shall make the following acknowledgement in any publication resulting from the use of the PROGRAM or any translation of the code into
|
||||
% another computing language:
|
||||
% "Data processing was carried out using the cSAXS ptychography MATLAB package developed by the Science IT and the coherent X-ray scattering (CXS) groups, Paul
|
||||
% Scherrer Institut, Switzerland."
|
||||
%
|
||||
% Additionally, any publication using the package, or any translation of the code into another computing language should cite for difference map:
|
||||
% P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer, High-resolution scanning X-ray diffraction microscopy, Science 321, 379–382 (2008).
|
||||
% (doi: 10.1126/science.1158573),
|
||||
% for maximum likelihood:
|
||||
% P. Thibault and M. Guizar-Sicairos, Maximum-likelihood refinement for coherent diffractive imaging, New J. Phys. 14, 063004 (2012).
|
||||
% (doi: 10.1088/1367-2630/14/6/063004),
|
||||
% for mixed coherent modes:
|
||||
% P. Thibault and A. Menzel, Reconstructing state mixtures from diffraction measurements, Nature 494, 68–71 (2013). (doi: 10.1038/nature11806),
|
||||
% and/or for multislice:
|
||||
% E. H. R. Tsai, I. Usov, A. Diaz, A. Menzel, and M. Guizar-Sicairos, X-ray ptychography with extended depth of field, Opt. Express 24, 29089–29108 (2016).
|
||||
% (doi: 10.1364/OE.24.029089).
|
||||
% 6. Except for the above-mentioned acknowledgment, LICENSEE shall not use the PROGRAM title or the names or logos of LICENSOR, nor any adaptation thereof, nor the
|
||||
% names of any of its employees or laboratories, in any advertising, promotional or sales material without prior written consent obtained from LICENSOR in each case.
|
||||
% 7. Ownership of all rights, including copyright in the PROGRAM and in any material associated therewith, shall at all times remain with LICENSOR, and LICENSEE
|
||||
% agrees to preserve same. LICENSEE agrees not to use any portion of the PROGRAM or of any IMPROVEMENTS in any machine-readable form outside the PROGRAM, nor to
|
||||
% make any copies except for its internal use, without prior written consent of LICENSOR. LICENSEE agrees to place the following copyright notice on any such copies:
|
||||
% © All rights reserved. PAUL SCHERRER INSTITUT, Switzerland, Laboratory for Macromolecules and Bioimaging, 2017.
|
||||
% 8. The LICENSE shall not be construed to confer any rights upon LICENSEE by implication or otherwise except as specifically set forth herein.
|
||||
% 9. DISCLAIMER: LICENSEE shall be aware that Phase Focus Limited of Sheffield, UK has an international portfolio of patents and pending applications which relate
|
||||
% to ptychography and that the PROGRAM may be capable of being used in circumstances which may fall within the claims of one or more of the Phase Focus patents,
|
||||
% in particular of patent with international application number PCT/GB2005/001464. The LICENSOR explicitly declares not to indemnify the users of the software
|
||||
% in case Phase Focus or any other third party will open a legal action against the LICENSEE due to the use of the program.
|
||||
% 10. This Agreement shall be governed by the material laws of Switzerland and any dispute arising out of this Agreement or use of the PROGRAM shall be brought before
|
||||
% the courts of Zürich, Switzerland.
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
%% TEST TEMPLATE FOR FUNTIONALITY CHECK IN GPU ENGINES
|
||||
% 1) call standard template to get fresh settings defaults
|
||||
% 2) generate artificial data that should serve as a standart test "sample"
|
||||
% 3) call GPU engine with different basic functionalities and test if all still works
|
||||
% !! THESE TEST ARE ONLY USEFUL TO FIND CRASHES IN THE CODE, QUALITY OF THE RECONSTRUCTION IS NOT EVALUATED !!
|
||||
|
||||
%% set shared parameters for all test scripts
|
||||
run(fullfile( fileparts(mfilename('fullpath')), 'init_test.m'))
|
||||
|
||||
plot_results = true;
|
||||
|
||||
%% general settings
|
||||
p. artificial_data_file = 'tests/test_data.m'; % artificial data parameters
|
||||
p. asize = [256 256]; % size of the reconstruction probe
|
||||
p. prop_regime = 'nearfield';
|
||||
p. focus_to_sample_distance = 5e-3; % sample to focus distance, very important parameter to be set for nearfield ptychography
|
||||
p. simulation.prop_from_focus = 5e-3;
|
||||
p. scan.lx = 10e-6; % round_roi scan: width of the roi
|
||||
p. scan.ly = 10e-6;
|
||||
|
||||
% first bin the data and then upsample -> use ptychrography to compemsate for the information loss
|
||||
p. binning = 1;
|
||||
p.data_upsampling = 1;
|
||||
|
||||
%% ENGINES
|
||||
% External C++ code
|
||||
|
||||
% --------- GPU engines -------------
|
||||
if 1
|
||||
eng = struct();
|
||||
eng. name = 'GPU';
|
||||
eng. use_gpu = true; % if false, run CPU code, but it will get very slow
|
||||
eng. keep_on_gpu = true; % keep data + projections on GPU, false is useful for large data if DM is used
|
||||
eng. compress_data = true; % use automatic online memory compression to limit meed of GPU memory
|
||||
eng. gpu_id = []; % default GPU id, [] means choosen by matlab
|
||||
eng. check_gpu_load = true; % check available GPU memory before starting GPU engines
|
||||
|
||||
%% general
|
||||
eng. number_iterations = 20; % number of iterations for selected method
|
||||
|
||||
|
||||
% basic recontruction parameters
|
||||
% PIE / ML methods
|
||||
eng. beta_object = 1; % object step size, larger == faster convergence, smaller == more robust, should not exceed 1
|
||||
eng. beta_probe = 1; % probe step size, larger == faster convergence, smaller == more robust, should not exceed 1
|
||||
eng. delta_p = 0.1; % LSQ dumping constant, 0 == no preconditioner, 0.1 is usually safe,
|
||||
% DM
|
||||
eng. pfft_relaxation = 0.1; % Relaxation in the Fourier domain projection, = 0 for full projection
|
||||
eng. probe_regularization = 0.1;% Weigth factor for the probe update (inertia)
|
||||
|
||||
|
||||
% ADVANCED OPTIONS
|
||||
% position refinement
|
||||
eng. apply_subpix_shift = false; % apply FFT-based subpixel shift, important for good position refinement but it is slow
|
||||
eng. probe_pos_search = 10; % reconstruct probe positions, from iteration == probe_pos_search, assume they are independed
|
||||
eng. probe_position_search = inf; % reconstruct probe positions, from iteration == probe_position_search, assume they have to match geometry model with error less than probe_position_error_max
|
||||
eng. probe_position_error_max = 10e-9; % max expected random position error of the stages
|
||||
|
||||
|
||||
end
|
||||
|
||||
eng_0 = eng;
|
||||
|
||||
if 1
|
||||
%% test DM solver
|
||||
eng = eng_0;
|
||||
eng. method = 'DM'; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng.grouping = 100;
|
||||
eng.probe_support_radius = [];
|
||||
eng.number_iterations = 20;
|
||||
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
if 1
|
||||
%% test MLc/s codes
|
||||
eng = eng_0;
|
||||
eng. method = 'MLc'; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng.grouping = 50;
|
||||
eng.probe_support_radius = [];
|
||||
eng.number_iterations = 20;
|
||||
eng.accelerated_gradients_start = 2;
|
||||
eng. apply_subpix_shift = false; % apply FFT-based subpixel shift, important for good position refinement but it is slow
|
||||
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
|
||||
if 1
|
||||
%% test nearfield propagation refinement
|
||||
eng = eng_0;
|
||||
|
||||
% introduce error in the propagation distance of 1%
|
||||
eng.z = 5.05e-3;
|
||||
|
||||
eng. method = 'MLc'; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng.grouping = 20;
|
||||
eng.probe_support_radius = [];
|
||||
eng.number_iterations = 100;
|
||||
eng.accelerated_gradients_start = 2;
|
||||
eng. estimate_NF_distance = 10; % try to estimate the nearfield propagation distance using gradient descent optimization
|
||||
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
|
||||
run(fullfile( fileparts(mfilename('fullpath')), 'run_test.m'))
|
||||
|
||||
|
||||
% Academic License Agreement
|
||||
%
|
||||
% Source Code
|
||||
%
|
||||
% Introduction
|
||||
% • This license agreement sets forth the terms and conditions under which the PAUL SCHERRER INSTITUT (PSI), CH-5232 Villigen-PSI, Switzerland (hereafter "LICENSOR")
|
||||
% will grant you (hereafter "LICENSEE") a royalty-free, non-exclusive license for academic, non-commercial purposes only (hereafter "LICENSE") to use the cSAXS
|
||||
% ptychography MATLAB package computer software program and associated documentation furnished hereunder (hereafter "PROGRAM").
|
||||
%
|
||||
% Terms and Conditions of the LICENSE
|
||||
% 1. LICENSOR grants to LICENSEE a royalty-free, non-exclusive license to use the PROGRAM for academic, non-commercial purposes, upon the terms and conditions
|
||||
% hereinafter set out and until termination of this license as set forth below.
|
||||
% 2. LICENSEE acknowledges that the PROGRAM is a research tool still in the development stage. The PROGRAM is provided without any related services, improvements
|
||||
% or warranties from LICENSOR and that the LICENSE is entered into in order to enable others to utilize the PROGRAM in their academic activities. It is the
|
||||
% LICENSEE’s responsibility to ensure its proper use and the correctness of the results.”
|
||||
% 3. THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
% A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE LICENSOR, THE AUTHORS OR THE COPYRIGHT
|
||||
% HOLDERS BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE
|
||||
% OF THE PROGRAM OR OTHER DEALINGS IN THE PROGRAM.
|
||||
% 4. LICENSEE agrees that it will use the PROGRAM and any modifications, improvements, or derivatives of PROGRAM that LICENSEE may create (collectively,
|
||||
% "IMPROVEMENTS") solely for academic, non-commercial purposes and that any copy of PROGRAM or derivatives thereof shall be distributed only under the same
|
||||
% license as PROGRAM. The terms "academic, non-commercial", as used in this Agreement, mean academic or other scholarly research which (a) is not undertaken for
|
||||
% profit, or (b) is not intended to produce works, services, or data for commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged
|
||||
% in the commercial use, application or exploitation of works similar to the PROGRAM.
|
||||
% 5. LICENSEE agrees that it shall make the following acknowledgement in any publication resulting from the use of the PROGRAM or any translation of the code into
|
||||
% another computing language:
|
||||
% "Data processing was carried out using the cSAXS ptychography MATLAB package developed by the Science IT and the coherent X-ray scattering (CXS) groups, Paul
|
||||
% Scherrer Institut, Switzerland."
|
||||
%
|
||||
% Additionally, any publication using the package, or any translation of the code into another computing language should cite for difference map:
|
||||
% P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer, High-resolution scanning X-ray diffraction microscopy, Science 321, 379–382 (2008).
|
||||
% (doi: 10.1126/science.1158573),
|
||||
% for maximum likelihood:
|
||||
% P. Thibault and M. Guizar-Sicairos, Maximum-likelihood refinement for coherent diffractive imaging, New J. Phys. 14, 063004 (2012).
|
||||
% (doi: 10.1088/1367-2630/14/6/063004),
|
||||
% for mixed coherent modes:
|
||||
% P. Thibault and A. Menzel, Reconstructing state mixtures from diffraction measurements, Nature 494, 68–71 (2013). (doi: 10.1038/nature11806),
|
||||
% and/or for multislice:
|
||||
% E. H. R. Tsai, I. Usov, A. Diaz, A. Menzel, and M. Guizar-Sicairos, X-ray ptychography with extended depth of field, Opt. Express 24, 29089–29108 (2016).
|
||||
% (doi: 10.1364/OE.24.029089).
|
||||
% 6. Except for the above-mentioned acknowledgment, LICENSEE shall not use the PROGRAM title or the names or logos of LICENSOR, nor any adaptation thereof, nor the
|
||||
% names of any of its employees or laboratories, in any advertising, promotional or sales material without prior written consent obtained from LICENSOR in each case.
|
||||
% 7. Ownership of all rights, including copyright in the PROGRAM and in any material associated therewith, shall at all times remain with LICENSOR, and LICENSEE
|
||||
% agrees to preserve same. LICENSEE agrees not to use any portion of the PROGRAM or of any IMPROVEMENTS in any machine-readable form outside the PROGRAM, nor to
|
||||
% make any copies except for its internal use, without prior written consent of LICENSOR. LICENSEE agrees to place the following copyright notice on any such copies:
|
||||
% © All rights reserved. PAUL SCHERRER INSTITUT, Switzerland, Laboratory for Macromolecules and Bioimaging, 2017.
|
||||
% 8. The LICENSE shall not be construed to confer any rights upon LICENSEE by implication or otherwise except as specifically set forth herein.
|
||||
% 9. DISCLAIMER: LICENSEE shall be aware that Phase Focus Limited of Sheffield, UK has an international portfolio of patents and pending applications which relate
|
||||
% to ptychography and that the PROGRAM may be capable of being used in circumstances which may fall within the claims of one or more of the Phase Focus patents,
|
||||
% in particular of patent with international application number PCT/GB2005/001464. The LICENSOR explicitly declares not to indemnify the users of the software
|
||||
% in case Phase Focus or any other third party will open a legal action against the LICENSEE due to the use of the program.
|
||||
% 10. This Agreement shall be governed by the material laws of Switzerland and any dispute arising out of this Agreement or use of the PROGRAM shall be brought before
|
||||
% the courts of Zürich, Switzerland.
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
%% TEST TEMPLATE FOR FUNTIONALITY CHECK IN GPU ENGINES
|
||||
% 1) call standard template to get fresh settings defaults
|
||||
% 2) generate artificial data that should serve as a standart test "sample"
|
||||
% 3) call GPU engine with different basic functionalities and test if all still works
|
||||
% !! THESE TEST ARE ONLY USEFUL TO FIND CRASHES IN THE CODE, QUALITY OF THE RECONSTRUCTION IS NOT EVALUATED !!
|
||||
|
||||
|
||||
%% set shared parameters for all test scripts
|
||||
run(fullfile( fileparts(mfilename('fullpath')), 'init_test.m'))
|
||||
|
||||
|
||||
%% general settings
|
||||
p. verbose_level = -1; % level -1 -> keep it totally quiet
|
||||
p. artificial_data_file = 'tests/test_offaxis_data.m'; % artificial data parameters
|
||||
p. asize = [512 256]; % size of the reconstruction probe
|
||||
|
||||
% Offaxis ptychography correction
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
p. sample_rotation_angles = [89.8,0,0]; % 3x1 vector rotation around [X,Y,beam] axes in degrees , apply a correction accounting for tilted plane oR the sample and ewald sphere curvature (high NA correction)
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
p. probe_support_radius = 0.8; % Normalized radius of circular support, = 1 for radius touching the window
|
||||
p. plot.realaxes = 0;
|
||||
|
||||
|
||||
%% ENGINES
|
||||
|
||||
% --------- GPU engines -------------
|
||||
if 1
|
||||
eng = struct();
|
||||
eng. name = 'GPU';
|
||||
eng. use_gpu = true; % if false, run CPU code, but it will get very slow
|
||||
eng. keep_on_gpu = true; % keep data + projections on GPU, false is useful for large data if DM is used
|
||||
eng. compress_data = true; % use automatic online memory compression to limit meed of GPU memory
|
||||
eng. gpu_id = []; % default GPU id, [] means choosen by matlab
|
||||
eng. check_gpu_load = true; % check available GPU memory before starting GPU engines
|
||||
|
||||
%% general
|
||||
eng. number_iterations = 100; % number of iterations for selected method
|
||||
%eng. share_probe = 1; % Share probe between scans. Can be either a number/boolean or a list of numbers, specifying the probe index; e.g. [1 2 2] to share the probes between the second and third scan.
|
||||
%eng. share_object = 0; % Share object between scans. Can be either a number/boolean or a list of numbers, specifying the object index; e.g. [1 2 2] to share the objects between the second and third scan.
|
||||
eng. method = 'MLs'; % choose GPU solver: DM, ePIE, pPIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng. opt_errmetric = 'L1' ; % optimization likelihood - poisson, L1
|
||||
eng. grouping = 50; % size of processed blocks, larger blocks need more memory but they use GPU more effeciently
|
||||
% for hPIE, ePIE, MLs methods smaller blocks lead to faster convergence,
|
||||
% for pPIE, MLc the convergence is similar
|
||||
% for DM, RAAR is has no effect on convergence
|
||||
%eng. probe_modes = 1; % Number of coherent modes for probe
|
||||
eng. object_change_start = 1; % Start updating object at this iteration number
|
||||
eng. probe_change_start = 1; % Start updating probe at this iteration number
|
||||
eng.probe_support_fft = true;
|
||||
eng. probe_modes = 1; % Number of coherent modes for probe
|
||||
|
||||
% regularizations
|
||||
eng. reg_mu = 0; % Regularization constant ( = 0 for no regularization)
|
||||
eng. delta = 0; % press values to zero out of the illumination area, usually 1e-2 is enough
|
||||
eng. positivity_constraint_object = 0; % enforce weak positivity in object, usually 1e-2 is already enough
|
||||
|
||||
eng. apply_multimodal_update = false; % apply all incoherent modes to object, it can cause isses if the modes collect some crap
|
||||
eng. probe_backpropagate = 0; % backpropagate the probe mask, inf == farfield
|
||||
|
||||
% basic recontruction parameters
|
||||
% PIE / ML methods
|
||||
eng. beta_object = 1; % object step size, larger == faster convergence, smaller == more robust, should not exceed 1
|
||||
eng. beta_probe = 1; % probe step size, larger == faster convergence, smaller == more robust, should not exceed 1
|
||||
eng. delta_p = 0.1; % LSQ dumping constant, 0 == no preconditioner, 0.1 is usually safe,
|
||||
% DM
|
||||
eng. pfft_relaxation = 0.1; % Relaxation in the Fourier domain projection, = 0 for full projection
|
||||
eng. probe_regularization = 0.1;% Weigth factor for the probe update (inertia)
|
||||
|
||||
|
||||
% ADVANCED OPTIONS
|
||||
% position refinement
|
||||
eng. apply_subpix_shift = false; % apply FFT-based subpixel shift, important for good position refinement but it is slow
|
||||
eng. probe_position_search = inf; % reconstruct probe positions, from iteration == probe_pos_search, assume they are independed
|
||||
eng. probe_position_error_max = 10e-9; % max expected random position error of the stages
|
||||
|
||||
% wavefront refinement
|
||||
eng. probe_fourier_shift_search = inf; % refine farfield position of the beam (ie angle) from iteration == probe_fourier_shift_search
|
||||
eng. estimate_NF_distance = inf; % try to estimate the nearfield propagation distance
|
||||
eng. variable_probe = false; % Use SVD to account for variable illumination during a single (coupled) scan
|
||||
eng. variable_SVD_modes = 3; % OPRP settings , number of SVD modes, apply only for PIE methods
|
||||
eng. variable_probe_smooth = 0; % OPRP settings , apply assumption of smooth evolution of the OPRP modes (ie slow drifts)
|
||||
eng. variable_intensity = false; % account to changes in probe intensity
|
||||
|
||||
|
||||
%%%%%%%%%%%%% correct for tilted plane by adjusting measured data %%%%%
|
||||
eng. apply_tilted_plane_correction = 'diffraction';
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
|
||||
|
||||
%%%%%%%%%%%%% correct for tilted plane by adjusting propagator %%%%%
|
||||
eng. apply_tilted_plane_correction = 'propagation';
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
|
||||
|
||||
end
|
||||
|
||||
run(fullfile( ptycho_path, 'tests/run_test.m'))
|
||||
|
||||
|
||||
|
||||
% Academic License Agreement
|
||||
%
|
||||
% Source Code
|
||||
%
|
||||
% Introduction
|
||||
% • This license agreement sets forth the terms and conditions under which the PAUL SCHERRER INSTITUT (PSI), CH-5232 Villigen-PSI, Switzerland (hereafter "LICENSOR")
|
||||
% will grant you (hereafter "LICENSEE") a royalty-free, non-exclusive license for academic, non-commercial purposes only (hereafter "LICENSE") to use the cSAXS
|
||||
% ptychography MATLAB package computer software program and associated documentation furnished hereunder (hereafter "PROGRAM").
|
||||
%
|
||||
% Terms and Conditions of the LICENSE
|
||||
% 1. LICENSOR grants to LICENSEE a royalty-free, non-exclusive license to use the PROGRAM for academic, non-commercial purposes, upon the terms and conditions
|
||||
% hereinafter set out and until termination of this license as set forth below.
|
||||
% 2. LICENSEE acknowledges that the PROGRAM is a research tool still in the development stage. The PROGRAM is provided without any related services, improvements
|
||||
% or warranties from LICENSOR and that the LICENSE is entered into in order to enable others to utilize the PROGRAM in their academic activities. It is the
|
||||
% LICENSEE’s responsibility to ensure its proper use and the correctness of the results.”
|
||||
% 3. THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
% A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE LICENSOR, THE AUTHORS OR THE COPYRIGHT
|
||||
% HOLDERS BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE
|
||||
% OF THE PROGRAM OR OTHER DEALINGS IN THE PROGRAM.
|
||||
% 4. LICENSEE agrees that it will use the PROGRAM and any modifications, improvements, or derivatives of PROGRAM that LICENSEE may create (collectively,
|
||||
% "IMPROVEMENTS") solely for academic, non-commercial purposes and that any copy of PROGRAM or derivatives thereof shall be distributed only under the same
|
||||
% license as PROGRAM. The terms "academic, non-commercial", as used in this Agreement, mean academic or other scholarly research which (a) is not undertaken for
|
||||
% profit, or (b) is not intended to produce works, services, or data for commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged
|
||||
% in the commercial use, application or exploitation of works similar to the PROGRAM.
|
||||
% 5. LICENSEE agrees that it shall make the following acknowledgement in any publication resulting from the use of the PROGRAM or any translation of the code into
|
||||
% another computing language:
|
||||
% "Data processing was carried out using the cSAXS ptychography MATLAB package developed by the Science IT and the coherent X-ray scattering (CXS) groups, Paul
|
||||
% Scherrer Institut, Switzerland."
|
||||
%
|
||||
% Additionally, any publication using the package, or any translation of the code into another computing language should cite for difference map:
|
||||
% P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer, High-resolution scanning X-ray diffraction microscopy, Science 321, 379–382 (2008).
|
||||
% (doi: 10.1126/science.1158573),
|
||||
% for maximum likelihood:
|
||||
% P. Thibault and M. Guizar-Sicairos, Maximum-likelihood refinement for coherent diffractive imaging, New J. Phys. 14, 063004 (2012).
|
||||
% (doi: 10.1088/1367-2630/14/6/063004),
|
||||
% for mixed coherent modes:
|
||||
% P. Thibault and A. Menzel, Reconstructing state mixtures from diffraction measurements, Nature 494, 68–71 (2013). (doi: 10.1038/nature11806),
|
||||
% and/or for multislice:
|
||||
% E. H. R. Tsai, I. Usov, A. Diaz, A. Menzel, and M. Guizar-Sicairos, X-ray ptychography with extended depth of field, Opt. Express 24, 29089–29108 (2016).
|
||||
% (doi: 10.1364/OE.24.029089).
|
||||
% 6. Except for the above-mentioned acknowledgment, LICENSEE shall not use the PROGRAM title or the names or logos of LICENSOR, nor any adaptation thereof, nor the
|
||||
% names of any of its employees or laboratories, in any advertising, promotional or sales material without prior written consent obtained from LICENSOR in each case.
|
||||
% 7. Ownership of all rights, including copyright in the PROGRAM and in any material associated therewith, shall at all times remain with LICENSOR, and LICENSEE
|
||||
% agrees to preserve same. LICENSEE agrees not to use any portion of the PROGRAM or of any IMPROVEMENTS in any machine-readable form outside the PROGRAM, nor to
|
||||
% make any copies except for its internal use, without prior written consent of LICENSOR. LICENSEE agrees to place the following copyright notice on any such copies:
|
||||
% © All rights reserved. PAUL SCHERRER INSTITUT, Switzerland, Laboratory for Macromolecules and Bioimaging, 2017.
|
||||
% 8. The LICENSE shall not be construed to confer any rights upon LICENSEE by implication or otherwise except as specifically set forth herein.
|
||||
% 9. DISCLAIMER: LICENSEE shall be aware that Phase Focus Limited of Sheffield, UK has an international portfolio of patents and pending applications which relate
|
||||
% to ptychography and that the PROGRAM may be capable of being used in circumstances which may fall within the claims of one or more of the Phase Focus patents,
|
||||
% in particular of patent with international application number PCT/GB2005/001464. The LICENSOR explicitly declares not to indemnify the users of the software
|
||||
% in case Phase Focus or any other third party will open a legal action against the LICENSEE due to the use of the program.
|
||||
% 10. This Agreement shall be governed by the material laws of Switzerland and any dispute arising out of this Agreement or use of the PROGRAM shall be brought before
|
||||
% the courts of Zürich, Switzerland.
|
||||
|
||||
@@ -0,0 +1,305 @@
|
||||
%% TEST TEMPLATE FOR FUNTIONALITY OF RECONSTRUCTION ON REAL DATA
|
||||
% 1) call standard template to get fresh settings defaults
|
||||
% 2) load example of measured data
|
||||
% 3) all c_solver engine to test quality
|
||||
|
||||
%% set shared parameters for all test scripts
|
||||
run(fullfile( fileparts(mfilename('fullpath')), 'init_test.m'))
|
||||
|
||||
|
||||
%% General
|
||||
|
||||
% Scan meta data
|
||||
p. z = 7.198; % Distance from object to detector
|
||||
p. src_metadata = 'spec';
|
||||
|
||||
% Scan queue
|
||||
p. scan_number = [12 13]; % Multiple scan numbers for shared scans
|
||||
|
||||
p. queue.name = ''; % specify file queue; currenlty only 'filelist' is supported
|
||||
p. queue.path=['/das/work/p16/p16602/code_testing_env3/reconstruction/']; % Folder where the queue of files is defined, note the content of files can overwrite some parameters in p-structure
|
||||
|
||||
% Data preparation
|
||||
p. asize = [320 320]; % Diffr. patt. array size
|
||||
p. ctr = [943 736;963 746]; % Diffr. patt. center coordinates (y,x) (empty means middle of the array); e.g. [100 207;100+20 207+10];
|
||||
p. detector.check_2_detpos = []; % = []; (ignores) = 270; compares to dettrx to see if p.ctr should be reversed (for OMNY shared scans 1221122), make equal to the middle point of dettrx between the 2 detector positions
|
||||
p. detector.data_prefix = 'e16403_1_'; % Default using current eaccount e.g. e14169_1_
|
||||
p. prepare.data_preparator = 'python'; % data preparator; 'python' or 'matlab'
|
||||
|
||||
% Scan positions
|
||||
p. src_positions = 'orchestra'; % 'spec', 'orchestra', 'load_from_file', 'matlab_pos' (scan params are defined below)
|
||||
p. angular_correction_setup = 'omny'; % if src_positions=='orchestra', choose angular correction for specific cSAXS experiment: 'flomni', 'omny', 'lamni', 'none',
|
||||
p. positions_file = ['/das/work/p16/p16812/data/pilatus/e16403/specES1/scan_positions/scan_%05d.dat']; % Filename pattern for position files, Example: ['../../specES1/scan_positions/scan_%05d.dat']; (the scan number will be automatically filled in)
|
||||
p. detector.name = 'Pilatus';
|
||||
|
||||
p.affine_matrix = [1, -0.001622 ; -0.0003122 , 1 ] ; %[1 0;tan(0.3*pi/180) 1]; % Applies affine transformation (e.g. rotation, stretching) to the positions (ignore by = []). Convention [yn;xn] = M*[y;x]. For flOMNI we found in September 2018: = [1 0;tan(0.36*pi/180) 1]; for OMNY we found in October 2018: = [1 0;tan(0.4*pi/180) 1]; laMNI in June 2018 [1,0.0154;-0.0017,1.01]; laMNI in August [1.01 0.0031; -0.0018 1.00]
|
||||
|
||||
|
||||
|
||||
% I/O
|
||||
p. base_path = fullfile(ptycho_path, 'tests'); % base path
|
||||
p. specfile = '/das/work/p16/p16812/data/pilatus/e16403/'; % Name of spec file to get motor positions and check end of scan, defaut is p.spec_file == p.base_path;
|
||||
p. detector.name = 'pilatus'; % 'pilatus' or 'eiger'
|
||||
p. raw_data_path{1} = '/das/work/p16/p16812/data/pilatus/e16403/'; % Default using compile_x12sa_filename, used only if data should be prepared automatically
|
||||
|
||||
%% Reconstruction
|
||||
|
||||
% Initial iterate object
|
||||
p. model_object = true; % Use model object
|
||||
p. model.object_type = 'rand'; % specify how the object shall be created; use 'rand' for a random initial guess; use 'amplitude' for an initial guess based on the prepared data
|
||||
|
||||
p. initial_iterate_object_file{1} = ''; % use this mat-file as initial guess of object, it is possible to use wild characters and pattern filling, example: '../analysis/S%05i/wrap_*_1024x1024_1_recons*'
|
||||
|
||||
|
||||
% Initial iterate probe
|
||||
p. model_probe = true; % Use model probe, if false load it from file
|
||||
p. model.probe_is_focused = true; % Model probe is focused (false: just a pinhole)
|
||||
p. model.probe_central_stop = true; % Model central stop
|
||||
p. model.probe_diameter = 170e-6; % Model probe pupil diameter
|
||||
p. model.probe_central_stop_diameter = 50e-6; % Model central stop diameter
|
||||
p. model.probe_zone_plate_diameter = 170e-6; % Model probe zone plate diameter
|
||||
p. model.probe_outer_zone_width = []; % Model probe zone plate outermost zone width (not used if not a focused probe)
|
||||
p. model.probe_propagation_dist = 1.2e-3; % Model probe propagation distance (pinhole <-> sample for unfocused, focal-plane <-> sample for focused)
|
||||
p. model.probe_focal_length = 51e-3; % Model probe focal length (used only if model_is_focused is true
|
||||
|
||||
p. model_upsample = 10; % Model probe upsample factor (for focused probes)
|
||||
p. initial_probe_file = 'probe_S00558_192x192_recons.mat';% Use probe from this mat-file (not used if model_probe is true)
|
||||
p. probe_file_propagation = []; % Distance for propagating the probe from file in meters, = [] to ignore
|
||||
|
||||
% Shared scans - Currently working only for sharing probe and object
|
||||
p. share_probe = 1; % Share probe between scans. Can be either a number/boolean or a list of numbers, specifying the probe index; e.g. [1 2 2] to share the probes between the second and third scan.
|
||||
p. share_object = 0; % Share object between scans. Can be either a number/boolean or a list of numbers, specifying the object index; e.g. [1 2 2] to share the objects between the second and third scan.
|
||||
|
||||
% Modes
|
||||
p. probe_modes = 2; % Number of coherent modes for probe
|
||||
p. object_modes = 1; % Number of coherent modes for object
|
||||
% Mode starting guess
|
||||
p. mode_start_pow = [0.02]; % Normalized intensity on probe modes > 1. Can be a number (all higher modes equal) or a vector
|
||||
p. mode_start = 'herm'; % (for probe) = 'rand', = 'herm' (Hermitian-like base), = 'hermver' (vertical modes only), = 'hermhor' (horizontal modes only)
|
||||
p. ortho_probes = true; % orthogonalize probes after each engine
|
||||
|
||||
|
||||
%% Plot and save
|
||||
|
||||
p. save.external = false; % Use a new Matlab session to run save final figures (saves ~6s per reconstruction). Please be aware that this might lead to an accumulation of Matlab sessions if your single reconstruction is very fast.
|
||||
p. plot.prepared_data = false; % plot prepared data
|
||||
p. save.store_images = 0; % Write nice jpegs in [p.base_path,'analysis/online/ptycho/'] if p.use_display = 0 then the figures are opened invisible in order to create the nice layout. It writes images in analysis/online/ptycho
|
||||
p. plot.calc_FSC = true; % Calculate the Fourier Shell correlation for 2 scans
|
||||
p. plot.show_FSC = false; % Show the FSC plots, including the cropped FOV
|
||||
|
||||
|
||||
%% ENGINES
|
||||
% External C++ code
|
||||
% Please notice that you have to force data preparation (force_prepare_h5_files=true) if you have made any changes to
|
||||
% the already prepared data (fmag, fmask, positions, sharing ...).
|
||||
eng. name = 'c_solver';
|
||||
eng. number_iterations = 600; % Total number of iterations
|
||||
eng. opt_iter = 300; % Iterations for optimization
|
||||
eng. probe_regularization = .1; % Weigth factor for the probe update;
|
||||
eng. probe_change_start = 1; % Start updating probe at this iteration number
|
||||
eng. probe_support_radius = 0.8; % Normalized radius of circular support, = 1 for radius touching the window
|
||||
eng. pfft_relaxation = .1; % Relaxation in the Fourier domain projection, = 0 for full projection
|
||||
eng. background = 0; % [PARTIALLY IMPLEMENTED (not fully optimized)] Add background to the ML model in form: |Psi|^2+B, B is in average counts per frame and pixel
|
||||
eng. probe_support_fft = false; % [PARTIALLY IMPLEMENTED (not fully optimized)] Apply probe support in Fourier space, ! uses model zoneplate settings to estimate support size
|
||||
|
||||
eng. N_layer = 1; % Number of virtual object layers (slices)
|
||||
eng. delta_z = 0e-6 * ones(1, eng.N_layer-1); % Separation between object slices
|
||||
%eng. ms_init_ob_fraction = [1 0];
|
||||
if eng. N_layer>1
|
||||
p.sufix = [p.sufix '_N' num2str(eng. N_layer)];
|
||||
eng. number_iterations = 0; % highly recommended
|
||||
end
|
||||
|
||||
eng. single_prec = true; % single or double precision
|
||||
eng. threads = 20; % number of threads for OMP
|
||||
eng. beamline_nodes = []; % beamline nodes for the MPI/OMP hybrid, e.g. ['x12sa-cn-2'; 'x12sa-cn-3'];
|
||||
eng. ra_nodes = 2; % number of nodes on ra cluster for the MPI/OMP hybrid; set to 0 for current node
|
||||
eng. caller_suffix = ''; % suffix for the external reconstruction program
|
||||
eng. reconstruction_program = ''; % specify external reconstruction program that overwrites previous settings, e.g. 'OMP_NUM_THREADS=20 ./ptycho_single_OMP';
|
||||
eng. check_cpu_load = true; % check if specified nodes are already in use (only x12sa). Disable check if you are sure that the nodes are free.
|
||||
eng. initial_conditions_path = ''; % path of the initial conditions file; default if empty (== prepare_data_path)
|
||||
eng. initial_conditions_file = ''; % Name of the initial conditions file, default if empty. Do not use ~ in the path
|
||||
eng. measurements_file = ''; % Name of the measurements file, default if empty. Do not use ~ in the path
|
||||
eng. solution_file = ''; % Name of the solution file, default if empty. Do not use ~ in the path
|
||||
eng. force_prepare_h5_files = 0; % If true before running the C-code the data h5 file is created and the h5 file with initial object and probe too, regardless of whether it exists. It will use the matlab data preparator.
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
|
||||
|
||||
if gpuDeviceCount
|
||||
% % --------- GPU engines ------------- See for more details: Odstrčil M, et al., Optics express. 2018 Feb 5;26(3):3108-23.
|
||||
eng = struct(); % reset settings for this engine
|
||||
eng. name = 'GPU';
|
||||
eng. gpu_id = []; % default GPU id, [] means choosen by matlab
|
||||
eng. probe_modes = 1;
|
||||
eng. probe_support_radius = 0.9; % Normalized radius of circular support, = 1 for radius touching the window
|
||||
eng. probe_support_fft = true; % assume that there is not illumination intensity out of the central FZP cone
|
||||
|
||||
% basic recontruction parameters
|
||||
% PIE / ML methods % See for more details: Odstrčil M, et al., Optics express. 2018 Feb 5;26(3):3108-23.
|
||||
eng. beta_object = 1; % object step size, larger == faster convergence, smaller == more robust, should not exceed 1
|
||||
eng. beta_probe = 1; % probe step size, larger == faster convergence, smaller == more robust, should not exceed 1
|
||||
eng. delta_p = 0.1; % LSQ dumping constant, 0 == no preconditioner, 0.1 is usually safe,
|
||||
eng. momentum = 0.5; % add momentum term to the MLc method, eng.momentum = multiplication gain for velocity
|
||||
eng. accelerated_gradients_start = 2; % iteration number from which the Nesterov gradient acceleration should be applied, this option is supposted only for MLc method
|
||||
|
||||
% DM
|
||||
eng. pfft_relaxation = 0.05; % Relaxation in the Fourier domain projection, = 0 for full projection
|
||||
eng. probe_regularization = 0.1; % Weight factor for the probe update (inertia)
|
||||
|
||||
% other extensions
|
||||
eng. background = 0.5; % average background scattering level, for OMNI values around 0.3 for 100ms, for flOMNI <0.1 per 100ms exposure, see for more details: Odstrcil, M., et al., Optics letters 40.23 (2015): 5574-5577.
|
||||
|
||||
eng. method = 'DM'; % choose GPU solver: DM, ePIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng. number_iterations = 300; % number of iterations for selected method
|
||||
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
|
||||
eng. method = 'MLc'; % choose GPU solver: DM, ePIE, hPIE, MLc, Mls, -- recommended are MLc and MLs
|
||||
eng. number_iterations = 500; % number of iterations for selected method
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
|
||||
%% Run the reconstruction
|
||||
% python data prep
|
||||
p.prepare.data_preparator = 'python';
|
||||
run_recons_test(p, 'libDetXR', 1);
|
||||
|
||||
% matlab data prep
|
||||
p.prepare.data_preparator = 'matlab';
|
||||
run_recons_test(p, 'matlab_ps', 1);
|
||||
|
||||
if gpuDeviceCount
|
||||
% matlab data prep
|
||||
p.prepare.data_preparator = 'matlab';
|
||||
run_recons_test(p, 'matlab_ps', 2:3);
|
||||
end
|
||||
|
||||
|
||||
|
||||
function run_recons_test(p, arg, engine_ids )
|
||||
|
||||
% run only preselected engines
|
||||
p.engines = p.engines(engine_ids);
|
||||
% reconstruct
|
||||
out = core.ptycho_recons(p);
|
||||
|
||||
cmp = load('/das/work/p16/p16812/data/pilatus/e16403/tests/reference.mat');
|
||||
|
||||
if all(cmp.ref.resolution-out.FSC.resolution>=1)
|
||||
fprintf('Testing real dataset "PILATUS - OMNY - %s engine %s" .... OK\n', arg, p.engines{1}.name)
|
||||
fprintf('The resolution improved from [%f %f] to [%f %f]. Please consider updating the reference!\n', cmp.ref.resolution, out.FSC.resolution)
|
||||
elseif all(cmp.ref.resolution-out.FSC.resolution<=-1)
|
||||
fprintf('Testing real dataset "PILATUS - OMNY - %s engine %s" .... failed\n', arg, p.engines{1}.name)
|
||||
warning('The resolution dropped from %f to %f!\n', cmp.ref.resolution, out.FSC.resolution)
|
||||
else
|
||||
fprintf('Testing real dataset "PILATUS - OMNY - %s engine %s" .... OK\n', arg, p.engines{1}.name)
|
||||
end
|
||||
|
||||
% delete temporal data
|
||||
for path = out.save_path
|
||||
rmdir(path{1}, 's')
|
||||
end
|
||||
end
|
||||
%end
|
||||
% 2011-11-24
|
||||
% Parameter to autoposition windows on first display - p.windowautopos
|
||||
% Replaced powerbound with countbound. countbound represents the mean
|
||||
% number of photons in a change below which no projection is taken. It
|
||||
% scales automatically with exposure time (number of photons in
|
||||
% measurement)
|
||||
% Real axes option to show plots in microns
|
||||
% Read parameters from spec
|
||||
% Implement user suplied object_flat_region
|
||||
% Implemented option for reconstructing when having 2 repeated scans in the prepared data file
|
||||
|
||||
% 2011-11-29
|
||||
% Template seemed extracted from an AFS run, I modified directories for
|
||||
% direct use on ../../
|
||||
% Implemented test mode
|
||||
% Added cutoff value at beginning
|
||||
% Added auto settings for prepare data, scan numbers
|
||||
% Implemented reading from spec. Note it will use the values from the first
|
||||
% scan
|
||||
% Added option for repeated scan, should be enabled for 2 detector positions
|
||||
|
||||
% 2012-08-23
|
||||
% Replaced default prepare data function to prepare_data_2d
|
||||
% In I/O section: added option for a sufix
|
||||
% Added default option for raw data path based on compile_x12sa_filename
|
||||
% Added options to autoprepare data, with cutoff and burstmode detected if
|
||||
% the file does not exist. Also added the possiblity to override and
|
||||
% force a repreparation of data
|
||||
% Added a data prefix option (for eaccount_1_) and defaults using
|
||||
% identify_eaccount
|
||||
|
||||
% 2012-10-29
|
||||
% Added option for binning and some checks for OMNY detector position scans
|
||||
|
||||
% 2012-10-31
|
||||
% Added options to use the external C-code for testing
|
||||
|
||||
% 2015-05-13
|
||||
% Added option to queue file tasks from OMNI.
|
||||
% For this I moved the default checks and generation of default names and
|
||||
% paths to ptycho_recons. Que Dios se apiade de nosotros.
|
||||
|
||||
% 2016-02-11
|
||||
% Removed old option for dump files
|
||||
% Added p.store_images, if this flag is on and p.use_display it will open
|
||||
% figures in the background and write nice jpegs of the reconstruction and error metric anyway
|
||||
|
||||
% Academic License Agreement
|
||||
%
|
||||
% Source Code
|
||||
%
|
||||
% Introduction
|
||||
% • This license agreement sets forth the terms and conditions under which the PAUL SCHERRER INSTITUT (PSI), CH-5232 Villigen-PSI, Switzerland (hereafter "LICENSOR")
|
||||
% will grant you (hereafter "LICENSEE") a royalty-free, non-exclusive license for academic, non-commercial purposes only (hereafter "LICENSE") to use the cSAXS
|
||||
% ptychography MATLAB package computer software program and associated documentation furnished hereunder (hereafter "PROGRAM").
|
||||
%
|
||||
% Terms and Conditions of the LICENSE
|
||||
% 1. LICENSOR grants to LICENSEE a royalty-free, non-exclusive license to use the PROGRAM for academic, non-commercial purposes, upon the terms and conditions
|
||||
% hereinafter set out and until termination of this license as set forth below.
|
||||
% 2. LICENSEE acknowledges that the PROGRAM is a research tool still in the development stage. The PROGRAM is provided without any related services, improvements
|
||||
% or warranties from LICENSOR and that the LICENSE is entered into in order to enable others to utilize the PROGRAM in their academic activities. It is the
|
||||
% LICENSEE’s responsibility to ensure its proper use and the correctness of the results.”
|
||||
% 3. THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
% A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE LICENSOR, THE AUTHORS OR THE COPYRIGHT
|
||||
% HOLDERS BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE
|
||||
% OF THE PROGRAM OR OTHER DEALINGS IN THE PROGRAM.
|
||||
% 4. LICENSEE agrees that it will use the PROGRAM and any modifications, improvements, or derivatives of PROGRAM that LICENSEE may create (collectively,
|
||||
% "IMPROVEMENTS") solely for academic, non-commercial purposes and that any copy of PROGRAM or derivatives thereof shall be distributed only under the same
|
||||
% license as PROGRAM. The terms "academic, non-commercial", as used in this Agreement, mean academic or other scholarly research which (a) is not undertaken for
|
||||
% profit, or (b) is not intended to produce works, services, or data for commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged
|
||||
% in the commercial use, application or exploitation of works similar to the PROGRAM.
|
||||
% 5. LICENSEE agrees that it shall make the following acknowledgement in any publication resulting from the use of the PROGRAM or any translation of the code into
|
||||
% another computing language:
|
||||
% "Data processing was carried out using the cSAXS ptychography MATLAB package developed by the Science IT and the coherent X-ray scattering (CXS) groups, Paul
|
||||
% Scherrer Institut, Switzerland."
|
||||
%
|
||||
% Additionally, any publication using the package, or any translation of the code into another computing language should cite for difference map:
|
||||
% P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer, High-resolution scanning X-ray diffraction microscopy, Science 321, 379–382 (2008).
|
||||
% (doi: 10.1126/science.1158573),
|
||||
% for maximum likelihood:
|
||||
% P. Thibault and M. Guizar-Sicairos, Maximum-likelihood refinement for coherent diffractive imaging, New J. Phys. 14, 063004 (2012).
|
||||
% (doi: 10.1088/1367-2630/14/6/063004),
|
||||
% for mixed coherent modes:
|
||||
% P. Thibault and A. Menzel, Reconstructing state mixtures from diffraction measurements, Nature 494, 68–71 (2013). (doi: 10.1038/nature11806),
|
||||
% and/or for multislice:
|
||||
% E. H. R. Tsai, I. Usov, A. Diaz, A. Menzel, and M. Guizar-Sicairos, X-ray ptychography with extended depth of field, Opt. Express 24, 29089–29108 (2016).
|
||||
% (doi: 10.1364/OE.24.029089).
|
||||
% 6. Except for the above-mentioned acknowledgment, LICENSEE shall not use the PROGRAM title or the names or logos of LICENSOR, nor any adaptation thereof, nor the
|
||||
% names of any of its employees or laboratories, in any advertising, promotional or sales material without prior written consent obtained from LICENSOR in each case.
|
||||
% 7. Ownership of all rights, including copyright in the PROGRAM and in any material associated therewith, shall at all times remain with LICENSOR, and LICENSEE
|
||||
% agrees to preserve same. LICENSEE agrees not to use any portion of the PROGRAM or of any IMPROVEMENTS in any machine-readable form outside the PROGRAM, nor to
|
||||
% make any copies except for its internal use, without prior written consent of LICENSOR. LICENSEE agrees to place the following copyright notice on any such copies:
|
||||
% © All rights reserved. PAUL SCHERRER INSTITUT, Switzerland, Laboratory for Macromolecules and Bioimaging, 2017.
|
||||
% 8. The LICENSE shall not be construed to confer any rights upon LICENSEE by implication or otherwise except as specifically set forth herein.
|
||||
% 9. DISCLAIMER: LICENSEE shall be aware that Phase Focus Limited of Sheffield, UK has an international portfolio of patents and pending applications which relate
|
||||
% to ptychography and that the PROGRAM may be capable of being used in circumstances which may fall within the claims of one or more of the Phase Focus patents,
|
||||
% in particular of patent with international application number PCT/GB2005/001464. The LICENSOR explicitly declares not to indemnify the users of the software
|
||||
% in case Phase Focus or any other third party will open a legal action against the LICENSEE due to the use of the program.
|
||||
% 10. This Agreement shall be governed by the material laws of Switzerland and any dispute arising out of this Agreement or use of the PROGRAM shall be brought before
|
||||
% the courts of Zürich, Switzerland.
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
%% INITIALIZE TEST TEMPLATE
|
||||
% check / set default parameters for the test scripts
|
||||
|
||||
%% check initial paths
|
||||
if ~exist('ptycho_path','var')
|
||||
ptycho_path = fileparts(mfilename('fullpath'));
|
||||
ptycho_path = replace(ptycho_path, 'tests', '');
|
||||
end
|
||||
if ~exist('temporal_data_path', 'var'); temporal_data_path = './temp/'; end
|
||||
if ~exist('base_path', 'var'); base_path = './'; end
|
||||
if ~exist('plot_results', 'var'); plot_results = false; end
|
||||
if ~exist('plot_save_results', 'var'); plot_save_results = false; end
|
||||
if ~exist('verbose_level', 'var'); verbose_level = -2; end
|
||||
|
||||
addpath(ptycho_path)
|
||||
|
||||
|
||||
|
||||
%% run common template for initalization
|
||||
addpath(ptycho_path)
|
||||
run(fullfile( ptycho_path, 'template_ptycho.m'))
|
||||
|
||||
%% autoestimate the location of base package
|
||||
p.cSAXS_matlab_path = core.find_base_package();
|
||||
if ~exist('+math/argmax.m','file') % test existence of some function from the package
|
||||
addpath(p.cSAXS_matlab_path)
|
||||
end
|
||||
% make sure that it will be correct even when the current working folder is changed
|
||||
p.cSAXS_matlab_path = utils.abspath(p.cSAXS_matlab_path);
|
||||
|
||||
|
||||
%% general settings
|
||||
p = rmfield(p, 'engines');
|
||||
p. base_path = base_path; % the basic working path
|
||||
p. scan_number = []; % leave empty for artificial data
|
||||
p. src_metadata = 'artificial'; % load meta data from file; currently only 'spec' is supported;
|
||||
p. prepare.data_preparator = 'matlab'; % data preparator; 'python' or 'matlab'
|
||||
p. verbose_level = verbose_level;
|
||||
|
||||
%% plotting
|
||||
p. save.external = false; % Use a new Matlab session to run save final figures (saves ~6s per reconstruction). Please be aware that this might lead to an accumulation of Matlab sessions if your single reconstruction is very fast.
|
||||
p. plot.prepared_data = false; % plot prepared data
|
||||
p. save.store_images = 1; % Write nice jpegs in [p.base_path,'analysis/online/ptycho/'] if p.use_display = 0 then the figures are opened invisible in order to create the nice layout. It writes images in analysis/online/ptycho
|
||||
p. plot.fov_box = 1; % Plot the scanning FOV box on the object (both phase and amplitude)
|
||||
p. plot.log_scale = [1 1]; % Plot on log scale for x and y
|
||||
p. plot.positions = 1; % Plot the scanning positions
|
||||
if plot_results
|
||||
p. plot.interval = 100;
|
||||
else
|
||||
p. plot.interval = inf;
|
||||
end
|
||||
%% io
|
||||
p. ptycho_matlab_path = ''; % cSAXS ptycho package path
|
||||
p. prepare_data_path = temporal_data_path;
|
||||
clear eng eng0
|
||||
|
||||
|
||||
% Academic License Agreement
|
||||
%
|
||||
% Source Code
|
||||
%
|
||||
% Introduction
|
||||
% • This license agreement sets forth the terms and conditions under which the PAUL SCHERRER INSTITUT (PSI), CH-5232 Villigen-PSI, Switzerland (hereafter "LICENSOR")
|
||||
% will grant you (hereafter "LICENSEE") a royalty-free, non-exclusive license for academic, non-commercial purposes only (hereafter "LICENSE") to use the cSAXS
|
||||
% ptychography MATLAB package computer software program and associated documentation furnished hereunder (hereafter "PROGRAM").
|
||||
%
|
||||
% Terms and Conditions of the LICENSE
|
||||
% 1. LICENSOR grants to LICENSEE a royalty-free, non-exclusive license to use the PROGRAM for academic, non-commercial purposes, upon the terms and conditions
|
||||
% hereinafter set out and until termination of this license as set forth below.
|
||||
% 2. LICENSEE acknowledges that the PROGRAM is a research tool still in the development stage. The PROGRAM is provided without any related services, improvements
|
||||
% or warranties from LICENSOR and that the LICENSE is entered into in order to enable others to utilize the PROGRAM in their academic activities. It is the
|
||||
% LICENSEE’s responsibility to ensure its proper use and the correctness of the results.”
|
||||
% 3. THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
% A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE LICENSOR, THE AUTHORS OR THE COPYRIGHT
|
||||
% HOLDERS BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE
|
||||
% OF THE PROGRAM OR OTHER DEALINGS IN THE PROGRAM.
|
||||
% 4. LICENSEE agrees that it will use the PROGRAM and any modifications, improvements, or derivatives of PROGRAM that LICENSEE may create (collectively,
|
||||
% "IMPROVEMENTS") solely for academic, non-commercial purposes and that any copy of PROGRAM or derivatives thereof shall be distributed only under the same
|
||||
% license as PROGRAM. The terms "academic, non-commercial", as used in this Agreement, mean academic or other scholarly research which (a) is not undertaken for
|
||||
% profit, or (b) is not intended to produce works, services, or data for commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged
|
||||
% in the commercial use, application or exploitation of works similar to the PROGRAM.
|
||||
% 5. LICENSEE agrees that it shall make the following acknowledgement in any publication resulting from the use of the PROGRAM or any translation of the code into
|
||||
% another computing language:
|
||||
% "Data processing was carried out using the cSAXS ptychography MATLAB package developed by the Science IT and the coherent X-ray scattering (CXS) groups, Paul
|
||||
% Scherrer Institut, Switzerland."
|
||||
%
|
||||
% Additionally, any publication using the package, or any translation of the code into another computing language should cite for difference map:
|
||||
% P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer, High-resolution scanning X-ray diffraction microscopy, Science 321, 379–382 (2008).
|
||||
% (doi: 10.1126/science.1158573),
|
||||
% for maximum likelihood:
|
||||
% P. Thibault and M. Guizar-Sicairos, Maximum-likelihood refinement for coherent diffractive imaging, New J. Phys. 14, 063004 (2012).
|
||||
% (doi: 10.1088/1367-2630/14/6/063004),
|
||||
% for mixed coherent modes:
|
||||
% P. Thibault and A. Menzel, Reconstructing state mixtures from diffraction measurements, Nature 494, 68–71 (2013). (doi: 10.1038/nature11806),
|
||||
% and/or for multislice:
|
||||
% E. H. R. Tsai, I. Usov, A. Diaz, A. Menzel, and M. Guizar-Sicairos, X-ray ptychography with extended depth of field, Opt. Express 24, 29089–29108 (2016).
|
||||
% (doi: 10.1364/OE.24.029089).
|
||||
% 6. Except for the above-mentioned acknowledgment, LICENSEE shall not use the PROGRAM title or the names or logos of LICENSOR, nor any adaptation thereof, nor the
|
||||
% names of any of its employees or laboratories, in any advertising, promotional or sales material without prior written consent obtained from LICENSOR in each case.
|
||||
% 7. Ownership of all rights, including copyright in the PROGRAM and in any material associated therewith, shall at all times remain with LICENSOR, and LICENSEE
|
||||
% agrees to preserve same. LICENSEE agrees not to use any portion of the PROGRAM or of any IMPROVEMENTS in any machine-readable form outside the PROGRAM, nor to
|
||||
% make any copies except for its internal use, without prior written consent of LICENSOR. LICENSEE agrees to place the following copyright notice on any such copies:
|
||||
% © All rights reserved. PAUL SCHERRER INSTITUT, Switzerland, Laboratory for Macromolecules and Bioimaging, 2017.
|
||||
% 8. The LICENSE shall not be construed to confer any rights upon LICENSEE by implication or otherwise except as specifically set forth herein.
|
||||
% 9. DISCLAIMER: LICENSEE shall be aware that Phase Focus Limited of Sheffield, UK has an international portfolio of patents and pending applications which relate
|
||||
% to ptychography and that the PROGRAM may be capable of being used in circumstances which may fall within the claims of one or more of the Phase Focus patents,
|
||||
% in particular of patent with international application number PCT/GB2005/001464. The LICENSOR explicitly declares not to indemnify the users of the software
|
||||
% in case Phase Focus or any other third party will open a legal action against the LICENSEE due to the use of the program.
|
||||
% 10. This Agreement shall be governed by the material laws of Switzerland and any dispute arising out of this Agreement or use of the PROGRAM shall be brought before
|
||||
% the courts of Zürich, Switzerland.
|
||||
@@ -0,0 +1,137 @@
|
||||
%% Prepare the reconstruction
|
||||
|
||||
if ~exist('eng', 'var')
|
||||
return % return if no engine is provided
|
||||
end
|
||||
|
||||
fprintf('Creating dataset .... ')
|
||||
|
||||
[p, status] = core.ptycho_recons(p, true);
|
||||
|
||||
if status && all(isfinite(p.fmag(:))) && all(isfinite(p.object{1}(:))) && all(isfinite(p.probes(:)))
|
||||
fprintf('OK\n')
|
||||
else
|
||||
error('Data creator failed, quitting ... ')
|
||||
end
|
||||
|
||||
p. plot.windowautopos = true; % distribute the plotted windows
|
||||
p. plot.remove_phase_ramp = true;
|
||||
|
||||
p_0 = p; % store the initial p-structure
|
||||
|
||||
|
||||
%% get all engines
|
||||
utils.verbose(struct('prefix', {'ptycho'}))
|
||||
for ieng=1:length(p.engines)
|
||||
if ~check_option(p, 'preserve_previous_results')
|
||||
p = p_0;
|
||||
end
|
||||
p.current_engine_id = ieng;
|
||||
|
||||
% engine call
|
||||
if ~isfield(p.engines{ieng}, 'method'); p.engines{ieng}.method = '' ;end
|
||||
fprintf('Testing engine "%s" using method "%s" .... ', p.engines{ieng}.name, p.engines{ieng}.method)
|
||||
utils.verbose(struct('prefix', {p.engines{ieng}.name}))
|
||||
|
||||
try
|
||||
t_start = tic;
|
||||
[p, fdb] = core.run_engine(p, ieng);
|
||||
if p.ortho_probes && size(p.probes,4)>1
|
||||
% orthogonalize probes
|
||||
p.probes = core.probe_modes_ortho(p.probes);
|
||||
end
|
||||
|
||||
warning on
|
||||
warning off backtrace
|
||||
if fdb.status.status ~= 0
|
||||
fprintf('failed\n')
|
||||
warning('Engine %s returned with exit status %d from %s [%d].\n', p.engines{ieng}.name, fdb.status.status, fdb.status.ln(1).name, fdb.status.ln(1).line);
|
||||
elseif any(~isfinite(p.object{1}(:))) || any(~isfinite(p.probes(:)))
|
||||
warning('Engine %s returned non finite values in reconstrutions',p.engines{ieng}.name)
|
||||
else
|
||||
fprintf('OK \tTime: %3.2gs\n', (toc(t_start)))
|
||||
p.plot.extratitlestring = sprintf('engine "%s" using method "%s"', p.engines{ieng}.name, p.engines{ieng}.method);
|
||||
if plot_save_results && plot_results
|
||||
p.use_display = true;
|
||||
p.save.save_reconstructions = false; % prevent writting to disk
|
||||
[p] = core.save.save_results(p, true);
|
||||
elseif plot_results && ~plot_save_results
|
||||
core.analysis.plot_results(p)
|
||||
elseif plot_save_results
|
||||
p.use_display = false;
|
||||
p.save.save_reconstructions = false; % prevent writting to disk
|
||||
[p] = core.save.save_results(p, true);
|
||||
p.use_display = true;
|
||||
end
|
||||
|
||||
end
|
||||
catch err
|
||||
fprintf(1, 'failed\n')
|
||||
warning(err.getReport)
|
||||
end
|
||||
end
|
||||
|
||||
% delete temporal data
|
||||
for path = p.save_path
|
||||
rmdir(path{1}, 's')
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
% Academic License Agreement
|
||||
%
|
||||
% Source Code
|
||||
%
|
||||
% Introduction
|
||||
% • This license agreement sets forth the terms and conditions under which the PAUL SCHERRER INSTITUT (PSI), CH-5232 Villigen-PSI, Switzerland (hereafter "LICENSOR")
|
||||
% will grant you (hereafter "LICENSEE") a royalty-free, non-exclusive license for academic, non-commercial purposes only (hereafter "LICENSE") to use the cSAXS
|
||||
% ptychography MATLAB package computer software program and associated documentation furnished hereunder (hereafter "PROGRAM").
|
||||
%
|
||||
% Terms and Conditions of the LICENSE
|
||||
% 1. LICENSOR grants to LICENSEE a royalty-free, non-exclusive license to use the PROGRAM for academic, non-commercial purposes, upon the terms and conditions
|
||||
% hereinafter set out and until termination of this license as set forth below.
|
||||
% 2. LICENSEE acknowledges that the PROGRAM is a research tool still in the development stage. The PROGRAM is provided without any related services, improvements
|
||||
% or warranties from LICENSOR and that the LICENSE is entered into in order to enable others to utilize the PROGRAM in their academic activities. It is the
|
||||
% LICENSEE’s responsibility to ensure its proper use and the correctness of the results.”
|
||||
% 3. THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
% A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE LICENSOR, THE AUTHORS OR THE COPYRIGHT
|
||||
% HOLDERS BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE
|
||||
% OF THE PROGRAM OR OTHER DEALINGS IN THE PROGRAM.
|
||||
% 4. LICENSEE agrees that it will use the PROGRAM and any modifications, improvements, or derivatives of PROGRAM that LICENSEE may create (collectively,
|
||||
% "IMPROVEMENTS") solely for academic, non-commercial purposes and that any copy of PROGRAM or derivatives thereof shall be distributed only under the same
|
||||
% license as PROGRAM. The terms "academic, non-commercial", as used in this Agreement, mean academic or other scholarly research which (a) is not undertaken for
|
||||
% profit, or (b) is not intended to produce works, services, or data for commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged
|
||||
% in the commercial use, application or exploitation of works similar to the PROGRAM.
|
||||
% 5. LICENSEE agrees that it shall make the following acknowledgement in any publication resulting from the use of the PROGRAM or any translation of the code into
|
||||
% another computing language:
|
||||
% "Data processing was carried out using the cSAXS ptychography MATLAB package developed by the Science IT and the coherent X-ray scattering (CXS) groups, Paul
|
||||
% Scherrer Institut, Switzerland."
|
||||
%
|
||||
% Additionally, any publication using the package, or any translation of the code into another computing language should cite for difference map:
|
||||
% P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer, High-resolution scanning X-ray diffraction microscopy, Science 321, 379–382 (2008).
|
||||
% (doi: 10.1126/science.1158573),
|
||||
% for maximum likelihood:
|
||||
% P. Thibault and M. Guizar-Sicairos, Maximum-likelihood refinement for coherent diffractive imaging, New J. Phys. 14, 063004 (2012).
|
||||
% (doi: 10.1088/1367-2630/14/6/063004),
|
||||
% for mixed coherent modes:
|
||||
% P. Thibault and A. Menzel, Reconstructing state mixtures from diffraction measurements, Nature 494, 68–71 (2013). (doi: 10.1038/nature11806),
|
||||
% and/or for multislice:
|
||||
% E. H. R. Tsai, I. Usov, A. Diaz, A. Menzel, and M. Guizar-Sicairos, X-ray ptychography with extended depth of field, Opt. Express 24, 29089–29108 (2016).
|
||||
% (doi: 10.1364/OE.24.029089).
|
||||
% 6. Except for the above-mentioned acknowledgment, LICENSEE shall not use the PROGRAM title or the names or logos of LICENSOR, nor any adaptation thereof, nor the
|
||||
% names of any of its employees or laboratories, in any advertising, promotional or sales material without prior written consent obtained from LICENSOR in each case.
|
||||
% 7. Ownership of all rights, including copyright in the PROGRAM and in any material associated therewith, shall at all times remain with LICENSOR, and LICENSEE
|
||||
% agrees to preserve same. LICENSEE agrees not to use any portion of the PROGRAM or of any IMPROVEMENTS in any machine-readable form outside the PROGRAM, nor to
|
||||
% make any copies except for its internal use, without prior written consent of LICENSOR. LICENSEE agrees to place the following copyright notice on any such copies:
|
||||
% © All rights reserved. PAUL SCHERRER INSTITUT, Switzerland, Laboratory for Macromolecules and Bioimaging, 2017.
|
||||
% 8. The LICENSE shall not be construed to confer any rights upon LICENSEE by implication or otherwise except as specifically set forth herein.
|
||||
% 9. DISCLAIMER: LICENSEE shall be aware that Phase Focus Limited of Sheffield, UK has an international portfolio of patents and pending applications which relate
|
||||
% to ptychography and that the PROGRAM may be capable of being used in circumstances which may fall within the claims of one or more of the Phase Focus patents,
|
||||
% in particular of patent with international application number PCT/GB2005/001464. The LICENSOR explicitly declares not to indemnify the users of the software
|
||||
% in case Phase Focus or any other third party will open a legal action against the LICENSEE due to the use of the program.
|
||||
% 10. This Agreement shall be governed by the material laws of Switzerland and any dispute arising out of this Agreement or use of the PROGRAM shall be brought before
|
||||
% the courts of Zürich, Switzerland.
|
||||
@@ -0,0 +1,88 @@
|
||||
% template for artificial data generation for tests of multilayer
|
||||
% reconstructions
|
||||
|
||||
ptycho_path = fileparts(mfilename('fullpath'));
|
||||
ptycho_path = replace(ptycho_path, 'tests', '');
|
||||
run(fullfile( ptycho_path, 'template_artificial_data.m'))
|
||||
|
||||
p.z = 0.7; % [m] sample to camera distance
|
||||
p.simulation.photons_per_pixel = inf; % Photon count; if photons_per_pixel = inf -> no noise
|
||||
|
||||
p.simulation.energy = 6.2; % Simulated energy
|
||||
p.simulation.delta = []; % Simulated refractive index (n = 1-delta+1j*beta); leave empty for CXRO values
|
||||
p.simulation.beta = []; % Simulated refractive index (n = 1-delta+1j*beta); leave empty for CXRO values
|
||||
p.simulation.material_density = [-1];
|
||||
% p.simulation.material = {'Al2O3'}; % Simulated material
|
||||
% p.simulation.ref_index = 1-1.2061e-05; % - 2.5742e-07i;
|
||||
p.simulation.dataset = {'3D_phantom'}; % Simulated sample; see +core/+simulations/create_object for more information
|
||||
p.simulation.rotation_angle = []; % apply rotation angle [degrees] on the 3D phantom dataset, [] == ignore
|
||||
p.simulation.flip_objects_180deg = []; % Simulated 0 vs 180 deg projection
|
||||
p.simulation.objheight = 5e-6; % Object height of the simulated sample
|
||||
p.simulation.apply_sub_px_shifts = false; % Allow sub-pixel shifts
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
p.simulation.thickness = 200e-6; %%% set effective thickness used for multilayer propagation, 0 == no propagation
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
p.scan. ly = 1e-6; % round_roi scan: width of the roi
|
||||
p.scan. lx = 3.5e-6; % round_roi scan: height of the roi
|
||||
p.scan. step = 0.2e-6; % fermat: step size
|
||||
|
||||
% p.simulation.material = {'Al2O3'}; % Simulated material
|
||||
p.simulation.ref_index = 1 -2.1372e-05 - 4.0946e-07i; % Al2O3 - loading from database for each angle is too slow
|
||||
|
||||
|
||||
% Academic License Agreement
|
||||
%
|
||||
% Source Code
|
||||
%
|
||||
% Introduction
|
||||
% • This license agreement sets forth the terms and conditions under which the PAUL SCHERRER INSTITUT (PSI), CH-5232 Villigen-PSI, Switzerland (hereafter "LICENSOR")
|
||||
% will grant you (hereafter "LICENSEE") a royalty-free, non-exclusive license for academic, non-commercial purposes only (hereafter "LICENSE") to use the cSAXS
|
||||
% ptychography MATLAB package computer software program and associated documentation furnished hereunder (hereafter "PROGRAM").
|
||||
%
|
||||
% Terms and Conditions of the LICENSE
|
||||
% 1. LICENSOR grants to LICENSEE a royalty-free, non-exclusive license to use the PROGRAM for academic, non-commercial purposes, upon the terms and conditions
|
||||
% hereinafter set out and until termination of this license as set forth below.
|
||||
% 2. LICENSEE acknowledges that the PROGRAM is a research tool still in the development stage. The PROGRAM is provided without any related services, improvements
|
||||
% or warranties from LICENSOR and that the LICENSE is entered into in order to enable others to utilize the PROGRAM in their academic activities. It is the
|
||||
% LICENSEE’s responsibility to ensure its proper use and the correctness of the results.”
|
||||
% 3. THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
% A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE LICENSOR, THE AUTHORS OR THE COPYRIGHT
|
||||
% HOLDERS BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE
|
||||
% OF THE PROGRAM OR OTHER DEALINGS IN THE PROGRAM.
|
||||
% 4. LICENSEE agrees that it will use the PROGRAM and any modifications, improvements, or derivatives of PROGRAM that LICENSEE may create (collectively,
|
||||
% "IMPROVEMENTS") solely for academic, non-commercial purposes and that any copy of PROGRAM or derivatives thereof shall be distributed only under the same
|
||||
% license as PROGRAM. The terms "academic, non-commercial", as used in this Agreement, mean academic or other scholarly research which (a) is not undertaken for
|
||||
% profit, or (b) is not intended to produce works, services, or data for commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged
|
||||
% in the commercial use, application or exploitation of works similar to the PROGRAM.
|
||||
% 5. LICENSEE agrees that it shall make the following acknowledgement in any publication resulting from the use of the PROGRAM or any translation of the code into
|
||||
% another computing language:
|
||||
% "Data processing was carried out using the cSAXS ptychography MATLAB package developed by the Science IT and the coherent X-ray scattering (CXS) groups, Paul
|
||||
% Scherrer Institut, Switzerland."
|
||||
%
|
||||
% Additionally, any publication using the package, or any translation of the code into another computing language should cite for difference map:
|
||||
% P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer, High-resolution scanning X-ray diffraction microscopy, Science 321, 379–382 (2008).
|
||||
% (doi: 10.1126/science.1158573),
|
||||
% for maximum likelihood:
|
||||
% P. Thibault and M. Guizar-Sicairos, Maximum-likelihood refinement for coherent diffractive imaging, New J. Phys. 14, 063004 (2012).
|
||||
% (doi: 10.1088/1367-2630/14/6/063004),
|
||||
% for mixed coherent modes:
|
||||
% P. Thibault and A. Menzel, Reconstructing state mixtures from diffraction measurements, Nature 494, 68–71 (2013). (doi: 10.1038/nature11806),
|
||||
% and/or for multislice:
|
||||
% E. H. R. Tsai, I. Usov, A. Diaz, A. Menzel, and M. Guizar-Sicairos, X-ray ptychography with extended depth of field, Opt. Express 24, 29089–29108 (2016).
|
||||
% (doi: 10.1364/OE.24.029089).
|
||||
% 6. Except for the above-mentioned acknowledgment, LICENSEE shall not use the PROGRAM title or the names or logos of LICENSOR, nor any adaptation thereof, nor the
|
||||
% names of any of its employees or laboratories, in any advertising, promotional or sales material without prior written consent obtained from LICENSOR in each case.
|
||||
% 7. Ownership of all rights, including copyright in the PROGRAM and in any material associated therewith, shall at all times remain with LICENSOR, and LICENSEE
|
||||
% agrees to preserve same. LICENSEE agrees not to use any portion of the PROGRAM or of any IMPROVEMENTS in any machine-readable form outside the PROGRAM, nor to
|
||||
% make any copies except for its internal use, without prior written consent of LICENSOR. LICENSEE agrees to place the following copyright notice on any such copies:
|
||||
% © All rights reserved. PAUL SCHERRER INSTITUT, Switzerland, Laboratory for Macromolecules and Bioimaging, 2017.
|
||||
% 8. The LICENSE shall not be construed to confer any rights upon LICENSEE by implication or otherwise except as specifically set forth herein.
|
||||
% 9. DISCLAIMER: LICENSEE shall be aware that Phase Focus Limited of Sheffield, UK has an international portfolio of patents and pending applications which relate
|
||||
% to ptychography and that the PROGRAM may be capable of being used in circumstances which may fall within the claims of one or more of the Phase Focus patents,
|
||||
% in particular of patent with international application number PCT/GB2005/001464. The LICENSOR explicitly declares not to indemnify the users of the software
|
||||
% in case Phase Focus or any other third party will open a legal action against the LICENSEE due to the use of the program.
|
||||
% 10. This Agreement shall be governed by the material laws of Switzerland and any dispute arising out of this Agreement or use of the PROGRAM shall be brought before
|
||||
% the courts of Zürich, Switzerland.
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
% template for artificial data generation for tests of multilayer
|
||||
% reconstructions
|
||||
%
|
||||
% see template_artificial_data.m for the full list of default parameters
|
||||
|
||||
ptycho_path = fileparts(mfilename('fullpath'));
|
||||
ptycho_path = replace(ptycho_path, 'tests', '');
|
||||
run(fullfile( ptycho_path, 'template_artificial_data.m'))
|
||||
|
||||
p.z = 1.4; % [m] sample to camera distance
|
||||
p.simulation.dataset = {[1,6,7]}; %, [1,6,7]}; % Simulated sample; see +core/+simulations/create_object for more information
|
||||
p.simulation.thickness = 70e-6; % Total thickness of the simulated sample if multiple layers are provided
|
||||
p.simulation.photons_per_pixel = inf; % Photon count; if photons_per_pixel = inf -> no noise
|
||||
|
||||
p. scan.lx = 7e-6; % round_roi scan: width of the roi
|
||||
p. scan.ly = 10e-6; % round_roi scan: height of the roi
|
||||
p. scan.step = 0.7e-6; % fermat: step size
|
||||
|
||||
|
||||
p. model_probe = 0; % Use model probe
|
||||
p. initial_probe_file = 'utils/imgs/probe_PSI.mat'; % Use probe from this mat-file (not used if model_probe is true)
|
||||
p. probe_file_propagation = [0.1e-3]; % Distance for propagating the probe from file in meters, = [] to ignore
|
||||
|
||||
|
||||
% Academic License Agreement
|
||||
%
|
||||
% Source Code
|
||||
%
|
||||
% Introduction
|
||||
% • This license agreement sets forth the terms and conditions under which the PAUL SCHERRER INSTITUT (PSI), CH-5232 Villigen-PSI, Switzerland (hereafter "LICENSOR")
|
||||
% will grant you (hereafter "LICENSEE") a royalty-free, non-exclusive license for academic, non-commercial purposes only (hereafter "LICENSE") to use the cSAXS
|
||||
% ptychography MATLAB package computer software program and associated documentation furnished hereunder (hereafter "PROGRAM").
|
||||
%
|
||||
% Terms and Conditions of the LICENSE
|
||||
% 1. LICENSOR grants to LICENSEE a royalty-free, non-exclusive license to use the PROGRAM for academic, non-commercial purposes, upon the terms and conditions
|
||||
% hereinafter set out and until termination of this license as set forth below.
|
||||
% 2. LICENSEE acknowledges that the PROGRAM is a research tool still in the development stage. The PROGRAM is provided without any related services, improvements
|
||||
% or warranties from LICENSOR and that the LICENSE is entered into in order to enable others to utilize the PROGRAM in their academic activities. It is the
|
||||
% LICENSEE’s responsibility to ensure its proper use and the correctness of the results.”
|
||||
% 3. THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
% A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE LICENSOR, THE AUTHORS OR THE COPYRIGHT
|
||||
% HOLDERS BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE
|
||||
% OF THE PROGRAM OR OTHER DEALINGS IN THE PROGRAM.
|
||||
% 4. LICENSEE agrees that it will use the PROGRAM and any modifications, improvements, or derivatives of PROGRAM that LICENSEE may create (collectively,
|
||||
% "IMPROVEMENTS") solely for academic, non-commercial purposes and that any copy of PROGRAM or derivatives thereof shall be distributed only under the same
|
||||
% license as PROGRAM. The terms "academic, non-commercial", as used in this Agreement, mean academic or other scholarly research which (a) is not undertaken for
|
||||
% profit, or (b) is not intended to produce works, services, or data for commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged
|
||||
% in the commercial use, application or exploitation of works similar to the PROGRAM.
|
||||
% 5. LICENSEE agrees that it shall make the following acknowledgement in any publication resulting from the use of the PROGRAM or any translation of the code into
|
||||
% another computing language:
|
||||
% "Data processing was carried out using the cSAXS ptychography MATLAB package developed by the Science IT and the coherent X-ray scattering (CXS) groups, Paul
|
||||
% Scherrer Institut, Switzerland."
|
||||
%
|
||||
% Additionally, any publication using the package, or any translation of the code into another computing language should cite for difference map:
|
||||
% P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer, High-resolution scanning X-ray diffraction microscopy, Science 321, 379–382 (2008).
|
||||
% (doi: 10.1126/science.1158573),
|
||||
% for maximum likelihood:
|
||||
% P. Thibault and M. Guizar-Sicairos, Maximum-likelihood refinement for coherent diffractive imaging, New J. Phys. 14, 063004 (2012).
|
||||
% (doi: 10.1088/1367-2630/14/6/063004),
|
||||
% for mixed coherent modes:
|
||||
% P. Thibault and A. Menzel, Reconstructing state mixtures from diffraction measurements, Nature 494, 68–71 (2013). (doi: 10.1038/nature11806),
|
||||
% and/or for multislice:
|
||||
% E. H. R. Tsai, I. Usov, A. Diaz, A. Menzel, and M. Guizar-Sicairos, X-ray ptychography with extended depth of field, Opt. Express 24, 29089–29108 (2016).
|
||||
% (doi: 10.1364/OE.24.029089).
|
||||
% 6. Except for the above-mentioned acknowledgment, LICENSEE shall not use the PROGRAM title or the names or logos of LICENSOR, nor any adaptation thereof, nor the
|
||||
% names of any of its employees or laboratories, in any advertising, promotional or sales material without prior written consent obtained from LICENSOR in each case.
|
||||
% 7. Ownership of all rights, including copyright in the PROGRAM and in any material associated therewith, shall at all times remain with LICENSOR, and LICENSEE
|
||||
% agrees to preserve same. LICENSEE agrees not to use any portion of the PROGRAM or of any IMPROVEMENTS in any machine-readable form outside the PROGRAM, nor to
|
||||
% make any copies except for its internal use, without prior written consent of LICENSOR. LICENSEE agrees to place the following copyright notice on any such copies:
|
||||
% © All rights reserved. PAUL SCHERRER INSTITUT, Switzerland, Laboratory for Macromolecules and Bioimaging, 2017.
|
||||
% 8. The LICENSE shall not be construed to confer any rights upon LICENSEE by implication or otherwise except as specifically set forth herein.
|
||||
% 9. DISCLAIMER: LICENSEE shall be aware that Phase Focus Limited of Sheffield, UK has an international portfolio of patents and pending applications which relate
|
||||
% to ptychography and that the PROGRAM may be capable of being used in circumstances which may fall within the claims of one or more of the Phase Focus patents,
|
||||
% in particular of patent with international application number PCT/GB2005/001464. The LICENSOR explicitly declares not to indemnify the users of the software
|
||||
% in case Phase Focus or any other third party will open a legal action against the LICENSEE due to the use of the program.
|
||||
% 10. This Agreement shall be governed by the material laws of Switzerland and any dispute arising out of this Agreement or use of the PROGRAM shall be brought before
|
||||
% the courts of Zürich, Switzerland.
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
% template for artificial data generation for standard methods tests
|
||||
%
|
||||
% see template_artificial_data.m for the full list of default parameters
|
||||
|
||||
ptycho_path = fileparts(mfilename('fullpath'));
|
||||
ptycho_path = replace(ptycho_path, 'tests', '');
|
||||
run(fullfile( ptycho_path, 'template_artificial_data.m'))
|
||||
|
||||
|
||||
p.simulation.dataset = {6}; % Simulated sample; see +core/+simulations/create_object for more information
|
||||
|
||||
|
||||
p. scan.lx = 10e-6; % round_roi scan: width of the roi
|
||||
p. scan.ly = 10e-6; % round_roi scan: height of the roi
|
||||
p. scan.step = 1.5e-6; % fermat: step size
|
||||
|
||||
p. model_probe = 0; % Use model probe
|
||||
p. initial_probe_file = 'utils/imgs/probe_PSI.mat'; % Use probe from this mat-file (not used if model_probe is true)
|
||||
p. probe_file_propagation = []; % Distance for propagating the probe from file in meters, = [] to ignore
|
||||
|
||||
|
||||
|
||||
% Academic License Agreement
|
||||
%
|
||||
% Source Code
|
||||
%
|
||||
% Introduction
|
||||
% • This license agreement sets forth the terms and conditions under which the PAUL SCHERRER INSTITUT (PSI), CH-5232 Villigen-PSI, Switzerland (hereafter "LICENSOR")
|
||||
% will grant you (hereafter "LICENSEE") a royalty-free, non-exclusive license for academic, non-commercial purposes only (hereafter "LICENSE") to use the cSAXS
|
||||
% ptychography MATLAB package computer software program and associated documentation furnished hereunder (hereafter "PROGRAM").
|
||||
%
|
||||
% Terms and Conditions of the LICENSE
|
||||
% 1. LICENSOR grants to LICENSEE a royalty-free, non-exclusive license to use the PROGRAM for academic, non-commercial purposes, upon the terms and conditions
|
||||
% hereinafter set out and until termination of this license as set forth below.
|
||||
% 2. LICENSEE acknowledges that the PROGRAM is a research tool still in the development stage. The PROGRAM is provided without any related services, improvements
|
||||
% or warranties from LICENSOR and that the LICENSE is entered into in order to enable others to utilize the PROGRAM in their academic activities. It is the
|
||||
% LICENSEE’s responsibility to ensure its proper use and the correctness of the results.”
|
||||
% 3. THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
% A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE LICENSOR, THE AUTHORS OR THE COPYRIGHT
|
||||
% HOLDERS BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE
|
||||
% OF THE PROGRAM OR OTHER DEALINGS IN THE PROGRAM.
|
||||
% 4. LICENSEE agrees that it will use the PROGRAM and any modifications, improvements, or derivatives of PROGRAM that LICENSEE may create (collectively,
|
||||
% "IMPROVEMENTS") solely for academic, non-commercial purposes and that any copy of PROGRAM or derivatives thereof shall be distributed only under the same
|
||||
% license as PROGRAM. The terms "academic, non-commercial", as used in this Agreement, mean academic or other scholarly research which (a) is not undertaken for
|
||||
% profit, or (b) is not intended to produce works, services, or data for commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged
|
||||
% in the commercial use, application or exploitation of works similar to the PROGRAM.
|
||||
% 5. LICENSEE agrees that it shall make the following acknowledgement in any publication resulting from the use of the PROGRAM or any translation of the code into
|
||||
% another computing language:
|
||||
% "Data processing was carried out using the cSAXS ptychography MATLAB package developed by the Science IT and the coherent X-ray scattering (CXS) groups, Paul
|
||||
% Scherrer Institut, Switzerland."
|
||||
%
|
||||
% Additionally, any publication using the package, or any translation of the code into another computing language should cite for difference map:
|
||||
% P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer, High-resolution scanning X-ray diffraction microscopy, Science 321, 379–382 (2008).
|
||||
% (doi: 10.1126/science.1158573),
|
||||
% for maximum likelihood:
|
||||
% P. Thibault and M. Guizar-Sicairos, Maximum-likelihood refinement for coherent diffractive imaging, New J. Phys. 14, 063004 (2012).
|
||||
% (doi: 10.1088/1367-2630/14/6/063004),
|
||||
% for mixed coherent modes:
|
||||
% P. Thibault and A. Menzel, Reconstructing state mixtures from diffraction measurements, Nature 494, 68–71 (2013). (doi: 10.1038/nature11806),
|
||||
% and/or for multislice:
|
||||
% E. H. R. Tsai, I. Usov, A. Diaz, A. Menzel, and M. Guizar-Sicairos, X-ray ptychography with extended depth of field, Opt. Express 24, 29089–29108 (2016).
|
||||
% (doi: 10.1364/OE.24.029089).
|
||||
% 6. Except for the above-mentioned acknowledgment, LICENSEE shall not use the PROGRAM title or the names or logos of LICENSOR, nor any adaptation thereof, nor the
|
||||
% names of any of its employees or laboratories, in any advertising, promotional or sales material without prior written consent obtained from LICENSOR in each case.
|
||||
% 7. Ownership of all rights, including copyright in the PROGRAM and in any material associated therewith, shall at all times remain with LICENSOR, and LICENSEE
|
||||
% agrees to preserve same. LICENSEE agrees not to use any portion of the PROGRAM or of any IMPROVEMENTS in any machine-readable form outside the PROGRAM, nor to
|
||||
% make any copies except for its internal use, without prior written consent of LICENSOR. LICENSEE agrees to place the following copyright notice on any such copies:
|
||||
% © All rights reserved. PAUL SCHERRER INSTITUT, Switzerland, Laboratory for Macromolecules and Bioimaging, 2017.
|
||||
% 8. The LICENSE shall not be construed to confer any rights upon LICENSEE by implication or otherwise except as specifically set forth herein.
|
||||
% 9. DISCLAIMER: LICENSEE shall be aware that Phase Focus Limited of Sheffield, UK has an international portfolio of patents and pending applications which relate
|
||||
% to ptychography and that the PROGRAM may be capable of being used in circumstances which may fall within the claims of one or more of the Phase Focus patents,
|
||||
% in particular of patent with international application number PCT/GB2005/001464. The LICENSOR explicitly declares not to indemnify the users of the software
|
||||
% in case Phase Focus or any other third party will open a legal action against the LICENSEE due to the use of the program.
|
||||
% 10. This Agreement shall be governed by the material laws of Switzerland and any dispute arising out of this Agreement or use of the PROGRAM shall be brought before
|
||||
% the courts of Zürich, Switzerland.
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
% template for artificial data generation for standard methods tests
|
||||
%
|
||||
% see template_artificial_data.m for the full list of default parameters
|
||||
|
||||
ptycho_path = fileparts(mfilename('fullpath'));
|
||||
ptycho_path = replace(ptycho_path, 'tests', '');
|
||||
run(fullfile( ptycho_path, 'template_artificial_data.m'))
|
||||
|
||||
|
||||
p.simulation.dataset = {8, 8}; % Simulated sample; see +core/+simulations/create_object for more information
|
||||
|
||||
p. z = 5;
|
||||
p. scan.lx = 20e-6; % round_roi scan: width of the roi
|
||||
p. scan.ly = 20e-6; % round_roi scan: height of the roi
|
||||
p. scan.step = 1.2e-6; % fermat: step size
|
||||
|
||||
p. model_probe = 0; % Use model probe
|
||||
p. initial_probe_file = 'utils/imgs/probe_PSI.mat'; % Use probe from this mat-file (not used if model_probe is true)
|
||||
p. probe_file_propagation = []; % Distance for propagating the probe from file in meters, = [] to ignore
|
||||
|
||||
if utils.verbose > -1
|
||||
warning off backtrace
|
||||
warning('Modified affine matrix')
|
||||
warning on backtrace
|
||||
end
|
||||
|
||||
|
||||
% % apply affine matrix to data which is not know by the ptycho code
|
||||
p. simulation. affine_matrix = eye(2); % apply inversion of the affine matrix to data so that p. affine_matrix = affmat; is the ideal correction
|
||||
|
||||
p. simulation.sample_rotation_angles = [0,0,0.1]; % simulate camera misrotate by 0.1 degree
|
||||
|
||||
%% make camera distance error
|
||||
p. simulation.z = p.z * 1.005;
|
||||
|
||||
|
||||
|
||||
p.simulation.flip_objects_180deg = [false, true]; % Simulated 0 vs 180 deg projection
|
||||
p.positions_pad = [0, 0];
|
||||
|
||||
|
||||
|
||||
% Academic License Agreement
|
||||
%
|
||||
% Source Code
|
||||
%
|
||||
% Introduction
|
||||
% • This license agreement sets forth the terms and conditions under which the PAUL SCHERRER INSTITUT (PSI), CH-5232 Villigen-PSI, Switzerland (hereafter "LICENSOR")
|
||||
% will grant you (hereafter "LICENSEE") a royalty-free, non-exclusive license for academic, non-commercial purposes only (hereafter "LICENSE") to use the cSAXS
|
||||
% ptychography MATLAB package computer software program and associated documentation furnished hereunder (hereafter "PROGRAM").
|
||||
%
|
||||
% Terms and Conditions of the LICENSE
|
||||
% 1. LICENSOR grants to LICENSEE a royalty-free, non-exclusive license to use the PROGRAM for academic, non-commercial purposes, upon the terms and conditions
|
||||
% hereinafter set out and until termination of this license as set forth below.
|
||||
% 2. LICENSEE acknowledges that the PROGRAM is a research tool still in the development stage. The PROGRAM is provided without any related services, improvements
|
||||
% or warranties from LICENSOR and that the LICENSE is entered into in order to enable others to utilize the PROGRAM in their academic activities. It is the
|
||||
% LICENSEE’s responsibility to ensure its proper use and the correctness of the results.”
|
||||
% 3. THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
% A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE LICENSOR, THE AUTHORS OR THE COPYRIGHT
|
||||
% HOLDERS BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE
|
||||
% OF THE PROGRAM OR OTHER DEALINGS IN THE PROGRAM.
|
||||
% 4. LICENSEE agrees that it will use the PROGRAM and any modifications, improvements, or derivatives of PROGRAM that LICENSEE may create (collectively,
|
||||
% "IMPROVEMENTS") solely for academic, non-commercial purposes and that any copy of PROGRAM or derivatives thereof shall be distributed only under the same
|
||||
% license as PROGRAM. The terms "academic, non-commercial", as used in this Agreement, mean academic or other scholarly research which (a) is not undertaken for
|
||||
% profit, or (b) is not intended to produce works, services, or data for commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged
|
||||
% in the commercial use, application or exploitation of works similar to the PROGRAM.
|
||||
% 5. LICENSEE agrees that it shall make the following acknowledgement in any publication resulting from the use of the PROGRAM or any translation of the code into
|
||||
% another computing language:
|
||||
% "Data processing was carried out using the cSAXS ptychography MATLAB package developed by the Science IT and the coherent X-ray scattering (CXS) groups, Paul
|
||||
% Scherrer Institut, Switzerland."
|
||||
%
|
||||
% Additionally, any publication using the package, or any translation of the code into another computing language should cite for difference map:
|
||||
% P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer, High-resolution scanning X-ray diffraction microscopy, Science 321, 379–382 (2008).
|
||||
% (doi: 10.1126/science.1158573),
|
||||
% for maximum likelihood:
|
||||
% P. Thibault and M. Guizar-Sicairos, Maximum-likelihood refinement for coherent diffractive imaging, New J. Phys. 14, 063004 (2012).
|
||||
% (doi: 10.1088/1367-2630/14/6/063004),
|
||||
% for mixed coherent modes:
|
||||
% P. Thibault and A. Menzel, Reconstructing state mixtures from diffraction measurements, Nature 494, 68–71 (2013). (doi: 10.1038/nature11806),
|
||||
% and/or for multislice:
|
||||
% E. H. R. Tsai, I. Usov, A. Diaz, A. Menzel, and M. Guizar-Sicairos, X-ray ptychography with extended depth of field, Opt. Express 24, 29089–29108 (2016).
|
||||
% (doi: 10.1364/OE.24.029089).
|
||||
% 6. Except for the above-mentioned acknowledgment, LICENSEE shall not use the PROGRAM title or the names or logos of LICENSOR, nor any adaptation thereof, nor the
|
||||
% names of any of its employees or laboratories, in any advertising, promotional or sales material without prior written consent obtained from LICENSOR in each case.
|
||||
% 7. Ownership of all rights, including copyright in the PROGRAM and in any material associated therewith, shall at all times remain with LICENSOR, and LICENSEE
|
||||
% agrees to preserve same. LICENSEE agrees not to use any portion of the PROGRAM or of any IMPROVEMENTS in any machine-readable form outside the PROGRAM, nor to
|
||||
% make any copies except for its internal use, without prior written consent of LICENSOR. LICENSEE agrees to place the following copyright notice on any such copies:
|
||||
% © All rights reserved. PAUL SCHERRER INSTITUT, Switzerland, Laboratory for Macromolecules and Bioimaging, 2017.
|
||||
% 8. The LICENSE shall not be construed to confer any rights upon LICENSEE by implication or otherwise except as specifically set forth herein.
|
||||
% 9. DISCLAIMER: LICENSEE shall be aware that Phase Focus Limited of Sheffield, UK has an international portfolio of patents and pending applications which relate
|
||||
% to ptychography and that the PROGRAM may be capable of being used in circumstances which may fall within the claims of one or more of the Phase Focus patents,
|
||||
% in particular of patent with international application number PCT/GB2005/001464. The LICENSOR explicitly declares not to indemnify the users of the software
|
||||
% in case Phase Focus or any other third party will open a legal action against the LICENSEE due to the use of the program.
|
||||
% 10. This Agreement shall be governed by the material laws of Switzerland and any dispute arising out of this Agreement or use of the PROGRAM shall be brought before
|
||||
% the courts of Zürich, Switzerland.
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
% template for artificial data generation for standard methods tests
|
||||
%
|
||||
% see template_artificial_data.m for the full list of default parameters
|
||||
|
||||
ptycho_path = fileparts(mfilename('fullpath'));
|
||||
ptycho_path = replace(ptycho_path, 'tests', '');
|
||||
run(fullfile( ptycho_path, 'template_artificial_data.m'))
|
||||
|
||||
|
||||
p.simulation.dataset = {1, 1}; % Simulated sample; see +core/+simulations/create_object for more information
|
||||
p.simulation.photons_per_pixel = 5e3; % Photon count; if photons_per_pixel = inf -> no noise
|
||||
|
||||
|
||||
p. scan.lx = 10e-6; % round_roi scan: width of the roi
|
||||
p. scan.ly = 10e-6; % round_roi scan: height of the roi
|
||||
p. scan.step = 1.5e-6; % fermat: step size
|
||||
|
||||
p. model_probe = 0; % Use model probe
|
||||
p. initial_probe_file = 'utils/imgs/probe_PSI.mat'; % Use probe from this mat-file (not used if model_probe is true)
|
||||
p. probe_file_propagation = []; % Distance for propagating the probe from file in meters, = [] to ignore
|
||||
|
||||
|
||||
|
||||
% Academic License Agreement
|
||||
%
|
||||
% Source Code
|
||||
%
|
||||
% Introduction
|
||||
% • This license agreement sets forth the terms and conditions under which the PAUL SCHERRER INSTITUT (PSI), CH-5232 Villigen-PSI, Switzerland (hereafter "LICENSOR")
|
||||
% will grant you (hereafter "LICENSEE") a royalty-free, non-exclusive license for academic, non-commercial purposes only (hereafter "LICENSE") to use the cSAXS
|
||||
% ptychography MATLAB package computer software program and associated documentation furnished hereunder (hereafter "PROGRAM").
|
||||
%
|
||||
% Terms and Conditions of the LICENSE
|
||||
% 1. LICENSOR grants to LICENSEE a royalty-free, non-exclusive license to use the PROGRAM for academic, non-commercial purposes, upon the terms and conditions
|
||||
% hereinafter set out and until termination of this license as set forth below.
|
||||
% 2. LICENSEE acknowledges that the PROGRAM is a research tool still in the development stage. The PROGRAM is provided without any related services, improvements
|
||||
% or warranties from LICENSOR and that the LICENSE is entered into in order to enable others to utilize the PROGRAM in their academic activities. It is the
|
||||
% LICENSEE’s responsibility to ensure its proper use and the correctness of the results.”
|
||||
% 3. THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
% A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE LICENSOR, THE AUTHORS OR THE COPYRIGHT
|
||||
% HOLDERS BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE
|
||||
% OF THE PROGRAM OR OTHER DEALINGS IN THE PROGRAM.
|
||||
% 4. LICENSEE agrees that it will use the PROGRAM and any modifications, improvements, or derivatives of PROGRAM that LICENSEE may create (collectively,
|
||||
% "IMPROVEMENTS") solely for academic, non-commercial purposes and that any copy of PROGRAM or derivatives thereof shall be distributed only under the same
|
||||
% license as PROGRAM. The terms "academic, non-commercial", as used in this Agreement, mean academic or other scholarly research which (a) is not undertaken for
|
||||
% profit, or (b) is not intended to produce works, services, or data for commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged
|
||||
% in the commercial use, application or exploitation of works similar to the PROGRAM.
|
||||
% 5. LICENSEE agrees that it shall make the following acknowledgement in any publication resulting from the use of the PROGRAM or any translation of the code into
|
||||
% another computing language:
|
||||
% "Data processing was carried out using the cSAXS ptychography MATLAB package developed by the Science IT and the coherent X-ray scattering (CXS) groups, Paul
|
||||
% Scherrer Institut, Switzerland."
|
||||
%
|
||||
% Additionally, any publication using the package, or any translation of the code into another computing language should cite for difference map:
|
||||
% P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer, High-resolution scanning X-ray diffraction microscopy, Science 321, 379–382 (2008).
|
||||
% (doi: 10.1126/science.1158573),
|
||||
% for maximum likelihood:
|
||||
% P. Thibault and M. Guizar-Sicairos, Maximum-likelihood refinement for coherent diffractive imaging, New J. Phys. 14, 063004 (2012).
|
||||
% (doi: 10.1088/1367-2630/14/6/063004),
|
||||
% for mixed coherent modes:
|
||||
% P. Thibault and A. Menzel, Reconstructing state mixtures from diffraction measurements, Nature 494, 68–71 (2013). (doi: 10.1038/nature11806),
|
||||
% and/or for multislice:
|
||||
% E. H. R. Tsai, I. Usov, A. Diaz, A. Menzel, and M. Guizar-Sicairos, X-ray ptychography with extended depth of field, Opt. Express 24, 29089–29108 (2016).
|
||||
% (doi: 10.1364/OE.24.029089).
|
||||
% 6. Except for the above-mentioned acknowledgment, LICENSEE shall not use the PROGRAM title or the names or logos of LICENSOR, nor any adaptation thereof, nor the
|
||||
% names of any of its employees or laboratories, in any advertising, promotional or sales material without prior written consent obtained from LICENSOR in each case.
|
||||
% 7. Ownership of all rights, including copyright in the PROGRAM and in any material associated therewith, shall at all times remain with LICENSOR, and LICENSEE
|
||||
% agrees to preserve same. LICENSEE agrees not to use any portion of the PROGRAM or of any IMPROVEMENTS in any machine-readable form outside the PROGRAM, nor to
|
||||
% make any copies except for its internal use, without prior written consent of LICENSOR. LICENSEE agrees to place the following copyright notice on any such copies:
|
||||
% © All rights reserved. PAUL SCHERRER INSTITUT, Switzerland, Laboratory for Macromolecules and Bioimaging, 2017.
|
||||
% 8. The LICENSE shall not be construed to confer any rights upon LICENSEE by implication or otherwise except as specifically set forth herein.
|
||||
% 9. DISCLAIMER: LICENSEE shall be aware that Phase Focus Limited of Sheffield, UK has an international portfolio of patents and pending applications which relate
|
||||
% to ptychography and that the PROGRAM may be capable of being used in circumstances which may fall within the claims of one or more of the Phase Focus patents,
|
||||
% in particular of patent with international application number PCT/GB2005/001464. The LICENSOR explicitly declares not to indemnify the users of the software
|
||||
% in case Phase Focus or any other third party will open a legal action against the LICENSEE due to the use of the program.
|
||||
% 10. This Agreement shall be governed by the material laws of Switzerland and any dispute arising out of this Agreement or use of the PROGRAM shall be brought before
|
||||
% the courts of Zürich, Switzerland.
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
% template for artificial data generation for standard methods tests
|
||||
%
|
||||
% see template_artificial_data.m for the full list of default parameters
|
||||
|
||||
ptycho_path = fileparts(mfilename('fullpath'));
|
||||
ptycho_path = replace(ptycho_path, 'tests', '');
|
||||
run(fullfile( ptycho_path, 'template_artificial_data.m'))
|
||||
|
||||
|
||||
p.simulation.dataset = {8, 8}; % Simulated sample; see +core/+simulations/create_object for more information
|
||||
|
||||
p. z = 5;
|
||||
p. scan.lx = 20e-6; % round_roi scan: width of the roi
|
||||
p. scan.ly = 20e-6; % round_roi scan: height of the roi
|
||||
p. scan.step = 1.2e-6; % fermat: step size
|
||||
|
||||
p. model_probe = 0; % Use model probe
|
||||
p. initial_probe_file = 'utils/imgs/probe_PSI.mat'; % Use probe from this mat-file (not used if model_probe is true)
|
||||
p. probe_file_propagation = []; % Distance for propagating the probe from file in meters, = [] to ignore
|
||||
|
||||
if utils.verbose > -1
|
||||
warning off backtrace
|
||||
warning('Modified affine matrix')
|
||||
warning on backtrace
|
||||
end
|
||||
|
||||
% test geometry refinement by applying affine matrix to data
|
||||
rotation = -0.3; % [deg]
|
||||
shear = 0.2; % [deg]
|
||||
scale = 1.005;
|
||||
asymmetry = 0.02;
|
||||
affmat = inv(math.compose_affine_matrix(scale, asymmetry, rotation, shear));
|
||||
|
||||
% % apply affine matrix to data which is not know by the ptycho code
|
||||
p. simulation. affine_matrix = affmat; % apply inversion of the affine matrix to data so that p. affine_matrix = affmat; is the ideal correction
|
||||
|
||||
% p.simulation.sample_rotation_angles = [0,0,0.1]; % simulate camera misrotate by 0.1 degree
|
||||
|
||||
|
||||
%% apply affine correction of the positions to the ptycho code, then the optimal correction should be zero
|
||||
% p. affine_matrix = affmat;
|
||||
|
||||
|
||||
%% make camera distance error
|
||||
% p.simulation.z = p.z * 1.01;
|
||||
|
||||
p.positions_pad = [0, 0];
|
||||
|
||||
if isfield(p, 'flip_objects_180deg')
|
||||
p.simulation.flip_objects_180deg = p.flip_objects_180deg;
|
||||
end
|
||||
|
||||
% Academic License Agreement
|
||||
%
|
||||
% Source Code
|
||||
%
|
||||
% Introduction
|
||||
% • This license agreement sets forth the terms and conditions under which the PAUL SCHERRER INSTITUT (PSI), CH-5232 Villigen-PSI, Switzerland (hereafter "LICENSOR")
|
||||
% will grant you (hereafter "LICENSEE") a royalty-free, non-exclusive license for academic, non-commercial purposes only (hereafter "LICENSE") to use the cSAXS
|
||||
% ptychography MATLAB package computer software program and associated documentation furnished hereunder (hereafter "PROGRAM").
|
||||
%
|
||||
% Terms and Conditions of the LICENSE
|
||||
% 1. LICENSOR grants to LICENSEE a royalty-free, non-exclusive license to use the PROGRAM for academic, non-commercial purposes, upon the terms and conditions
|
||||
% hereinafter set out and until termination of this license as set forth below.
|
||||
% 2. LICENSEE acknowledges that the PROGRAM is a research tool still in the development stage. The PROGRAM is provided without any related services, improvements
|
||||
% or warranties from LICENSOR and that the LICENSE is entered into in order to enable others to utilize the PROGRAM in their academic activities. It is the
|
||||
% LICENSEE’s responsibility to ensure its proper use and the correctness of the results.”
|
||||
% 3. THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
% A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE LICENSOR, THE AUTHORS OR THE COPYRIGHT
|
||||
% HOLDERS BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE
|
||||
% OF THE PROGRAM OR OTHER DEALINGS IN THE PROGRAM.
|
||||
% 4. LICENSEE agrees that it will use the PROGRAM and any modifications, improvements, or derivatives of PROGRAM that LICENSEE may create (collectively,
|
||||
% "IMPROVEMENTS") solely for academic, non-commercial purposes and that any copy of PROGRAM or derivatives thereof shall be distributed only under the same
|
||||
% license as PROGRAM. The terms "academic, non-commercial", as used in this Agreement, mean academic or other scholarly research which (a) is not undertaken for
|
||||
% profit, or (b) is not intended to produce works, services, or data for commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged
|
||||
% in the commercial use, application or exploitation of works similar to the PROGRAM.
|
||||
% 5. LICENSEE agrees that it shall make the following acknowledgement in any publication resulting from the use of the PROGRAM or any translation of the code into
|
||||
% another computing language:
|
||||
% "Data processing was carried out using the cSAXS ptychography MATLAB package developed by the Science IT and the coherent X-ray scattering (CXS) groups, Paul
|
||||
% Scherrer Institut, Switzerland."
|
||||
%
|
||||
% Additionally, any publication using the package, or any translation of the code into another computing language should cite for difference map:
|
||||
% P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer, High-resolution scanning X-ray diffraction microscopy, Science 321, 379–382 (2008).
|
||||
% (doi: 10.1126/science.1158573),
|
||||
% for maximum likelihood:
|
||||
% P. Thibault and M. Guizar-Sicairos, Maximum-likelihood refinement for coherent diffractive imaging, New J. Phys. 14, 063004 (2012).
|
||||
% (doi: 10.1088/1367-2630/14/6/063004),
|
||||
% for mixed coherent modes:
|
||||
% P. Thibault and A. Menzel, Reconstructing state mixtures from diffraction measurements, Nature 494, 68–71 (2013). (doi: 10.1038/nature11806),
|
||||
% and/or for multislice:
|
||||
% E. H. R. Tsai, I. Usov, A. Diaz, A. Menzel, and M. Guizar-Sicairos, X-ray ptychography with extended depth of field, Opt. Express 24, 29089–29108 (2016).
|
||||
% (doi: 10.1364/OE.24.029089).
|
||||
% 6. Except for the above-mentioned acknowledgment, LICENSEE shall not use the PROGRAM title or the names or logos of LICENSOR, nor any adaptation thereof, nor the
|
||||
% names of any of its employees or laboratories, in any advertising, promotional or sales material without prior written consent obtained from LICENSOR in each case.
|
||||
% 7. Ownership of all rights, including copyright in the PROGRAM and in any material associated therewith, shall at all times remain with LICENSOR, and LICENSEE
|
||||
% agrees to preserve same. LICENSEE agrees not to use any portion of the PROGRAM or of any IMPROVEMENTS in any machine-readable form outside the PROGRAM, nor to
|
||||
% make any copies except for its internal use, without prior written consent of LICENSOR. LICENSEE agrees to place the following copyright notice on any such copies:
|
||||
% © All rights reserved. PAUL SCHERRER INSTITUT, Switzerland, Laboratory for Macromolecules and Bioimaging, 2017.
|
||||
% 8. The LICENSE shall not be construed to confer any rights upon LICENSEE by implication or otherwise except as specifically set forth herein.
|
||||
% 9. DISCLAIMER: LICENSEE shall be aware that Phase Focus Limited of Sheffield, UK has an international portfolio of patents and pending applications which relate
|
||||
% to ptychography and that the PROGRAM may be capable of being used in circumstances which may fall within the claims of one or more of the Phase Focus patents,
|
||||
% in particular of patent with international application number PCT/GB2005/001464. The LICENSOR explicitly declares not to indemnify the users of the software
|
||||
% in case Phase Focus or any other third party will open a legal action against the LICENSEE due to the use of the program.
|
||||
% 10. This Agreement shall be governed by the material laws of Switzerland and any dispute arising out of this Agreement or use of the PROGRAM shall be brought before
|
||||
% the courts of Zürich, Switzerland.
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
% template for artificial data generation for standard methods tests
|
||||
%
|
||||
% see template_artificial_data.m for the full list of default parameters
|
||||
|
||||
ptycho_path = fileparts(mfilename('fullpath'));
|
||||
ptycho_path = replace(ptycho_path, 'tests', '');
|
||||
run(fullfile( ptycho_path, 'template_artificial_data.m'))
|
||||
|
||||
|
||||
p.simulation.dataset = {1}; % Simulated sample; see +core/+simulations/create_object for more information
|
||||
p.simulation.incoherence_blur=1.2; % Incoherence blur
|
||||
|
||||
|
||||
p. lx = 10e-6; % round_roi scan: width of the roi
|
||||
p. ly = 10e-6; % round_roi scan: height of the roi
|
||||
p. step = 1.5e-6; % fermat: step size
|
||||
|
||||
|
||||
p. model_probe = 0; % Use model probe
|
||||
p. initial_probe_file = 'utils/imgs/probe_PSI.mat'; % Use probe from this mat-file (not used if model_probe is true)
|
||||
p. probe_file_propagation = []; % Distance for propagating the probe from file in meters, = [] to ignore
|
||||
|
||||
|
||||
|
||||
% Academic License Agreement
|
||||
%
|
||||
% Source Code
|
||||
%
|
||||
% Introduction
|
||||
% • This license agreement sets forth the terms and conditions under which the PAUL SCHERRER INSTITUT (PSI), CH-5232 Villigen-PSI, Switzerland (hereafter "LICENSOR")
|
||||
% will grant you (hereafter "LICENSEE") a royalty-free, non-exclusive license for academic, non-commercial purposes only (hereafter "LICENSE") to use the cSAXS
|
||||
% ptychography MATLAB package computer software program and associated documentation furnished hereunder (hereafter "PROGRAM").
|
||||
%
|
||||
% Terms and Conditions of the LICENSE
|
||||
% 1. LICENSOR grants to LICENSEE a royalty-free, non-exclusive license to use the PROGRAM for academic, non-commercial purposes, upon the terms and conditions
|
||||
% hereinafter set out and until termination of this license as set forth below.
|
||||
% 2. LICENSEE acknowledges that the PROGRAM is a research tool still in the development stage. The PROGRAM is provided without any related services, improvements
|
||||
% or warranties from LICENSOR and that the LICENSE is entered into in order to enable others to utilize the PROGRAM in their academic activities. It is the
|
||||
% LICENSEE’s responsibility to ensure its proper use and the correctness of the results.”
|
||||
% 3. THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
% A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE LICENSOR, THE AUTHORS OR THE COPYRIGHT
|
||||
% HOLDERS BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE
|
||||
% OF THE PROGRAM OR OTHER DEALINGS IN THE PROGRAM.
|
||||
% 4. LICENSEE agrees that it will use the PROGRAM and any modifications, improvements, or derivatives of PROGRAM that LICENSEE may create (collectively,
|
||||
% "IMPROVEMENTS") solely for academic, non-commercial purposes and that any copy of PROGRAM or derivatives thereof shall be distributed only under the same
|
||||
% license as PROGRAM. The terms "academic, non-commercial", as used in this Agreement, mean academic or other scholarly research which (a) is not undertaken for
|
||||
% profit, or (b) is not intended to produce works, services, or data for commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged
|
||||
% in the commercial use, application or exploitation of works similar to the PROGRAM.
|
||||
% 5. LICENSEE agrees that it shall make the following acknowledgement in any publication resulting from the use of the PROGRAM or any translation of the code into
|
||||
% another computing language:
|
||||
% "Data processing was carried out using the cSAXS ptychography MATLAB package developed by the Science IT and the coherent X-ray scattering (CXS) groups, Paul
|
||||
% Scherrer Institut, Switzerland."
|
||||
%
|
||||
% Additionally, any publication using the package, or any translation of the code into another computing language should cite for difference map:
|
||||
% P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer, High-resolution scanning X-ray diffraction microscopy, Science 321, 379–382 (2008).
|
||||
% (doi: 10.1126/science.1158573),
|
||||
% for maximum likelihood:
|
||||
% P. Thibault and M. Guizar-Sicairos, Maximum-likelihood refinement for coherent diffractive imaging, New J. Phys. 14, 063004 (2012).
|
||||
% (doi: 10.1088/1367-2630/14/6/063004),
|
||||
% for mixed coherent modes:
|
||||
% P. Thibault and A. Menzel, Reconstructing state mixtures from diffraction measurements, Nature 494, 68–71 (2013). (doi: 10.1038/nature11806),
|
||||
% and/or for multislice:
|
||||
% E. H. R. Tsai, I. Usov, A. Diaz, A. Menzel, and M. Guizar-Sicairos, X-ray ptychography with extended depth of field, Opt. Express 24, 29089–29108 (2016).
|
||||
% (doi: 10.1364/OE.24.029089).
|
||||
% 6. Except for the above-mentioned acknowledgment, LICENSEE shall not use the PROGRAM title or the names or logos of LICENSOR, nor any adaptation thereof, nor the
|
||||
% names of any of its employees or laboratories, in any advertising, promotional or sales material without prior written consent obtained from LICENSOR in each case.
|
||||
% 7. Ownership of all rights, including copyright in the PROGRAM and in any material associated therewith, shall at all times remain with LICENSOR, and LICENSEE
|
||||
% agrees to preserve same. LICENSEE agrees not to use any portion of the PROGRAM or of any IMPROVEMENTS in any machine-readable form outside the PROGRAM, nor to
|
||||
% make any copies except for its internal use, without prior written consent of LICENSOR. LICENSEE agrees to place the following copyright notice on any such copies:
|
||||
% © All rights reserved. PAUL SCHERRER INSTITUT, Switzerland, Laboratory for Macromolecules and Bioimaging, 2017.
|
||||
% 8. The LICENSE shall not be construed to confer any rights upon LICENSEE by implication or otherwise except as specifically set forth herein.
|
||||
% 9. DISCLAIMER: LICENSEE shall be aware that Phase Focus Limited of Sheffield, UK has an international portfolio of patents and pending applications which relate
|
||||
% to ptychography and that the PROGRAM may be capable of being used in circumstances which may fall within the claims of one or more of the Phase Focus patents,
|
||||
% in particular of patent with international application number PCT/GB2005/001464. The LICENSOR explicitly declares not to indemnify the users of the software
|
||||
% in case Phase Focus or any other third party will open a legal action against the LICENSEE due to the use of the program.
|
||||
% 10. This Agreement shall be governed by the material laws of Switzerland and any dispute arising out of this Agreement or use of the PROGRAM shall be brought before
|
||||
% the courts of Zürich, Switzerland.
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
% template for artificial data generation for standard methods tests
|
||||
%
|
||||
% see template_artificial_data.m for the full list of default parameters
|
||||
|
||||
ptycho_path = fileparts(mfilename('fullpath'));
|
||||
ptycho_path = replace(ptycho_path, 'tests', '');
|
||||
run(fullfile( ptycho_path, 'template_artificial_data.m'))
|
||||
|
||||
|
||||
p.simulation.dataset = {1,1}; % Simulated sample; see +core/+simulations/create_object for more information
|
||||
|
||||
p.simulation.flip_objects_180deg = [false, true]; % Simulated 0 vs 180 deg projection
|
||||
|
||||
p. scan.lx = 10e-6; % round_roi scan: width of the roi
|
||||
p. scan.ly = 10e-6; % round_roi scan: height of the roi
|
||||
p. scan.step = 1.5e-6; % fermat: step size
|
||||
|
||||
p. model_probe = 0; % Use model probe
|
||||
p. initial_probe_file = 'utils/imgs/probe_PSI.mat'; % Use probe from this mat-file (not used if model_probe is true)
|
||||
p. probe_file_propagation = []; % Distance for propagating the probe from file in meters, = [] to ignore
|
||||
|
||||
|
||||
|
||||
% Academic License Agreement
|
||||
%
|
||||
% Source Code
|
||||
%
|
||||
% Introduction
|
||||
% • This license agreement sets forth the terms and conditions under which the PAUL SCHERRER INSTITUT (PSI), CH-5232 Villigen-PSI, Switzerland (hereafter "LICENSOR")
|
||||
% will grant you (hereafter "LICENSEE") a royalty-free, non-exclusive license for academic, non-commercial purposes only (hereafter "LICENSE") to use the cSAXS
|
||||
% ptychography MATLAB package computer software program and associated documentation furnished hereunder (hereafter "PROGRAM").
|
||||
%
|
||||
% Terms and Conditions of the LICENSE
|
||||
% 1. LICENSOR grants to LICENSEE a royalty-free, non-exclusive license to use the PROGRAM for academic, non-commercial purposes, upon the terms and conditions
|
||||
% hereinafter set out and until termination of this license as set forth below.
|
||||
% 2. LICENSEE acknowledges that the PROGRAM is a research tool still in the development stage. The PROGRAM is provided without any related services, improvements
|
||||
% or warranties from LICENSOR and that the LICENSE is entered into in order to enable others to utilize the PROGRAM in their academic activities. It is the
|
||||
% LICENSEE’s responsibility to ensure its proper use and the correctness of the results.”
|
||||
% 3. THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
% A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE LICENSOR, THE AUTHORS OR THE COPYRIGHT
|
||||
% HOLDERS BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE
|
||||
% OF THE PROGRAM OR OTHER DEALINGS IN THE PROGRAM.
|
||||
% 4. LICENSEE agrees that it will use the PROGRAM and any modifications, improvements, or derivatives of PROGRAM that LICENSEE may create (collectively,
|
||||
% "IMPROVEMENTS") solely for academic, non-commercial purposes and that any copy of PROGRAM or derivatives thereof shall be distributed only under the same
|
||||
% license as PROGRAM. The terms "academic, non-commercial", as used in this Agreement, mean academic or other scholarly research which (a) is not undertaken for
|
||||
% profit, or (b) is not intended to produce works, services, or data for commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged
|
||||
% in the commercial use, application or exploitation of works similar to the PROGRAM.
|
||||
% 5. LICENSEE agrees that it shall make the following acknowledgement in any publication resulting from the use of the PROGRAM or any translation of the code into
|
||||
% another computing language:
|
||||
% "Data processing was carried out using the cSAXS ptychography MATLAB package developed by the Science IT and the coherent X-ray scattering (CXS) groups, Paul
|
||||
% Scherrer Institut, Switzerland."
|
||||
%
|
||||
% Additionally, any publication using the package, or any translation of the code into another computing language should cite for difference map:
|
||||
% P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer, High-resolution scanning X-ray diffraction microscopy, Science 321, 379–382 (2008).
|
||||
% (doi: 10.1126/science.1158573),
|
||||
% for maximum likelihood:
|
||||
% P. Thibault and M. Guizar-Sicairos, Maximum-likelihood refinement for coherent diffractive imaging, New J. Phys. 14, 063004 (2012).
|
||||
% (doi: 10.1088/1367-2630/14/6/063004),
|
||||
% for mixed coherent modes:
|
||||
% P. Thibault and A. Menzel, Reconstructing state mixtures from diffraction measurements, Nature 494, 68–71 (2013). (doi: 10.1038/nature11806),
|
||||
% and/or for multislice:
|
||||
% E. H. R. Tsai, I. Usov, A. Diaz, A. Menzel, and M. Guizar-Sicairos, X-ray ptychography with extended depth of field, Opt. Express 24, 29089–29108 (2016).
|
||||
% (doi: 10.1364/OE.24.029089).
|
||||
% 6. Except for the above-mentioned acknowledgment, LICENSEE shall not use the PROGRAM title or the names or logos of LICENSOR, nor any adaptation thereof, nor the
|
||||
% names of any of its employees or laboratories, in any advertising, promotional or sales material without prior written consent obtained from LICENSOR in each case.
|
||||
% 7. Ownership of all rights, including copyright in the PROGRAM and in any material associated therewith, shall at all times remain with LICENSOR, and LICENSEE
|
||||
% agrees to preserve same. LICENSEE agrees not to use any portion of the PROGRAM or of any IMPROVEMENTS in any machine-readable form outside the PROGRAM, nor to
|
||||
% make any copies except for its internal use, without prior written consent of LICENSOR. LICENSEE agrees to place the following copyright notice on any such copies:
|
||||
% © All rights reserved. PAUL SCHERRER INSTITUT, Switzerland, Laboratory for Macromolecules and Bioimaging, 2017.
|
||||
% 8. The LICENSE shall not be construed to confer any rights upon LICENSEE by implication or otherwise except as specifically set forth herein.
|
||||
% 9. DISCLAIMER: LICENSEE shall be aware that Phase Focus Limited of Sheffield, UK has an international portfolio of patents and pending applications which relate
|
||||
% to ptychography and that the PROGRAM may be capable of being used in circumstances which may fall within the claims of one or more of the Phase Focus patents,
|
||||
% in particular of patent with international application number PCT/GB2005/001464. The LICENSOR explicitly declares not to indemnify the users of the software
|
||||
% in case Phase Focus or any other third party will open a legal action against the LICENSEE due to the use of the program.
|
||||
% 10. This Agreement shall be governed by the material laws of Switzerland and any dispute arising out of this Agreement or use of the PROGRAM shall be brought before
|
||||
% the courts of Zürich, Switzerland.
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
% template for artificial data generation for standard methods tests
|
||||
%
|
||||
% see template_artificial_data.m for the full list of default parameters
|
||||
|
||||
ptycho_path = fileparts(mfilename('fullpath'));
|
||||
ptycho_path = replace(ptycho_path, 'tests', '');
|
||||
run(fullfile( ptycho_path, 'template_artificial_data.m'))
|
||||
|
||||
|
||||
p.simulation.dataset = {1,1,1}; % Simulated sample; see +core/+simulations/create_object for more information
|
||||
|
||||
p. scan.lx = 20e-6; % round_roi scan: width of the roi
|
||||
p. scan.ly = 20e-6; % round_roi scan: height of the roi
|
||||
p. scan.step = 1.5e-6; % fermat: step size
|
||||
|
||||
p. model_probe = 0; % Use model probe
|
||||
p. initial_probe_file = 'utils/imgs/probe_PSI.mat'; % Use probe from this mat-file (not used if model_probe is true)
|
||||
p. probe_file_propagation = []; % Distance for propagating the probe from file in meters, = [] to ignore
|
||||
|
||||
p. simulation.positions_pad = [0,0; 10, 10; 20, 20];
|
||||
|
||||
% Academic License Agreement
|
||||
%
|
||||
% Source Code
|
||||
%
|
||||
% Introduction
|
||||
% • This license agreement sets forth the terms and conditions under which the PAUL SCHERRER INSTITUT (PSI), CH-5232 Villigen-PSI, Switzerland (hereafter "LICENSOR")
|
||||
% will grant you (hereafter "LICENSEE") a royalty-free, non-exclusive license for academic, non-commercial purposes only (hereafter "LICENSE") to use the cSAXS
|
||||
% ptychography MATLAB package computer software program and associated documentation furnished hereunder (hereafter "PROGRAM").
|
||||
%
|
||||
% Terms and Conditions of the LICENSE
|
||||
% 1. LICENSOR grants to LICENSEE a royalty-free, non-exclusive license to use the PROGRAM for academic, non-commercial purposes, upon the terms and conditions
|
||||
% hereinafter set out and until termination of this license as set forth below.
|
||||
% 2. LICENSEE acknowledges that the PROGRAM is a research tool still in the development stage. The PROGRAM is provided without any related services, improvements
|
||||
% or warranties from LICENSOR and that the LICENSE is entered into in order to enable others to utilize the PROGRAM in their academic activities. It is the
|
||||
% LICENSEE’s responsibility to ensure its proper use and the correctness of the results.”
|
||||
% 3. THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
% A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE LICENSOR, THE AUTHORS OR THE COPYRIGHT
|
||||
% HOLDERS BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE
|
||||
% OF THE PROGRAM OR OTHER DEALINGS IN THE PROGRAM.
|
||||
% 4. LICENSEE agrees that it will use the PROGRAM and any modifications, improvements, or derivatives of PROGRAM that LICENSEE may create (collectively,
|
||||
% "IMPROVEMENTS") solely for academic, non-commercial purposes and that any copy of PROGRAM or derivatives thereof shall be distributed only under the same
|
||||
% license as PROGRAM. The terms "academic, non-commercial", as used in this Agreement, mean academic or other scholarly research which (a) is not undertaken for
|
||||
% profit, or (b) is not intended to produce works, services, or data for commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged
|
||||
% in the commercial use, application or exploitation of works similar to the PROGRAM.
|
||||
% 5. LICENSEE agrees that it shall make the following acknowledgement in any publication resulting from the use of the PROGRAM or any translation of the code into
|
||||
% another computing language:
|
||||
% "Data processing was carried out using the cSAXS ptychography MATLAB package developed by the Science IT and the coherent X-ray scattering (CXS) groups, Paul
|
||||
% Scherrer Institut, Switzerland."
|
||||
%
|
||||
% Additionally, any publication using the package, or any translation of the code into another computing language should cite for difference map:
|
||||
% P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer, High-resolution scanning X-ray diffraction microscopy, Science 321, 379–382 (2008).
|
||||
% (doi: 10.1126/science.1158573),
|
||||
% for maximum likelihood:
|
||||
% P. Thibault and M. Guizar-Sicairos, Maximum-likelihood refinement for coherent diffractive imaging, New J. Phys. 14, 063004 (2012).
|
||||
% (doi: 10.1088/1367-2630/14/6/063004),
|
||||
% for mixed coherent modes:
|
||||
% P. Thibault and A. Menzel, Reconstructing state mixtures from diffraction measurements, Nature 494, 68–71 (2013). (doi: 10.1038/nature11806),
|
||||
% and/or for multislice:
|
||||
% E. H. R. Tsai, I. Usov, A. Diaz, A. Menzel, and M. Guizar-Sicairos, X-ray ptychography with extended depth of field, Opt. Express 24, 29089–29108 (2016).
|
||||
% (doi: 10.1364/OE.24.029089).
|
||||
% 6. Except for the above-mentioned acknowledgment, LICENSEE shall not use the PROGRAM title or the names or logos of LICENSOR, nor any adaptation thereof, nor the
|
||||
% names of any of its employees or laboratories, in any advertising, promotional or sales material without prior written consent obtained from LICENSOR in each case.
|
||||
% 7. Ownership of all rights, including copyright in the PROGRAM and in any material associated therewith, shall at all times remain with LICENSOR, and LICENSEE
|
||||
% agrees to preserve same. LICENSEE agrees not to use any portion of the PROGRAM or of any IMPROVEMENTS in any machine-readable form outside the PROGRAM, nor to
|
||||
% make any copies except for its internal use, without prior written consent of LICENSOR. LICENSEE agrees to place the following copyright notice on any such copies:
|
||||
% © All rights reserved. PAUL SCHERRER INSTITUT, Switzerland, Laboratory for Macromolecules and Bioimaging, 2017.
|
||||
% 8. The LICENSE shall not be construed to confer any rights upon LICENSEE by implication or otherwise except as specifically set forth herein.
|
||||
% 9. DISCLAIMER: LICENSEE shall be aware that Phase Focus Limited of Sheffield, UK has an international portfolio of patents and pending applications which relate
|
||||
% to ptychography and that the PROGRAM may be capable of being used in circumstances which may fall within the claims of one or more of the Phase Focus patents,
|
||||
% in particular of patent with international application number PCT/GB2005/001464. The LICENSOR explicitly declares not to indemnify the users of the software
|
||||
% in case Phase Focus or any other third party will open a legal action against the LICENSEE due to the use of the program.
|
||||
% 10. This Agreement shall be governed by the material laws of Switzerland and any dispute arising out of this Agreement or use of the PROGRAM shall be brought before
|
||||
% the courts of Zürich, Switzerland.
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
% template for artificial data generation for standard methods tests
|
||||
%
|
||||
% see template_artificial_data.m for the full list of default parameters
|
||||
|
||||
ptycho_path = fileparts(mfilename('fullpath'));
|
||||
ptycho_path = replace(ptycho_path, 'tests', '');
|
||||
run(fullfile( ptycho_path, 'template_artificial_data.m'))
|
||||
|
||||
|
||||
p.simulation.dataset = {5}; % Simulated sample; see +core/+simulations/create_object for more information
|
||||
|
||||
|
||||
% Offaxis ptychography
|
||||
rotation = p.sample_rotation_angles; % 3x1 vector rotation around [X,Y,beam] axes in degrees , apply a correction accounting for tilted plane oR the sample and ewald sphere curvature (high NA correction)
|
||||
p.simulation.sample_rotation_angles = rotation; % 3x1 vector rotation around [X,Y,beam] axes in degrees , apply a correction accounting for tilted plane oR the sample and ewald sphere curvature (high NA correction)
|
||||
p.sample_rotation_angles = rotation; % 3x1 vector rotation around [X,Y,beam] axes in degrees , apply a correction accounting for tilted plane oR the sample and ewald sphere curvature (high NA correction)
|
||||
|
||||
|
||||
|
||||
p. scan.type = 'raster'; % {'round', 'raster', 'round_roi', 'custom'}
|
||||
p. scan.nx = 10; % raster scan: number of steps in x
|
||||
p. scan.ny = 10; % raster scan: number of steps in y
|
||||
p. scan.step_size_x = 1e-6/cosd(rotation(2)); % raster scan: step size (grid spacing)
|
||||
p. scan.step_size_y = 1e-6/cosd(rotation(1)); % raster scan: step size (grid spacing)
|
||||
p. scan.step_randn_offset = 0.1; % raster scan: random offset added to the position to avoid periodic artefacts, offset is relative to the selected step size
|
||||
|
||||
|
||||
p. model_probe = 0; % Use model probe
|
||||
p. initial_probe_file = 'utils/imgs/probe_PSI.mat'; % Use probe from this mat-file (not used if model_probe is true)
|
||||
p. probe_file_propagation = []; % Distance for propagating the probe from file in meters, = [] to ignore
|
||||
|
||||
|
||||
% Academic License Agreement
|
||||
%
|
||||
% Source Code
|
||||
%
|
||||
% Introduction
|
||||
% • This license agreement sets forth the terms and conditions under which the PAUL SCHERRER INSTITUT (PSI), CH-5232 Villigen-PSI, Switzerland (hereafter "LICENSOR")
|
||||
% will grant you (hereafter "LICENSEE") a royalty-free, non-exclusive license for academic, non-commercial purposes only (hereafter "LICENSE") to use the cSAXS
|
||||
% ptychography MATLAB package computer software program and associated documentation furnished hereunder (hereafter "PROGRAM").
|
||||
%
|
||||
% Terms and Conditions of the LICENSE
|
||||
% 1. LICENSOR grants to LICENSEE a royalty-free, non-exclusive license to use the PROGRAM for academic, non-commercial purposes, upon the terms and conditions
|
||||
% hereinafter set out and until termination of this license as set forth below.
|
||||
% 2. LICENSEE acknowledges that the PROGRAM is a research tool still in the development stage. The PROGRAM is provided without any related services, improvements
|
||||
% or warranties from LICENSOR and that the LICENSE is entered into in order to enable others to utilize the PROGRAM in their academic activities. It is the
|
||||
% LICENSEE’s responsibility to ensure its proper use and the correctness of the results.”
|
||||
% 3. THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
% A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE LICENSOR, THE AUTHORS OR THE COPYRIGHT
|
||||
% HOLDERS BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE
|
||||
% OF THE PROGRAM OR OTHER DEALINGS IN THE PROGRAM.
|
||||
% 4. LICENSEE agrees that it will use the PROGRAM and any modifications, improvements, or derivatives of PROGRAM that LICENSEE may create (collectively,
|
||||
% "IMPROVEMENTS") solely for academic, non-commercial purposes and that any copy of PROGRAM or derivatives thereof shall be distributed only under the same
|
||||
% license as PROGRAM. The terms "academic, non-commercial", as used in this Agreement, mean academic or other scholarly research which (a) is not undertaken for
|
||||
% profit, or (b) is not intended to produce works, services, or data for commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged
|
||||
% in the commercial use, application or exploitation of works similar to the PROGRAM.
|
||||
% 5. LICENSEE agrees that it shall make the following acknowledgement in any publication resulting from the use of the PROGRAM or any translation of the code into
|
||||
% another computing language:
|
||||
% "Data processing was carried out using the cSAXS ptychography MATLAB package developed by the Science IT and the coherent X-ray scattering (CXS) groups, Paul
|
||||
% Scherrer Institut, Switzerland."
|
||||
%
|
||||
% Additionally, any publication using the package, or any translation of the code into another computing language should cite for difference map:
|
||||
% P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer, High-resolution scanning X-ray diffraction microscopy, Science 321, 379–382 (2008).
|
||||
% (doi: 10.1126/science.1158573),
|
||||
% for maximum likelihood:
|
||||
% P. Thibault and M. Guizar-Sicairos, Maximum-likelihood refinement for coherent diffractive imaging, New J. Phys. 14, 063004 (2012).
|
||||
% (doi: 10.1088/1367-2630/14/6/063004),
|
||||
% for mixed coherent modes:
|
||||
% P. Thibault and A. Menzel, Reconstructing state mixtures from diffraction measurements, Nature 494, 68–71 (2013). (doi: 10.1038/nature11806),
|
||||
% and/or for multislice:
|
||||
% E. H. R. Tsai, I. Usov, A. Diaz, A. Menzel, and M. Guizar-Sicairos, X-ray ptychography with extended depth of field, Opt. Express 24, 29089–29108 (2016).
|
||||
% (doi: 10.1364/OE.24.029089).
|
||||
% 6. Except for the above-mentioned acknowledgment, LICENSEE shall not use the PROGRAM title or the names or logos of LICENSOR, nor any adaptation thereof, nor the
|
||||
% names of any of its employees or laboratories, in any advertising, promotional or sales material without prior written consent obtained from LICENSOR in each case.
|
||||
% 7. Ownership of all rights, including copyright in the PROGRAM and in any material associated therewith, shall at all times remain with LICENSOR, and LICENSEE
|
||||
% agrees to preserve same. LICENSEE agrees not to use any portion of the PROGRAM or of any IMPROVEMENTS in any machine-readable form outside the PROGRAM, nor to
|
||||
% make any copies except for its internal use, without prior written consent of LICENSOR. LICENSEE agrees to place the following copyright notice on any such copies:
|
||||
% © All rights reserved. PAUL SCHERRER INSTITUT, Switzerland, Laboratory for Macromolecules and Bioimaging, 2017.
|
||||
% 8. The LICENSE shall not be construed to confer any rights upon LICENSEE by implication or otherwise except as specifically set forth herein.
|
||||
% 9. DISCLAIMER: LICENSEE shall be aware that Phase Focus Limited of Sheffield, UK has an international portfolio of patents and pending applications which relate
|
||||
% to ptychography and that the PROGRAM may be capable of being used in circumstances which may fall within the claims of one or more of the Phase Focus patents,
|
||||
% in particular of patent with international application number PCT/GB2005/001464. The LICENSOR explicitly declares not to indemnify the users of the software
|
||||
% in case Phase Focus or any other third party will open a legal action against the LICENSEE due to the use of the program.
|
||||
% 10. This Agreement shall be governed by the material laws of Switzerland and any dispute arising out of this Agreement or use of the PROGRAM shall be brought before
|
||||
% the courts of Zürich, Switzerland.
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
%% TEST TEMPLATE FOR FUNTIONALITY CHECK OF CPU ENGINES
|
||||
% 1) call standard template to get fresh settings defaults
|
||||
% 2) generate artificial data that should serve as a standart test "sample"
|
||||
% 3) call GPU engine with different basic functionalities and test if all still works
|
||||
% !! THESE TEST ARE ONLY USEFUL TO FIND CRASHES IN THE CODE, QUALITY OF THE RECONSTRUCTION IS NOT EVALUATED !!
|
||||
|
||||
|
||||
%% set shared parameters for all test scripts
|
||||
run(fullfile( fileparts(mfilename('fullpath')), 'init_test.m'))
|
||||
close all
|
||||
|
||||
plot_results = true;
|
||||
plot_save_results = true;
|
||||
|
||||
|
||||
%% general settings
|
||||
p. artificial_data_file = 'tests/test_data_double_scan.m'; % artificial data parameters
|
||||
p. asize = [128 128]; % size of the reconstruction probe
|
||||
Nlayers = 2;
|
||||
|
||||
|
||||
%% Plot, save and analyze
|
||||
|
||||
p. plot.prepared_data = false; % plot prepared data
|
||||
p. plot.interval = []; % plot each interval-th iteration, does not work for c_solver code
|
||||
p. plot.log_scale = [1 1]; % Plot on log scale for x and y
|
||||
p. plot.realaxes = true; % Plots show scale in microns
|
||||
p. plot.remove_phase_ramp = true; % Remove phase ramp from the plotted / saved phase figures
|
||||
p. plot.fov_box = true; % Plot the scanning FOV box on the object (both phase and amplitude)
|
||||
p. plot.fov_box_color = 'r'; % Color of the scanning FOV box
|
||||
p. plot.positions = true; % Plot the scanning positions
|
||||
p. plot.mask_bool = true; % Mask the noisy contour of the reconstructed object in plots
|
||||
p. plot.windowautopos = true; % First plotting will auto position windows
|
||||
p. plot.obj_apod = false; % Apply apodization to the reconstructed object;
|
||||
p. plot.prop_obj = 1e-12; % Distance to propagate reconstructed object before plotting [m]
|
||||
p. plot.show_layers = true; % show each layer in multilayer reconstruction
|
||||
p. plot.show_layers_stack = true; % show each layer in multilayer reconstruction by imagesc3D
|
||||
p. plot.object_spectrum = true; % Plot propagated object (FFT for conventional ptycho); if empty then default is false if verbose_level < 3 and true otherwise
|
||||
p. plot.conjugate = true; % plot complex conjugate of the reconstruction
|
||||
p. plot.horz_fact = 2.5; % Scales the space that the ptycho figures take horizontally
|
||||
p. plot.FP_maskdim = 180e-6; % Filter the backpropagation (Fourier Ptychography)
|
||||
p. plot.calc_FSC = true; % Calculate the Fourier Shell correlation for 2 scans or compare with model in case of artificial data tests
|
||||
p. plot.show_FSC = true; % Show the FSC plots, including the cropped FOV
|
||||
p. plot.residua = true; % highlight phase-residua in the image of the reconstructed phase
|
||||
|
||||
|
||||
|
||||
%% ENGINES
|
||||
|
||||
if isunix
|
||||
% Please notice that you have to force data preparation (force_prepare_h5_files=true) if you have made any changes to
|
||||
% the already prepared data (fmag, fmask, positions, sharing ...).
|
||||
eng. name = 'c_solver';
|
||||
eng. method = 'DM+ML';
|
||||
eng. number_iterations = 100; % Total number of iterations
|
||||
eng. opt_iter = 100; % Iterations for optimization
|
||||
eng. probe_regularization = .1; % Weigth factor for the probe update;
|
||||
eng. probe_change_start = 1; % Start updating probe at this iteration number
|
||||
eng. probe_support_radius = 0.8; % Normalized radius of circular support, = 1 for radius touching the window
|
||||
eng. pfft_relaxation = .05; % Relaxation in the Fourier domain projection, = 0 for full projection
|
||||
eng. background = 0; % [PARTIALLY IMPLEMENTED (not fully optimized)] Add background to the ML model in form: |Psi|^2+B, B is in average counts per frame and pixel
|
||||
eng. probe_support_fft = false; % [PARTIALLY IMPLEMENTED (not fully optimized)] Apply probe support in Fourier space, ! uses model zoneplate settings to estimate support size
|
||||
|
||||
eng. N_layer = Nlayers; % Number of virtual object layers (slices)
|
||||
eng. delta_z = 10e-6 * ones(1, eng.N_layer-1); % Separation between object slices
|
||||
%eng. ms_init_ob_fraction = [1 0];
|
||||
if eng. N_layer>1
|
||||
p.suffix = [p.suffix '_N' num2str(eng. N_layer)];
|
||||
eng. number_iterations = 0; % highly recommended
|
||||
end
|
||||
|
||||
eng. single_prec = true; % single or double precision
|
||||
eng. threads = 20; % number of threads for OMP
|
||||
eng. beamline_nodes = []; % beamline nodes for the MPI/OMP hybrid, e.g. ['x12sa-cn-2'; 'x12sa-cn-3'];
|
||||
eng. ra_nodes = 0; % number of nodes on ra cluster for the MPI/OMP hybrid; set to 0 for current node
|
||||
eng. caller_suffix = ''; % suffix for the external reconstruction program
|
||||
eng. reconstruction_program = ''; % specify external reconstruction program that overwrites previous settings, e.g. 'OMP_NUM_THREADS=20 ./ptycho_single_OMP';
|
||||
eng. check_cpu_load = true; % check if specified nodes are already in use (only x12sa). Disable check if you are sure that the nodes are free.
|
||||
eng. initial_conditions_path = ''; % path of the initial conditions file; default if empty (== prepare_data_path)
|
||||
eng. initial_conditions_file = ''; % Name of the initial conditions file, default if empty. Do not use ~ in the path
|
||||
eng. measurements_file = ''; % Name of the measurements file, default if empty. Do not use ~ in the path
|
||||
eng. solution_file = ''; % Name of the solution file, default if empty. Do not use ~ in the path
|
||||
eng. force_prepare_h5_files = 1; % If true before running the C-code the data h5 file is created and the h5 file with initial object and probe too, regardless of whether it exists. It will use the matlab data preparator.
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
else
|
||||
eng = struct();
|
||||
eng. name = 'DM';
|
||||
eng. method = 'matlab';
|
||||
eng. number_iterations = 10; % Total number of iterations
|
||||
eng. probe_change_start = 1; % Start updating probe at this iteration number
|
||||
eng. average_start = 300; % Start averaging at this iteration number
|
||||
eng. average_interval = 5; % Number of iterations between reconstruction estimates for average
|
||||
eng. count_bound = 4e-2; % Relaxed Fourier projection parameter - average photons of change per pixel (= 0 no relaxation)
|
||||
eng. pfft_relaxation = 0.05 ; % Relaxation in the Fourier domain projection, = 0 for full projection
|
||||
eng. probe_regularization = .1; % Weigth factor for the probe update
|
||||
eng. probe_mask_bool = true; % If true, impose a support constraint to the probe
|
||||
eng. probe_mask_area = .9; % Area ratio of the mask
|
||||
eng. probe_mask_use_auto = false; % Use autocorrelation for probe_mask (if false: circular circle)
|
||||
eng. object_flat_region = []; % Mask for enforcing a flat region in the object (to reduce artifacts)
|
||||
eng. remove_scaling_ambiguity = true; % Remove ambiguity of the probe times object scalling by probe normalization
|
||||
eng. clip_object = true; % Clip the object transmission function
|
||||
eng. clip_max = 1.0; % Upper bound
|
||||
eng. clip_min = 0.0; % Lower bound
|
||||
eng. compute_rfact = false; % If set to true, R-factor is computed at every iteration (large overhead!!!)
|
||||
eng. use_mex = [0,0,0];
|
||||
[p, ~] = core.append_engine(p, eng); % Adds this engine to the reconstruction process
|
||||
end
|
||||
|
||||
|
||||
|
||||
run(fullfile( ptycho_path, 'tests/run_test.m'))
|
||||
|
||||
|
||||
|
||||
% Academic License Agreement
|
||||
%
|
||||
% Source Code
|
||||
%
|
||||
% Introduction
|
||||
% • This license agreement sets forth the terms and conditions under which the PAUL SCHERRER INSTITUT (PSI), CH-5232 Villigen-PSI, Switzerland (hereafter "LICENSOR")
|
||||
% will grant you (hereafter "LICENSEE") a royalty-free, non-exclusive license for academic, non-commercial purposes only (hereafter "LICENSE") to use the cSAXS
|
||||
% ptychography MATLAB package computer software program and associated documentation furnished hereunder (hereafter "PROGRAM").
|
||||
%
|
||||
% Terms and Conditions of the LICENSE
|
||||
% 1. LICENSOR grants to LICENSEE a royalty-free, non-exclusive license to use the PROGRAM for academic, non-commercial purposes, upon the terms and conditions
|
||||
% hereinafter set out and until termination of this license as set forth below.
|
||||
% 2. LICENSEE acknowledges that the PROGRAM is a research tool still in the development stage. The PROGRAM is provided without any related services, improvements
|
||||
% or warranties from LICENSOR and that the LICENSE is entered into in order to enable others to utilize the PROGRAM in their academic activities. It is the
|
||||
% LICENSEE’s responsibility to ensure its proper use and the correctness of the results.”
|
||||
% 3. THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
|
||||
% A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE LICENSOR, THE AUTHORS OR THE COPYRIGHT
|
||||
% HOLDERS BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE
|
||||
% OF THE PROGRAM OR OTHER DEALINGS IN THE PROGRAM.
|
||||
% 4. LICENSEE agrees that it will use the PROGRAM and any modifications, improvements, or derivatives of PROGRAM that LICENSEE may create (collectively,
|
||||
% "IMPROVEMENTS") solely for academic, non-commercial purposes and that any copy of PROGRAM or derivatives thereof shall be distributed only under the same
|
||||
% license as PROGRAM. The terms "academic, non-commercial", as used in this Agreement, mean academic or other scholarly research which (a) is not undertaken for
|
||||
% profit, or (b) is not intended to produce works, services, or data for commercial use, or (c) is neither conducted, nor funded, by a person or an entity engaged
|
||||
% in the commercial use, application or exploitation of works similar to the PROGRAM.
|
||||
% 5. LICENSEE agrees that it shall make the following acknowledgement in any publication resulting from the use of the PROGRAM or any translation of the code into
|
||||
% another computing language:
|
||||
% "Data processing was carried out using the cSAXS ptychography MATLAB package developed by the Science IT and the coherent X-ray scattering (CXS) groups, Paul
|
||||
% Scherrer Institut, Switzerland."
|
||||
%
|
||||
% Additionally, any publication using the package, or any translation of the code into another computing language should cite for difference map:
|
||||
% P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, F. Pfeiffer, High-resolution scanning X-ray diffraction microscopy, Science 321, 379–382 (2008).
|
||||
% (doi: 10.1126/science.1158573),
|
||||
% for maximum likelihood:
|
||||
% P. Thibault and M. Guizar-Sicairos, Maximum-likelihood refinement for coherent diffractive imaging, New J. Phys. 14, 063004 (2012).
|
||||
% (doi: 10.1088/1367-2630/14/6/063004),
|
||||
% for mixed coherent modes:
|
||||
% P. Thibault and A. Menzel, Reconstructing state mixtures from diffraction measurements, Nature 494, 68–71 (2013). (doi: 10.1038/nature11806),
|
||||
% and/or for multislice:
|
||||
% E. H. R. Tsai, I. Usov, A. Diaz, A. Menzel, and M. Guizar-Sicairos, X-ray ptychography with extended depth of field, Opt. Express 24, 29089–29108 (2016).
|
||||
% (doi: 10.1364/OE.24.029089).
|
||||
% 6. Except for the above-mentioned acknowledgment, LICENSEE shall not use the PROGRAM title or the names or logos of LICENSOR, nor any adaptation thereof, nor the
|
||||
% names of any of its employees or laboratories, in any advertising, promotional or sales material without prior written consent obtained from LICENSOR in each case.
|
||||
% 7. Ownership of all rights, including copyright in the PROGRAM and in any material associated therewith, shall at all times remain with LICENSOR, and LICENSEE
|
||||
% agrees to preserve same. LICENSEE agrees not to use any portion of the PROGRAM or of any IMPROVEMENTS in any machine-readable form outside the PROGRAM, nor to
|
||||
% make any copies except for its internal use, without prior written consent of LICENSOR. LICENSEE agrees to place the following copyright notice on any such copies:
|
||||
% © All rights reserved. PAUL SCHERRER INSTITUT, Switzerland, Laboratory for Macromolecules and Bioimaging, 2017.
|
||||
% 8. The LICENSE shall not be construed to confer any rights upon LICENSEE by implication or otherwise except as specifically set forth herein.
|
||||
% 9. DISCLAIMER: LICENSEE shall be aware that Phase Focus Limited of Sheffield, UK has an international portfolio of patents and pending applications which relate
|
||||
% to ptychography and that the PROGRAM may be capable of being used in circumstances which may fall within the claims of one or more of the Phase Focus patents,
|
||||
% in particular of patent with international application number PCT/GB2005/001464. The LICENSOR explicitly declares not to indemnify the users of the software
|
||||
% in case Phase Focus or any other third party will open a legal action against the LICENSEE due to the use of the program.
|
||||
% 10. This Agreement shall be governed by the material laws of Switzerland and any dispute arising out of this Agreement or use of the PROGRAM shall be brought before
|
||||
% the courts of Zürich, Switzerland.
|
||||
Reference in New Issue
Block a user