Difference between revisions of "L498 Thermolysin"

From cctbx_xfel
Jump to: navigation, search
(Prepare to mask out the untrusted pixels)
Line 179: Line 179:
 
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.   
 
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.   
 
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e157.cfg]].
 
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e157.cfg]].
 +
 +
Now we'll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:
 +
* Hot pixels--on the average-dark the pixel values exceed 1350 (should be fine tuned by inspecting the dark & using trial and error)
 +
* Hot pixels--on the standard deviation-dark the stddev exceeds 5 and therefore unreliable (also should be fine tuned by trial and error)
 +
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 20 here)
 +
 +
cxi.make_mask -v --maxproj_min 20 --avg_max 1350 --stddev_max 5 --output mask_base.pickle \
 +
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r0031/000/out/avg-r0031.pickle \
 +
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r0031/000/out/stddev-r0031.pickle \
 +
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e157/r0020/000/out/max-r0020.pickle
 +
 +
Inspect the mask:
 +
cctbx.image_viewer mask_base.pickle show_untrusted=true
 +
 +
Simple thresholding wasn't sufficient for capturing some shadow areas and also an apparent untrusted region in one of the ASICs.  Calculate some additional masks using the polygon feature; tied to our current metrology.  Reading off polygon vertices from the cctbx.image_viewer, be sure to read coordinates as fast,slow (reverse order).
 +
 +
cxi.make_mask -v --poly_mask=1258,83,1148,9,1258,9 --output=mask_inactive.pickle -a 3000 -s 100 -m 0 \
 +
/reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r0031/000/out/avg-r0031.pickle \
 +
/reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r0031/000/out/stddev-r0031.pickle \
 +
/reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e157/r0020/000/out/max-r0020.pickle
 +
 +
Shadow on
 +
 +
libtbx.python
 +
> from libtbx import easy_pickle
 +
> data1= easy_pickle.load(path1)
 +
> data1["DATA"] |= data2["DATA"]
 +
> easy_pickle.dump(data1, path3)
 +
