lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
Loading...
Searching...
No Matches
psalgos::PeakFinderAlgos Class Reference

PeakFinderAlgos - class contains collection of methods for peak finding algorithms of 2-d image. More...

#include <PeakFinderAlgos.hh>

Public Member Functions

 PeakFinderAlgos (Allocator *allocator, const size_t &seg=0, const unsigned &pbits=0, const size_t &lim_rank=50, const size_t &lim_peaks=6000)
 Class constructor is used for initialization of all paramaters.
 
virtual ~PeakFinderAlgos ()
 Delete the local-maxima, local-minima and connected-pixel maps.
 
void printParameters ()
 Prints memeber data.
 
void _initMapsAndVectors_drp ()
 Initialaise maps and vectors per event; uses m_img_size, m_npksmax, vectors and maps.
 
void _evaluateRingIndexes_drp ()
 Evaluate ring indexes for S/N algorithm.
 
void printMatrixOfRingIndexes ()
 Prints indexes for S/N algorithm.
 
void printVectorOfRingIndexes_drp ()
 Print the (row, col) offsets used for the background ring to stdout, ten per line, computing them first with _evaluateRingIndexes_drp() if the list is empty.
 
void setPeakSelectionPars (const float &npix_min=0, const float &npix_max=1e6, const float &amax_thr=0, const float &atot_thr=0, const float &son_min=0)
 Set peak selection parameters.
 
void printSelectionPars ()
 Prints peak selection parameters.
 
bool _peakIsSelected (const Peak &peak)
 Decide if peak should be included or not in the output v_peaks.
 
void _makeVectorOfSelectedPeaks_drp ()
 Makes vector of selected peaks v_peaks_sel from v_peaks.
 
void _printVectorOfPeaks_drp (AllocArray1D< Peak > v)
 Prints vector of peaks, i.e. v_peaks_sel or v_peaks.
 
const Peak & peakSelected (const int &i=0)
 Returns peak from v_peaks_sel by specified index.
 
const AllocArray1D< Peak > & vectorOfPeaks ()
 Returns vector of peaks v_peaks.
 
const AllocArray1D< Peak > & vectorOfPeaksSelected_drp ()
 Returns vector of selected peaks v_peaks_sel.
 
void _convPeaksSelected ()
 Converts selected peaks to arrays of fundamental types, rows, cols, intens.
 
void localMaxima (extrim_t *map, const size_t &rows, const size_t &cols)
 Fills-out (returns) array of local maxima.
 
void localMinima (extrim_t *map, const size_t &rows, const size_t &cols)
 Fills-out (returns) array of local minima.
 
void connectedPixels (conmap_t *map, const size_t &rows, const size_t &cols)
 Fills-out (returns) array of m_conmap.
 
void setAllocator (Allocator *allocator)
 Set the stored Allocator pointer (the trailing comment says it is changed for each event).
 
template<typename T >
void peakFinderV3r3 (const T *data, const mask_t *mask, const size_t &rows, const size_t &cols, const size_t &rank, const double &r0=7.0, const double &dr=2.0, const double &nsigm=0)
 peakFinderV3r3 - "Ranker" - further development of ImgAlgos.peakFinderV3r2.
 
template<typename T >
void _makeMapOfConnectedPixelsForLocalMaximums_drp (const T *data)
 full peak processing in a right order
 
template<typename T >
RingAvgRms _evaluateRingAvgRmsV1_drp (const T *data, const int &row, const int &col)
 Evaluate background average and rms in the ring around pixel using data, mask, and map of local intensity extremes.
 
template<typename T >
void _findConnectedPixelsForLocalMaximumV2_drp (const T *data, const int &r0, const int &c0)
 _findConnectedPixelsForLocalMaximumV2_drp - apply flood filling algorithms to find a group of connected pixels around r0,c0 in constrained by rad region.
 
template<typename T >
void _findConnectedPixelsInRegionV3_drp (const T *data, const int &r, const int &c)
 Recursively add pixel (r, c) and its 4-connected neighbours to the current pixel group: a pixel is taken if it is unmasked, not yet in the connected-pixel map and not below the region threshold, and it is marked there with the current region number.
 
template<typename T >
void _procPixGroupV1_drp (const T *data, const RingAvgRms &bkgd, AllocArray1D< TwoIndexes > &vinds)
 _procPixGroupV1 - process a pixel group for peakFinderV3r3 further development of ImgAlgos::AlgImgProc::_procPixGroup V1 news: get rid of ndarray, use member data to pass parameters, subtract base level brfore processing
 

Public Attributes

AllocArray1D< float > rows
 Row centers of gravity of the selected peaks, filled by _convPeaksSelected().
 
AllocArray1D< float > cols
 Column centers of gravity of the selected peaks, filled by _convPeaksSelected().
 
AllocArray1D< float > intens
 Total intensities (amp_tot) of the selected peaks, filled by _convPeaksSelected().
 
