Top Banner
Introduction Using the software Plans and summary The 4th International Workshop on FEL Science DIXE: Software for Coherent X-ray Diffractive Imaging N. M. Davidson , B. Abbey, H. M. Quiney and K. A. Nugent The University of Melbourne Thursday, September 1st 2011 N. M. Davidson , B. Abbey, H. M. Quiney and K. A. Nugent DIXE: Software for Coherent X-ray Diffractive Imaging 1 / 14
27

DIXE: Software for Coherent X-ray Diffractive Imaging

Feb 03, 2022

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: DIXE: Software for Coherent X-ray Diffractive Imaging

IntroductionUsing the softwarePlans and summary

The 4th International Workshop on FEL Science

DIXE: Software for Coherent X-ray

Diffractive Imaging

N. M. Davidson, B. Abbey, H. M. Quiney and K. A. Nugent

The University of Melbourne

Thursday, September 1st 2011

N. M. Davidson, B. Abbey, H. M. Quiney and K. A. Nugent DIXE: Software for Coherent X-ray Diffractive Imaging 1 / 14

Page 2: DIXE: Software for Coherent X-ray Diffractive Imaging

IntroductionUsing the softwarePlans and summary

Motivation

The last decade has seen an advancement in diffractive imagingtechniques due to a combination of superior experimental set-ups,growing computer power and the development of algorithms for imagereconstruction.

Traditionally each researcher or group has written their own code forimplementing the reconstruction algorithms - a task which is timeconsuming and error prone.

As experiments (and experimental collaborations) become larger andmore complex, it is necessary that software is engineered and thatstandard software packages are created for the CDI community.

The software package HAWKE (F. Maia et. al.) exists for plane wavediffractive imaging, however, to the best of our knowledge there is nopackage publically available which also incorporates Fresnel diffractiveimaging.

N. M. Davidson, B. Abbey, H. M. Quiney and K. A. Nugent DIXE: Software for Coherent X-ray Diffractive Imaging 2 / 14

Page 3: DIXE: Software for Coherent X-ray Diffractive Imaging

IntroductionUsing the softwarePlans and summary

Introducing DIXE

DIXE - Diffractive Imaging for X-rays and Electrons

Is a software library for performing:

Plane wave coherent diffractive imaging (Planar CDI)Fresnel coherent diffractive imaging (FCDI)- Reconstruction of the white-field- Reconstruction of the exit-surface wave and transmissionfunction of the samplePhase-Diverse/Ptychographic image reconstruction

In addition to a C++ library which users can import into their ownC/C++ code, it also has wrapper routines for IDL users, and some basiccommand line tools.

Various examples are provided to demonstrate how to use the C++functions, IDL routines and command-line tools for both reconstructionand simulation.

It is multi-platform - source code and instructions for installing areprovided for Ubuntu (link), Mac (OS X 10.6), Windows with Cygwin. 32bit binary files for IDL only are provided for Windows.

The first developmental version of the software library is now ready fortesting/use. It is available under the GNU General Public License.

N. M. Davidson, B. Abbey, H. M. Quiney and K. A. Nugent DIXE: Software for Coherent X-ray Diffractive Imaging 3 / 14

Page 4: DIXE: Software for Coherent X-ray Diffractive Imaging

IntroductionUsing the softwarePlans and summary

How to use DIXE

scale intensity apply support

propagate to sample plane

propagate to detector plane

Load input data

Initialise the recon-struction library

Iterate

Save Result

N. M. Davidson, B. Abbey, H. M. Quiney and K. A. Nugent DIXE: Software for Coherent X-ray Diffractive Imaging 4 / 14

Page 5: DIXE: Software for Coherent X-ray Diffractive Imaging

IntroductionUsing the softwarePlans and summary

How to use DIXE

Functions are provided for reading hdf, tiffand ppm image files.

In C++

//read in the data

Double_2D data;

read_image(‘‘data_file_name.tiff’’, data);

//read in the support shape

Double_2D support;

read_image(‘‘support_file_name.tiff’’, support );

In IDL

data = CXS_READ_PPM (1024 , 1024, ’data_file.ppm’)

etc. or use one of IDLs built in libraries toget the input in matrix form.

Load input data

Initialise the recon-struction library

Iterate

Save Result

N. M. Davidson, B. Abbey, H. M. Quiney and K. A. Nugent DIXE: Software for Coherent X-ray Diffractive Imaging 4 / 14

