areaDetector Plugin NDPluginStats

March 7, 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 calculationscan be enabled or disabled independently.

NDPluginROI 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.

Parameter Definitions in NDPluginStats.h and EPICS Record Definitions in NDStats.template
Enum name asyn interface Access Description drvUser string EPICS record name EPICS record type
NDPluginROI
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
NDPluginROI
ComputeStatistics
asynInt32 r/w Flag to control whether to compute statistics for this ROI (0=No, 1=Yes). Not computing statistics reduces CPU load. COMPUTE_STATISTICS $(P)$(R)ComputeStatistics
$(P)$(R)ComputeStatistics_RBV
bo
bi
NDPluginROI
MinValue
asynFloat64 r/o Minimum value in any element in the ROI MIN_VALUE $(P)$(R)MinValue_RBV ai
NDPluginROI
MaxValue
asynFloat64 r/o Maximum value in any element in the ROI MAX_VALUE $(P)$(R)MaxValue_RBV ai
NDPluginROI
MeanValue
asynFloat64 r/o Mean value in the ROI MEAN_VALUE $(P)$(R)MeanValue_RBV ai
NDPluginROI
Total
asynFloat64 r/o Sum (total) of all elements in the ROI TOTAL $(P)$(R)Total_RBV ai
NDPluginROI
Net
asynFloat64 r/o Net (background subtracted) total of all elements in the ROI. The background is calculated by determining the average counts per array element in a border around the ROI of width NDPluginROIBgdWidth. This average background counts per element is then subtracted from all elements inside the ROI. If NDPluginROIBgdWidth is ≤ 0 then no background is computed. Note that this background subtraction is done after the "array" background is subtracted if EnableBackground=1, as described above. NET $(P)$(R)Net_RBV ai
NDPluginROI
CentroidX
asynFloat64 r/o X centroid of the ROI. CENTROIDX_VALUE $(P)$(R)CentroidX_RBV ai
NDPluginROI
CentroidY
asynFloat64 r/o Y centroid of the ROI. CENTROIDY_VALUE $(P)$(R)CentroidY_RBV ai
ROI histogram
NDPluginROI
ComputeHistogram
asynInt32 r/w Flag to control whether to compute the histogram for this ROI (0=No, 1=Yes). Not computing the histogram reduces CPU load. COMPUTE_HISTOGRAM $(P)$(R)ComputeHistogram
$(P)$(R)ComputeHistogram_RBV
bo
bi
NDPluginROI
HistSize
asynInt32 r/w Number of elements (bins) in the histogram HIST_SIZE $(P)$(R)HistSize
$(P)$(R)HistSize_RBV
longout
longin
NDPluginROI
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
NDPluginROI
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
NDPluginROI
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
NDPluginROI
HistArray
asynFloat64Array r/o Histogram array, i.e. counts in each histogram bin. HIST_ARRAY $(P)$(R)Histogram_RBV waveform

Configuration

The NDPluginROI 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 NDROIConfigure 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.

NDROI.adl

NDStats.png