Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
# List of windows
winds = None # entire size of all segments will be used for peak finding
winds = (( 0, 0, 185, 0, 388),              
         ( 1, 20,160, 30,300),
         ( 7, 0, 185, 0, 388))

# Mask
mask = None                   # (default) all pixels in windows will be used for peak finding
mask = det.mask()             # see class Detector.PyDetector
mask = np.loadtxt(fname_mask) # 
mask.shape = <should be the same as shape of data n-d array>

Evaluation of the background level, rms, and S/N ratio

When peak is found, its parameters can be precised for background level, noise rms, and signal over background ratio (S/N) can be estimated. All these values can be evaluated using pixels surrounding the peak on some distance. For all peak-finders we use the same algorithm. Surrounding pixels are defined by the ring with internal radial parameter r0 and ring width dr (both in pixels). The number of surrounding pixels depends on r0 and dr parameters as shown in matrices below. We use notation

  • + central pixel with maximal intensity,
  • 1 pixels counted in calculation of averaged background level and noise rms,
  • 0 pixels not counted.

Matrices of pixels for r0=3 and 4 and different dr values

 

 

Hit finders

Hit finders return simple values for decision on event selection. Two algorithms are implemented in ImgAlgos.PyAlgos. They count number of pixels and intensity above threshold in the Region Of Interest (ROI) defined by windows and mask parameters in object constructor.

Number of pixels above threshold

number_of_pix_above_thr

Code Block
npix = alg.number_of_pix_above_thr(data, thr=10)

Total intensity above threshold

intensity_of_pix_above_thr

Code Block
intensity = alg.intensity_of_pix_above_thr(data, thr=12)

 

Peak finders

All peak finders have a few parameters

    • nda - calibrated n-d array of data, pedestals and background should be subtracted, common mode - corrected
    • thr_* - different type of thresholds
    • rank - peak rank as explained in .
    •  r0=5, dr=0.05 - ring internal radius and width to evaluate background and noise rms as explained in .

Two threshold "Droplet finder"

two-threshold peak-finding algorithm in restricted region around pixel with maximal intensity.

peak_finder_v1

Code Block
peaks = alg.peak_finder_v1(nda, thr_low=10, thr_high=150, radius=5, dr=0.05)

 

Flood filling algorithm

define peaks for regions of connected pixels above threshold

peak_finder_v2

Code Block
peaks = alg.peak_finder_v2(nda, thr=10, r0=5, dr=0.05)

 

Local maximums search algorithm

define peaks in local maximums of specified rank (radius), for example rank=2 means 5x5 pixel region around central pixel.

peak_finder_v3

Code Block
peaks = alg.peak_finder_v3(nda, rank=2, r0=5, dr=0.05)

 

  • makes a map of pixels with local maximums of requested rank for data ndarray and mask, pixel code in the map may have bits 0/1/2/4 standing for not-a-maximum / maximum-in-row / maximum-in-column / maximum-in-rectangular-region of radius=rank.
  • for each pixel with local maximal intensity in the region defined by the rank radius counts a number of pixels with intensity above zero, total positive intensity, center of gravity coordinates and rms,
  • using parameters r0(ex.=5.0), dr(ex.=0.05) evaluates background level, rms of noise, and S/N for the pixel with maximal intensity.
  • makes list of peaks which pass selector with parameters set in set_peak_selection_pars, for example
Code Block
alg.set_peak_selection_pars(npix_min=5, npix_max=500, amax_thr=0, atot_thr=1000, son_min=6)

 

Anchor
peak_rank
peak_rank

Demonstration for local maximum map

Test for 100x100 image with random normal distribution of intensitiesImage Added

Example of the map of local maximums found for rank from 1 to 5:

Image AddedImage AddedImage AddedImage AddedImage Added

color coding of pixels:

  • blue=0 - not a local maximum
  • green=1 - local maximum in row
  • yellow=1+2 - local maximum in row and column
  • red=1+2+4 - local maximum in rectangular region of radius=rank.