unsigned numPeaksSelected = 0
 Number of selected peaks, set by _convPeaksSelected() (0 initially).
 

Detailed Description

PeakFinderAlgos - class contains collection of methods for peak finding algorithms of 2-d image.

This software was developed for the LCLS project.
If you use all or part of it, please give an appropriate acknowledgment.

Author
Mikhail Dubrovin
See also
ImgAlgos.ImgImgProc

Interface Description
  • Includes and typedefs
    #include <cstddef> // for size_t
    #include "psalgos/PeakFinderAlgos.h"
    #include "psalgos/Types.h"
    Non-owning view of an array of T: a data pointer, a pointer to a shape array and a rank.
    Definition Array.hh:27
    types::mask_t mask_t
    Alias for types::mask_t (uint16_t).
    Definition PeakFinderAlgos.hh:40
    types::extrim_t extrim_t
    Alias for types::extrim_t (uint16_t).
    Definition PeakFinderAlgos.hh:42

Constructor & Destructor Documentation

◆ PeakFinderAlgos()

psalgos::PeakFinderAlgos::PeakFinderAlgos ( Allocator *  allocator,
const size_t &  seg = 0,
const unsigned &  pbits = 0,
const size_t &  lim_rank = 50,
const size_t &  lim_peaks = 6000 
)

Class constructor is used for initialization of all paramaters.

Parameters
[in]seg- ROI segment index in the ndarray
[in]pbits- print control bit-word; =0-print nothing, =1 debug, =2 info, ...

◆ ~PeakFinderAlgos()

virtual psalgos::PeakFinderAlgos::~PeakFinderAlgos ( )
virtual

Delete the local-maxima, local-minima and connected-pixel maps.

Member Function Documentation

◆ _convPeaksSelected()

void psalgos::PeakFinderAlgos::_convPeaksSelected ( )

Converts selected peaks to arrays of fundamental types, rows, cols, intens.

◆ _evaluateRingAvgRmsV1_drp()

template<typename T >
RingAvgRms psalgos::PeakFinderAlgos::_evaluateRingAvgRmsV1_drp ( const T *  data,
const int &  row,
const int &  col 
)
inline

Evaluate background average and rms in the ring around pixel using data, mask, and map of local intensity extremes.

development of ImgAlgos.Alg.imgProc._evaluateBkgdAvgRmsV3 _evaluateRingAvgRmsV1 news: get rid of ndarray, mask, m_r0, m_dr etc are passed as member data, RingAvgRms is created at return.

Background average and rms are evaluated for any pixel specified by the (row,col).
Uses mask. Good non-extreme pixels are used. This algorithm uses pixels in the ring m_r0, m_dr.

Parameters
[in]data- pointer to 2-d array with calibrated intensities
[in]row- pixel row
[in]col- pixel column

◆ _evaluateRingIndexes_drp()

void psalgos::PeakFinderAlgos::_evaluateRingIndexes_drp ( )

Evaluate ring indexes for S/N algorithm.

◆ _findConnectedPixelsForLocalMaximumV2_drp()

template<typename T >
void psalgos::PeakFinderAlgos::_findConnectedPixelsForLocalMaximumV2_drp ( const T *  data,
const int &  r0,
const int &  c0 
)
inline

_findConnectedPixelsForLocalMaximumV2_drp - apply flood filling algorithms to find a group of connected pixels around r0,c0 in constrained by rad region.

  • check that r0,c0 is absolute maximum, returns false if not found
  • apply flood filling and make vector of connected pixels in rad constrained by region. V2 news: mask and rank are passed as member data
Parameters
[in]data- pointer to 2-d array with calibrated intensities
[in]r0- droplet central pixel row-coordinate
[in]c0- droplet central pixel column-coordinate

◆ _findConnectedPixelsInRegionV3_drp()

template<typename T >
void psalgos::PeakFinderAlgos::_findConnectedPixelsInRegionV3_drp ( const T *  data,
const int &  r,
const int &  c 
)
inline

Recursively add pixel (r, c) and its 4-connected neighbours to the current pixel group: a pixel is taken if it is unmasked, not yet in the connected-pixel map and not below the region threshold, and it is marked there with the current region number.

The search stays inside the current region limits.

◆ _initMapsAndVectors_drp()

void psalgos::PeakFinderAlgos::_initMapsAndVectors_drp ( )

Initialaise maps and vectors per event; uses m_img_size, m_npksmax, vectors and maps.

◆ _makeMapOfConnectedPixelsForLocalMaximums_drp()

template<typename T >
void psalgos::PeakFinderAlgos::_makeMapOfConnectedPixelsForLocalMaximums_drp ( const T *  data)
inline

full peak processing in a right order

  1. estimate background
  2. finds connected pixels
  3. fills vector of peaks
Parameters
[in]data- pointer to 2-d array with calibrated intensities

◆ _makeVectorOfSelectedPeaks_drp()

void psalgos::PeakFinderAlgos::_makeVectorOfSelectedPeaks_drp ( )

