Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


ScanImage allows to select several regions of interest (ROIs) for live analysis. The pixel intensities within these ROIs is averaged. The resulting time trace is plotted over time in the ROI Integration Display and can be used to drive a digital or analog output.

titleROI Integration Experiment Setup
<center><iframe width="600" height="337" src="" allowfullscreen frameborder="0"></iframe></center>

Integration ROIs

An Integration ROI is a 3D object, that defines the geometry of an image feature. See Scanfields, ROIs, ROI Groups to learn more about the ROI concept. The ROI is defined by 2D-cross sections at different z-positions. For each of these slices, a mask can be defined that weighs the underlying pixel values.


title3D ROI Integration Experiment Setup
<center><iframe width="600" height="337" src="" allowfullscreen frameborder="0"></iframe></center>

Cross-section of an Integration ROI at one z-slice. The ROI contains a weighted mask.

Calculation of Intensity

If no mask is assigned to an integration ROI, the sum of all pixels of the ROI is calculated and is divided by the number of all pixels in the ROI. If the ROI stretches over more than one slice, the sum of all pixels of all slices in the ROI is calculated. The final output is generated when the last slice of the integration ROI is acquired. 

If a mask is assigned to an integration ROI, each pixel is multiplied by the associate weight of the mask. Next, the sum of all weighted pixels is calculated. This sum is then divided by the sum of all elements in the mask.


The ROI integration is done in the Matlab thread. If processing a single frame does not finish before the next frame arrives, Matlab can drop the incoming frame to stay in sync with the acquisition (the frame data is still logged to disk in this case). If this happens, the ROI Integration does not process the dropped frame.


Output File Format

If ROI Integration is enabled in the Integration Control Window, saving is enabled in the Main Controls Window, and a Grab or Loop is performed, ScanImage saves the integration value for all integration values into a CSV file, which is located in the same directory as the Tiff file containing the video stream.


Programmatic ROI access

The integration ROIs can be created, modified and deleted using the ScanImage API. See ROI API to learn more.

Code Block
titleExample: Modify the geometry of an Integration ROI
hSI.hIntegrationRoiManager.roiGroup.rois(1).scanfields(1).centerXY = [1,1];      % define the center of the scanfield in scan angle coordinates
hSI.hIntegrationRoiManager.roiGroup.rois(1).scanfields(1).sizeXY = [1,1];        % define the size of the scanfield in scan angle coordinates
hSI.hIntegrationRoiManager.roiGroup.rois(1).scanfields(1).mask = rand(10,10);    % define a (random) weighted mask for an integration scanfield


Motion Correction

If the sample moves during an active acquisition, the pre-defined Integration ROIs might not process the correct portion of the image. To ensure the Integration ROIs track the sample, enable ScanImage's Motion Correction feature.


Output Channels

The output generated by the ROI Integration module can be used to drive analog and digital outputs or to call user defined functions. See ROI Integration Output Channels for more information.