Skip to content

Data Processor Algorithms

The Data Processor module executes various algorithms to transform raw images during or after acquisition. This document provides the conceptual overview and the exact mathematical formulation for each available processing operation.


No Processor

Overview

The NO_PROCESSOR operation acts as a pass-through node in the processing pipeline. It forwards the input image stream to the next node or to storage without performing any modifications.

Mathematical Formulation

For an input image \(I_{\text{in}} (x, y)\) at pixel coordinate \((x, y)\), the output image \(I_{\text{out}} (x, y)\) is identical to the input:

\[I_{\text{out}} (x, y) = I_{\text{in}} (x, y)\]

Simple Tiling

Overview

The SIMPLE_TILING processor combines a sequence of individual tile images acquired during a grid-based acquisition into a single large mosaic image. It maps each tile to its coordinates on a global grid using nominal offsets without performing any alignment optimization or edge blending.

Mathematical Formulation

Let the input tile image at grid column index \(i \in [0, N_x)\) and grid row index \(j \in [0, N_y)\) be denoted as \(I_{\text{in}, i, j}\). Let \(W_{\text{tile}}\) and \(H_{\text{tile}}\) represent the width and height of a standard tile (in pixels), respectively, and let \(O_x\) and \(O_y\) represent the fractional grid overlaps along the X and Y dimensions (in the range \([0, 1)\)).

  1. Mosaic Dimensions: The total width \(W_{\text{out}}\) and height \(H_{\text{out}}\) of the output mosaic image (in pixels) are defined as:
\[W_{\text{out}} = (N_x - 1) \cdot W_{\text{tile}} \cdot (1 - O_x) + W_{\text{last}}\]
\[H_{\text{out}} = (N_y - 1) \cdot H_{\text{tile}} \cdot (1 - O_y) + H_{\text{last}}\]

where \(W_{\text{last}}\) and \(H_{\text{last}}\) represent the actual width and height of the boundary tiles.

  1. Tile Offset Calculation: The top-left offset coordinate \((x_{\text{offset}} (i), y_{\text{offset}} (j))\) for the tile at column index \(i\) and row index \(j\) is calculated as:
\[x_{\text{offset}} (i) = i \cdot W_{\text{tile}} \cdot (1 - O_x)\]
\[y_{\text{offset}} (j) = j \cdot H_{\text{tile}} \cdot (1 - O_y)\]
  1. Mosaic Synthesis: Each pixel \((x', y')\) in the output mosaic \(I_{\text{out}}\) corresponding to tile \(I_{\text{in}, i, j}\) at local pixel coordinates \((x, y)\) is copied directly:
\[I_{\text{out}} (x_{\text{offset}} (i) + x, y_{\text{offset}} (j) + y) = I_{\text{in}, i, j} (x, y)\]

where \(x \in [0, W_{\text{tile}})\) and \(y \in [0, H_{\text{tile}})\). If tiles overlap, pixels are mapped directly as they are written to the mosaic canvas, with no blending applied.


Stitch Tiling

Overview

The STITCH_TILING processor aligns and blends adjacent tiles in a mosaic to create a seamless composite image. It uses correlation-based image registration to compute optimal relative offsets between adjacent tiles, followed by a distance-based blending algorithm inside the overlapping regions to smooth intensity transitions.

Mathematical Formulation

The processor performs its operations in two sequential phases: registration (offset optimization) and blending (image merging).

Phase 1: Registration and Offset Optimization

Relative displacement vectors (offsets) between adjacent tiles are calculated by maximizing the normalized cross-correlation across their expected overlap regions. If a boundary transition lacks sufficient texture or contains high alignment errors, the registration algorithm handles the transition using one of three alternative modes:

  1. Displacement Interpolation: The processor calculates the mean relative East-West displacement \((WE_x, WE_y)\) and North-South displacement \((NS_x, NS_y)\) using only tile boundaries whose correlation score exceeds a correlation threshold \(T_{\text{corr}}\). For any boundary transition where the correlation score falls below \(T_{\text{corr}}\), or where the calculated relative offset deviates from the average displacement by more than 10 pixels, the processor overrides the offset using the respective mean displacement:
\[\text{Offset}_{E-W} = (WE_x, WE_y)\]
\[\text{Offset}_{N-S} = (NS_x, NS_y)\]
  1. Tile Exclusion: Tiles lacking any neighbor boundary correlation above the threshold \(T_{\text{corr}}\) are excluded from the global offset calculation and from the final stitched mosaic.

  2. Stage Coordinate Fallback: The processor retains the default stage coordinates provided by the microscope stage controller.