Makes vector of selected peaks v_peaks_sel from v_peaks.

◆ _peakIsSelected()

bool psalgos::PeakFinderAlgos::_peakIsSelected ( const Peak &  peak)

Decide if peak should be included or not in the output v_peaks.

◆ _printVectorOfPeaks_drp()

void psalgos::PeakFinderAlgos::_printVectorOfPeaks_drp ( AllocArray1D< Peak >  v)

Prints vector of peaks, i.e. v_peaks_sel or v_peaks.

◆ _procPixGroupV1_drp()

template<typename T >
void psalgos::PeakFinderAlgos::_procPixGroupV1_drp ( const T *  data,
const RingAvgRms &  bkgd,
AllocArray1D< TwoIndexes > &  vinds 
)
inline

_procPixGroupV1 - process a pixel group for peakFinderV3r3 further development of ImgAlgos::AlgImgProc::_procPixGroup V1 news: get rid of ndarray, use member data to pass parameters, subtract base level brfore processing

Parameters
[in]data- pointer to data array with calibrated intensities
[in]bkgd- structure of base level ave, rms, npix
[in]vinds- vector of connected pixel indexes

◆ connectedPixels()

void psalgos::PeakFinderAlgos::connectedPixels ( conmap_t *  map,
const size_t &  rows,
const size_t &  cols 
)
inline

Fills-out (returns) array of m_conmap.

◆ localMaxima()

void psalgos::PeakFinderAlgos::localMaxima ( extrim_t *  map,
const size_t &  rows,
const size_t &  cols 
)
inline

Fills-out (returns) array of local maxima.

◆ localMinima()

void psalgos::PeakFinderAlgos::localMinima ( extrim_t *  map,
const size_t &  rows,
const size_t &  cols 
)
inline

Fills-out (returns) array of local minima.

◆ peakFinderV3r3()

template<typename T >
void psalgos::PeakFinderAlgos::peakFinderV3r3 ( const T *  data,
const mask_t *  mask,
const size_t &  rows,
const size_t &  cols,
const size_t &  rank,
const double &  r0 = 7.0,
const double &  dr = 2.0,
const double &  nsigm = 0 
)
inline

peakFinderV3r3 - "Ranker" - further development of ImgAlgos.peakFinderV3r2.

Changes:

  • use packahe psalgos
  • get rid of ndarray
  • pass most of parameters via member data

◆ peakSelected()

const Peak & psalgos::PeakFinderAlgos::peakSelected ( const int &  i = 0)
inline

Returns peak from v_peaks_sel by specified index.

◆ printMatrixOfRingIndexes()

void psalgos::PeakFinderAlgos::printMatrixOfRingIndexes ( )

Prints indexes for S/N algorithm.

◆ printParameters()

void psalgos::PeakFinderAlgos::printParameters ( )

Prints memeber data.

◆ printSelectionPars()

void psalgos::PeakFinderAlgos::printSelectionPars ( )

Prints peak selection parameters.

◆ printVectorOfRingIndexes_drp()

void psalgos::PeakFinderAlgos::printVectorOfRingIndexes_drp ( )

Print the (row, col) offsets used for the background ring to stdout, ten per line, computing them first with _evaluateRingIndexes_drp() if the list is empty.

◆ setAllocator()

void psalgos::PeakFinderAlgos::setAllocator ( Allocator *  allocator)

Set the stored Allocator pointer (the trailing comment says it is changed for each event).

◆ setPeakSelectionPars()

void psalgos::PeakFinderAlgos::setPeakSelectionPars ( const float &  npix_min = 0,
const float &  npix_max = 1e6,
const float &  amax_thr = 0,
const float &  atot_thr = 0,
const float &  son_min = 0 
)

Set peak selection parameters.

◆ vectorOfPeaks()

const AllocArray1D< Peak > & psalgos::PeakFinderAlgos::vectorOfPeaks ( )
inline

Returns vector of peaks v_peaks.

◆ vectorOfPeaksSelected_drp()

const AllocArray1D< Peak > & psalgos::PeakFinderAlgos::vectorOfPeaksSelected_drp ( )
inline

Returns vector of selected peaks v_peaks_sel.

Member Data Documentation

◆ cols

AllocArray1D<float> psalgos::PeakFinderAlgos::cols

Column centers of gravity of the selected peaks, filled by _convPeaksSelected().

◆ intens

AllocArray1D<float> psalgos::PeakFinderAlgos::intens

Total intensities (amp_tot) of the selected peaks, filled by _convPeaksSelected().

◆ numPeaksSelected

unsigned psalgos::PeakFinderAlgos::numPeaksSelected = 0

Number of selected peaks, set by _convPeaksSelected() (0 initially).

◆ rows

AllocArray1D<float> psalgos::PeakFinderAlgos::rows

Row centers of gravity of the selected peaks, filled by _convPeaksSelected().


The documentation for this class was generated from the following file: