areaDetector Plugin NDPluginStats

March 20, 2010

Mark Rivers

University of Chicago

Contents

Overview

NDPluginStats computes array statistics, including minimum, maximum, mean, sigma, total, net (background subtracted), and centroid values. It can also compute a histogram of the values (e.g. number of pixels versus intensity per pixel). The basic statistics, centroid, and histogram calculations can be enabled or disabled independently.

NDPluginStats inherits from NDPluginDriver. The NDPluginStats class documentation describes this class in detail.

NDPluginStats.h defines the following parameters. It also implements all of the standard plugin parameters from NDPluginDriver. The EPICS database NDStats.template provide access to these parameters, listed in the following table. Note that to reduce the width of this table the parameter index variable names have been split into 2 lines, but these are just a single name, for example NDPluginStatsComputeStatistics.

Parameter Definitions in NDPluginStats.h and EPICS Record Definitions in NDStats.template
Parameter index variable asyn interface Access Description drvInfo string EPICS record name EPICS record type
Basic statistics
NDPluginStats
ComputeStatistics
asynInt32 r/w Flag to control whether to compute statistics for this array (0=No, 1=Yes). Not computing statistics reduces CPU load. Basic statistics computations are quite fast, since they involve mostly double precision addition, with 1 multiply to compute sigma, per array element. Setting this to No will disable both basic statistics and centroid statistics, but will not disable histogram calculation. COMPUTE_STATISTICS $(P)$(R)ComputeStatistics
$(P)$(R)ComputeStatistics_RBV
bo
bi
NDPluginStats
BgdWidth
asynInt32 r/w Width of the background in pixels to use when computing net counts. 0=no background subtraction, so the net counts is the same as the total counts. BGD_WIDTH $(P)$(R)BgdWidth
$(P)$(R)BgdWidth_RBV
longout
longin
NDPluginStats
MinValue
asynFloat64 r/o Minimum value in any element in the array MIN_VALUE $(P)$(R)MinValue_RBV ai
NDPluginStats
MaxValue
asynFloat64 r/o Maximum value in any element in the array MAX_VALUE $(P)$(R)MaxValue_RBV ai
NDPluginStats
MeanValue
asynFloat64 r/o Mean value in the array MEAN_VALUE $(P)$(R)MeanValue_RBV ai
NDPluginStats
Total
asynFloat64 r/o Sum (total) of all elements in the array TOTAL $(P)$(R)Total_RBV ai
NDPluginStats
Net
asynFloat64 r/o Net (background subtracted) total of all elements in the array. The background is calculated by determining the average counts per array element in a border around the array of width NDPluginStatsBgdWidth. This average background counts per element is then subtracted from all elements inside the array. If NDPluginStatsBgdWidth is ≤ 0 then no background is computed. NET $(P)$(R)Net_RBV ai
NDPluginStats
SigmaValue
asynFloat64 r/o Sigma (standard deviation) of all elements in the array SIGMA_VALUE $(P)$(R)Sigma_RBV ai
Centroid statistics
NDPluginStats
ComputeCentroid
asynInt32 r/w Flag to control whether to compute the centroid statistics (0=No, 1=Yes). Centroid calculations require several double precision multiplications per array element, so not computing these reduces CPU load. In order for centroid statistics to be computed both ComputeStatistics and ComputeCentroid must be set to Yes. COMPUTE_CENTROID $(P)$(R)ComputeCentroid
$(P)$(R)ComputeCentroid_RBV
bo
bi
NDPluginStats
CentroidThreshold
asynFloat64 r/w Threshold used when computing the centroid statistics. All array elements less than this value are set to 0 for computing the centroid statistics. It is important to set this value to ignore the "background" when computing the position and size of a "beam" image, for example. CENTROID_THRESHOLD $(P)$(R)CentroidThreshold
$(P)$(R)CentroidThreshold_RBV
ao
ai
NDPluginStats
CentroidX
asynFloat64 r/o X centroid of the array above the centroid threshold. CENTROIDX_VALUE $(P)$(R)CentroidX_RBV ai
NDPluginStats
CentroidY
asynFloat64 r/o Y centroid of the array above the centroid threshold. CENTROIDY_VALUE $(P)$(R)CentroidY_RBV ai
NDPluginStats
SigmaX
asynFloat64 r/o Sigma X (width) of the distribution above the centroid threshold. SIGMAX_VALUE $(P)$(R)SigmaX_RBV ai
NDPluginStats
SigmaY
asynFloat64 r/o Sigma Y (height) of the distribution above the centroid threshold. SIGMAY_VALUE $(P)$(R)SigmaY_RBV ai
Array histogram
NDPluginStats
ComputeHistogram
asynInt32 r/w Flag to control whether to compute the histogram for this array (0=No, 1=Yes). Not computing the histogram reduces CPU load. COMPUTE_HISTOGRAM $(P)$(R)ComputeHistogram
$(P)$(R)ComputeHistogram_RBV
bo
bi
NDPluginStats
HistSize
asynInt32 r/w Number of elements (bins) in the histogram HIST_SIZE $(P)$(R)HistSize
$(P)$(R)HistSize_RBV
longout
longin
NDPluginStats
HistMin
asynFloat64 r/w Minimum value for the histogram. All values less than or equal to this will be in the first bin of the histogram. HIST_MIN $(P)$(R)HistMin
$(P)$(R)HistMin_RBV
ao
ai
NDPluginStats
HistMax
asynFloat64 r/w Maximum value for the histogram. All values greater than or equal to this will be in the last bin of the histogram. HIST_MAX $(P)$(R)HistMax
$(P)$(R)HistMax_RBV
ao
ai
NDPluginStats
HistEntropy
asynFloat64 r/o Entropy of the image. This is a measure of the sharpness of the histogram, and is often a useful figure of merit for determining sharpness of focus, etc. It is defined as -SUM(BIN[i]*log(BIN[i]), where the sum is over the number of bins in the histogram and BIN[i] is the number of elements in bin i. HIST_ENTROPY $(P)$(R)HistEntropy_RBV ai
NDPluginStats
HistArray
asynFloat64Array r/o Histogram array, i.e. counts in each histogram bin. HIST_ARRAY $(P)$(R)Histogram_RBV waveform

Configuration

The NDPluginStats plugin is created with the NDStatsConfigure command, either from C/C++ or from the EPICS IOC shell.

NDStatsConfigure(const char *portName, int queueSize, int blockingCallbacks,
               const char *NDArrayPort, int NDArrayAddr,
               int maxBuffers, size_t maxMemory,
               int priority, int stackSize)
  

For details on the meaning of the parameters to this function refer to the detailed documentation on the NDStatsConfigure function in the NDPluginStats.cpp documentation and in the documentation for the constructor for the NDPluginStats class.

Screen shots

The following is the MEDM screen that provides access to the parameters in NDPluginDriver.h and NDPluginStats.h through records in NDPluginBase.template and NDStats.template.

NDStats.adl

NDStats.png