Once the relative offsets between neighbors are established, a global coordinate system is constructed by setting the top-left tile as the global reference origin \((0, 0)\) and recursively adding the relative offset vectors to propagate global coordinates to all remaining tiles.

Phase 2: Blending and Merging

Let \(S\) represent the set of input tiles that overlap at a given global mosaic coordinate \((x, y)\). The blended output intensity \(I_{\text{out}} (x, y)\) is computed as follows:

  • Single-Tile Regions (\(|S| = 1\)): If only one input tile \(k \in S\) covers the coordinate, the pixel value is written directly:
\[I_{\text{out}} (x, y) = I_{\text{in}, k} (x - x_{\text{offset}, k}, y - y_{\text{offset}, k})\]
  • Double-Tile Overlap Regions (\(|S| = 2\) with Horizontal or Vertical Alignment): When exactly two tiles overlap and their offsets align strictly along a single axis, the pixel value is linearly blended using a normalized distance ratio \(r \in [0, 1]\):
\[I_{\text{out}} (x, y) = (1 - r) \cdot I_{\text{in}, 1} (x - x_{\text{offset}, 1}, y - y_{\text{offset}, 1}) + r \cdot I_{\text{in}, 2} (x - x_{\text{offset}, 2}, y - y_{\text{offset}, 2})\]

where \(r\) represents the relative distance of the pixel coordinate \((x, y)\) from the boundary of the overlap region.

  • Multi-Tile Overlap Regions (\(|S| > 1\)): For corner overlaps or complex overlapping configurations, the processor calculates a weighted average based on the shortest distance from the pixel to the boundary of each overlapping tile. The weight \(w_k (x, y)\) for input tile \(k \in S\) is defined as:
\[w_k (x, y) = \max \left( \min \left( x - x_{\text{offset}, k}, x_{\text{offset}, k} + W_{\text{tile}} - x, y - y_{\text{offset}, k}, y_{\text{offset}, k} + H_{\text{tile}} - y \right), 1 \right)\]

The blended output pixel intensity is:

\[I_{\text{out}} (x, y) = \frac{\sum_{k \in S} w_k (x, y) \cdot I_{\text{in}, k} (x - x_{\text{offset}, k}, y - y_{\text{offset}, k})}{\sum_{k \in S} w_k (x, y)}\]

Standard Deviation on Fly

Overview

The STANDARD_DEVIATION_ON_FLY processor computes the pixel-wise standard deviation across a chosen acquisition dimension (e.g., over time or Z-planes) as new images are acquired. To minimize memory usage and processing overhead, it implements Welford's online variance calculation algorithm, updating the variance incrementally for each pixel without storing the full stack in memory.

Mathematical Formulation

Let \(I_{\text{in}, k} (x, y)\) represent the intensity of the pixel at coordinate \((x, y)\) for the \(k\)-th input image added to the stack. At step \(k\) (for \(k \ge 1\)):

  1. Mean Update: The running mean \(\mu_k (x, y)\) is updated as:
\[\mu_k (x, y) = \mu_{k-1} (x, y) + \frac{I_{\text{in}, k} (x, y) - \mu_{k-1} (x, y)}{k}\]

with initial condition \(\mu_0 (x, y) = 0\).

  1. Squared Difference Sum Update: The running sum of squared differences \(Q_k (x, y)\) is updated as:
\[Q_k (x, y) = Q_{k-1} (x, y) + \left( I_{\text{in}, k} (x, y) - \mu_{k-1} (x, y) \right) \cdot \left( I_{\text{in}, k} (x, y) - \mu_k (x, y) \right)\]

with initial condition \(Q_0 (x, y) = 0\).

  1. Standard Deviation Computation: The output standard deviation image \(I_{\text{out}} (x, y)\) at step \(k\) is defined as:
\[I_{\text{out}} (x, y) = \begin{cases} 0 & \text{if } k = 1 \\ \sqrt{\frac{Q_k (x, y)}{k - 1}} & \text{if } k > 1 \end{cases}\]

Shading Correction

Overview

The SHADING_CORRECTION processor corrects for spatial variations in illumination intensity, vignetting, and optical dust artifacts. It normalizes each pixel in the input image using a pre-acquired background (or flatfield) calibration image.

Mathematical Formulation

