You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 27 Next »

Sections in this tutorial

It is important for people doing analysis to be able to look at the detector images and probe intensity values. Given that a typical LCLS experiment has millions of snapshots to choose from, it is also critical that you can quickly select images of interest and set regions of interest using masks. By the end of this tutorial, you will be able to browse image, jump to images of interest, generate mask, find peaks in your images and index crystal diffraction patterns.

 

Citation for psocake (and other psana-based programs):
@article{Damiani:zw5004, 
author = "Damiani, D. and Dubrovin, M. and Gaponenko, I. and Kroeger, W. and Lane, T. J. and Mitra, A. 
and O'Grady, C. P. and Salnikov, A. and Sanchez-Gonzalez, A. and Schneider, D. and Yoon, C. H.", 
title = "{Linac Coherent Light Source data analysis using {it psana}}", 
journal = "Journal of Applied Crystallography", 
year = "2016", volume = "49", number = "2", pages = "672--679", month = "Apr", 
doi = {10.1107/S1600576716004349}, url = {http://dx.doi.org/10.1107/S1600576716004349}, }

Starting psocake

Make sure you have the psana environment setup (psana python Setup) before starting this tutorial. Also, check out a kerberos ticket by typing “kinit” which is needed for communicating with the experiment e-Log.

Type "psocake" on your terminal to open up the GUI. For crystallography, we will need to open it in sfx mode (-m):

$ sit_setup nightly-20160717 # (Optional) To get the bleeding edge version, use the nightly build
$ psocake -m sfx

 

1) There are four parameters required to uniquely identify an image at LCLS. Type the experiment name, run number, detector name, and event number in the Experiment Parameters panel.

For this tutorial, we will look at experiment cxitut13, run 10, detector DscCsPad, event 11.

Note that available detector names will be printed on the terminal once you have typed in the experiment name and the run number. 
#######################################
# Available area detectors: 
# ('CxiDs1.0:Cspad.0', 'DscCsPad', '')
#######################################

2)  You can specify the experiment parameters as command line arguments in psocake using the psana-style experiment run string:

$ psocake exp=cxitut13:run=10 -d DscCsPad -n 11 -m sfx

3)  You can also use the -e and -r arguments for the experiment and the run number:

$ psocake -e cxitut13 -r 10 -d DscCsPad -n 11 -m sfx

To check psocake version:

$ psocake --version

Don’t worry if you don’t remember these arguments. For argument options, use --help:

$ psocake --help

Mask making

In this example, let's mask out pixels that should not be used for analysis, mask out the jet streak at the centre of the detector, and mask out the water ring.

Note: the Image Panel must be in the default "greyscale" colormap for the mask colors to display properly.

1) On the mask panel, click on "Use psana mask". This will mask out the following pixels that should not be used for analysis; calib, status, edge, central, unbonded pixels, unbonded pixel neighbor pixels. These pixels are shown as green on the image panel.

2) On the mask panel, click on "Use streak mask". This will mask out strong intensities originating from the edges of the central asics.

3) To make a donut mask over the water ring, click on "Use user-defined mask". This will bring up a cyan circle and cyan square mask generator.

Select "Toggle" in Masking mode. Move the cyan circle to the centre of the detector by dragging the circle. Resize the cyan circle by dragging the diamond on the perimeter. Once you are happy with the position, click "mask circular ROI" button on the mask panel.

Increase the cyan circle again by dragging the diamond on the perimeter. Click "mask circular ROI" button on the mask panel. Because we are in the "toggle" mode, the previous mask gets toggled and disappears. The area that does not overlap with the previous mask get masked out.

To save the user-defined mask, click on "Save user-defined mask" on the mask panel which will save the mask in the scratch folder. For this example, the mask will be saved here:

/reg/d/psdm/cxi/cxitut13/scratch/<username>/psocake/r0010/mask.npy (3D ndarray)

/reg/d/psdm/cxi/cxitut13/scratch/<username>/psocake/r0010/mask.txt (2D text)

You can load the user-defined mask using the "Load user-defined mask" button and selecting mask.npy.

Peak finding

 

To find the Bragg peaks on the image, set the "Algorithm" to “Droplet” in the Peak Finder panel.
Examine the peaks found by zooming in/out with the middle mouse scroll (or a two finger slide on a Mac touchpad). Notice that the Bragg peaks are composed of 2 to 6 connected pixels. Setting the radius to 2 sets a 5x5 cyan boundary around the Bragg peaks (radius x 2+1 = 5). Change the following values in the Peak Finder panel.
  • Set npix_min: 2
  • Set npix_max: 5
  • radius: 2

Hover the mouse pointer over the Bragg peaks to study the intensities. The sum of the Bragg peak pixels are above 400 ADUs. Set the following values:

  • Set atot_thr: 400
Move the green square over the water ring to study the level of background noise in the ROI Histogram panel. Notice that the water ring intensities can go up to 160 ADUs. A Bragg spot is at least 250 ADUs. Signal to noise ration seems to be around 4, so set the following values.
  • thr_low: 160
  • thr_high: 250
  • son_min: 4

 