Page 6: DIXE: Software for Coherent X-ray Diffractive Imaging

IntroductionUsing the softwarePlans and summary

How to use DIXE

The reconstruction code must be initialisedfor either plane-wave, Fresnel white-field,Fresnel or phase diverse reconstruction.

In C++

// Create a complex 2D field which will

//hold the result of the reconstruction.

Complex_2D object_estimate(nx ,ny);

// Create the planar CDI object which will

//be used to perform the reconstruction.

PlanarCDI planar(object_estimate );

//set the support and intensity

planar.set_support(support ,false);

planar.set_intensity(data);

In IDL

CXS_INIT_PLANAR , data , support

Load input data

Initialise the recon-struction library

Iterate

Save Result

N. M. Davidson, B. Abbey, H. M. Quiney and K. A. Nugent DIXE: Software for Coherent X-ray Diffractive Imaging 4 / 14

Page 7: DIXE: Software for Coherent X-ray Diffractive Imaging

IntroductionUsing the softwarePlans and summary

How to use DIXE

Run the reconstruction!

In C++

planar.iterate ();

In IDL

; Perform one iteration. The exit -

; surface -wave is return to ’result ’

result = CXS_ITERATE ()

; Perform 50 iterations

result = CXS_ITERATE (50)

Load input data

Initialise the recon-struction library

Iterate

Save Result

N. M. Davidson, B. Abbey, H. M. Quiney and K. A. Nugent DIXE: Software for Coherent X-ray Diffractive Imaging 4 / 14

Page 8: DIXE: Software for Coherent X-ray Diffractive Imaging

IntroductionUsing the softwarePlans and summary

How to use DIXE

Save the result to file.

In C++

// write out the result:

// - as a complex binary file

write_cplx(temp_str.str(), object_estimate );

// - just the magnitude as an image

Double_2D object_mag;

object_estimate.get_2d(MAG ,object_mag );

write_image("mag.tiff",object_mag );

In IDL

; Record the complex field to a binary file

CXS_WRITE_CPLX , result , ’result_file.cplx’

The magnitude and phase of the complexmatrix can be viewed and saved using thestandard IDL routines.

Load input data

Initialise the recon-struction library

Iterate

Save Result

N. M. Davidson, B. Abbey, H. M. Quiney and K. A. Nugent DIXE: Software for Coherent X-ray Diffractive Imaging 4 / 14

Page 9: DIXE: Software for Coherent X-ray Diffractive Imaging

IntroductionUsing the softwarePlans and summary

Software Options

Various aspects of the reconstruction can be configured:

Changing between different algorithms (e.g. HIO to ER) or creating acustom algorithm.

C++

// to error reduction:

planar.set_algorithm(ER);

// or to a custom algorithm:

planar.set_custom_algorithm (0.5,0,-1,0,-1,0,0,0,0,0);

// where the input parameters are coefficients to

// a set of projection operators.

IDL

CXS_SET_ALGORITHM , ’ER’

CXS_SET_CUSTOM_ALGORITHM ,0.5,0,-1,0,-1,0,0,0,0,0

Available Algorithms

ER - error reduction, BIO - basic input-output, BOO - basic output-output, HIO - hybrid input-output, DM -

difference map, SF - solvent-flipping, ASR - averaged successive reflections, HPR - hybrid projection reflection,

RAAR - relaxed averaged alternating reflectors

N. M. Davidson, B. Abbey, H. M. Quiney and K. A. Nugent DIXE: Software for Coherent X-ray Diffractive Imaging 5 / 14

Page 10: DIXE: Software for Coherent X-ray Diffractive Imaging

IntroductionUsing the softwarePlans and summary

Updating the support or use the shrink-wrap algorithm at any point inthe reconstruction.C++

planar.set_support(support );

planar.apply_shrinkwrap ()

IDL

CXS_SET_SUPPORT , my_support_matrix

CXS_APPLY_SHRINKWRAP

N. M. Davidson, B. Abbey, H. M. Quiney and K. A. Nugent DIXE: Software for Coherent X-ray Diffractive Imaging 6 / 14

Page 11: DIXE: Software for Coherent X-ray Diffractive Imaging

IntroductionUsing the softwarePlans and summary

Updating the support or use the shrink-wrap algorithm at any point inthe reconstruction.C++

planar.set_support(support );

planar.apply_shrinkwrap ()

