Interactive lab · digital pathology · data

Five stations for one slideA digital pathology data pipeline, run on the page

A scanned pathology slide is one very large picture. A data pipeline for slides does the jobs any pipeline does (move files, check them, pass them on), but most of its checks look at pixels. This page follows one slide through five stations and runs a small version of each station's job right here, on a slide drawn by code.

The slide is made up and much smaller than a real one, and each station uses the simplest version of a real method. A note under each station says where it simplifies. Two other pages on this site sit on either side of this one: Slide to Screen follows tissue from the specimen to the scanner, and One Script to a Pipeline grows a general data pipeline stage by stage. This one starts at the scanned file.

Each station has controls. Move them and watch what changes, there and in the stations after it.

01The file

The scanner writes the slide out as one file, usually holding the full-resolution image plus smaller copies of it for zooming out [23]. These files are big:

1–2 GBa typical slide file, per Databricks [1]
100,000 pxon a side, about as large as images get at one scanning facility [2]
0.25 µmper pixel at 40x on common scanners; 0.5 µm at 20x [3]

Each scanner maker also has its own file layout: Aperio's SVS, Hamamatsu's NDPI, Philips' TIFF, and others. A pipeline that takes slides from more than one kind of scanner either reads all of them or converts them to one format first. DICOM, the medical imaging standard, has a format for whole-slide images, and open-source converters such as wsidicomizer turn vendor files into it [4]. The Imaging Data Commons project has been testing that converter as a replacement for the PixelMed tools it converts with now, and in 2026 reported gaps still to fix before switching [5].

Moving and converting files of this size is ordinary pipeline work, the kind the general pipeline page covers. The stations after this one are where slides differ.

02Find the tissue

Most of a slide is empty glass. Cutting the glass into tiles would waste storage and computing, so the first pixel job is a tissue mask. A common recipe, used by libraries such as histolab and TIAToolbox, turns a small overview of the slide to grey and splits it with Otsu's method [6] [7]: it picks the grey level that best splits the picture into a light group and a dark group. Anything darker counts as tissue. Analysis usually works on small square tiles cut from the slide rather than on the whole picture at once (more at station 5), so the mask decides which tiles are worth cutting. The grid on the drawn slide stands in for those tiles; ones with enough tissue go on to the next station.

Otsu's pick
Tiles kept
Kept tiles with pen ink in them
Tissue tiles dropped
Show
0 darkgrey level255 light
Watch the pen mark. Ink is dark, so a grey cutoff calls it tissue. This is a known weak spot: one study found that Otsu thresholding on its own removed none of the artefacts in its 30 test slides [8]. Pushing the cutoff low enough to drop the ink drops the tissue with it. The next station looks for ink on purpose.

Real masks are usually made on a small overview image and then cleaned up: histolab's, for example, grows the mask outward and removes small holes and specks [6]. This one only applies the cutoff, so lone specks of dust show up in the mask view, though they rarely fill enough of a tile to keep it.

03Check the pixels

A scan can be out of focus in places. Tissue can fold over on itself when it is laid on the glass, and slides often carry pen marks. HistoQC, an open-source quality-control tool, has separate parts for these: a trained classifier that can find pen markings, one that finds tissue and folded tissue by how light or dark it is, and one for blur [9] [10]. This station runs three simple checks of the same kinds on every tile station 2 kept, and crosses out the ones that fail.

Jump to:
Tiles in from station 2
Crossed out for blur
Crossed out for ink
Crossed out for a fold
Passed

How each check works

Blur. The sharpness score is the variance of the Laplacian. The Laplacian responds to sudden changes in brightness, like the edge of a nucleus. A sharp tile has many of them and scores high; a blurred one scores low [11]. Pipelines set the cutoff for their own scanner, magnification, and tile size. One study, for example, drew its line between sharp and blurred tiles at a score of 500 [11]. The scores here are on this page's own scale. Slide the cutoff up and the crosses spread from the blurred patch into sharp tissue with few nuclei, which has few edges too.

Ink. A pixel counts as ink if it is much greener than it is red, a colour neither stain on this drawn slide makes. That rule is this page's own; real tools use colour rules or trained classifiers.

Fold. Where tissue folds over, light passes through two layers, and the tile comes out darker. A tile is flagged when its tissue pixels average darker than a cutoff set between one layer and two on this slide.

The drawn slide has one blurred patch, one fold, and one pen mark, each put there on purpose so the checks have something to find. Real artefacts are messier, and tools like HistoQC look at each slide at several scales. Checks that look at the whole tile, as these do, also catch good tissue at the edge of a bad patch.

04Even out the colour

Stain colour varies. Labs stain a little differently, and scanners see colour differently, so the same kind of tissue comes out a different pink from one place to the next. Models trained on one lab's slides often do worse on another lab's [12] [13]. One study, across 9 labs and 4 organs, compared two fixes: varying the colours while training (augmentation) and shifting new slides toward the training colours (normalization) [12]. This station tries the second.

