> For the complete documentation index, see [llms.txt](https://docs.nimbusimage.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nimbusimage.com/documentation/image-processing.md).

# Image processing

Images often can be improved through various image processing techniques. These are for things like background correction to remove uneven illumination, image registration to fix shaky timelapses, and enhance spots.

NimbusImage supports a number of these image processing techniques and we are planning to make more in the near future.

## Overall workflow

The image processing workflow in NimbusImage follows these steps:

1. **Select "ADD NEW TOOL"** from the Toolset panel
2. **Choose a processing tool** (such as "Crop") and create the tool
3. **Configure the tool parameters** as needed in the worker panel that appears after clicking on the tool
4. **Run the worker process** to apply the selected tool to your image
5. **Review results** a new dropdown appears just below the dataset navigator that allows you to switch between the orignal and processed images

<div align="left"><figure><img src="https://4239675806-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX54NriBmLyFl6hdSGC9K%2Fuploads%2Fgit-blob-df103d262d6b6cda59da5efaac213aba47ac0637%2Fimage-processing-crop.png?alt=media" alt=""><figcaption><p>A processing tool's worker panel (here, Crop) where you configure parameters and click Compute</p></figcaption></figure></div>

<div align="left"><figure><img src="https://4239675806-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX54NriBmLyFl6hdSGC9K%2Fuploads%2Fgit-blob-57881c16c9feb26bb60960e8fdd65e552439570f%2Fimage-processing-select-image.png?alt=media" alt="" width="314"><figcaption><p>After processing, a "Select Image" dropdown lets you switch between the original and the processed images</p></figcaption></figure></div>

## Crop

The Crop tool allows you to reduce your image dimensions by selecting only a portion of the original image. This is useful for focusing on regions of interest, removing unnecessary image areas. You can both remove entire slices and also crop to particular regions.

### How to use

1. **Add the Crop tool** by clicking the "ADD NEW TOOL" button in the Toolset panel
2. **Configure crop parameters** using one of the following methods:
   * **XY Range**: Specify which XY positions to retain (especially useful for multi-position datasets)
   * **Z Range**: Specify which Z-slices to retain (for 3D images)
   * **Time Range**: Specify which time points to retain (for time-lapse sequences)
   * **Crop Rectangle**: Select a previously drawn rectangle or polygon annotation to define the crop region.
3. **Process the image** by running the worker
4. **Review the result** by switching between "Original image" and "cropped" in the dropdown menu

### Parameters

* **XY Range**: Enter position numbers to retain (format: "1-3, 5-8", or `all`). Default is all positions.
* **Z Range**: Enter Z-slice numbers to retain (format: "1-3, 5-8", or `all`). Default is all Z-slices.
* **Time Range**: Enter time point numbers to retain (format: "1-3, 5-8", or `all`). Default is all time points.
* **Crop Rectangle**: Select a tag that identifies a rectangle or polygon annotation to define the crop region.

### Technical details

The Crop tool works by creating a new image that contains only the specified region of interest from the original image. For annotation-based cropping, the tool uses the bounding box coordinates of the selected annotation to define the crop region. All metadata from the original image is preserved in the cropped output.

## Registration

The Registration tool corrects for movement and shift in time-lapse image sequences, helping to stabilize your data for more accurate analysis. This is particularly useful for long time-lapse experiments where sample drift occurs. It allows you to use both automated algorithms and manual control points to guide the registration process; you can even use both at the same time.

### How to use

1. **Add the Registration tool** by clicking the "ADD NEW TOOL" button in the Toolset panel
2. **Set the reference** parameters:
   * **Reference Z Coordinate**: Specify which Z-slice to use as reference
   * **Reference Time Coordinate**: Specify which time point to use as reference
   * **Reference Channel**: Select which channel to use for registration calculations
   * **Reference region tag**: Optionally restrict registration to a specific region of interest
3. **Select correction options**:
   * **Channels to correct**: Check which channels should be adjusted
   * **Control point tag**: Optionally use point annotations to guide registration
   * **Algorithm**: Choose the registration method that best suits your data
4. **Process the image** by running the worker
5. **Review the result** by switching between "Original image" and "registered" in the dropdown menu

### Parameters

* **Apply to XY coordinates**: Specify which XY positions to correct (format: "1-3, 5-8")
* **Reference Z Coordinate**: The Z-slice used as reference (default: 1)
* **Reference Time Coordinate**: The time point used as reference (default: 1)
* **Reference Channel**: Channel used for calculating registration
* **Channels to correct**: Select which channels to apply registration to
* **Reference region tag**: Optional tag for a region to use for registration calculations
* **Control point tag**: Optional tag for point annotations to use as registration anchors
* **Apply algorithm after control points**: When checked, applies the algorithm after control point corrections. For instance, you can use control points to roughly register your images and then use the algorithm to fine-tune the registration.
* **Algorithm**: Registration method to use (strongly recommended to use the default "Translation" algorithm):
  * **None (control points only)**: Uses only control points for registration
  * **Translation**: Corrects for X/Y movement (shifting)
  * **Rigid**: Corrects for translation and rotation
  * **Affine**: Corrects for translation, rotation, and scaling

### Technical details

The Registration tool calculates transformation matrices between time points using the StackReg algorithm from the PyStackReg library. For time-lapse sequences, each frame is aligned relative to the reference frame, creating a stable series where features remain in consistent positions.

The tool can use manual control points (annotated points that indicate the same feature across time points) to guide registration or can automatically detect and track features. When both are used, control points provide initial guidance followed by algorithmic refinement.

## Histogram Matching

The Histogram Matching tool normalizes intensity distributions across multiple images by matching their histograms to a reference image. This is particularly useful for correcting intensity variations in time-lapse sequences or multi-position acquisitions, ensuring consistent visualization and analysis.

### How to use

1. **Add the Histogram Matching tool** by clicking the "ADD NEW TOOL" button in the Toolset panel
2. **Set the reference image** by specifying:
   * **Reference XY Coordinate**: The position to use as reference
   * **Reference Z Coordinate**: The Z-slice to use as reference
   * **Reference Time Coordinate**: The time point to use as reference
3. **Select channels to correct** by checking the appropriate channel boxes
4. **Process the image** by running the worker
5. **Review the result** by switching between "Original image" and "normalized" in the dropdown menu

### Parameters

* **Reference XY Coordinate**: The XY position to use as intensity reference (default: 1)
* **Reference Z Coordinate**: The Z-slice to use as intensity reference (default: 1)
* **Reference Time Coordinate**: The time point to use as intensity reference (default: 1)
* **Channels to correct**: Select which channels should be histogram-matched

### Technical details

The Histogram Matching tool works by analyzing the intensity distribution of each specified channel in the reference image, then transforming the histograms of all other images to match that reference. This process preserves the relative differences in intensity within each image while making the overall intensity ranges consistent across the entire dataset.

This technique is especially valuable when:

* Comparing images acquired with different exposure settings
* Analyzing time-lapse data where photobleaching causes intensity decay over time
* Standardizing multi-position acquisitions with varying background intensities
* Preparing datasets for quantitative analysis that requires consistent intensity values

The implementation uses scikit-image's `match_histograms` function to perform precise histogram transformations while maintaining image details.

## Gaussian Blur

The Gaussian Blur tool smooths images by applying a Gaussian filter, which reduces noise and detail. This is useful for removing high-frequency noise, creating soft focus effects, or as a preprocessing step for other analysis techniques.

### How to use

1. **Add the Gaussian Blur tool** by clicking the "ADD NEW TOOL" button in the Toolset panel
2. **Configure the blur settings**:
   * **Sigma**: Control the blur strength (higher values create stronger blurring)
   * **Channel**: Select the default channel to blur
   * **All channels**: Check which channels should be processed
3. **Process the image** by running the worker
4. **Review the result** by switching between "Original image" and the blurred result in the dropdown menu

### Parameters

* **Sigma**: Determines the strength of the blur effect (range: 0-100, default: 20)
* **Channel**: The default channel to blur
* **All channels**: Select multiple channels to apply blurring to

### Technical details

The Gaussian Blur tool applies a Gaussian filter to the selected channels of your image. This filter uses a Gaussian function (bell curve) to create a weighted average of each pixel's neighborhood. The sigma parameter controls the standard deviation of this Gaussian function - larger values consider pixels from a wider area, creating stronger blurring effects.

The implementation uses scikit-image's `filters.gaussian` function to perform the blurring operation. The tool preserves the original image's data type and dynamic range while applying the blur effect proportionally to the image's intensity values.

This technique is particularly useful for:

* Reducing random noise in images
* Softening edges and textures
* Preprocessing images before feature detection or segmentation
* Creating depth-of-field effects

## Deconvolution (Deconwolf)

The Deconvolution tool uses [deconwolf](https://github.com/elgw/deconwolf), an open-source 3D deconvolution engine, to computationally reverse the optical blurring inherent in fluorescence microscopy images. It applies the Richardson-Lucy algorithm with a theoretically generated Born-Wolf point spread function (PSF) to produce sharper images with improved contrast and resolution. GPU acceleration is supported and enabled by default.

This tool is designed for fluorescence microscopy Z-stacks. If the input image has only a single Z-slice, deconvolution is not applicable and the image will pass through unchanged.

### How to use

1. **Add the Deconvolution tool** by clicking the "ADD NEW TOOL" button in the Toolset panel
2. **Select channels to deconvolve** using the channel checkboxes. Unselected channels pass through to the output unchanged.
3. **Set optical parameters** either manually or by enabling "Auto-extract from ND2" to read them from your image metadata:
   * **Numerical Aperture (NA)**: The NA of your objective lens
   * **Refractive Index**: The immersion medium refractive index (1.0 for air, 1.515 for oil)
   * **Pixel Size XY**: Lateral pixel size in nanometers
   * **Z Step**: Axial step size between Z-slices in nanometers
   * **Emission Wavelength**: Emission wavelengths for your channels
4. **Adjust processing settings** as needed:
   * **Iterations**: Number of Richardson-Lucy iterations (higher = sharper but slower)
   * **Use GPU**: Enable for faster processing (falls back to CPU automatically if unavailable)
   * **Tile Size / Overlap**: For processing large images in tiles
5. **Process the image** by running the worker
6. **Review the result** by switching between "Original image" and the deconvolved result in the dropdown menu

### Parameters

* **Channels to deconvolve**: Select which channels to deconvolve; unselected channels pass through unchanged
* **Auto-extract from ND2**: Attempt to read optical parameters (pixel size, NA, refractive index, emission wavelengths) from image metadata. Any parameters not found fall back to the manually entered values.
* **Numerical Aperture (NA)**: Numerical aperture of the objective lens (range: 0.1–1.7, default: 0.75)
* **Refractive Index (ni)**: Immersion medium refractive index (range: 1.0–1.6, default: 1.0)
* **Pixel Size XY (nm)**: Lateral pixel size in nanometers (range: 1–10000, default: 325)
* **Z Step (nm)**: Axial step size between Z-slices in nanometers (range: 1–50000, default: 5000)
* **Emission Wavelength (nm)**: Comma-separated emission wavelengths, one per channel in order. A single value applies to all channels. Defaults to 450, 520, 580, 680 nm if left blank.
* **Iterations**: Number of Richardson-Lucy iterations (range: 1–200, default: 50). Typical range is 20–100.
* **Use GPU**: Enable GPU acceleration via OpenCL. Falls back to CPU automatically if no compatible GPU is available.
* **Tile Size (pixels)**: Maximum tile dimension for processing large images (range: 256–8192, default: 1024). Images exceeding this size in either dimension are processed in tiles.
* **Tile Overlap (pixels)**: Overlap between adjacent tiles to reduce edge artifacts (range: 0–500, default: 100).

### Technical details

The tool wraps two deconwolf command-line programs:

* **`dw_bw`** generates a theoretical PSF using the Born-Wolf diffraction model given the optical parameters. The PSF axial size is set to `2 × num_z_slices − 1` to cover the full extent of the image.
* **`dw`** performs Richardson-Lucy deconvolution of each Z-stack against the corresponding PSF.

Each Z-stack (grouped by XY position, timepoint, and channel) is deconvolved independently. The deconvolved and pass-through frames are then assembled into a multi-dimensional TIFF preserving the original image structure.

**GPU acceleration**: When enabled, deconvolution is attempted on the GPU first. If OpenCL fails (e.g., no compatible GPU is present), the worker automatically falls back to CPU processing, so the tool is safe to use on any machine.

**Tiling**: For images where either dimension exceeds the tile size, deconwolf's built-in tiling mode splits the image into overlapping tiles, deconvolves each independently, and stitches them back together. The overlap parameter controls how much adjacent tiles share to minimize edge artifacts.

**ND2 metadata extraction**: When auto-extraction is enabled, the worker reads pixel size, NA, refractive index, and emission wavelengths from the image's ND2 metadata. Any parameters not found in the metadata fall back to the manually entered values.

For more details on the deconwolf algorithm, see: Wernersson, E. (2024). deconwolf — Large deconvolution with GPU or CPU. *SoftwareX*, 27, 101747.

## Stitch Refinement + Illumination Correction

When you upload a tiled acquisition with **Composite** checked, NimbusImage assembles the individual stage positions into one large image using the stage coordinates recorded by the microscope. Those coordinates are usually close but rarely perfect, so tiled images often show faint seams. Two things cause them: the stage position for each tile can be off by a few pixels, and each raw tile is typically brighter in the middle than at its edges (vignetting), which makes the tile boundaries appear as a grid pattern across the mosaic.

The Stitch Refinement + Illumination Correction tool fixes both problems at once. It goes back to the original raw tiles, measures how neighboring tiles actually overlap, solves for a consistent set of corrected tile positions, and fits a per-channel flat-field model from those same overlaps. The corrected mosaic is uploaded as a **new** image in your dataset — your original image is never modified.

{% hint style="info" %}
This tool needs the original, unstitched tiles, so it only works on datasets that were composited by NimbusImage from a Nikon .nd2 file. It cannot run on an image that was already stitched before it reached NimbusImage (for instance, one stitched in Nikon Elements), because the overlapping raw tiles it measures no longer exist in such a file. For images like that, use [Stitched TIFF Illumination Correction](#stitched-tiff-illumination-correction) instead.
{% endhint %}

### Before you start: upload with "Composite" checked

The tool can only run on a dataset that has NimbusImage's compositing geometry. To set that up:

1. **Use Advanced Import** when you upload your .nd2 file, rather than Quick Import.
2. **Check "Composite"** at the variable-assignment step. This tells NimbusImage to lay the stage positions out side by side into a single large image instead of making them a variable you scroll through. See [Compositing](/documentation/images-datasets-and-collections.md) for more on what this option does.
3. **Keep the original .nd2 file** in the dataset. The tool re-reads the raw tiles from it, and it will stop with an error if that file has been deleted.

The dataset must be composited from a single .nd2 file; composites assembled from a mix of source files are not supported.

### How to use

1. **Add the tool** by clicking "ADD NEW TOOL" in the Toolset panel and choosing "Stitch Refinement + Illumination Correction" from the Image Processing category
2. **Choose a refinement channel** — the channel used to align neighboring tiles. A channel with sharp, high-contrast structure works best; the first channel (usually DAPI) is a good default.
3. **Decide whether to refine positions.** Leave "Refine stitch positions" checked to correct tile placement as well as illumination. Clearing it applies illumination correction only and keeps the original tile positions exactly as they are.
4. **Pick an illumination algorithm.** The recommended option additionally corrects for small brightness differences between individual tiles.
5. **Run the worker.** Processing takes a while for large mosaics, since every raw plane in the file is corrected and rewritten.
6. **Review the result** by selecting the new corrected image from the "Select Image" dropdown just below the dataset navigator.

{% hint style="warning" %}
Existing objects are **not** moved when tile positions are refined. If your dataset already has annotations, their coordinates can shift by tens of pixels relative to the corrected image. It is best to run this tool before you start annotating.
{% endhint %}

### Parameters

* **Refine stitch positions**: When checked (default), applies the corrected tile translations. When cleared, overlaps are still measured for the illumination fit, but the original tile positions are kept.
* **Refinement channel**: The channel used to align neighboring tiles (default: the first channel). Tiles are aligned on a maximum-intensity projection through Z of this channel.
* **NCC threshold**: The minimum normalized cross-correlation score an adjacent tile pair must reach to be trusted (range: 0.5–1.0, default: 0.5). Lower values keep more dim or low-texture pairs but risk false matches; higher values are stricter but can leave parts of the tile grid disconnected.
* **Illumination algorithm**: Choose between "Overlap DCT + tile gains (recommended)", which also fits a small per-tile brightness gain, and "Overlap DCT", which fits only the shared flat-field shape.
* **Output filename**: An optional name for the resulting `.tif`/`.tiff` file. Left blank, the name is derived automatically from the source .nd2.

### Technical details

**Position refinement.** The existing stage geometry is used as a starting point rather than thrown away — the tool never re-derives the stage layout from scratch and never changes the camera's rotation or flip, only the translations. For each adjacent tile pair it builds a maximum-Z reference tile from the refinement channel, then searches around the position the metadata predicts (a coarse ±24 pixel search at 3 pixel steps, followed by a fine ±4 pixel search at 1 pixel steps), scoring each candidate by normalized cross-correlation. Pairs scoring below the NCC threshold are discarded. All the remaining constraints are then solved together, weighted by their NCC scores, with the average coordinate shift held at zero so the mosaic does not drift as a whole. If part of the tile grid ends up disconnected, a conservative global fit is used as a fallback for those tiles.

**Illumination correction.** A smooth flat field is fitted per channel from the aligned raw-tile overlaps: wherever two tiles image the same piece of sample, any brightness difference between them must come from the illumination profile rather than the specimen. The fit uses a low-order (order-5) two-dimensional discrete cosine transform with a robust, outlier-resistant regression, computed at 128×128 and expanded to the full camera dimensions. The recommended algorithm additionally fits a regularized per-position gain, capped to a 1.10-fold range, to absorb small tile-to-tile brightness differences. Every channel is corrected independently, and all time points and Z planes are corrected using the model fitted from the reference Z plane at the first time point.

**Output.** Corrected raw planes are streamed into a lossless pyramidal TIFF — the assembled mosaic is never held in memory, so very large tiled images can be processed. The result is uploaded as a new item in the dataset and appears alongside the original in the "Select Image" dropdown, where it can also be deleted independently if you don't want to keep it.

**Diagnostics.** The job report and the new image's metadata record the predicted and measured offset and NCC score for every tile pair, the number of pairs accepted, the per-pair residuals from the solved fit, the mosaic bounds before and after, and per-channel illumination model diagnostics. A warning appears if the largest residual exceeds 2 pixels, or if the outer edge of the mosaic moves by more than 16 pixels.

### Tuning and troubleshooting

* **Leave the NCC threshold at 0.5** for normal runs. On a well-behaved dataset, essentially every adjacent pair scores far above it.
* **Raise the threshold** only if the report shows low-scoring pairs with inconsistent offsets, a large residual, or you can still see misregistration in the output. Be aware that raising it too far can disconnect part of the tile grid.
* **If the job reports that no pairs met the threshold**, the refinement channel probably lacks texture in the overlap regions. Choose a sharper, higher-contrast channel, or lower the threshold back toward 0.5.

### Limitations

* Only composited Nikon .nd2 datasets are supported, and the composite must come from a single .nd2 file.
* Already-stitched images are rejected before processing, as are datasets whose original .nd2 has been deleted.
* Only tile translations are refined; all tiles must share a single camera orientation.
* Existing object coordinates are not migrated to the corrected image.

## Stitched TIFF Illumination Correction

If your tiled image was already stitched before it reached NimbusImage — for example, a mosaic exported from Nikon Elements or another stitching program — the raw overlapping tiles that [Stitch Refinement + Illumination Correction](#stitch-refinement--illumination-correction) relies on are gone. The Stitched TIFF Illumination Correction tool is the fallback for that situation. It works only from the pixels in the stitched image: it detects the repeating tile grid, fits an illumination model per channel, and uploads a corrected copy as a **new** image in your dataset. Your original image is never modified.

Because it can't see the true overlaps, this tool can't refine tile positions and has to be more careful about what it corrects. Its default "Automatic" mode fits several candidate correction models, tests each of them on Z planes it didn't fit on, and keeps a correction only if it clearly improves the grid pattern without damaging your data. If nothing passes, the channel is left unchanged and you get a warning saying so. This is deliberately conservative — it will sometimes decline to correct a channel rather than risk altering real biology.

{% hint style="info" %}
Whenever the original .nd2 is still in your dataset, prefer Stitch Refinement + Illumination Correction. It has access to the raw tile overlaps and produces a better-constrained correction, and it fixes tile placement at the same time.
{% endhint %}

### How to use

1. **Navigate to a well-focused plane.** The tool fits its models on the XY position, Z plane, and time point you are currently viewing (unless you override them in the parameters), so pick a representative, in-focus plane.
2. **Add the tool** by clicking "ADD NEW TOOL" in the Toolset panel and choosing "Stitched TIFF Illumination Correction" from the Image Processing category.
3. **Check the channels to correct.** Each checked channel gets its own independently fitted model; unchecked channels are copied through untouched.
4. **Leave the algorithm on "Automatic"** unless you have a reason to force a specific model.
5. **Run the worker.** Automatic mode takes longer than a single algorithm because it fits and evaluates several candidates per channel.
6. **Review the result** by selecting the new corrected image from the "Select Image" dropdown just below the dataset navigator. Check the job report for any channels that were left unchanged.

{% hint style="warning" %}
Only the current XY position and time point are corrected (across all Z planes). Other positions and time points are copied to the output unchanged, because their tile grids and brightness offsets can differ. Multi-position or time-lapse datasets need a separate run per position or time point.
{% endhint %}

### Parameters

* **Channels to correct**: The channels for which correction models are fitted and applied. Each channel is corrected independently; only the grid geometry is shared.
* **Algorithm**: "Automatic (recommended)" compares every candidate and picks the best one per channel, including leaving the channel unchanged. You can instead force BaSiC, Folded log-gradient, or Split-half affine (see below).
* **Reference channel mode**: By default the tool scans all channels and uses the one with the clearest tile grid to determine the grid geometry. Switch to manual mode to name the channel yourself.
* **Reference channel**: The channel used for grid detection when the reference mode is manual (default: the first channel).
* **Reference XY / Z / Time** (1-based): The plane used for fitting. Left blank, the tool uses the position you are currently viewing. Choose a well-focused Z plane.
* **BaSiC darkfield**: When forcing the BaSiC algorithm, choose whether to include an additive dark-field term. Automatic mode always evaluates both settings.
* **Per-tile gain correction**: Off by default. An experimental option that also corrects whole-tile brightness differences for the BaSiC and Folded log-gradient models. Because a tile that is genuinely brighter (more cells, more signal) looks the same as a tile with a gain error, this can absorb real biological differences — enable it with care.
* **Punctate channels for spot metric**: Channels containing spot-like signal (for example, RNA FISH). For these channels, Automatic mode additionally checks that detected spot counts are uniform across the tile grid. Leave empty for diffuse signal.
* **Output type**: "Float32 (recommended)" keeps the corrected values exactly. "Preserve source dtype" writes the original integer type instead, and fails if more than a negligible fraction of pixels would be clipped.
* **Validate every corrected plane**: On by default. Re-checks each output plane for damage to object intensities, fine detail, and numeric range, not just the held-out planes used for selection.
* **Minimum / Maximum tile pitch**: The range of tile sizes, in pixels, the grid detector will consider (default: 150–1400 px). Adjust only if your tiles fall outside this range.

### Technical details

**Grid detection.** The tool looks for a repeating brightness pattern in each image axis to find the physical tile pitch and the seam positions between tiles. Each axis must contain at least four full tile periods for detection to work. In automatic reference mode, every channel is analysed and the dominant pitch shared across channels is used, taken from the channel where it is measured most cleanly.

**Candidate algorithms.**

* **BaSiC** resamples complete tile-to-tile intervals onto a common tile coordinate and fits a multiplicative flat-field (and optionally an additive dark-field) using the BaSiCPy implementation, then expands the result across the mosaic using the measured seam positions. Both darkfield settings are tried in Automatic mode.
* **Folded log-gradient** combines the gradients of log intensity across all tiles, integrates the resulting periodic gradient field with a Fourier-domain Poisson solve, and expands the result over the mosaic. It is useful for dense or saturated channels where the background is dominated by signal.
* **Split-half affine** estimates separable multiplicative and additive curves along each axis, keeping each spatial frequency only in proportion to how reproducibly it appears in two independent halves of the tiles. It is the most conservative candidate.
* **Identity** — leaving the channel unchanged — is always a candidate and is the baseline every correction must beat.

**Automatic selection.** Models are fitted on the reference Z plane and scored on held-out Z planes (the first, middle, and last planes, excluding the one used for fitting). Scores measure the residual grid pattern: within-tile brightness falloff, modulation at the tile frequency, position-dependent background, background dynamic range, and tile-to-tile scatter. A correction replaces the unchanged image only if it improves the aggregate score by more than 5% *and* improves every held-out plane; ties go to the simpler model. Candidates are rejected outright if they reorder object intensities (Spearman rank below 0.98), lose fine detail (high-frequency power below 90% of the original), push any real object's intensity to zero, or produce non-finite or newly non-positive pixels. Because selection needs at least one Z plane it didn't fit on, Automatic mode leaves single-Z datasets unchanged; you can still force a specific algorithm on those, accepting that it is fitted and applied on the same plane.

**Output.** The corrected image is uploaded to your dataset with channel names, pixel size, and magnification carried over from the source. Its metadata records the requested and selected algorithm per channel, the full candidate scores and rejection reasons, the reference coordinates and held-out planes, the measured pitch and seam positions, and the worker version.

### Limitations

* Requires a stitched mosaic with a regular, repeating tile pattern; irregular or single-tile images cannot be processed.
* Tile positions are not refined — only illumination is corrected.
* Only the reference XY position and time point are corrected; other positions and time points are passed through unchanged.
* Automatic mode needs at least two Z planes.