You can jump to other events to see if your peak parameters are well tuned. Once you are happy, let's launch the peak finder on the cluster.

The output directory on the peak finder panel should already be automatically set to: /reg/d/psdm/cxi/cxitut13/scratch/<username>/psocake

Since we are analyzing run 10, /r0010 directory will be generated under the output directory.
The default setting will analyze run 10 on psanaq with 24 CPUs. Number of events to process set to 0 analyzes all the events.
Click "Launch peak finder”. For this demo, let's analyze only 30 events with 2 CPUs
  • Run(s): 10
  • CPUs: 2
  • Number of events to process: 30
Note: You can launch peak finding jobs on multiple runs, e.g. Run(s) 1,10:13 will launch peak finding on runs 1, 10, 11, and 13.
The CXIDB file is generated in the output directory in the following format: <experiment name>_<4-digit run number>.cxi (i.e., /reg/d/psdm/cxi/cxitut13/scratch/<username>/psocake/r0010/cxitut13_0010.cxi) 

Two virtual powder patterns will also be generated in the run directory:
1) cxitut13_0010_maxHits.npy: Maximum pixel values for hits found
2) cxitut13_0010_maxMisses.npy: Maximum pixel values for misses
If the hit finding parameters are good, cxitut13_0010_maxMisses.npy should not contain many Bragg spots. You can look at these images by using the "Load image" button in the Image Control panel.

Jumping to interesting images based on the number of peaks

Once you have submitted the peak finder job, let's plot the number of peaks found for each event.

In the small data panel, type the CXIDB filename:

  • filename: /reg/d/psdm/cxi/cxitut13/scratch/<username>/psocake/r0010/cxitut13_0010.cxi
  • dataset: /entry_1/result_1/nPeaksAll
"/entry_1/result_1/nPeaksAll" is an array containing number of peaks found for each event. Unfortunately the naming convention is cryptic, but it is how it is named inside a CXIDB file.
This should load a plot of all the peaks found so far per event. Click "Refresh" to update the plot even if your batch job is still running.
You can click on the red marker in the plot to jump to the corresponding events. These lysozyme diffraction patterns have between 15 to 60 peaks.
Note: If you already have indexed the crystals, you can jump to the indexed patterns by using:
  • dataset: /entry_1/result_1/index

Indexing crystals

First things first, crystal indexing requires an accurate detector geometry. Latest CXI geometry files can be found here: Geometry history

Detector panels can manually adjusted using: calibman

If you are on a psana machine, you can run CrystFEL programs by setting up your environment:

source /reg/g/cfel/crystfel/crystfel-dev/setup-sh
CFDEPDIR=/reg/g/cfel/dependencies
export PATH=${CFDEPDIR}/bin:$PATH

Let's try to index the diffraction pattern at event 11.

  • In the experiment parameters panel, set Event Number to 11.

In the indexing panel, tick "Indexing on". Indexed peaks will be marked with magenta circles. These triple rings represent the integration radius.

Hopefully, you have indexed this diffraction pattern. Notice that the unitcell parameters are a bit off compared to what is expected. Let's load a CrystFEL unitcell file to help the indexer along.

  • In the Indexing panel, set the PDB field to: /reg/d/psdm/cxi/cxitut13/scratch/psocake/lys.cell
  • Set Indexing Method field to: dirax-axes-cell
CrystFEL unit cell file version 1.0
lattice_type = tetragonal
centering = P
unique_axis = c
a = 77.05 A
b = 77.05 A
c = 37.21 A
al = 90 deg
be = 90 deg
ga = 90 deg
You should notice that the reindexed result will match the known unit cell parameters more closely.
It is often the case at the beginning of a beamtime that the detector distance to the interaction point (coffset) is not well known, and we can use the Diffraction Geometry panel to find this distance.
  • In the diffraction geometry panel, set "Detector distance" to 156mm. Try incrementing this distance in 1mm step till the unit cell parameters are as close as possible to lys.cell. The optimum detector distance is around 158mm.
    Everytime the "Detector distance" value is changed by the user, psocake converts the psana geometry (in /reg/d/psdm/cxi/cxitut13/calib/CsPad\:\:CalibV1/CxiDs1.0\:Cspad.0/geometry/10-11.data) to a CrystFEL geom file (in /reg/d/psdm/cxi/cxitut13/scratch/<username>/psocake/<runNumber>/.temp.geom).
  • Try drawing a resolution ring on top of the water ring by using “Resolution (pixels)” field. If your detector distance is correct, the crystallographic resolution ring should display 3.2A.

Jumping to indexed images

Once you have completed indexing a run, you may want to look at the indexed events.

In the small data panel, type the CXIDB filename:

  • filename: /reg/d/psdm/cxi/cxitut13/scratch/<username>/psocake/r0010/cxitut13_0010.cxi
  • dataset: /entry_1/result_1/index
You can click on the red marker in the plot to jump to the corresponding events.

Bug/Comments:

Please send bug reports/comments to Chuck:

yoon82@slac.stanford.edu

  • No labels