Page History
...
Examples for Package ImgAlgos
See Package ImgAlgos
Example for Module ImgAlgos::
...
ImgAverage
See Module ImgAlgos::ImgCalibImgAverage
Code Block |
---|
[ImgAlgos.CameraImageProducerpsana] source = DetInfo(:Opal1000) key_in = key_out = img subtract_offset = true print_bits = 1 [ImgAlgos.ImgCalib] source = DetInfo(:Opal1000) key_in files = img key_out /reg/d/psdm/AMO/amo42112/xtc/e138-r0065-s00-c00.xtc modules = ImgAlgos.CameraImageProducer \ = calibrated fname_peds ImgAlgos.ImgAverage events = 1000 [ImgAlgos.CameraImageProducer] source = <pedestal-file-name> fname_mask = <mask-file-name> fname_bkgdDetInfo(:Opal1000) key_in = fname_gainkey_out = img subtract_offset = true print_bits = 31 |
Example of the mask file and resulting image:
Example for Module ImgAlgos::ImgPeakFinder
See Module ImgAlgos::ImgPeakFinder
Configuration file example:
Code Block |
---|
[psana]1 [ImgAlgos.ImgAverage] source = DetInfo(:Opal1000) key = img avefile = img-ave.dat rmsfile = img-rms.dat print_bits = 31 evts_stage1 = 100 evts_stage2 = files 100 gate_width1 = /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-1>.xtc \ 200 gate_width2 = 20 |
Example for Module ImgAlgos::ImgCalib
Code Block |
---|
[ImgAlgos.CameraImageProducer] source /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-2>.xtc \ = DetInfo(:Opal1000) key_in = key_out = ... img subtract_offset = true print_bits = 1 [ImgAlgos.ImgCalib] source /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-N>.xtc modules = ImgAlgos.ImgPeakFinder PrintSeparator #skip-events = 500 eventsDetInfo(:Opal1000) key_in = 120 [ImgAlgos.ImgPeakFinder] sourceimg key_out = DetInfo(:Opal1000) keycalibrated fname_peds = <pedestal-file-name> fname_mask = peaksKey<mask-file-name> fname_bkgd = peaks thresholdfname_lowgain = 20 threshold_high = 50 sigma print_bits = 31 |
Example of the mask file and resulting image:
Example for Module ImgAlgos::ImgRadialCorrection
See Module ImgAlgos::ImgRadialCorrection
Code Block |
---|
[psana] files = /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-1>.xtc \ /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-2>.xtc \ 1.5 smear_radius = 2 peak_radius = 3 xmin = 200... xmax = 800 ymin/reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-N>.xtc skip-events = 500 events = 10 modules = cspad_mod.CsPadCalib 100\ ymax# ImgAlgos.CSPadBkgdSubtract \ = 900 testEvent = CSPadPixCoords.CSPadImageProducer 115\ print_bits = 0 finderIsOn ImgAlgos.ImgRadialCorrection \ ImgAlgos.ImgSaveInFile:1 [cspad_mod.CsPadCalib] inputKey = outputKey true |
- This algorithm consumes ~15 ms/event on psana0101 for full Opal1000 (1024x1024) camera image.
- Smearing algorithm use a "safety margin" which is currently set to 10 pixels (offset from each boarder of the full image size).
Image on different stages of this algorithm:
- raw image,
- image in the window with amplitudes above the
threshold_low
- few peaks at the edges were discarded by the window limits,
- image still contains many 1-photon pixels, which need to be eliminated,
- smeared image,
- raw image with found peaks (marked by the red circles)
- zoom of the previous plot.
Example for Module ImgAlgos::ImgPeakFilter
Code Block |
---|
[ImgAlgos.ImgPeakFilter] source = DetInfo(:Opal1000) key = calibrated doPedestals = yes doPixelStatus = no doCommonMode = no [ImgAlgos.CSPadBkgdSubtract] source = DetInfo(CxiDs1.0:Cspad.0) inputKey = calibrated outputKey = bkgd_subtracted_arr bkgd_fname = <the-file-name-with-background-array> norm_sector = 0 print_bits = 0 [CSPadPixCoords.CSPadImageProducer] calibDir = /reg/d/psdm/<instrument>/<experiment>/calib typeGroupName = CsPad::CalibV1 source = peaks threshold_peak = 5 threshold_total= CxiDs1.0:Cspad.0 n_peaks_minkey = 10 print_bits = 11calibrated fname imgkey = current_img selection_mode#tiltIsApplied = SELECTION_ON |
Example for Module ImgPeakFinder and ImgPeakFilter for CSPad
Module ImgAlgos::ImgPeakFinder
works on image. In order to apply this algorithm to CSPad the image should be produced. In next example the image is produced using consequtive modules cspad_mod.CsPadCalib
, ImgAlgos.CSPadMaskApply
, and CSPadPixCoords.CSPadImageProducer
:
Code Block |
---|
[psana] files = /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-1>.xtc \ true [ImgAlgos.ImgRadialCorrection] source = ... DetInfo(CxiDs1.0:Cspad.0) inkey /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-N>.xtc events= current_img outkey = 1000 experimentr_cor_img xcenter = cxii0212 calib-dir = ana-cxii0212/calib modules = cspad_mod.CsPadCalib \ 866 ycenter ImgAlgos.CSPadMaskApply \ = 857 rmin CSPadPixCoords.CSPadImageProducer= \100 rmax ImgAlgos.ImgPeakFinder= \810 n_phi_bins = 60 event ImgAlgos.ImgPeakFilter \ = 0 print_bits = 3 [ImgAlgos.ImgSaveInFile:1 [cspad_mod.CsPadCalib] inputKeysource = outputKeyCxiDs1.0:Cspad.0 key = calibrated doPedestals = yes doPixelStatus = no doCommonMode = yes [ImgAlgos.CSPadMaskApply] source r_cor_img fname = DetInfo(CxiDs1.0:Cspad.0) inkey= <file-name-for-image-array> #saveAll = true eventSave = calibrated outkey = masked_arr mask_fname = <your-local-directory>/<mask-file-name>.dat masked_amp8 |
Note: the option of the background subtraction (ImgAlgos.CSPadBkgdSubtract
) is commented out in this configuration file . In order to evoke this option, the comment sign (#) should be removed from the list of modules
and the key=bkgd_subtracted_arr
should be used in CSPadPixCoords.CSPadImageProducer
.
Calibrated image and spectrum:
Calibrated and radial-corrected image, spectrum, and subtracted r-phi65 distribution for n_phi_bins
=65:
Calibrated and radial-corrected image, spectrum, and subtracted r-phi12 distribution for n_phi_bins
=12:
Example for Module ImgAlgos::ImgPeakFinder
See Module ImgAlgos::ImgPeakFinder
Configuration file example:
Code Block |
---|
[psana] = 0 print_bits = 5 mask_control_bits = 15 [CSPadPixCoords.CSPadImageProducer] calibDir = /reg/d/psdm/<instrument>/<experiment>/calib typeGroupName = CsPad::CalibV1 source = CxiDs1.0:Cspad.0 key = masked_arr imgkeyfiles = img print_bits /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-1>.xtc \ = 0 #tiltIsApplied = true [ImgAlgos.ImgPeakFinder] source /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-2>.xtc \ = DetInfo(CxiDs1.0:Cspad.0) key = img peaksKey... = peaks threshold_low = 2 threshold_high = 5 sigma /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-N>.xtc modules = 1.5 smear_radius = 5 peak_radiusImgAlgos.ImgPeakFinder PrintSeparator #skip-events = 500 events = 7 xmin 120 [ImgAlgos.ImgPeakFinder] source = 20 xmaxDetInfo(:Opal1000) key = 1700 yminpeaksKey = peaks threshold_low = 20 ymaxthreshold_high = 50 sigma = 1700 #testEvent = 1.5 smear_radius = 52 printpeak_bitsradius = = 3 #finderIsOnxmin = true [ImgAlgos.ImgPeakFilter] source = 200 xmax = DetInfo(CxiDs1.0:Cspad.0) key = peaks threshold_peak = 5 threshold_total= 0 n_peaks_min800 ymin = 10 print_bits = 11 100 fnameymax = cspad-img selection_mode = SELECTION_ON [ImgAlgos.ImgSaveInFile:1] source900 testEvent = = CxiDs1.0:Cspad.0 key115 print_bits = 0 finderIsOn = img fname = cspad-img #eventSave = 1 saveAll = true |
Example for Module ImgAlgos::ImgSaveInFile
true
|
- This algorithm consumes ~15 ms/event on psana0101 for full Opal1000 (1024x1024) camera image.
- Smearing algorithm use a "safety margin" which is currently set to 10 pixels (offset from each boarder of the full image size).
Image on different stages of this algorithm:
- raw image,
- image in the window with amplitudes above the
threshold_low
- few peaks at the edges were discarded by the window limits,
- image still contains many 1-photon pixels, which need to be eliminated,
- smeared image,
- raw image with found peaks (marked by the red circles)
- zoom of the previous plot.
Example for Module ImgAlgos::ImgPeakFilter
Code Block |
---|
[ImgAlgos.ImgPeakFilter] |
Code Block |
modules = ... ImgAlgos.ImgSaveInFile:1 ... [ImgAlgos.ImgSaveInFile:1] source = DetInfo(:Opal1000) key # or CxiDs1.0:Cspad.0 key = peaks threshold_peak = 5 threshold_total= img fname0 n_peaks_min = 10 print_bits = my-img #eventSave 11 fname = 5 saveAll = img selection_mode = true |
...
SELECTION_ON
|
Example for Module
...
ImgPeakFinder and ImgPeakFilter for CSPad
See Module ImgAlgos::
CSPadArrAverageConfiguration file example for evaluation of pedestalsImgPeakFinder
works on image. In order to apply this algorithm to CSPad the image should be produced. In next example the image is produced using consequtive modules cspad_mod.CsPadCalib
, ImgAlgos.CSPadMaskApply
, and CSPadPixCoords.CSPadImageProducer
:
Code Block |
---|
[psana] modules = ImgAlgos.CSPadArrAverage files = <path-to-the-dark-run-file>.xtc [ImgAlgos.CSPadArrAverage] source = DetInfo(CxiDs1.0:Cspad.0) key/reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-1>.xtc \ ... = avefile = cspad-pedestals-ave.dat rmsfile = cspad-pedestals-rms.dat print_bits /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-N>.xtc events = 1000 experiment = 15 evts_stage1 = 100 evts_stage2cxii0212 calib-dir = 100 gate_width1ana-cxii0212/calib modules = 100 gate_width2 = 10 |
Configuration file example for evaluation of background:
Code Block |
---|
[psana] filescspad_mod.CsPadCalib \ ImgAlgos.CSPadMaskApply \ CSPadPixCoords.CSPadImageProducer \ = <path-to-the-background-run-file>.xtc modules ImgAlgos.ImgPeakFinder \ = cspad_mod.CsPadCalib ImgAlgos.CSPadArrAverage skip-events = 500 eventsImgPeakFilter \ = 1000000ImgAlgos.ImgSaveInFile:1 [cspad_mod.CsPadCalib] inputKey = outputKey = calibrated doPedestals = yes doPixelStatus = no doCommonMode = noyes [ImgAlgos.CSPadArrAverageCSPadMaskApply] source = = DetInfo(CxiDs1.0:Cspad.0) keyinkey = calibrated avefileoutkey = masked_arr mask_fname = cspad-background-ave<your-local-directory>/<mask-file-name>.dat rmsfilemasked_amp = cspad-background-rms.dat 0 print_bits = 15 |
Images of the CSPad arrays for averaged and rms values, respectively, in one of the CXI runs:
Example for Module ImgAlgos::CSPadBkgdSubtract
See Module ImgAlgos::CSPadBkgdSubtract
Code Block |
---|
[psana] files 5 mask_control_bits = 15 [CSPadPixCoords.CSPadImageProducer] calibDir = /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-1>.xtc \ calib typeGroupName = CsPad::CalibV1 source /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-2>.xtc \ = CxiDs1.0:Cspad.0 key ... = masked_arr imgkey /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-N>.xtc skip-events = 500img eventsprint_bits = = 100 modules #tiltIsApplied = cspad_mod.CsPadCalib ImgAlgos.CSPadBkgdSubtracttrue [cspad_modImgAlgos.CsPadCalib] inputKey =ImgPeakFinder] outputKeysource = calibrated doPedestals = yes doPixelStatus = no doCommonMode = no [ImgAlgos.CSPadBkgdSubtract] sourceDetInfo(CxiDs1.0:Cspad.0) key = DetInfo(CxiDs1.0:Cspad.0) inputKeyimg peaksKey = calibratedpeaks outputKeythreshold_low = 2 threshold_high = bkgd_subtracted bkgd_fname5 sigma = <the-file-name-with-background-array> norm_sector1.5 smear_radius = 05 printpeak_bitsradius = 3 |
The file with the background array, bkgd_fname
, was obtained by averaging 1000 events using module CSPadArrAverage. Subtraction is done with normalization for norm_sector=0
.
Event image and pixel amplitude spectrum before and after the background subtraction are shown in plots:
Other event with better subtracted background:
Example for Module ImgAlgos::CSPadMaskApply
See Module ImgAlgos::CSPadMaskApply
The array for mask contains zeros and ones for masked and passed pixels, respectively, and has a shape of full-size CSPad array 4*8*185388.
For example, it can be generated by the command
Code Block |
---|
./MakePixelMask.py <input-background-cspad-arr-file-name> <threshold> <output-file-name>
|
for the averaged background amplitude array <input-background-cspad-arr-file-name>
abtained as a result of ImgAlgos::CSPadArrAverage
module.
Plots show the averaged background, and the mask arrays generated from this background for three thresholds 10, 20, and 30 EDU:
The best results in filtering can be achieved in combination of modiles:
7
xmin = 20
xmax = 1700
ymin = 20
ymax = 1700
#testEvent = 5
print_bits = 3
#finderIsOn = true
[ImgAlgos.ImgPeakFilter]
source = DetInfo(CxiDs1.0:Cspad.0)
key = peaks
threshold_peak = 5
threshold_total= 0
n_peaks_min = 10
print_bits = 11
fname = cspad-img
selection_mode = SELECTION_ON
[ImgAlgos.ImgSaveInFile:1]
source = CxiDs1.0:Cspad.0
key = img
fname = cspad-img
#eventSave = 1
saveAll = true
|
Example for Module ImgAlgos::ImgSaveInFile
Code Block |
---|
modules = ... ImgAlgos.ImgSaveInFile:1 ...
[ImgAlgos.ImgSaveInFile:1]
source = DetInfo(:Opal1000) # or CxiDs1.0:Cspad.0
key |
Code Block |
modules = cspad_mod.CsPadCalib \ ImgAlgos.CSPadBkgdSubtract \ ImgAlgos.CSPadMaskApply \ = img fname ... [cspad_mod.CsPadCalib] inputKey = my-img #eventSave = 5 outputKeysaveAll = calibrated_arr doPedestals = yes doPixelStatus = no doCommonMode = no= true |
See Module ImgAlgos::ImgSaveInFile
Example for Module ImgAlgos::CSPadArrAverage
See Module ImgAlgos::CSPadArrAverage
Configuration file example for evaluation of pedestals:
Code Block |
---|
[psana] modules = ImgAlgos.CSPadArrAverage files = <path-to-the-dark-run-file>.xtc [ImgAlgos.CSPadBkgdSubtractCSPadArrAverage] source = DetInfo(CxiDs1.0:Cspad.0) inputKeykey = avefile = calibrated_arr outputKey cspad-pedestals-ave.dat rmsfile = cspad-pedestals-rms.dat print_bits = bkgd_subtracted_arr bkgd_fname = ana-cxi49012/cspad-cxi49012-r0025-background-ave.dat norm_sector = 0 print_bits = 0 [ImgAlgos.CSPadMaskApply15 evts_stage1 = 100 evts_stage2 = 100 gate_width1 = 100 gate_width2 = 10 |
Configuration file example for evaluation of background:
Code Block |
---|
[psana] files ] source = <path-to-the-background-run-file>.xtc modules = DetInfo(CxiDs1.0:Cspad.0) inkey cspad_mod.CsPadCalib ImgAlgos.CSPadArrAverage skip-events = 500 events = bkgd_subtracted_arr outkey 1000000 [cspad_mod.CsPadCalib] inputKey = masked_arr mask_fname outputKey = calibrated doPedestals = ana-cxi49012/cspad-cxi49012-r0025-mask-40.dat masked_amp = 0 print_bits yes doPixelStatus = no doCommonMode = no [ImgAlgos.CSPadArrAverage] source = DetInfo(CxiDs1.0:Cspad.0) key = 3 mask_control_bits = 1 |
where
cspad_mod.CsPadCalib
- subtracts the pedestals from raw CSPad data,ImgAlgos.CSPadBkgdSubtract
- subtracts the background,ImgAlgos.CSPadMaskApply
- apply the mask.
In the test with images for background represented by the water and solvent rings this filter provides the background suppression factor about 100.
The background images that still pass this filter have significantly larger intensity with respect to averaged background:
Input parameter mask_control_bits
allows to control masking regions of 2x1. For example, if all edges need to be masked, then use mask_control_bits = 15
, which gives image array like:
where red regions/lines of pixels of amplitude=8 are masked.
calibrated
avefile = cspad-background-ave.dat
rmsfile = cspad-background-rms.dat
print_bits = 15
|
Images of the CSPad arrays for averaged and rms values, respectively, in one of the CXI runs:
Example for Module ImgAlgos::
...
CSPadBkgdSubtract
See Module ImgAlgos::ImgRadialCorrectionCSPadBkgdSubtract
Code Block |
---|
[psana] files = /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-1>.xtc \ /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-2>.xtc \ ... /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-N>.xtc skip-events = 500 events = 10 modules = cspad_mod.CsPadCalib ImgAlgos.CSPadBkgdSubtract [cspad_mod.CsPadCalib] inputKey = 10 modulesoutputKey = cspad_mod.CsPadCalib \ #calibrated doPedestals = yes doPixelStatus = no doCommonMode = no [ImgAlgos.CSPadBkgdSubtract \] source CSPadPixCoords.CSPadImageProducer \ = DetInfo(CxiDs1.0:Cspad.0) inputKey ImgAlgos.ImgRadialCorrection \ = calibrated outputKey = bkgd_subtracted bkgd_fname ImgAlgos.ImgSaveInFile:1 [cspad_mod.CsPadCalib] inputKey = outputKey= <the-file-name-with-background-array> norm_sector = 0 print_bits = calibrated doPedestals = yes doPixelStatus = no doCommonMode = no [ImgAlgos.CSPadBkgdSubtract] source = DetInfo(CxiDs1.0:Cspad.0) inputKey = calibrated outputKey = bkgd_subtracted_arr bkgd_fname = <the-file-name-with-background-array> norm_sector = 0 print_bits = 0 [CSPadPixCoords.CSPadImageProducer] calibDir = /reg/d/psdm/<instrument>/<experiment>/calib typeGroupName = CsPad::CalibV1 source = CxiDs1.0:Cspad.0 key3 |
The file with the background array, bkgd_fname
, was obtained by averaging 1000 events using module CSPadArrAverage. Subtraction is done with normalization for norm_sector=0
.
Event image and pixel amplitude spectrum before and after the background subtraction are shown in plots:
Other event with better subtracted background:
Example for Module ImgAlgos::CSPadMaskApply
See Module ImgAlgos::CSPadMaskApply
The array for mask contains zeros and ones for masked and passed pixels, respectively, and has a shape of full-size CSPad array 4*8*185388.
For example, it can be generated by the command
Code Block |
---|
./MakePixelMask.py <input-background-cspad-arr-file-name> <threshold> <output-file-name>
|
for the averaged background amplitude array <input-background-cspad-arr-file-name>
abtained as a result of ImgAlgos::CSPadArrAverage
module.
Plots show the averaged background, and the mask arrays generated from this background for three thresholds 10, 20, and 30 EDU:
The best results in filtering can be achieved in combination of modiles:
Code Block |
---|
modules = cspad_mod.CsPadCalib \ = calibrated imgkeyImgAlgos.CSPadBkgdSubtract \ = current_img #tiltIsApplied = true [ImgAlgos.ImgRadialCorrection] sourceCSPadMaskApply \ = DetInfo(CxiDs1.0:Cspad.0) inkey ... [cspad_mod.CsPadCalib] inputKey = current_img outkey outputKey = rcalibrated_cor_imgarr xcenterdoPedestals = yes doPixelStatus = 866 ycenter no doCommonMode = 857 rmin no [ImgAlgos.CSPadBkgdSubtract] source = 100 rmaxDetInfo(CxiDs1.0:Cspad.0) inputKey = calibrated_arr outputKey = 810 n_phi_binsbkgd_subtracted_arr bkgd_fname = 60 event ana-cxi49012/cspad-cxi49012-r0025-background-ave.dat norm_sector = 0 print_bits = 30 [ImgAlgos.ImgSaveInFile:1CSPadMaskApply] source = DetInfo(CxiDs1.0:Cspad.0) inkey = CxiDs1.0:Cspad.0 keybkgd_subtracted_arr outkey = rmasked_corarr mask_img fname = <file-name-for-image-array> #saveAllana-cxi49012/cspad-cxi49012-r0025-mask-40.dat masked_amp = true eventSave0 print_bits = 3 mask_control_bits = 81 |
Note: the option of the background subtraction (ImgAlgos.CSPadBkgdSubtract
) is commented out in this configuration file . In order to evoke this option, the comment sign (#) should be removed from the list of modules
and the key=bkgd_subtracted_arr
should be used in CSPadPixCoords.CSPadImageProducer
.
Calibrated image and spectrum:
Calibrated and radial-corrected image, spectrum, and subtracted r-phi65 distribution for n_phi_bins
=65:
where
cspad_mod.CsPadCalib
- subtracts the pedestals from raw CSPad data,ImgAlgos.CSPadBkgdSubtract
- subtracts the background,ImgAlgos.CSPadMaskApply
- apply the mask.
In the test with images for background represented by the water and solvent rings this filter provides the background suppression factor about 100.
The background images that still pass this filter have significantly larger intensity with respect to averaged background:
Input parameter mask_control_bits
allows to control masking regions of 2x1. For example, if all edges need to be masked, then use mask_control_bits = 15
, which gives image array like:
where red regions/lines of pixels of amplitude=8 are masked.Calibrated and radial-corrected image, spectrum, and subtracted r-phi12 distribution for n_phi_bins
=12:
Example for Module ImgAlgos::CSPadArrNoise
...