Table for rank, associated 2-d region size, fraction of pixels recognized as local maximums for rank, and time consumption for this algorithm.

rank2-d regionfractiontime, ms
13x30.10625.4
25x50.03725.2
37x70.01795.1
49x90.01045.2
511x110.00665.2

 

Anchor
bkg_rms
bkg_rms

Evaluation of the background level, rms, and S/N ratio

When peak is found, its parameters can be precised for background level, noise rms, and signal over background ratio (S/N) can be estimated. All these values can be evaluated using pixels surrounding the peak on some distance. For all peak-finders we use the same algorithm. Surrounding pixels are defined by the ring with internal radial parameter r0 and ring width dr (both in pixels). The number of surrounding pixels depends on r0 and dr parameters as shown in matrices below. We use notation

  • + central pixel with maximal intensity,
  • 1 pixels counted in calculation of averaged background level and noise rms,
  • 0 pixels not counted.

Matrices of pixels for r0=3 and 4 and different dr values

Code Block
r0=3  dr=0.1 (4 pixels)   r0=3  dr=0.5 (12 pixels)   r0=3  dr=1 (24 pixels) 
0 0 0 0 0 0 0 0 0         
Code Block
r0=3  dr=0.1 (4 pixels)   r0=3  dr=0.5 (12 pixels)   r0=3  dr=1 (24 pixels) 
0 0 0 0 0 0 0 0 0         0 0 0 0 0 0 0 0 0          0 0 0 0 1 0 0 0 0       
0 0 0 0 1 0 0 0 0         0 0 0 1 1 1 0 0 0          0 0 1 1 1 1 1 0 0       
0 0 0 0 0 0 0 0 0         0 0 0 0 0 0 0 0 0          0 1 0 0 0 0 0 1 0       
0 0 0 0 0 0 0 0 0         0 1 0 0 0 0 0 1 0          0 1 0 0 0 0 0 1 0       
0 1 0 0 + 0 0 1 0         0 1 0 0 + 0 0 1 0          1 1 0 0 + 0 0 1 1       
0 0 0 0 0 0 0 0 0         0 1 0 0 0 0 0 1 0          0 1 0 0 0 0 0 1 0       
0 0 0 0 0 0 0 0 0         0 0 0 0 0 0 0 0 0          0 1 0 0 0 0 0 1 0       
0 0 0 0 1 0 0 0 0         0 0 0 1 1 1 0 0 0          0 0 1 1 1 1 1 0 0       
0 0 0 0 0 0 0 0 0         0 0 0 0 0 0 0 0 0          0 1 0 0 0 10 0 01 0 0

r0=4      dr=
0.2 (120 pixels)0 0 0 r0=40 0 dr=0.3 (160 pixels)    r0=4  dr=0.5 (24 pixels)
0 01 0 0 0 0 0 01 0 0 0      0 0 0 01 0 0 0 0 0 01 0       
0 1 0 0 0+ 0 0 01 0 0 0 0
0  0 0 0 1 10 1 0 0 + 0 0 1 0    0  0 0 0 1 1 1 0 0 0 0       + 0 0 01 1 1 1 1 1 0 0 0
0 0 0 0 0 0 0 0 0 0 0      0 0 1 0 0 0 0 0 1 0 0        0 0 1 0 0 0 0 0 1 0 0       
0 0 0 0 0 0 0 0 0  0 0      0 0 0 0 0 0 0 0 0 0  0       0 1 0 0 0 0 0 01 0 1 0
0 1 0 0 0 
0 0 0 0 1 0 0 0 0   0   1 0 0 0 0 0 01 01 1 0 0 0     0 1 0 0 0 0 0 01 01 1 0
01 1 0 0 0 + 0 0 0 1 
0      0 1 0 0 0 + 0 0 0 1 0       0 1 0 0 0 + 0 0 0 1 0
0 1 0 0 0 0 0 0 0 1 0   0 0 0 0 1 0 0 0 0

