CFEL - ASG Software Suite
2.5.0
CASS
|
find bragg peaks and store them in list More...
#include <hitfinder.h>
Public Member Functions | |
pp208 (const name_t &name) | |
constructor More... | |
virtual void | process (const CASSEvent &, result_t &) |
process event More... | |
virtual void | loadSettings (size_t) |
load the settings of this pp More... | |
![]() | |
Processor (const name_t &name) | |
constructor More... | |
virtual | ~Processor () |
virtual destructor More... | |
virtual void | processEvent (const CASSEvent &event) |
process the event More... | |
virtual const result_t & | result (const CASSEvent::id_t eventid=0) |
retrieve a result for a given id. More... | |
virtual void | releaseEvent (const CASSEvent &event) |
tell the list that the result for event can be overwritten More... | |
result_t::shared_pointer | resultCopy (const uint64_t eventid) |
retrieve histogram for id More... | |
virtual void | load () |
load the general settings More... | |
virtual void | aboutToQuit () |
function that will be called when the processor is about to be deleted More... | |
const names_t & | dependencies () |
Define all processors keys a processor depends on. More... | |
void | clearDependencies () |
clear the dependenies More... | |
void | clearHistograms () |
clear the histograms More... | |
virtual void | processCommand (std::string command) |
process command in pp More... | |
const name_t | name () const |
retrieve the name of this processor More... | |
bool | hide () const |
retrieve the hide flag of this processor More... | |
const std::string & | comment () const |
retrieve the comment of this processor More... | |
Protected Types | |
enum | ColumnNames { Intensity = 0, centroidColumn = 1, centroidRow = 2, nbrOfPixels = 3, SignalToNoiseHighestPixel = 4, Index = 5, Column = 6, Row = 7, LocalBackground = 8, LocalBackgroundDeviation = 9, MaxRadius = 10, MinRadius = 11, MaxADU = 12, nUpOutliers = 13, Resolution = 14, SignalToNoiseSpot = 15, nbrOf } |
enum describing the contents of the resulting table More... | |
typedef result_t::storage_t | table_t |
definition of the table More... | |
typedef result_t::storage_t::value_type | pixelval_t |
define the type of the pixel in image More... | |
typedef CummulativeStatisticsNoOutlier< pixelval_t > | stat_t |
define the type of statistics used More... | |
typedef int64_t | index_t |
define the index in the image More... | |
typedef std::pair< index_t, index_t > | shape_t |
define the shape of the image More... | |
typedef std::vector< index_t > | neighbourList_t |
define the list of neighbours More... | |
Protected Member Functions | |
int | getBoxStatistics (result_t::const_iterator pixel, const index_t linIdx, const shape_t &box, stat_t &stat) |
retrieve the box statistics More... | |
int | isNotHighest (result_t::const_iterator pixel, const index_t linIdx, shape_t box, stat_t &stat) |
check if pixel is not highest within box More... | |
double | lambdaFromConstant (const CASSEvent::id_t &) |
retrieve the constant wavelength More... | |
double | lambdaFromProcessor (const CASSEvent::id_t &id) |
retrieve the wavelength from the processor More... | |
double | distanceFromConstant (const CASSEvent::id_t &) |
retrieve the constant detector distance More... | |
double | distanceFromProcessor (const CASSEvent::id_t &id) |
retrieve the detector distance from the processor More... | |
pixelval_t | thresholdFromProcessor (const CASSEvent::id_t &id) |
retrieve the threshold from the processor More... | |
pixelval_t | thresholdFromConstant (const CASSEvent::id_t &id) |
retrieve the threshold constant More... | |
![]() | |
virtual void | createHistList (result_t::shared_pointer result) |
create result list. More... | |
void | setupGeneral () |
general setup of the processor More... | |
bool | setupCondition (bool defaultConditionType=true) |
setup the condition. More... | |
shared_pointer | setupDependency (const std::string &depVarName, const name_t &name="") |
setup the dependecy. More... | |
Protected Attributes | |
shared_pointer | _imagePP |
processor containing the image to find the bragg peaks in More... | |
shape_t | _box |
the size of the box within which the peak should lie More... | |
shape_t | _section |
size of a image section More... | |
shape_t | _imageShape |
size of the incomming image More... | |
stat_t::value_type | _minSnr |
minimum Signal to Noise Ratio thats is needed for a pixel to be an outlier More... | |
float | _minRatio |
minimum ratio of nbr of points used for statistics to nbr of outliers More... | |
stat_t::count_type | _minNbrPixels |
the minimum nbr of pixels in the bragg peak More... | |
neighbourList_t | _neighbourOffsets |
the list of offsets to next neighbours More... | |
std::vector< double > | _src2labradius |
the conversion table from raw to lab More... | |
double | _wavelength |
the wavelength in case its fixed More... | |
shared_pointer | _wavelengthPP |
pp containing wavelength in case its not fixed More... | |
std::tr1::function< double(const CASSEvent::id_t &)> | _getLambda |
function that gets the wavelength More... | |
double | _detdist |
the detector distance in case its fixed More... | |
shared_pointer | _detdistPP |
pp containing detector distance in case its not fixed More... | |
std::tr1::function< double(const CASSEvent::id_t &)> | _getDistance |
function that gets the detectordistance More... | |
pixelval_t | _threshold |
pixel threshold to be exceeded More... | |
shared_pointer | _threshPP |
pp containing threshold in case its not fixed More... | |
std::tr1::function< pixelval_t(const CASSEvent::id_t &)> | _thresh |
function that gets the detectordistance More... | |
![]() | |
const name_t | _name |
the processors name More... | |
bool | _hide |
flag to tell whether this pp should be hidden in the dropdown list More... | |
std::string | _comment |
optional comment that one can add to a processor. More... | |
CachedList | _resultList |
the list of results More... | |
names_t | _dependencies |
the list of dependencies More... | |
shared_pointer | _condition |
pointer to the processor that will contain the condition More... | |
Additional Inherited Members | |
![]() | |
typedef std::tr1::shared_ptr< Processor > | shared_pointer |
a shared pointer of this More... | |
typedef std::string | name_t |
define the name type More... | |
typedef std::list< name_t > | names_t |
define the list of names More... | |
typedef CachedList::item_type | result_t |
define the results More... | |
typedef CachedList::item_sp | resultsp_t |
define the shared pointer to the result More... | |
find bragg peaks and store them in list
Finds bragg peaks by checking how many pixels that are connected are above the given singal to noise ratio. The mean and standart deviation for calculating the SNR is determined by a local box size. Here the statistics is cleaned from the outliers so that pixels that are potentially part of the peak are not included in the background and stdv calculation. If the ratio between outliers of the distribution and pixel that are part of the distribution does not satisfy the user setting, the box size will be increased and the process to determine the local background and std is repeated.
This algorithm was inspired by an algorithm described in Zhang et al. J. Appl. Cryst. (2006). 39, 112-119 [ doi:10.1107/S0021889805040677 ]
Processor/%name%/{ImageName}
the processor name that contain the 2d histogram. Default is "blubb".
Processor/%name%/{SectionSizeX|SectionSizeY}
Size of the subsection of the image. Default is 1024|512.
Processor/%name%/{BraggPeakDiameter}
Minimum Diameter of a Bragg Peak. Used for determining the optimal box size and nbr of pixels in the Bragg Peak. Default is 2.
Processor/%name%/{MinRatio}
The minimum ratio of pixel that are outliers of the distribution in the box to the pixels that are part of the distribution in the box. 3 mean that there have to be at least 3 times as meany pixels that are part of the distribution than outliers of the distribution. Default is 3.
Processor/%name%/{Threshold}
Threshold of pixel in adu to be exeeded. Can also be the name of a Processor that contains the Threshold value.
Processor/%name%/{MinSignalToNoiseRatio}
Signal to noise ratio of a pixel. Value needs to be exceeded in order for the pixel to be part of a bragg peak. Default is 4.
Processor/%name%/{MinNbrPixels}
Minimum Nbr of Pixels to be part of a Bragg Peak. Default is determined by BraggPeakRadius.
Processor/%name%/{BoxSizeX|BoxSizeY}
col (x) and rows (y) of the box that is used for determining the background. The box is going from -BoxSizeX ... BoxSizeX in x and same in y. Default is determined by the BraggPeakRadius.
Processor/%name%/{GeometryFilename}
The geom file to use. Default is "wrong_file" in which case the resolution will be calculated completely wrong
Processor/%name%/{ConvertCheetahToCASSLayout}
Set this true if the geom file is for a cheetah layout of the data, but the image in ImageName is the image in CASS layout.
Processor/%name%/{Wavelength_A}
The wavelength in Angstroem. Can also be the name of a Processor that contains the Wavelength. Default is 1.
Processor/%name%/{DetectorDistance_m}
The detector distance in m. Can also be the name of a Processor that contains the detector distance. Default is 60e-2.
Processor/%name%/{PixelSize_m}
The pixel size in m. Default is 109.92-6
Definition at line 387 of file hitfinder.h.
|
protected |
define the index in the image
Definition at line 413 of file hitfinder.h.
|
protected |
define the list of neighbours
Definition at line 419 of file hitfinder.h.
|
protected |
define the type of the pixel in image
Definition at line 407 of file hitfinder.h.
|
protected |
define the shape of the image
Definition at line 416 of file hitfinder.h.
|
protected |
define the type of statistics used
Definition at line 410 of file hitfinder.h.
|
protected |
definition of the table
Definition at line 404 of file hitfinder.h.
|
protected |
enum describing the contents of the resulting table
Definition at line 422 of file hitfinder.h.
pp208::pp208 | ( | const name_t & | name | ) |
|
inlineprotected |
retrieve the constant detector distance
id | unused |
Definition at line 489 of file hitfinder.h.
References _detdist.
Referenced by loadSettings().
|
protected |
retrieve the detector distance from the processor
id | the id of the event to get the detector distance from |
Definition at line 888 of file hitfinder.cpp.
References _detdistPP.
Referenced by loadSettings().
|
protected |
retrieve the box statistics
Details:
pixel | const iterator to the center pixel |
linIdx | the linearized index of the pixel |
box | the shape of the box to check |
stat | the statistics calculator used to determine mean and stdv of pixels in box |
get coordinates of pixel from the linearized index
make sure that pixel is located such that the box will not conflict with the image and section boundaries. If it does continue with next pixel
go through all pixels defined by the box from -rows ... rows, -cols ... cols
check if the current box pixel value is bigger than the center pixel value. If so skip this pixel
if its not a bad pixel add pixel to statistics
Definition at line 907 of file hitfinder.cpp.
References _imageShape, _section, cass::CummulativeStatisticsNoOutlier< Type >::addDatum(), and use.
Referenced by isNotHighest().
|
protected |
check if pixel is not highest within box
Details:
pixel | const iterator to the pixel to be checked |
linIdx | the linearized index of the pixel |
box | the shape of the box to be checked (cols x rows) |
stat | the statistics calculator used to determine mean and stdv of pixels in box |
check whether current pixel value is highest and generate background values
increase the box size and start over if the fraction of outliers to points used in the statistics is smaller than requested.
skip this pixel if there are not enough pixels that could potentially be part of the bragg peak.
Definition at line 946 of file hitfinder.cpp.
References _minNbrPixels, _minRatio, getBoxStatistics(), cass::CummulativeStatisticsNoOutlier< Type >::nbrPointsUsed(), cass::CummulativeStatisticsNoOutlier< Type >::nbrUpperOutliers(), cass::CummulativeStatisticsNoOutlier< Type >::reset(), and use.
Referenced by process().
|
inlineprotected |
retrieve the constant wavelength
id | unused |
Definition at line 477 of file hitfinder.h.
References _wavelength.
Referenced by loadSettings().
|
protected |
retrieve the wavelength from the processor
id | the id of the event to get the wavelength from |
Definition at line 881 of file hitfinder.cpp.
References _wavelengthPP.
Referenced by loadSettings().
|
virtual |
load the settings of this pp
area of box should at least be ratio times area of peak.
If goes from
then
convert to integer
min nbr of pixels should reflect the area under the bragg peak
use fixed value for wavelength if value can be converted to double, otherwise use the wavelength from the processor
use fixed value for detector distance if value can be converted to double, otherwise use the detector distance from the processor
use fixed value for threshold if value can be converted to double, otherwise use the detector distance from the processor
check if the input processors have the correct type
generate the lookuptable for the radia, if no geom file is provided, set the radia to 0
set up the neighbouroffset list
Create the result output
log what the user was requesting
Reimplemented from cass::Processor.
Definition at line 697 of file hitfinder.cpp.
References _box, cass::Processor::_condition, _detdist, _detdistPP, _getDistance, _getLambda, _imagePP, _imageShape, _minNbrPixels, _minRatio, _minSnr, _neighbourOffsets, _section, _src2labradius, _thresh, _threshold, _threshPP, _wavelength, _wavelengthPP, cass::Log::add(), QSettings::beginGroup(), cass::Processor::createHistList(), distanceFromConstant(), distanceFromProcessor(), QString::fromStdString(), cass::GeometryInfo::generateConversionMap(), cass::Log::INFO, lambdaFromConstant(), lambdaFromProcessor(), cass::Processor::name(), nbrOf, cass::Processor::setupCondition(), cass::Processor::setupDependency(), cass::Processor::setupGeneral(), cass::square(), thresholdFromConstant(), thresholdFromProcessor(), cass::toString(), QSettings::value(), cass::ACQIRIS::x, and cass::ACQIRIS::y.
Referenced by pp208().
process event
clear the resulting table to fill it with the values of this image
get a table row that we can later add to the table
set up a mask that we can see which pixels have been treated
get iterators for the mask and the image with which we can iterate through the image, also rember which linearized index we are working on right now, to be able to retrieve the column and row that the current pixel corresponsed to.
check if pixel should be treated, when it has been treated before continue with the next pixel
check if pixel is above the threshold, otherwise continue with the next pixel
check if pixel is highest within box. If so, check if there are enough pixels that are not outliers. If there are not enough pixels in the box increase the box size and do the checks all over again. If the pixel is not highest within the bigger box continue with the next pixel.
retrive statistical values from the calculator
get coordinates of pixel in image from the linearized index
from the central pixel look around and see which pixels are direct part of the peak. If a neighbour is found, mask it such that one does not use it twice.
Create a list that should contain the indizes of the pixels that are part of the peak. Go through that list and check for each found neighbour whether it also has a neighbour. If so add it to the list, but only if it is part of the box.
if the peak doesn't have enough pixels continue with next pixel
go through all pixels in the box, find out which pixels are part of the peak and centroid them. Mask all pixels in the box as checked so one does not check them again
set the peak's properties and add peak to the list of found peaks
tell that only the result of one event (image) is present in the table
Reimplemented from cass::Processor.
Definition at line 985 of file hitfinder.cpp.
References _box, _getDistance, _getLambda, _imagePP, _imageShape, _minNbrPixels, _minSnr, _neighbourOffsets, _src2labradius, _thresh, cass::Result< T >::appendRows(), cass::Result< T >::begin(), centroidColumn, centroidRow, Column, cass::Result< T >::end(), cass::CASSEvent::id(), Index, cass::ACQIRIS::integral, Intensity, isNotHighest(), LocalBackground, LocalBackgroundDeviation, cass::Result< T >::lock, MaxADU, MaxRadius, cass::CummulativeStatisticsNoOutlier< Type >::mean(), MinRadius, nbrOf, nbrOfPixels, cass::CummulativeStatisticsNoOutlier< Type >::nbrUpperOutliers(), nUpOutliers, cass::Result< T >::resetTable(), Resolution, Row, SignalToNoiseHighestPixel, SignalToNoiseSpot, cass::Result< T >::size(), and cass::CummulativeStatisticsNoOutlier< Type >::stdv().
|
protected |
retrieve the threshold constant
id | the id of the event to get the detector distance from |
Definition at line 902 of file hitfinder.cpp.
References _threshold.
Referenced by loadSettings().
|
protected |
retrieve the threshold from the processor
id | the id of the event to get the detector distance from |
Definition at line 895 of file hitfinder.cpp.
References _threshPP.
Referenced by loadSettings().
|
protected |
the size of the box within which the peak should lie
Definition at line 511 of file hitfinder.h.
Referenced by loadSettings(), and process().
|
protected |
the detector distance in case its fixed
Definition at line 544 of file hitfinder.h.
Referenced by distanceFromConstant(), and loadSettings().
|
protected |
pp containing detector distance in case its not fixed
Definition at line 547 of file hitfinder.h.
Referenced by distanceFromProcessor(), and loadSettings().
|
protected |
function that gets the detectordistance
Definition at line 550 of file hitfinder.h.
Referenced by loadSettings(), and process().
|
protected |
function that gets the wavelength
Definition at line 541 of file hitfinder.h.
Referenced by loadSettings(), and process().
|
protected |
processor containing the image to find the bragg peaks in
Definition at line 401 of file hitfinder.h.
Referenced by loadSettings(), and process().
|
protected |
size of the incomming image
Definition at line 517 of file hitfinder.h.
Referenced by getBoxStatistics(), loadSettings(), and process().
|
protected |
the minimum nbr of pixels in the bragg peak
Definition at line 526 of file hitfinder.h.
Referenced by isNotHighest(), loadSettings(), and process().
|
protected |
minimum ratio of nbr of points used for statistics to nbr of outliers
Definition at line 523 of file hitfinder.h.
Referenced by isNotHighest(), and loadSettings().
|
protected |
minimum Signal to Noise Ratio thats is needed for a pixel to be an outlier
Definition at line 520 of file hitfinder.h.
Referenced by loadSettings(), and process().
|
protected |
the list of offsets to next neighbours
Definition at line 529 of file hitfinder.h.
Referenced by loadSettings(), and process().
|
protected |
size of a image section
Definition at line 514 of file hitfinder.h.
Referenced by getBoxStatistics(), and loadSettings().
|
protected |
the conversion table from raw to lab
Definition at line 532 of file hitfinder.h.
Referenced by loadSettings(), and process().
|
protected |
function that gets the detectordistance
Definition at line 559 of file hitfinder.h.
Referenced by loadSettings(), and process().
|
protected |
pixel threshold to be exceeded
Definition at line 553 of file hitfinder.h.
Referenced by loadSettings(), and thresholdFromConstant().
|
protected |
pp containing threshold in case its not fixed
Definition at line 556 of file hitfinder.h.
Referenced by loadSettings(), and thresholdFromProcessor().
|
protected |
the wavelength in case its fixed
Definition at line 535 of file hitfinder.h.
Referenced by lambdaFromConstant(), and loadSettings().
|
protected |
pp containing wavelength in case its not fixed
Definition at line 538 of file hitfinder.h.
Referenced by lambdaFromProcessor(), and loadSettings().