IDL

CXS_SET_SUPPORT , my_support_matrix

CXS_APPLY_SHRINKWRAP

Starting with any exit-surface wave initialisation (e.g. reloading a resultfrom a previous reconstruction), or use the default initialisation.C++

// if a complex matrix called ‘‘esw ’’ has already been loaded or created

PlanarCDI planar(esw); //or

planar.set_exit_surface_wave (esw);

//or to initialise with random numbers do

planar.initialise_estimate ();

// for Fresnel CDI you can also use

my_fresnel.set_transmission_function(transmission)

IDL

CXS_INIT_PLANAR , my_data , my_support , my_starting_point

CXS_INITIALISE_ESW

N. M. Davidson, B. Abbey, H. M. Quiney and K. A. Nugent DIXE: Software for Coherent X-ray Diffractive Imaging 6 / 14

Page 12: DIXE: Software for Coherent X-ray Diffractive Imaging

IntroductionUsing the softwarePlans and summary

And there are many others options.. for example:

Choice of image file to read in and out from.

Saving a subset of results with the lowest error metric (e.g. for the HIOalgorithm).

Adding extra constraints such as charge flipping, enforce homogeneity ofthe material etc.

Phase-diverse/ptychographic reconstruction may be performed in parallelor series.

Automatic alignment of image positions (transverse to beam) forphase-diverse/ptychographic reconstruction.

If a user requires some special functionality which is not provided, they caneasily create a customised reconstruction algorithm using the building blocksprovided.

N. M. Davidson, B. Abbey, H. M. Quiney and K. A. Nugent DIXE: Software for Coherent X-ray Diffractive Imaging 7 / 14

Page 13: DIXE: Software for Coherent X-ray Diffractive Imaging

IntroductionUsing the softwarePlans and summary

Video demonstration

Fresnel Reconstruction in IDL (using C. Putkunz’s data)

Reconstruction of the white-field at the detector:

Load images of the white-field intensity (in the detector plane)and support (zone plate plane)Initialise the white-field reconstruction libraryPerform 20 iterations of 3-plane propagation(detector→focal→zone-plate)

Reconstruction of the sample:

Load the sample’s diffraction pattern and the support shape.Initialise the Fresnel reconstruction librarySet some extra constraints (e.g. charge-flipping)Perform 20 iterations to reconstruct the sample’sexit-surface-wave

Save the result

N. M. Davidson, B. Abbey, H. M. Quiney and K. A. Nugent DIXE: Software for Coherent X-ray Diffractive Imaging 8 / 14

Page 14: DIXE: Software for Coherent X-ray Diffractive Imaging

IntroductionUsing the softwarePlans and summary

Video Demonstration

N. M. Davidson, B. Abbey, H. M. Quiney and K. A. Nugent DIXE: Software for Coherent X-ray Diffractive Imaging 9 / 14

Page 15: DIXE: Software for Coherent X-ray Diffractive Imaging

IntroductionUsing the softwarePlans and summary

IDL ROUTINES

N. M. Davidson, B. Abbey, H. M. Quiney and K. A. Nugent DIXE: Software for Coherent X-ray Diffractive Imaging 10 / 14

Page 16: DIXE: Software for Coherent X-ray Diffractive Imaging

IntroductionUsing the softwarePlans and summary

C++ Functions

BaseCDI

+BaseCDI()+~BaseCDI()+iterate()+initialise_estimate()+get_best_result()+set_support()+set_intensity()+set_beam_stop()+set_relaxation_parameter()+get_size_x()+get_size_y()+get_exit_surface_wave()+set_exit_surface_wave()+set_algorithm()+set_custom_algorithm()+print_algorithm()+get_error()+apply_shrinkwrap()+get_support()+apply_support()+project_intensity()+scale_intensity()+propagate_to_detector()+propagate_from_detector()+set_fftw_type()+set_complex_constraint()

PlanarCDI

+PlanarCDI()+get_intensity_autocorrelation()

TransmissionConstraint

+TransmissionConstraint()+~TransmissionContraint()+add_complex_constraint()+set_charge_flipping()+set_enforce_unity()+set_custom_constraint()+apply_constraint()

FresnelCDI

+FresnelCDI()+~FresnelCDI()+initialise_estimate()+auto_set_norm()+get_transmission_function()+apply_support(): virtual void +set_transmission_function()+scale_intensity()+propagate_from_detector()+propagate_to_detector()+set_normalisation()+set_experimental_parameters()+get_illumination_at_sample()

PhaseDiverseCDI

+PhaseDiverseCDI()+~PhaseDiverseCDI()+iterate()+add_new_position()+set_iterations_per_cycle()+set_feedback_parameter()+set_amplification_factor()+set_probe_scaling()+initialise_estimate()+get_transmission()+set_transmission()+adjust_positions()+get_final_x_position()+get_final_y_position()

FresnelCDI_WF

+FresnelCDI_WF()+~FresnelCDI_WF()+iterate()+propagate_from_detector()+propagate_to_detector()+initialise_estimate()+set_support()

ComplexConstraint

+ComplexConstraint()+set_fixed_c()+get_c_mean()+set_c_mean()+set_alpha1()+set_alpha2()+get_new_mag()+get_new_phase()+get_region()

may apply a

1

contains

1..*

consists of several

1..*

Each “class” (box) is one module of the library with its associated functions

N. M. Davidson, B. Abbey, H. M. Quiney and K. A. Nugent DIXE: Software for Coherent X-ray Diffractive Imaging 11 / 14

Page 17: DIXE: Software for Coherent X-ray Diffractive Imaging

IntroductionUsing the softwarePlans and summary

Command line tools

Some simple tools are provided for the Windows and Linux/Unix terminal as ademonstrative tool or to obtain results quickly. However, they are less flexibilitythan using C++ or IDL.

CDI reconstruction.exe - For performing Planar or Fresnel reconstruction.

CDI_reconstruction.exe <config filename > <reco_type > <seed >

PhaseDiverseFresnelRec.exe - For performing phase-diverse andptychographic reconstructions of Fresnel data.

PhaseDiverseFresnelRec.exe <data list filename > <iterations > <sub -iterations >

optional parameters:

<beta > <gamma > <running -mode > <do alignment > <seed > <unity > <flipping >

Conversion between image file formats.

N. M. Davidson, B. Abbey, H. M. Quiney and K. A. Nugent DIXE: Software for Coherent X-ray Diffractive Imaging 12 / 14

Page 18: DIXE: Software for Coherent X-ray Diffractive Imaging

IntroductionUsing the softwarePlans and summary

Future Objectives

In the short-term we plan to add functionality to the code for:

reconstructing with partial coherence anddata cleaning and raw data processing.

As well as some technical improvements:

allow parallel processing,add experimental parameters to the meta data of input/outputimages andwriting binding for the library in more languages (in particularMatlab and/or python).

As more members of the community begin using the code, there is nodoubt that bugs and extra requirements will be revealed. We plan toinvest some effort in making the software as robust as possible.

More documentation.

N. M. Davidson, B. Abbey, H. M. Quiney and K. A. Nugent DIXE: Software for Coherent X-ray Diffractive Imaging 13 / 14

Page 19: DIXE: Software for Coherent X-ray Diffractive Imaging

IntroductionUsing the softwarePlans and summary

Summary

CXS has been developing software for the coherent diffractive imagingcommunity.

The first developmental version of the software library is now ready fortesting/use.

We have already had success within CXS with new members using thesoftware.

The priority for future releases will be parallelisation of the code andadded functionality for partial coherence.

http://www.ph.unimelb.edu.au/~ndavidson/cxs/

Acknowledgements go to various Latrobe and Melbourne University membersof CXS who have tested the software or provided test data: M. Jones, C.Putkunz, A. Torrance, A. Carroll, M. B. Luu and I. Peterson.

N. M. Davidson, B. Abbey, H. M. Quiney and K. A. Nugent DIXE: Software for Coherent X-ray Diffractive Imaging 14 / 14

Page 20: DIXE: Software for Coherent X-ray Diffractive Imaging

IntroductionUsing the softwarePlans and summary

EXTRA SLIDES

N. M. Davidson, B. Abbey, H. M. Quiney and K. A. Nugent DIXE: Software for Coherent X-ray Diffractive Imaging 15 / 14

Page 21: DIXE: Software for Coherent X-ray Diffractive Imaging

IntroductionUsing the softwarePlans and summary

Speed

1.2 GHz Laptop with 1.5 GB RAMIteration per Second

PlanarCDI (ER) 3.3PlanarCDI (HIO) 2.7FresnelCDI - white field 2.0FresnelCDI 2.7FresnelCDI with Complex Constraints 1.8