r0=4 0 dr=0.2 0 1 0(12 pixels)   r0=4    dr=0.3 1(16 0pixels) 0 0 0 0r0=4 0 dr=0.5 1(24 0pixels)
0 0 0 0 0 0 0 0 0 0 0      0 0 0 0 0 0 0 0 0 0 0       0 10 0 0 0 0 0 0 0 10 0
0 0 0 0 01 01 01 0 0 0 0      0 0 1 0 0 01 01 0 1 0 0 0 0     0 0 1 0 0 0 01 01 1 1 1 0 0 0
0 0 0 0 10 10 10 0 0 0 0      0 0 1 0 0 10 1 10 0 01 0 0       0 0 1 0 10 10 10 10 1 0 0 0
0 0 0 0 0 0 0 0 0 0 0      0 0 0 0 0 0 0 0 0 0 0       0 1 0 0 0 0 0 0 0 1 0
0 1 0 0 

 

Matrices of pixels for r0=5 and 6 and different dr values

Code Block
r0=5  dr=0.05 (12 pixels)  0 0 0 0 0 1 0    r0=5  dr=0.5 1 0 (280 pixels)0 0 0 0 0 1 0      
0 0 01 0 0 0 0 0 0 0 01 0 
0 1 0 0 0 + 0 0 0 1 0 0 0 0 0 0 0 01 0 0
0 0 0+ 0 0 0 1 0 0 0 0 0 0  0 1 0 0 0 + 0 0 0 1 10
0 1 10 1 0 0 0 0
0 0 0 1 0 0   0 0 0 1 0 0 0 0     0 0 0 1 0 0 0 0 0 1 0 0 0
0 0 1 0 0 0 0 0 0 0 1 0
0 0 0 0    0 0 1 0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0      0 1 0 0 0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0     0 0 1 0 0 0 0 0 1 0 0       0 0 1 0
0 1 0 0 0 0 +1 0 0
0 0 0 1 0 1 1    0 1 0 0 0 0 + 0 0 0 0 1 0
0 0 0 0 01 01 01 0 0 0 0 0 0      0 1 0 0 01 01 01 01 01 0 0 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0      0 1 0 0 0 0 0 0 0 0 0 1 0
0 0 1 0 0 0 0 0 0 0 1 0 0      0 0 1 0 0 0 0 

 

Matrices of pixels for r0=5 and 6 and different dr values

Code Block
r0=5  dr=0.05 (12 pixels)      r0=5  dr=0.5  (28 pixels)            0 0 0 1 0 0
0 0 0 10 0 0 0 0 0 10 0 0 0      0 0 0 10 0 0 0 0 0 10 0 0 0
0 0 0 0 0 0 1 0 0 0 0 0 0      0 0 0 0 1 1 1 1 1 0 0 0 0
0 0 0 01 0 0 0 0 0 01 0 0 0      0 0 0 1 0 0 0 0 0 1 0 0 0
0 0 1 0 0

r0=6 0 dr=0.2 (120 pixels)0 0 1 0 0    r0=6  dr=0.5 (280 pixels)1 0 0 0 0 0 
0 0 1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0    0 0 0 01 0 0 0 0 0 0 0 0 0 01 0
0 0 0 0 0 0 1 1 10 0 0 0 0 0 0     0 0 1 0 0 0 10 10 1 10 1 0 0 0 01 0
0 01 0 0 0 0 0+ 0 0 0 0 01 0 0 0    0 01 0 0 1 0 0 0+ 0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0     0 0 1 0 0 0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0     0 01 0 0 0 0 0 0 0 0 0 01 0 0 0
0 0 01 0 0 0 0 0 0 0 01 0 0 0 0    0 0 1 0 0 0 0 0 0 0 1 0 0 
0 0 1 0
0 1 0 0 0 0 0 01 0 0 0 0 0 1 0     0 1 0 0 01 0 0 0 0 0 01 0 0 1 0
0 1 0 0 0 0 0 +1 0 0 0 0 0 10 0     0 1 0 0 0 01 01 +1 01 01 0 0 0 1 0
0 10 0 0 0 0 0 0 0 0 0 0 0 1 0     0 1 0 0 0 0 0 0 0 0 0 0 0 1 0