Let \(I_{\text{in}} (x, y)\) represent the input image pixel intensity, and let \(B (x, y)\) represent the corresponding pixel intensity in the calibration background image.

Let \(\mu_B\) represent the average pixel intensity computed across the entire background calibration image:

\[\mu_B = \frac{1}{W \cdot H} \sum_{x=0}^{W-1} \sum_{y=0}^{H-1} B (x, y)\]

The output corrected pixel intensity \(I_{\text{out}} (x, y)\) is computed as:

\[I_{\text{out}} (x, y) = \frac{I_{\text{in}} (x, y) \cdot \mu_B}{B (x, y)}\]

where:

  • If the background image dimensions do not match the input image, the background image is automatically rescaled to match the input image dimensions using nearest-neighbor scaling (specifically, midpoint pixel subsampling) before correction.
  • The background intensity \(B (x, y)\) is assumed to be non-zero to avoid division by zero.

Max Intensity Projection

Overview

The processors TIME_MAX and FOCUS_MAX project an image series into a 2D image by selecting the maximum intensity value for each pixel location along the specified dimension.

  • TIME_MAX calculates a maximum intensity projection along the time dimension.
  • FOCUS_MAX calculates a maximum intensity projection along the Z-stack focus dimension.

Mathematical Formulation

Let \(I_{\text{in}} (c, t, z, x, y)\) represent the input pixel intensity at coordinate \((x, y)\) for channel \(c\) at time index \(t\) and Z-stack index \(z\).

  • For TIME_MAX: The output maximum intensity projection \(I_{\text{out}} (c, z, x, y)\) across all \(T\) time points is defined as:
\[I_{\text{out}} (c, z, x, y) = \max_{t \in [0, T)} I_{\text{in}} (c, t, z, x, y)\]
  • For FOCUS_MAX: The output maximum intensity projection \(I_{\text{out}} (c, t, x, y)\) across all \(Z\) focus positions is defined as:
\[I_{\text{out}} (c, t, x, y) = \max_{z \in [0, Z)} I_{\text{in}} (c, t, z, x, y)\]

Average Intensity Projection

Overview

The processors TIME_AVERAGE and FOCUS_AVERAGE project an image series into a single 2D projection by calculating the arithmetic mean intensity value for each pixel location along the specified dimension.

  • TIME_AVERAGE calculates the mean projection along the time dimension.
  • FOCUS_AVERAGE calculates the mean projection along the Z-stack focus dimension.

Mathematical Formulation

Let \(I_{\text{in}} (c, t, z, x, y)\) represent the input pixel intensity at coordinate \((x, y)\) for channel \(c\) at time index \(t\) and Z-stack index \(z\).

  • For TIME_AVERAGE: The output average intensity projection \(I_{\text{out}} (c, z, x, y)\) across all \(T\) time points is defined as:
\[I_{\text{out}} (c, z, x, y) = \frac{1}{T} \sum_{t=0}^{T-1} I_{\text{in}} (c, t, z, x, y)\]
  • For FOCUS_AVERAGE: The output average intensity projection \(I_{\text{out}} (c, t, x, y)\) across all \(Z\) focus positions is defined as:
\[I_{\text{out}} (c, t, x, y) = \frac{1}{Z} \sum_{z=0}^{Z-1} I_{\text{in}} (c, t, z, x, y)\]

Subtract Background

Overview

The SUBTRACT_BACKGROUND processor reduces background fluorescence or ambient light noise. It calculates the average pixel intensity within a user-defined Region of Interest (ROI) representing background, and subtracts this constant value from every pixel in the image.

Mathematical Formulation

Let \(I_{\text{in}} (x, y)\) represent the input pixel intensity. Let \(\mathcal{A}\) be the set of coordinates defining the background region.

  1. Background Mean Calculation: The average background intensity value \(\mu_{\text{bg}}\) is calculated as:
\[\mu_{\text{bg}} = \frac{1}{|\mathcal{A}|} \sum_{(x_r, y_r) \in \mathcal{A}} I_{\text{in}} (x_r, y_r)\]
  1. Subtraction and Clamping: The output intensity \(I_{\text{out}} (x, y)\) is computed as:
\[I_{\text{out}} (x, y) = \max \left( 0, I_{\text{in}} (x, y) - \mu_{\text{bg}} \right)\]

If no ROI is defined, the processor acts as a pass-through and performs no modification:

\[I_{\text{out}} (x, y) = I_{\text{in}} (x, y)\]