Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Ashlar: stitching and registration

What it does

A slide is scanned as overlapping tiles, once per staining cycle. Ashlar places the tiles into one mosaic and aligns every cycle onto the first, so each cell sits at the same pixel in every channel.

Parameters

How it works

Ashlar works in three phases, using one reference channel, usually the nuclear stain.

Stitching. Neighbouring tiles are found from the recorded stage positions and aligned on their overlap by phase correlation. Phase correlation returns a shift even for an empty overlap, so Ashlar sets an error threshold from 1000 pairs of non-adjacent tiles and discards alignments above it, or shifted further than --maximum-shift. A minimum spanning tree over the remaining pairs fixes one position per tile. Discarding pairs can split the mosaic into pieces; a linear model of corrected against recorded stage positions places them Muhlich et al., 2022.

Registration. Each later cycle is first aligned coarsely on downsampled thumbnails, then tile by tile against the nearest first-cycle tile. Tiles that fail, usually in empty or damaged regions, are placed by the linear model. Every cycle is registered to the first, not to the one before, so errors do not add up.

Mosaic. All cycles are written as one many-channel image.

Three columns of schematic steps: stitching (A1 to A5), registration (B1 to B5) and mosaic generation.

Ashlar’s phases. (a) Stitching within one cycle. (b) Registration across cycles. (c) Mosaic generation. Reproduced from Muhlich et al., 2022, CC BY 4.0.

A poor alignment does not stop the run: rejected tiles are placed by the stage model and the mosaic is written anyway. Check the report every time.

Inputs and outputs. In: all cycles of one sample (OME-TIFF or other Bio-Formats tile files), in cycle_number order, with their BaSiCPy profiles. Out: one pyramidal OME-TIFF, preprocessing/registration/{sample}.ome.tif, with every channel of every cycle; and, with use_qc, the folder {sample}_ashlar_qc/. The OME-TIFF keeps the pixel size but has no marker names; those are added later, in the SpatialData store. See Preprocessing outputs.

When stitching looks wrong

Open the “Stitching and registration” section of the QC report (the slide report on a TMA), then preprocessing/registration/{sample}_ashlar_qc/: the PDF report with per-tile maps, and overlay_cycleN.jpg, cycle 1 in magenta over a later cycle in green.

What you seeLikely causeTry in ashlar_args
Rejected pairs or several pieces inside tissueStage error larger than --maximum-shift, or a weak stainRaise --maximum-shift; check -c is a bright nuclear stain
Pair errors overlap the random-strip errorsThe alignment channel has little structureA different -c; --filter-sigma 1 for noisy images
One cycle with many tiles far from the modelTissue moved or deformed in that cycleRaise --maximum-shift; look at that cycle’s overlay
Kept tiles no better than chanceAlignment locked onto noise in background tilesUsually harmless at the tissue edge; check the overlay
Doubled nuclei everywhere in one cycle’s overlayThe coarse offset or rotation of that cycle failedCheck that cycle’s dashed outline in the Ashlar PDF

To try a change quickly:

  1. Set ashlar_args in your params.yml, repeating what you want to keep: ashlar_args: "--maximum-shift 50 --filter-sigma 1".

  2. Add preprocessing_only: true, so the run stops after stitching.

  3. Run again from the same folder with -resume: illumination correction is reused and only Ashlar runs again. Check the PDF and overlays.

  4. When it looks right, remove preprocessing_only and run again with -resume; the stitched image is reused.

Keep -c on a dna channel in every cycle, or the run stops at startup. Do not pass --qc-output or --report: the pipeline adds them.

Similar tools

These stitch one acquisition; Ashlar also registers the cycles to each other in the same step. Ashlar came with the preprocessing half from nf-core/mcmicro. The pipeline runs its own build, josenimo/ashlar: the only way to get rotation correction between cycles, alignment of each cycle on its own last channel, and the machine-readable quality report.

Read more

Version used:

ModuleToolVersionContainerPaper
ASHLARashlar1.22.1docker.io/josenimo/ashlar:1.22.1Muhlich et al. (2022)
References
  1. Muhlich, J. L., Chen, Y.-A., Yapp, C., Russell, D., Santagata, S., & Sorger, P. K. (2022). Stitching and registering highly multiplexed whole-slide images of tissues and tumors using ASHLAR. Bioinformatics, 38(19), 4613–4621. 10.1093/bioinformatics/btac544
  2. Chalfoun, J., Majurski, M., Blattner, T., Bhadriraju, K., Keyrouz, W., Bajcsy, P., & Brady, M. (2017). MIST: Accurate and Scalable Microscopy Image Stitching Tool with Stage Modeling and Error Minimization. Scientific Reports, 7(1). 10.1038/s41598-017-04567-y
  3. Preibisch, S., Saalfeld, S., & Tomancak, P. (2009). Globally optimal stitching of tiled 3D microscopic image acquisitions. Bioinformatics, 25(11), 1463–1465. 10.1093/bioinformatics/btp184
  4. Hörl, D., Rojas Rusak, F., Preusser, F., Tillberg, P., Randel, N., Chhetri, R. K., Cardona, A., Keller, P. J., Harz, H., Leonhardt, H., Treier, M., & Preibisch, S. (2019). BigStitcher: reconstructing high-resolution image datasets of cleared and expanded samples. Nature Methods, 16(9), 870–874. 10.1038/s41592-019-0501-0