0r0=6 0 dr=0.2 0(12 0pixels) 0 0 0 0 0 0 0 0r0=6 0 dr=0.5 (28 pixels)      
0 10 0 0 0 0 0 0 0 0 0 0 0 10 0
     0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 1 1 0 0 0 0 0 0     0 0 0 0 0 1 1 1 1 1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0     0 0 0 1 0 0 0 0 0 0 0 01 0 1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0     0 0 1 0 10 0 0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 10 10 10 0 0 0 0 0 0     0 0 0 0 0 10 10 10 10 10 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0     0 1 0 0 0 0 0 0 0 0 0 0 0 1 0
0 1 0 0 0 0 0 0 0 0 0 0 0

 

 

Hit finders

Hit finders return simple values for decision on event selection. Two algorithms are implemented in ImgAlgos.PyAlgos. They count number of pixels and intensity above threshold in the Region Of Interest (ROI) defined by windows and mask parameters in object constructor.

Number of pixels above threshold

number_of_pix_above_thr

Code Block
npix = alg.number_of_pix_above_thr(data, thr=10)

Total intensity above threshold

intensity_of_pix_above_thr

Code Block
intensity = alg.intensity_of_pix_above_thr(data, thr=12)

 

Peak finders

Two threshold "Droplet finder"

two-threshold peak-finding algorithm in restricted region around pixel with maximal intensity.

peak_finder_v1

Code Block
peaks = alg.peak_finder_v1(nda, thr_low=10, thr_high=150, radius=5, dr=0.05)

 

 

Flood filling algorithm

define peaks for regoins of connected pixels above threshold

peak_finder_v2

Code Block
peaks = alg.peak_finder_v2(nda, thr=10, r0=5, dr=0.05)

 

Local maximums search algorithm

define peaks in local maximums of specified rank (radius), for example rank=2 means 5x5 pixel region around central pixel.

peak_finder_v3

Code Block
peaks = alg.peak_finder_v3(nda, rank=2, r0=5, dr=0.05)

 

  • makes a map of pixels with local maximums of requested rank for data ndarray and mask, pixel code in the map may have bits 0/1/2/4 standing for not-a-maximum / maximum-in-row / maximum-in-column / maximum-in-rectangular-region of radius=rank.
  • for each pixel with local maximal intensity in the region defined by the rank radius counts a number of pixels with intensity above zero, total positive intensity, center of gravity coordinates and rms,
  • using parameters r0(ex.=5.0), dr(ex.=0.05) evaluates background level, rms of noise, and S/N for the pixel with maximal intensity.
  • makes list of peaks which pass selector with parameters set in set_peak_selection_pars, for example
Code Block
alg.set_peak_selection_pars(npix_min=5, npix_max=500, amax_thr=0, atot_thr=1000, son_min=6)

 

Demonstration for local maximum map

Test for 100x100 image with random normal distribution of intensitiesImage Removed

Example of the map of local maximums found for rank from 1 to 5:

Image RemovedImage RemovedImage RemovedImage RemovedImage Removed

color coding of pixels:

  • blue=0 - not a local maximum
  • green=1 - local maximum in row
  • yellow=1+2 - local maximum in row and column
  • red=1+2+4 - local maximum in rectangular region of radius=rank.

Table for rank, associated 2-d region size, fraction of pixels recognized as local maximums for rank, and time consumption for this algorithm.

...

 1 0     0 1 0 0 0 0 0 0 0 0 0 0 0 1 0
0 1 0 0 0 0 0 + 0 0 0 0 0 1 0     0 1 0 0 0 0 0 + 0 0 0 0 0 1 0
0 1 0 0 0 0 0 0 0 0 0 0 0 1 0     0 1 0 0 0 0 0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0     0 1 0 0 0 0 0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0     0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0     0 0 1 0 0 0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0     0 0 0 1 0 0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 1 1 1 0 0 0 0 0 0     0 0 0 0 0 1 1 1 1 1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0     0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

 

...

 

References

...