The model here is much simpler than a real one: a nucleus finder that marks any pixel darker than a fixed grey level as nucleus, then counts the blobs. Its cutoff was set on lab A's slides. The tile is drawn from known amounts of two stains, so the true count is known.

As scanned
Into the finder
What it found
Nuclei in the tile
Found
Missed
Blobs that are not one nucleus
Where the slide came from

Reinhard's method converts the picture to Lab colour (one lightness axis and two colour axes), then shifts and stretches each axis so its average and spread match a reference image from the lab the model knows [14] [15]. Other methods, such as Macenko's, first separate the two stains in optical density space [22], and papers on stain normalization compare several of them side by side [16]. Reinhard's has known weak spots: it struggles when the amount of empty background changes a lot between images [17]. The tile here is all tissue, which suits it: on these tiles it brings the count back almost every time, close to its best case.

The labs and the scanner are made up, and the stain colours are chosen to look roughly like H&E. Colour is drawn with the Beer–Lambert idea that colour deconvolution rests on: each stain absorbs light in proportion to how much is there [18]. Real models learn far more than a grey cutoff, and their failures on new colours are subtler than this one's.

05Cut the tiles

What leaves the pipeline is a set of tiles: small squares, often 224 or 512 pixels on a side, cut from the full-resolution image [19] [20]. The drawn slide stands for about 24 by 14 mm of glass, so each of its overview tiles covers a square 0.6 mm on a side. Scaled up to a real scan, the tiles that passed station 3 become:

Scan
Tile size

Each of those tiles is a read from storage, often more than once while a model trains. A study of analysis runs over whole-slide images found that the slow part is often reading the data rather than computing on it. Reading tiles in parallel with an I/O library roughly doubled the I/O speed on CPUs in its tests [21].

The count assumes the tissue fills each passed tile and ignores the overlap some pipelines leave between tiles. Real slides carry more or less tissue than this one, so their counts differ. Change the cutoff at station 2 or the checks at station 3 and the count here moves with them.

+Already out there

This page runs toy versions of each stage to show what it is for. The tools below are open-source projects that cover these stages for real slides.

§Sources

  1. Databricks, "Automating the Analysis of Digital Pathology Images with Deep Learning" (webinar page): image files of about 1–2 GB per slide.
  2. UBC Centre for Heart Lung Innovation, digital slide scanning: images up to 100,000 by 100,000 pixels.
  3. Vanderbilt Digital Histology Shared Resource, brightfield whole slide imaging: about 0.5 µm per pixel at 20x and 0.25 at 40x on common scanners; other models differ.
  4. wsidicomizer on GitHub: formats it reads and converts.
  5. NA-MIC Project Week 44 (2026), wsidicomizer-based conversion for Imaging Data Commons.
  6. histolab documentation, masks: grey conversion, Otsu threshold, then dilation and removal of small holes and objects.
  7. TIAToolbox, "Masking tissue region in whole slide images".
  8. "H&E Otsu thresholding" preprint (arXiv 2308.13304): Otsu alone removed none of the artefacts in 30 slides.
  9. Janowczyk et al., "HistoQC: An Open-Source Quality Control Tool for Digital Pathology Slides", JCO Clinical Cancer Informatics (2019).
  10. A later review listing HistoQC's modules: classification (used for pen), light and dark (tissue and folds), and blur.
  11. Xiang, Liu and Rantalainen, "Deep Blur Multi-Model (DeepBlurMM)" (arXiv 2405.09298): variance of the Laplacian as a tile blur score, with a line at 500.
  12. Tellez et al., "Quantifying the effects of data augmentation and stain color normalization in convolutional neural networks for computational pathology" (2019): 4 organs, 9 labs.
  13. Stacke et al., "A Closer Look at Domain Shift for Deep Learning in Histopathology": CAMELYON17 slides from three scanners and five medical centres.
  14. StainTools documentation, normalization: Reinhard's method, after Reinhard et al., "Color transfer between images" (2001).
  15. TIAToolbox stain normalization source: Reinhard's method matches the mean and standard deviation of each Lab channel to a target.
  16. StainGAN paper (arXiv 1804.01601): compares Reinhard's, Macenko's and other methods.
  17. StainNet paper (arXiv 2012.12535): Reinhard's method does poorly when the amount of blank background varies.
  18. Landini, Colour Deconvolution 2: the Beer–Lambert basis of colour deconvolution, after Ruifrok and Johnston (2001).
  19. compay-syntax on PyPI: quick start with 224-pixel tiles.
  20. TilGenPro on GitHub: 512 by 512 pixel tiles.
  21. "High-performance Data Management for Whole Slide Image Analysis in Digital Pathology" (arXiv 2308.05784): I/O as the bottleneck; about a two-fold I/O speed-up on CPUs with ADIOS2.
  22. Macenko et al., "A Method for Normalizing Histology Slides for Quantitative Analysis" (2009).
  23. OpenSlide Python documentation: slide levels, from level 0 at full resolution down to lower-resolution copies.