Table: CPU time for a 1024×1024 pixel reconstruction.

N. M. Davidson, B. Abbey, H. M. Quiney and K. A. Nugent DIXE: Software for Coherent X-ray Diffractive Imaging 16 / 14

Page 22: DIXE: Software for Coherent X-ray Diffractive Imaging

IntroductionUsing the softwarePlans and summary

Memory Usage

Number of N×N With p=4, N=1024pixel arrays used (MB)

PlanarCDI (ER) 4 17PlanarCDI (HIO) 10 42FresnelCDI - white field 4.5 19FresnelCDI 8.5 36FresnelCDI with complex constraints 11.5 + c 57 (c=2)Phase-Diverse/Ptychography I (1 + X ) + 2M/N 30,000 (I=400,M = 11002,

X = FresnelCDI)

Table: The memory used....... In total the memory used will be thefactor given in the second column of Figure 2 multiplied by pN2. (N -image side length in pixels, p - precision in bytes, c - number of complexconstraint regions, I - number of images, M - area, in pixels, of thephase-diverse image, X - number of arrays needed for a singlereconstruction )

N. M. Davidson, B. Abbey, H. M. Quiney and K. A. Nugent DIXE: Software for Coherent X-ray Diffractive Imaging 17 / 14

Page 23: DIXE: Software for Coherent X-ray Diffractive Imaging

IntroductionUsing the softwarePlans and summary

Functional Requirements

A preliminary set of requirements can be found on the website.The functionality which the software should provide for reconstruction is:

Essential

X Planar reconstruction

X Reconstruct the phase of thewhite-field using 3-planepropagation

X Fresnel reconstruction

Holographic 1 stepreconstruction

Refine the experimentalparameters duringreconstruction

X Update the support or use theshrink-wrap algorithm

X Be able to change betweenalgorithms (e.g HIO to ER)

X Stop a reconstruction, save theresult and restart at the sameplace

X Perform Simulations

Very Useful

X Ptychography

X Additional Constraints

Extension

Partial CDI reconstruction

Form an initial support (e.g.based on autocorrelation)

Automatically check forstagnation duringreconstruction

Automatically check thattransmission function isconsistent with objectproperties (e.g. check forphase wrapping)

Automatically check forconsistency between ESW andobject properties (e.g. checkfor phase wrapping)

Estimate the resolution

X - implemented

N. M. Davidson, B. Abbey, H. M. Quiney and K. A. Nugent DIXE: Software for Coherent X-ray Diffractive Imaging 18 / 14

Page 24: DIXE: Software for Coherent X-ray Diffractive Imaging

IntroductionUsing the softwarePlans and summary

Requirements for cleaning raw data prior to input into the reconstructionalgorithms:

Essential

X Read HDF files and convert between different file formats

X Darkfield Subtraction

X Get data on a log scale

Very Useful

Plot the average intensity versus frame number, full-frame and ROI

Check for saturation/dead pixels

Run correlations on data and white-fields

Extract ring current, motor positions etc. from HDF files

Check the beam stability in data over time

Check correlations after dark-field subtraction

X Merge (add or average) data files together

Determine the normalisation of the white-field to data

X Get the autocorrelation function

Extension

Scroll through O(100) low resolution version of the data

N. M. Davidson, B. Abbey, H. M. Quiney and K. A. Nugent DIXE: Software for Coherent X-ray Diffractive Imaging 19 / 14

Page 25: DIXE: Software for Coherent X-ray Diffractive Imaging

IntroductionUsing the softwarePlans and summary

Documentation

N. M. Davidson, B. Abbey, H. M. Quiney and K. A. Nugent DIXE: Software for Coherent X-ray Diffractive Imaging 20 / 14

Page 26: DIXE: Software for Coherent X-ray Diffractive Imaging

IntroductionUsing the softwarePlans and summary

C++ Functions - Doxygen

N. M. Davidson, B. Abbey, H. M. Quiney and K. A. Nugent DIXE: Software for Coherent X-ray Diffractive Imaging 21 / 14

Page 27: DIXE: Software for Coherent X-ray Diffractive Imaging

IntroductionUsing the softwarePlans and summary

Doxygen cont.

N. M. Davidson, B. Abbey, H. M. Quiney and K. A. Nugent DIXE: Software for Coherent X-ray Diffractive Imaging 22 / 14