areadetector: a module for epics area detector support
DESCRIPTION
areaDetector: A module for EPICS area detector support. Mark Rivers GeoSoilEnviroCARS, Advanced Photon Source University of Chicago. areaDetector Talk Outline. Motivation & goals for areaDetector module Overview of architecture Drivers for detectors & cameras - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/1.jpg)
areaDetector: A module for EPICS area detector support
Mark Rivers
GeoSoilEnviroCARS, Advanced Photon Source
University of Chicago
![Page 2: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/2.jpg)
• Motivation & goals for areaDetector module
• Overview of architecture• Drivers for detectors & cameras• Plugins for real-time processing• Viewers and other clients
areaDetector Talk Outline
![Page 3: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/3.jpg)
• NDArray– N-Dimensional array.
• Everything is done in N-dimensions (up to 10), rather than 2. This is needed even for 2-D detectors to support color.
– This is what plug-ins callbacks receive from device drivers.
• NDAttribute– Each NDArray has a list of associated attributes (metadata) that
travel with the array through the processing pileline. Attributes can come from driver parameters, any EPICS PV or any user-supplied function; e.g. can store motor positions, temperature, ring current, etc. with each frame.
• NDArrayPool– Allocates NDArray objects from a freelist– Plugins access in readonly mode, increment reference count– Eliminates need to copy data when sending it to callbacks.
areaDetector – Data structures
![Page 4: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/4.jpg)
ADBase.template
Standard asyn device support(device-independent)
Vendor API
Driver
Channel Access Clients (medm, IDL, ImageJ, SPEC, etc.)
EPICS areaDetector Architecture
xxxDriver.template
Hardware
C++ Base classes (NDArray, asynPortDriver, asynNDArrayDriver, ADDriver, NDPluginDriver)
Layer 5 Standard EPICS records
Layer 4EPICS device support
Layer 3 Plug-ins
Layer 1 Hardware API
Layer 2 Device drivers
Layer 6EPICS CA clients
StdArraysFile
(netCDF, TIFF, JPEG, HDF)
NDPluginXXX.template
Channel access
Record/device supportasynInt32, Float64, Octet
asynGenericPointer (NDArray)
asynXXXArray
C library calls
NDPluginBase.template
ROIColorConvert
![Page 5: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/5.jpg)
class epicsShareClass NDArray {public: /* Methods */ NDArray(); ~NDArray(); int initDimension (NDDimension_t *pDimension, size_t size); int getInfo (NDArrayInfo_t *pInfo); int reserve(); int release(); int report(FILE *fp, int details); friend class NDArrayPool;
areaDetector – Data structures
![Page 6: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/6.jpg)
public: class NDArrayPool *pNDArrayPool int uniqueId double timeStamp epicsTimeStamp epicsTS int ndims; NDDimension_t dims[ND_ARRAY_MAX_DIMS]; NDDataType_t dataType; size_t dataSize; void *pData; NDAttributeList *pAttributeList;};
areaDetector – Data structures
![Page 7: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/7.jpg)
Detector drivers• ADDriver
– Base C++ class from which detector drivers derive. Handles details of EPICS interfaces, and other common functions.
• Simulation driver– Produces calculated images up to very high rates. Implements nearly
all basic parameters, including color. Useful as a model for real detector drivers, and to test plugins and clients.
• Prosilica driver– Gigabit Ethernet cameras, mono and color– High resolution, high speed, e.g. 1360x1024 at 30 frames/second =
40MB/second.• Firewire (IEEE-1396 DCAM)
– Vendor-independent Firewire camera drivers for Linux and Windows• Roper driver
– Princeton Instruments and Photometrics cameras controlled via WinView
![Page 8: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/8.jpg)
Detector drivers (continued)• PVCAM driver
– Princeton Instruments and Photometrics cameras controlled via PVCAM library
• LightField driver– New Princeton Instruments cameras controlled via LightField application
• Pilatus driver– Pilatus pixel-array detectors.
• marCCD driver– Rayonix (MAR-USA) CCD x-ray detectors
• ADSC driver– ADSC CCD detectors
• mar345 driver– marResearch mar345 online image plate
• Perkin-Elmer driver– Perkin-Elmer amorphous silicon detectors
![Page 9: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/9.jpg)
Detector drivers (continued)
• Bruker driver– Bruker detectors controlled via their Bruker Instrument Server (BIS)
• PSL driver– Photonic Sciences Limited detectors
• URL driver– Driver to display images from any URL. Works with Web cameras,
Axis video servers, static images, etc.
• Andor driver– Driver for Andor CCD cameras
– Driver for new Andor sCMOS cameras (Neo, Zyla)
• Generic GigE driver– Should work with any GigEVision compliant camera. From Tom Cobb
at Diamond. Uses Aravis reverse-engineered GigEVision library
![Page 10: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/10.jpg)
Detector drivers (continued)
• PCO driver– For PCO Edge and PCO Dimax cameras. From Tim Madden at
APS; not yet part of areaDetector. Depends on specific CameraLink cards and drivers.
– There are 2 other versions of this driver, one from SLAC, one from DLS.
• Several others, not in areaDetector package or DLS Web site.
![Page 11: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/11.jpg)
ADBase.adl – Generic control screen
• Works with any detector
• Normally write custom control for each detector type to hide unimplemented features and expose driver-specific features
![Page 12: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/12.jpg)
Pilatus specific control screen
![Page 13: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/13.jpg)
MAR-345 specific control screen
![Page 14: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/14.jpg)
URL Driver• Driver that can read images from any URL. • Can be used with Web cameras and Axis video servers. • Uses GraphicsMagick to read the images, and can thus handle a large number of image
formats (JPEG, TIFF, PNG, etc.).
![Page 15: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/15.jpg)
Andor Driver• Supports USB and PCI CCD cameras from Andor. • Runs on 32-bit and 64-bit Linux and 32-bit and 64-
bit Windows. • Original version by Matt Pearson from Diamond
Light Source.
![Page 16: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/16.jpg)
Perkin Elmer Flat Panel Driver
![Page 17: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/17.jpg)
Plugins• Designed to perform real-time processing of data, running in the EPICS
IOC (not over EPICS Channel Access)• Receive NDArray data over callbacks from drivers or other plugins• Plug-ins can execute in their own threads (non-blocking) or in callback
thread (blocking)– If non-blocking then NDArray data is queued
• Can drop images if queue is full
– If executing in callback thread, no queuing, but slows device driver
• Allows – Enabling/disabling– Throttling rate (no more than 0.5 seconds, etc)– Changing data source for NDArray callbacks to another driver or plugin
• Some plugins are also sources of NDArray callbacks, as well as consumers.
– Allows creating a data processing pipeline running at very high speed, each in a different thread, and hence in multiple cores on modern CPUs.
![Page 18: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/18.jpg)
Plugins (continued)
• NDPlugInStdArrays– Receives arrays (images) from device drivers, converts to standard arrays, e.g.
waveform records.
– This plugin is what EPICS channel access viewers normally talk to.
• NDPluginROI– Performs region-of-interest calculations
– Select a subregion. Optionally bin, reverse in either direction, convert data type.
– Divide the array by a scale factor, which is useful for avoiding overflow when binning.
• NDPluginColorConvert– Convert from one color model to another (Bayer, Mono, RGB1 (pixel), RGB2
(row) or RGB3 (planar) interleave)
– Bayer conversion is restricted to Linux and WIN32.
• NDPluginTransform– Performs geometric operations (rotate, mirror in X or Y, etc.)
![Page 19: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/19.jpg)
• NDPluginStats– Calculates basic statistics on an array (min, max, sigma)– Optionally computes centroid centroid position, width and tilt. – Optionally Computes X and Y profiles, including average profiles, profiles at the
centroid position, and profiles at a user-defined cursor position.– Optionally computes the image histogram and entropy
• NDPluginProcess– Does arithmetic processing on arrays– Background subtraction. – Flat field normalization. – Offset and scale. – Low and high clipping. – Recursive filtering in the time domain. – Conversion to a different output data type.
• NDPluginOverlay– Adds graphic overlays to an image. – Can be used to display ROIs, multiple cursors, user-defined boxes, etc.
• NDPluginMJPEG– MJPEG server that allows viewing images in a Web browser. From DLS.
Plugins (continued)
![Page 20: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/20.jpg)
commonPlugins.adl All plugins at a glance
![Page 21: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/21.jpg)
NDStdArrays plugin
![Page 22: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/22.jpg)
ROI plugin
![Page 23: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/23.jpg)
Statistics plugin
![Page 24: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/24.jpg)
Statistics plugin (continued)
![Page 25: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/25.jpg)
Overlay plugin
Centroid of laser pointer calculated by statistics pluginCursor overlay X, Y position linked to centroid
![Page 26: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/26.jpg)
Overlay plugin – 8 overlays on 1 screen
![Page 27: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/27.jpg)
Processing plugin
![Page 28: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/28.jpg)
Processing plugin30 microsec exposure time
No filtering N=100 recursive average filter
![Page 29: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/29.jpg)
Plugins: NDPluginFile• Saves NDArrays to disk• 3 modes:
– Single array per disk file– Capture N arrays in memory, write to disk either multiple files or
as a single large file (for file formats that support this.)– Stream arrays to a single large disk file
![Page 30: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/30.jpg)
Plugins: NDPluginFile• File formats currently supported
– NDFileTIFF• Now supports any NDArray data type
– NDFileJPEG• With compression control)
– NDFileNetCDF• Popular self-describing binary format, supported by Unidata at UCAR)
– NDFileNeXus• Standard file format for neutron and x-ray communities, based on HDF5, which is
another popular self-describing binary format; richer than netCDF
– NDFileHDF5• Writes HDF5 files with the native HDF5 API, unlike the NeXus plugin which uses the NeXus
API. Supports 3 types of compression. (Ulrik Pedersen)
– NDFileMagick• Uses GraphicsMagick to write files, and can write in dozens of file formats, including
JPEG, TIFF, PNG, PDF, etc.
– NDFileNull• Used only to delete original driver files when no other file plugin is running
![Page 31: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/31.jpg)
NDPluginFile Enhancements• New record, DeleteDriverFile. Allows file writing plugins to delete the
"original" file that the driver created for that array if the following are all true:
– The DeleteDriverFile record is "Yes". – The file plugin has successfully written a new file. – The array contains an attribute called "DriverFileName" that contains the full file name of
the original file. The driver attributes XML file should contain a line like the following:<Attribute name="DriverFileName" type="PARAM" source="FULL_FILE_NAME"
datatype="string" description="Driver file name"/>
• Support for getting the file name and file number from array attributes rather than from the normal EPICS PVs. Allows the driver to control which plugin saves a particular array. (Ulrik Pedersen)
• Added XML Schema file (iocBoot/attributes.xsd) to allow syntax validation of an NDArray driver attributes XML file. (Pete Jemian)
• 2 new records, WriteStatus and WriteMessage to display status of file writing operations.
![Page 32: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/32.jpg)
File saving with driver
• In addition to file saving plugins, many vendor libraries also support saving files (e.g. marCCD, mar345, Pilatus, etc.) and this is supported at the driver level.
• File saving plugin can be used instead of or in addition to vendor file saving
– Can add additional metadata vendor does not support– Could write JPEGS for Web display every minute, etc.
![Page 33: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/33.jpg)
NDFileTIFF Enhancements
• Previously TIFF files were being written without the SampleFormat TIFF tag.
– File did not distinguish between signed and unsigned integers– Floating point TIFF files were not supported.
• Some readers, notably the Python Imaging Library (PIL), do not recognize 32-bit TIFF files unless they contain the SampleFormat tag.
• Added the SampleFormat TIFF tag, and added support for 32-bit and 64-bit floating point arrays.
• Plugin can now write TIFF files with any NDArray type (Int8, UInt8, Int16, UInt16, Int32, UInt32, Float32, and Float64).
– IDL can read TIFF files with all of these data types. – ImageJ can read all except Float64. – PIL can read all except Int8, UInt32, and Float64.
![Page 34: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/34.jpg)
NDPluginFile display: TIFF
Example: saving 82 frames/second of 1024x1024 video to TIFF files, a few dropped frames.
![Page 35: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/35.jpg)
NDPluginFile display: netCDF
Example: streaming 47 frames/second of 1024x1024 video to netCDF files, no dropped frames.
![Page 36: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/36.jpg)
Viewers
• areaDetector allows generic viewers to be written that receive images as EPICS waveform records over Channel Access
• Current viewers include:– ImageJ plugin EPICS_AD_Display. ImageJ is a very
popular image analysis program, written in Java, derived from NIH Image.
– IDL EPICS_AD_Display.
– MJPEG server allows image display in any Web browser
![Page 37: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/37.jpg)
ImageJ Viewer
![Page 38: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/38.jpg)
InternalsClass hierarchy
![Page 39: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/39.jpg)
• Architecture works well, easily extended to new detector drivers, new plugins and new clients
• Base classes, asynPortDriver, asynNDArrayDriver, asynPluginDriver actually are generic, nothing “areaDetector” specific about them.
• They can be used to implement any N-dimension detector, e.g. the XIA xMAP (16 detectors x 2048 channels x 512 points in a scan line).
• Also used for X-ray BPM quadEM application I’ll talk about on Friday
• Can get source code and pre-built binaries (Linux, Windows, Cygwin, Darwin) from our Web site:
– http://cars.uchicago.edu/software/epics/areaDetector
• Can also get code on APS BCDA Subversion repository– https://subversion.xray.aps.anl.gov/synApps/areaDetector/
Conclusions
![Page 40: areaDetector: A module for EPICS area detector support](https://reader036.vdocuments.mx/reader036/viewer/2022062519/56815303550346895dc12749/html5/thumbnails/40.jpg)
• Brian Tieman (APS) Roper PVCAM driver
• John Hammonds (APS) Perkin-Elmer driver and NeXus file saving plugin
• Tim Madden (APS) initial version of ImageJ viewer, PCO driver
• Ulrik Pedersen, Matt Pearson, Tom Cobb (Diamond) MJPEG plugin, Linux Firewire driver, Aravis GigE driver, enhancements to Pilatus
• Lewis Muir (U Chicago) ADSC CCD driver
• NSF-EAR and DOE-Geosciences for support of GSECARS where most of this work was done
• Thanks for your attention!!!
Acknowledgments