StrataQuest Home › StrataQuest Glossary › Distance Maps
Spatial Tool

Distance Maps

Measuring spatial relationships between cells

View
Definition
A distance map gives each pixel a value equal to its distance from a structure, for example the distance from a point in the stroma to the nearest epithelium. Distance Map Outside (global) and Distance Map Outside (local) give every background pixel its distance to the closest foreground pixel. Distance Map – inside (global) gives every foreground pixel its distance to the closest background pixel, its depth inside the event.
Supporting
User Interface - How to use ROI, ANN and EA tool
Video · Supporting
Pre processing - Advanced - Phenotype Interaction
Video · Supporting
User Interface - Image Viewer + Toolbar
Video · Supporting
H&EDSPTCH
Video · Supporting
User Interface - Object Inspector
Video · Supporting
TQ to SQ workflow
Video · Supporting
Background pixels get numbers
Outside engines measure from areas of interest
Three engines, not modes
Outside global, Outside local, inside global
Feeds proximity and measurement
Proximity Areas and per-cell distance readouts
Accurate or Fast
Euclidean distance, or a quicker approximation

How It Works

Take a mask of epithelium: white where epithelium is, black everywhere else. A Distance Map Outside writes into each black pixel how far it is to the nearest white pixel, so the epithelium is the zero reference and the numbers grow as you walk into the stroma. The three engines share that idea and differ in direction, storage and reach. All three sit in a layerLoading...'s Pre-Processing section, under Add Operations (advanced).

Distance Map Outside (global). Seeds is an 8-bit maskLoading... of the areas of interest. Distances are stored as 32-bit values and displayed with the Parula colormap, blue for short distances and red for long ones, so read exact values with the Pixel Inspector. The engine works across fields of view (FOVs), one FOV per iteration, up to Maximum iterations (default 7).

Distance Map Outside (local). It measures in the same direction but stores an 8-bit grayscale map, which the Engines Reference calls less accurate than the global variant. Distances above 255 are approximated with Max scaling. The reference warns that it is not suited to areas of interest one FOV apart.

Distance Map – inside (global). Events is a coded image, and each foreground pixel gets its distance to the closest background pixel: the inner distance from the event's contour. Values are highest deep inside large structures. It works on stitched, global objects and handles macrostructures spanning several FOVs, such as the glomeruli in the reference's kidney example.

Both global engines also take a Mask, and distances are computed only along paths inside its white areas. A path that must stay inside the white area cannot cut across what the mask leaves out, so you can measure distance within tissue instead of straight across an empty gap.

Simplified

The result can be read as a landscape. The structures you start from sit at ground level, and the ground rises the farther you walk from them. The two outside engines map the surrounding background; the inside engine maps how deep each point lies within a structure.

Science Behind It

The distance transform. In image processing generally, a distance map is called a distance transform, and textbooks such as Gonzalez and Woods describe three common metrics. Euclidean distance is the straight line, with circular contours of equal distance; city-block distance follows the grid axes and draws diamonds; chessboard distance lets a diagonal step cost one and draws squares. StrataQuest's Accurate mode uses the Euclidean distance. The reference says only that Fast is an approximation; approximations built from small neighbor steps generally draw polygons instead of circles, which fits the hexagonal patterns it warns about.

Every buffer at once. Cut a Euclidean distance map at a value d and you get every pixel within d of the structure, the same set a dilationLoading... by a disk of radius d would give. One map holds every such buffer, so you can try a new distance without recomputing anything. Proximity AreasLoading... makes exactly these cuts, at a list of distances you give it.

Depth and shape. Inside a convex object the inner distance peaks at the center, and the peak equals the radius of the largest circle that fits inside. Where two objects touch, a saddle of lower values marks the neck between them, which is why the textbook watershedLoading... recipe floods an inverted inner distance map to split touching objects. StrataQuest's own Watershed (global) example uses a distance map computed with the membranes as reference as its Topographic Map, with the fat cell bodies as seeds.

Distance to a structure, not to a cell. A distance map measures from pixels to the nearest foreground structure. Cell-to-cell distances between two phenotypes, such as each tumor cell's nearest CD8+ T cell, come from Phenotype InteractionsLoading... and its Minimum Range, which the reference doesn't describe as using a distance map.

Simplified

Inside a structure, the distance to its edge describes shape: highest at the center, lower near the border and at narrow necks. Outside, it describes proximity. A band such as "within 50 µm of the epithelium" is one cut through the same map, and a different band is another cut through it.

Parameters & Settings

ParameterEngineDescription
SeedsOutside (global), Outside (local)The areas of interest the distances are computed from: an 8-bit mask for the global engine, a grayscale image for the local one.
Eventsinside (global)The coded image of the events whose inner distances are computed.
MaskOutside (global), inside (global)Distances are computed only along paths inside the white areas.
Maximum distance / Max distanceOutside (global) / inside (global)The upper limit for the distances.
Maximum iterations / Max iterationsOutside (global) / inside (global)The maximum number of iterations allowed to find all distance values (default 7). For the Outside engine, one field of view per iteration.
ModeOutside (global), inside (global)Accurate uses the Euclidean distance: slower, more accurate. Fast uses an approximation: quicker, but tends to produce hexagonal patterns.
Max scalingOutside (local)Scaling factor for distances above 255, the 8-bit maximum. The default, 255, is 1:1; at 512 the relation is 1:2, so a pixel value of 10 means a distance of 20.

Pick the engine by direction first, then by reach: the global engines follow structures across fields of view and keep 32-bit values. Use Accurate when the distances will be measured or gated. Because the global maps are shown through a colormap, check a value with the Pixel Inspector rather than by its color. Derived MeasurementsLoading... notes that event distances are usually in pixels and converts them with the pixel size.

Source: StrataQuest 8.1 Engines Reference, ch. 13 (p. 404), ch. 14–16 (pp. 405–416), ch. 36 (pp. 500–503), ch. 41 (p. 538), ch. 43 (pp. 547–549).

Simplified

Choose an outside engine to measure into the background around your structures, or the inside engine to measure depth within them. Choose Accurate when the distances will be measured or gated, and set a maximum distance that covers the range you care about.

Practical Example

Suppose you want to see how CD8+ T cells are distributed with distance from the epithelium in a colorectal cancer section.

  1. Detect the epithelial area and make it a mask, as the Engines Reference does in its colorectal cancer example.
  2. Add Distance Map Outside (global) with that mask as Seeds and Mode set to Accurate. Every stromal pixel now holds its distance from the nearest epithelium, and the epithelium reads zero.
  3. In the layer that holds the CD8+ T cells, add Standard MeasurementsLoading... with the distance map as Shades and select Minimum. Each cell now carries the distance of its closest pixel to the epithelium.
  4. Plot that measurement on a histogramLoading... and gateLoading... bands such as 0, 0–20, 20–50 and 50–100 µm. For fixed bands, Proximity AreasLoading... with Assign classes to objectsLoading... gives each cell its band number instead.

Bands differ in area, so compare densities rather than raw counts. In immuno-oncology generally, T cells concentrated inside and at the epithelium read as an inflamed pattern, cells held in the surrounding stroma as an excluded pattern, and few cells anywhere as a desert.

Simplified

Map every point's distance from the epithelium, give each CD8+ T cell its distance, then count the cells in bands. The profile shows whether T cells enter the epithelium, gather around it, or stay away.

Connected Terms

Share This Term
Term Connections