The command syntax is explained [[Pre-processing#Creating_a_mask_image | here]].  Move the mask to a suitable directory:
 +
mv mask_*.pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e157/mask_calibrate17.pickle
  
 
=Correct the detector metrology=
 
=Correct the detector metrology=

Revision as of 22:28, 19 August 2014

In this tutorial, we assume that we are handed an SFX dataset containing thermolysin diffraction, but are not told anything else. We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology. At this point, we will be prepared to integrate and merge the data. Finally, we will perform simple molecular replacement and ask whether there is any Zn signal in the anomalous difference Fourier.

Discovery of data collection parameters

Log in to pslogin.slac.stanford.edu, and then to psana. Carry through flags so that X-windows will work

ssh -YAC $USER@pslogin.slac.stanford.edu
ssh -YAC psana

Go in to the working directory and source the package manager:

cd ~/myrelease
sit_setup

Create a subdirectory for the 2014 tutorial files if not already done:

mkdir -p cxi84914

List out the thermolysin XTC files:

ls /reg/d/psdm/cxi/cxi84914/xtc/e157

Notice that there are numerous runs in the directory. Now we will create composite averages for each run. Grab this configuration file: mkdark.cfg and put it in your cxi84914 directory. For one run only:

cxi.lsf -c ~/myrelease/cxi84914/mkdark.cfg \
-o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/ \
-i /reg/d/psdm/cxi/cxi84914/xtc/e157 -q psanacsq -s -p 8 -x 157 -r 16 -t 0

Take note:

  • -c configuration file
  • -o output directory (will be created)
  • -i input files (directory containing the XTC streams)
  • -q which batch queue to use
  • -s funnel all streams for the run into one node (takes longer, but necessary for averaging)
  • -p number of cores to use on the node
  • -x which experiment number
  • -r which run number
  • -t which processing trial (auto increments from 0 if not given)

For all the runs in the thermolysin data set:

kinit
aklog
for m in 16 17 18 19 20 21 22 23 24 25 26 27 31 71 72 73; \
 do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark.cfg \
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/ \
 -i /reg/d/psdm/cxi/cxi84914/xtc/e157 -q psanacsq -s -p 8 -x 157 -r ${m} -t 0; done

bjobs lists all your batch jobs; use this form for more information including other-user load:

bjobs -w -u all -q psanacsq
bkill [number] # stops unwanted job

Some runs take up to 2 hrs wall time to average. Find the averages, view the max-composites, and list out header information:

ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r*/000/out/*.pickle
cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r*/000 -name "max*.pickle"`
for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r*/000 -name "max*.pickle"`; 
 do echo $m; cxi.print_pickle $m; echo; done

Let's make a table of the results:

Run Distance Wavelength Diffraction Comments
16 271.0 1.2686 weak powder
17 221.0 1.2686 weak powder
18 221.0 1.2686 weak powder
19 221.0 1.2686 weak powder
20 221.0 1.2686 strong powder
21 171.0 1.2686 strong powder shadow
22 171.0 1.2686 strong powder shadow
23 171.0 1.2686 strong powder shadow
24 171.0 1.2686 strong powder shadow
25 171.0 1.2686 strong powder shadow
26 171.0 1.2686 strong powder shadow
27 171.0 1.2686 strong powder shadow
31 570.9 1.2686 Dark
71 271.0 1.2966 weak powder
72 131.0 1.2966 weak powder shadow
73 131 1.2966 strong powder shadow

Some conclusions:

  • Run 31 was the dark run. We'll use the average and standard deviation for further processing. Tutorial students can take result from the instructor's directory:
/reg/d/psdm/cxi/cxi84914/scratch/nksauter/initial_dark/e157/r0031/000/out/avg-r0031.pickle
/reg/d/psdm/cxi/cxi84914/scratch/nksauter/initial_dark/e157/r0031/000/out/stddev-r0031.pickle
  • We are interested in getting the Zn anomalous signal from thermolysin, therefore we'll discard runs 71-73 collected at 1.2966 Angstroms, lower energy than the Zn K-edge at 9659 eV or 1.2836 Angstroms. See the X-ray handbook.
  • We'll also discard run 16 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.
  • We'll accept runs 17-20 ("calibration17"), and runs 21-27 ("calibration21").

Prepare to mask out the untrusted pixels

We'll now calculate dark-subtracted averages.

for m in 17 18 19 20 21 22 23 24 25 26 27; \
 do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e157.cfg \
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e157/ \
 -i /reg/d/psdm/cxi/cxi84914/xtc/e157 -q psanacsq -s -p 8 -x 157 -r ${m} -t 0; done

This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted. The dark image to be subtracted (along with its std deviation) is defined in the configuration file mkavg_e157.cfg.

Now we'll figure out which pixels are untrusted, and thus should not be integrated. Three criteria will be used:

  • Hot pixels--on the average-dark the pixel values exceed 1350 (should be fine tuned by inspecting the dark & using trial and error)
  • Hot pixels--on the standard deviation-dark the stddev exceeds 5 and therefore unreliable (also should be fine tuned by trial and error)
  • Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 20 here)
cxi.make_mask -v --maxproj_min 20 --avg_max 1350 --stddev_max 5 --output mask_base.pickle \
 /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r0031/000/out/avg-r0031.pickle \
 /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r0031/000/out/stddev-r0031.pickle \
 /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e157/r0020/000/out/max-r0020.pickle

Inspect the mask:

cctbx.image_viewer mask_base.pickle show_untrusted=true

Simple thresholding wasn't sufficient for capturing some shadow areas and also an apparent untrusted region in one of the ASICs. Calculate some additional masks using the polygon feature; tied to our current metrology. Reading off polygon vertices from the cctbx.image_viewer, be sure to read coordinates as fast,slow (reverse order).

cxi.make_mask -v --poly_mask=1258,83,1148,9,1258,9 --output=mask_inactive.pickle -a 3000 -s 100 -m 0 \
/reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r0031/000/out/avg-r0031.pickle \
/reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r0031/000/out/stddev-r0031.pickle \
/reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e157/r0020/000/out/max-r0020.pickle

Shadow on

libtbx.python 
> from libtbx import easy_pickle
> data1= easy_pickle.load(path1)
> data1["DATA"] |= data2["DATA"]
> easy_pickle.dump(data1, path3)

The command syntax is explained here. Move the mask to a suitable directory:

mv mask_*.pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e157/mask_calibrate17.pickle

Correct the detector metrology

Integrate the data

Merge the data

Solve the structure