Skip to main content

How Ultrasound Works and How to Read an Ultrasound Image

What is ultrasound imaging?​

Ultrasound imaging (sonography; the picture is called a sonogram) is a way of looking inside the body with sound. A handheld probe sends short pulses of sound, far above the range of human hearing, into the body and listens for the echoes. A computer turns the timing and strength of every echo into a moving greyscale picture.

A simulated B-mode ultrasound image from a curved probe, drawn as a fan-shaped polar heatmap on a dark navy background: bright skin and fascia lines at the top, a blood vessel crossing the image coloured red on the left and blue on the right by colour Doppler, a black fluid-filled cyst with a brighter band below it, and a bright stone casting a dark shadow down to the bottom of the image, with a depth scale in centimetres down the right edge

A simulated scan of a tissue phantom, not a patient: a vessel in colour Doppler, a black fluid-filled cyst and a bright stone casting a shadow. Try the interactive version.

This guide explains how ultrasound pictures are made and what their shades and colours mean. It is educational, not medical advice. Scans are interpreted by a sonographer or a doctor, with the patient's history, and only they can say what a particular image shows.

Key takeaways
  • The probe times echoes: at about 1,540 m/s in soft tissue, every centimetre of depth adds about 13 microseconds to the round trip.
  • On a B-mode image, black is no echo (usually fluid), grey is soft tissue and bright white is a strong reflector such as bone, a stone or gas.
  • Higher frequencies give sharper pictures but can't see as deep, so the probe is chosen for the depth of the organ.
  • The top of the image is the skin; the fan shape comes from scan lines spreading out from a curved or small probe.
  • Colour Doppler colours flow by direction relative to the probe, usually red towards and blue away, not artery and vein.

How does ultrasound work?​

The probe, or transducer, holds a row of small piezoelectric crystal elements: materials that vibrate when a voltage is applied and produce a voltage when they are squeezed. A short electrical pulse makes them ring for a few cycles and send a burst of sound into the body. Then the probe falls silent and listens. Each returning echo presses on the same crystals, which turn it back into a tiny electrical signal.

Echoes come from boundaries between materials that carry sound differently (they have a different acoustic impedance). Between two soft tissues, such as fat and liver, less than 1% of the sound energy reflects, so most of it carries on and deeper boundaries also send echoes back. At a boundary between tissue and air, more than 99.9% reflects. That's why the sonographer spreads gel on the skin: a thin layer of air between probe and skin would stop almost all the sound going in.

How the scanner works out depth​

The scanner can't see where an echo came from, only when it arrived. It assumes sound travels at 1,540 metres per second, an average for soft tissue, and halves the round trip:

depth=1540 m/s×echo time2\text{depth} = \frac{1540\ \text{m/s} \times \text{echo time}}{2}
DepthEcho arrives after
1 cm13 µs (microseconds)
5 cm65 µs
10 cm130 µs
20 cm260 µs

Each pulse gives one scan line: a column of echo strengths at every depth. The probe fires its elements in turn to make the next line beside it, and a few hundred lines make one picture, or frame. The deeper the image, the longer the probe waits for the last echo before the next pulse. With one pulse per line, 256 lines to 15 cm take about 50 ms, so about 20 frames a second; at 5 cm the same frame takes about 17 ms. Real scanners change this, for example by forming several lines from one pulse, or by firing extra pulses for each line to sharpen the focus at more than one depth.

The strength of each echo sets the brightness of a dot on the screen. This is B-mode, for brightness mode, the standard greyscale ultrasound picture. Sonar and industrial ultrasonic testing use the same pulse-echo timing, in water and in steel: see the sonar guide and the non-destructive testing guide.

Frequency, depth and resolution​

Medical imaging usually uses frequencies between about 2 and 15 MHz, millions of vibrations a second. Frequency sets two things that pull in opposite directions:

  • Resolution. A higher frequency has a shorter wavelength (1,540 m/s divided by the frequency), so the pulse is shorter and the beam can be focused more tightly. Fine detail shows.
  • Penetration. Tissue absorbs and scatters sound, and it does so faster at higher frequencies. A typical figure for soft tissue is about 0.5 dB per centimetre for every megahertz, and the echo pays it twice, on the way in and on the way out.
FrequencyWavelength in soft tissueEcho loss from 10 cm deep (at 0.5 dB/cm/MHz)Used for
2.5 MHz0.62 mm25 dBDeep abdomen and pelvis, larger patients
3.5 MHz0.44 mm35 dBGeneral abdominal and pregnancy scans
5 MHz0.31 mm50 dBShallower organs, children
7.5 MHz0.21 mm75 dBBlood vessels, muscles, breast
10 to 15 MHz0.15 to 0.10 mm100 to 150 dBTendons, thyroid, structures just under the skin

Every 10 dB is a factor of ten in power, so an echo that has lost 75 dB comes back with less than a ten-millionth of the power it would have had from close to the probe. At high frequencies, deep echoes sink below the electronic noise of the receiver, and no amount of gain brings them back. In the interactive scan, switch from 3.5 MHz to 7.5 MHz at 20 cm depth and watch the bottom of the image go dark.

Ultrasound probes and why the image is a fan​

The shape of the image comes from the shape of the probe.

Three ultrasound probes and their image shapes. A linear probe with a flat face makes a rectangular image of parallel scan lines; it uses high frequencies for fine detail near the surface, such as vessels, muscles, tendons and the thyroid. A curved, curvilinear probe with a convex face makes a wide fan whose top follows the curve of the probe; it uses lower frequencies to see deep into the abdomen and pelvis, including pregnancy scans. A phased array probe has a small face and steers its beam electronically, making a fan that starts from a point; it fits between the ribs for heart scans

ProbeFaceImage shapeFrequencyTypical scans
LinearFlatRectangle, as wide as the probeHigh (often 5 to 10 MHz or more)Vessels, muscles and tendons, thyroid, breast, guiding needles
Curved (curvilinear)ConvexWide fan with a curved topLow (often 1 to 5 MHz)Abdomen, pelvis, pregnancy
Phased arraySmall, flatFan from a pointLowHeart, between the ribs
Endocavity (for example transvaginal)Small, tightly curvedNarrow fanHighEarly pregnancy, the pelvis, from inside the body

On a curved probe each element points in a slightly different direction, so the scan lines spread out like the spokes of a wheel. A phased array fires all its elements with tiny time delays that steer the beam to one angle after another, so its lines all start from the small face. Either way the image is narrow at the top and wide at depth: close to the probe you see a small patch of tissue, deeper down a much wider one, so a scan through a narrow gap, such as between two ribs, can still show a whole heart.

Endocavity probes can use higher frequencies because they sit close to the organ, so the sound has less tissue to cross.

B-mode: what bright, grey and black mean​

The shade of each part of a B-mode image describes how strongly it sends echoes back, its echogenicity. Sonographers describe it with four words, always compared with the tissue around it:

TermLooksWhat it meansExamples
HyperechoicBright, whiteStrong echoesBone surfaces, stones, gas, fibrous sheets such as fascia
IsoechoicThe same as its neighboursSimilar echoesA structure that blends into the tissue around it
HypoechoicDarker greyWeaker echoesFat under the skin, muscle
AnechoicBlackNo echoesSimple fluid: urine in the bladder, bile, blood in vessels, amniotic fluid, a simple cyst

The words are relative. Turning the gain up makes everything brighter, so a reader compares one structure with another in the same picture rather than judging a shade on its own.

The fine, grainy texture of solid organs is speckle. It comes from echoes off many scatterers far smaller than the pulse, which add up or cancel out depending on their exact spacing. Speckle doesn't show individual cells or fibres; it's an interference pattern, and it changes when the probe moves.

Acoustic shadowing and posterior enhancement​

What lies below a structure says as much about it as the structure itself.

  • Acoustic shadow. A strong reflector or absorber, such as bone, a gallstone or a kidney stone, stops most of the sound. Its front surface shows as a bright line, and below it is a dark band running straight down the scan lines, because almost no sound reaches the tissue behind. Gas reflects too, but it leaves a greyer, "dirty" shadow with streaks in it.
  • Posterior enhancement. Fluid absorbs very little sound. The scanner adds gain with depth on the assumption that sound has crossed ordinary tissue (see below), so the tissue behind a fluid-filled structure gets more sound than expected and looks brighter. A bright band below a black area is a clue that the black area really is fluid.

Both are artefacts, in that they show something that isn't really there (a dark or bright band of tissue), but they're among the most useful clues in the picture.

Gain, TGC and depth: the controls that change the picture​

The same tissue can look very different depending on three controls.

  • Gain amplifies every echo by the same amount, like the brightness on a television. Too much and fluid fills with grey noise and stops looking black; too little and weak echoes from tissue vanish.
  • Time gain compensation (TGC) adds more gain to later echoes, which come from deeper, to make up for the loss with depth. It's usually a set of sliders, one for each band of depth. Set well, the same tissue looks the same brightness from the top of the image to the bottom.
  • Depth sets how far down the image reaches. Too shallow and deeper structures are cut off; too deep and the area of interest is small, and the frame rate drops.

Scanners also have a frequency control (often labelled resolution, general and penetration) and a focus control, shown as a small marker beside the depth scale, which sets the depth where the beam is narrowest. All of these change the picture, not the patient, which is one reason a single print can't be compared shade for shade with another taken on a different day or machine.

How to read an ultrasound image, step by step​

A labelled drawing of a fan-shaped B-mode ultrasound image from a curved probe, with numbered callouts. The probe sits at the top, so the top of the image is the skin, depth increases downwards and a depth scale in centimetres runs down the right edge. An orientation marker dot at the top left matches the marked side of the probe. 1, the bright skin line. 2, darker hypoechoic fat. 3, muscle between bright fascia lines. 4, a vessel shown with colour Doppler, red on the left where the flow comes towards the probe and blue on the right where the same flow goes away, with a black gap in the middle where the flow is at right angles to the beam. 5, mid-grey speckled organ tissue. 6, a black anechoic cyst. 7, the brighter band of posterior enhancement below it. 8, the bright front surface of a stone. 9, the dark acoustic shadow below the stone. 10, a bright curved boundary between tissues

This is a general way to look at any ultrasound picture. It helps you understand what is on the screen or the print; it doesn't replace the report.

  1. Read the labels. The screen or print usually shows the date, the probe and preset, the frequency, the depth scale and often a body marker or typed note from the sonographer, such as "RT KIDNEY LONG" (right kidney, lengthways).
  2. Find the top. The top of the image is the skin, right under the probe. Everything below is deeper, and the scale at the side gives the depth in centimetres. A fan-shaped image comes from a curved or phased array probe, a rectangle from a linear probe.
  3. Find the orientation marker. A dot or logo at the top of the image matches a ridge or light on one side of the probe. In most general scans the probe marker points to the patient's head in a lengthways view, which puts the head on the left of the screen, or to the patient's right in a crossways view, which puts their right on the left of the screen, as on a CT scan viewed from the feet. Heart scans usually put the marker on the right of the screen instead.
  4. Work down through the layers. Near the top you'll usually see a bright skin line, then darker fat and muscle separated by bright lines of connective tissue, then the organ being scanned.
  5. Read the shades. Black is no echo: usually fluid, sometimes shadow. Grey is tissue. Bright white is a strong reflector.
  6. Look below anything very bright or very black. A dark band straight down the scan lines below something bright is a shadow; a brighter band below something black suggests fluid.
  7. Check any colour against the colour bar. The bar beside the colour box shows which colour means towards the probe; on most settings red is towards and blue is away.
  8. Read the measurements. Small crosses or plus signs are calipers, and the numbers beside them (for example "D1 2.3 cm") are distances the sonographer measured between them.
  9. Remember that a still image is one thin slice. The sonographer sweeps the probe through the organ and judges it from many views, and the report is written from all of them.

Reading a pregnancy scan picture​

Pregnancy scans are the ultrasound pictures most people take home, and the same rules apply. Amniotic fluid around the baby is black, because it's fluid. The skull, spine and limb bones are bright, often with shadows below them. Soft tissues are grey. In early pregnancy the pregnancy sac shows as a black, fluid-filled space.

The numbers on a pregnancy print are measurements used to estimate the stage of pregnancy and the baby's growth. Before about 14 weeks the main one is the crown–rump length (CRL), from the top of the head to the bottom. From 14 weeks the usual set is the biparietal diameter (BPD) and head circumference (HC), the abdominal circumference (AC) and the femur length (FL), the thigh bone. The scanner may also print an estimated age (GA) and due date (EDD) worked out from them.

An image of a baby can be hard to read because it's a slice: a cross-section through the head looks like an oval, and a limb cut across looks like a dot. If anything on a scan worries you, ask the person who did it or your midwife or doctor; in many clinics the person doing the scan isn't the one who writes the report, so they may not be able to discuss it on the spot.

Doppler ultrasound: colour, power and spectral​

Doppler ultrasound measures movement, almost always of blood. When sound reflects off moving blood cells, its frequency shifts: up if they're moving towards the probe, down if away. The shift is:

fD=2 f0 vcos⁡θcf_D = \frac{2\, f_0\, v \cos\theta}{c}

where f0f_0 is the transmitted frequency, vv the blood speed, θ\theta the angle between the beam and the flow, and cc the speed of sound. For a 5 MHz beam, blood at 50 cm/s and an angle of 60°, fD=2×5,000,000×0.5×0.5/1540≈1,600f_D = 2 \times 5{,}000{,}000 \times 0.5 \times 0.5 / 1540 \approx 1{,}600 Hz. That's within human hearing, which is why Doppler machines can play the flow as a whooshing sound.

The cos⁡θ\cos\theta matters. Flow straight along the beam gives the full shift, and flow at right angles to it gives none at all, however fast it is.

Colour Doppler​

Colour Doppler measures the shift in every cell of a box drawn over the greyscale image and colours it by direction and speed. The colour is direction relative to the probe, not artery or vein. By the usual setting, red is towards the probe and blue away, with brighter shades for faster flow; the colour bar on the screen shows which way round it's set, and the sonographer can invert it.

A vessel running across the image can be red at one end and blue at the other, because the flow turns from towards the probe to away from it as the scan lines fan out. Where the flow is exactly at right angles to the beam there's no colour, which can look like a gap in the vessel. The interactive scan below shows this in one straight vessel.

Power Doppler shows how much moving blood there is, but not its direction, in a single colour. It's more sensitive to slow flow in small vessels.

Spectral Doppler​

Spectral (pulsed-wave) Doppler measures flow at one spot, a small sample gate placed in a vessel, and draws the speeds there as a graph against time. The waveform's shape shows how the flow changes with each heartbeat. To turn the shift into a speed, the sonographer lines up an angle marker with the vessel, and the reading is most reliable at angles of 60° or less: a 5° error in the angle gives about a 15% speed error at 60°, but about 49% at 80°. Continuous-wave Doppler transmits and listens all the time, so it measures very high speeds, such as jets through a narrowed heart valve, but can't tell at what depth they are.

Pulsed Doppler can't measure speeds above a limit set by how often it pulses (the Nyquist limit, half the pulse repetition frequency). Faster flow wraps round to the other colour or to the other side of the graph. This is aliasing, and it can look like flow reversing when it isn't.

Ultrasound modes: B-mode, M-mode, Doppler and 3D​

ModeWhat it showsUsed for
A-modeEcho strength along one line, as a traceRare in medicine now; eye measurements. Still standard in industrial testing
B-modeA 2D greyscale pictureAlmost every scan
M-modeOne scan line drawn over time, as a scrolling stripHeart valves and walls; measuring an early pregnancy's heart rate
Colour and power DopplerFlow on top of the B-mode pictureFinding vessels and checking flow
Spectral DopplerSpeed against time at one spotMeasuring flow speed and its pattern
3D and 4DA volume built from many slices, and a volume shown movingSome pregnancy, gynaecology and heart scans

M-mode (motion mode) picks one scan line through a moving structure and plots its echoes left to right over time. Things that move, such as a heart valve, draw wavy lines; still tissue draws straight ones. Because it samples one line many times a second, it shows quick movements that a B-mode frame would blur.

Common ultrasound artefacts​

An artefact is something on the image that doesn't match the anatomy. Most come from the scanner's three assumptions: sound travels in a straight line, at 1,540 m/s, and each echo comes from the first thing it met.

ArtefactWhat you seeWhy it happens
ReverberationEvenly spaced bright lines repeating into the depthSound bounces back and forth between two strong reflectors, such as the probe face and a needle, and each bounce returns later, so it's drawn deeper
Comet tail and ring-downA short, tapering bright tail below a small reflector or gasReverberation within something very small, or ringing in gas bubbles
Mirror imageA copy of a structure on the far side of a strong curved reflector, such as the diaphragmSound reflects off the surface, then off the structure, then back; the scanner assumes a straight path and draws a ghost
Side lobeFaint grey echoes inside fluid that should be black, such as false "debris" in the bladderSome energy leaves the probe off to the side; a strong reflector there sends echoes that are drawn as if they came from the main beam
RefractionA structure doubled or shifted sideways, or thin dark shadows at the edges of round fluid-filled structuresSound bends as it crosses a boundary at an angle, so the scanner draws echoes in the wrong place
Speed errorStructures behind fat placed slightly too deepSound is slower in fat than 1,540 m/s, so echoes arrive late
Shadow and enhancementDark or bright bands below a structureToo much or too little sound lost on the way down (see above)

Sonographers tell artefacts from anatomy by moving the probe: a real structure stays in place when seen from another angle, while most artefacts move or vanish.

Ultrasound vs MRI vs CT vs X-ray​

UltrasoundMRICTX-ray
How it worksEchoes of high-frequency soundStrong magnetic field and radio wavesX-rays from many angles, made into slicesX-rays through the body onto a detector
Ionising radiationNoNoYesYes, a small dose
Real timeYes, moving imagesNo (some fast sequences)NoNo (except fluoroscopy)
WhereBedside, clinic, handheldLarge scannerLarge scannerX-ray room or portable
Good atFluid-filled structures, soft tissue near the surface, moving organs, blood flow, pregnancySoft-tissue detail: brain, spine, jointsFast, whole-body: injuries, bleeding, lungs, boneBones, chest
Struggles withSeeing through bone and gas; large patients; depends on the operator's skillMetal implants, claustrophobia, movement, timeRadiation dose; soft-tissue contrast below MRISoft tissue

Ultrasound is often the first test for a question about soft tissue or fluid, because it's quick, widely available and less expensive than most other imaging. MRI or CT follow when the area is hidden behind bone or gas, or more detail is needed. The MRI guide explains how MRI images are made and read, including MRI vs CT.

Is ultrasound safe?​

Diagnostic ultrasound doesn't use ionising radiation, and standard diagnostic scans have no known harmful effects in people. Sound does carry energy, though: it can warm tissue slightly, and at high pressures it can make tiny gas bubbles form (cavitation). Scanners show two numbers on screen to track this, the thermal index (TI) and the mechanical index (MI), and sonographers follow the principle of using as little exposure as reasonably achievable (ALARA).

Professional bodies and regulators recommend scans only for a medical reason. In the United States the FDA discourages ultrasound done only to make keepsake pictures or videos of a baby; pictures taken during a medically needed scan are fine to keep. The American Institute of Ultrasound in Medicine advises caution with spectral Doppler in the first trimester, because it delivers more energy, and recommends M-mode or B-mode to record an embryo's heart rate.

Common mistakes when looking at an ultrasound image​

  • Reading the colours as artery and vein. Red and blue are directions relative to the probe. One vessel can be both, and an artery can be blue.
  • Seeing a black area as empty. Black means no echoes. It's usually fluid, but it can be a shadow, or a place too deep for the frequency in use.
  • Mistaking a shadow for something missing. Tissue below a bone or stone hasn't gone; the sound just didn't reach it.
  • Judging brightness on its own. Gain, TGC and the display settings change every shade. Compare a structure with its neighbours in the same picture.
  • Guessing size by eye. The fan is narrow at the top and wide at depth, so use the depth scale and the calipers, not the apparent size.
  • Taking a ghost for a second structure. Mirror images and reverberations look solid in a single frame; the sonographer checks from another angle.
  • Forgetting which way round the image is. Check the marker dot. Heart scans and general scans put it on opposite sides of the screen.
  • Expecting the print to give the answer. A print is one slice chosen from a whole sweep. The report, written with the rest of the examination, is the result.

How to build an ultrasound image display in JavaScript, React or Angular​

SciChart.js draws heatmaps with WebGL, including polar heatmaps with an angular range of less than a full circle, so a fan-shaped scan of more than 100,000 cells can be redrawn many times a second. The example below simulates a curved probe scanning a tissue phantom: skin, fat and muscle layers, an organ, a blood vessel in colour Doppler, a fluid-filled cyst with posterior enhancement, a stone with an acoustic shadow and a deeper boundary. The image is formed from a simple model of the physics, with speckle, frequency-dependent attenuation and resolution, and electronic noise. It's simulated data, not a patient scan.

Move Gain and TGC to brighten the image overall or with depth. Change Depth to see more or less, and Frequency to trade sharpness against penetration; changing the frequency resets TGC as a scanner preset would. Turn Colour Doppler on and off to see the pulsing flow, red on one side of the vessel and blue on the other. Tick Slow motion to watch the image built one scan line at a time. Hover over the image for the depth, the echo's return time, its brightness and what it shows. Scroll to zoom, drag to pan and double-click to reset.

Here is the code for this example. The phantom and the image model are plain JavaScript; SciChart.js draws the fan-shaped heatmap, the colour Doppler overlay and the scan line. The React and Angular versions draw a B-mode frame from your own data.

// A B-mode ultrasound image as a fan-shaped polar heatmap, with a colour Doppler overlay, an optional
// line-by-line scan and a readout of the echo under the mouse, charted with SciChart.js
const {
SciChartPolarSurface,
PolarNumericAxis,
EPolarAxisMode,
NumberRange,
EAutoRange,
UniformHeatmapDataSeries,
PolarUniformHeatmapRenderableSeries,
HeatmapColorMap,
PolarLineRenderableSeries,
PolarColumnRenderableSeries,
XyxDataSeries,
XyDataSeries,
EColumnMode,
GradientParams,
Point,
CustomChartModifier2D,
EModifierType,
translateFromCanvasToSeriesViewRect,
SciChartJsNavyTheme,
PolarMouseWheelZoomModifier,
PolarPanModifier,
PolarZoomExtentsModifier
} = SciChart;
// or, for npm, import { SciChartPolarSurface, ... } from "scichart"

const { sciChartSurface, wasmContext } = await SciChartPolarSurface.create(ui.chartDiv, {
theme: new SciChartJsNavyTheme()
});
const toRad = (deg) => (deg * Math.PI) / 180;
// The angle of each scan line: 0° is straight down. The polar chart's angles start at 3 o'clock and run
// anticlockwise, so the fan starts at 240° (lower left) and spans 60°.
const angleAxis = new PolarNumericAxis(wasmContext, {
polarAxisMode: EPolarAxisMode.Angular,
visibleRange: new NumberRange(-SECTOR_DEG / 2, SECTOR_DEG / 2),
autoRange: EAutoRange.Never,
startAngle: toRad(270 - SECTOR_DEG / 2),
totalAngle: toRad(SECTOR_DEG),
drawLabels: false,
drawMajorTickLines: false,
drawMinorTickLines: false,
drawMajorGridLines: false,
drawMinorGridLines: false,
drawMajorBands: false
});
// Distance from the fan's tip. The image starts at the probe face (PROBE_RADIUS from the tip), so innerRadius
// keeps the fan in proportion. The labels show depth below the skin, down the right-hand edge.
let depthCm = 12;
const depthAxis = new PolarNumericAxis(wasmContext, {
polarAxisMode: EPolarAxisMode.Radial,
visibleRange: new NumberRange(PROBE_RADIUS, PROBE_RADIUS + depthCm),
autoRange: EAutoRange.Never,
startAngle: toRad(270 + SECTOR_DEG / 2),
innerRadius: PROBE_RADIUS / (PROBE_RADIUS + depthCm),
autoTicks: false,
majorDelta: 2,
minorDelta: 1,
drawMajorGridLines: false,
drawMinorGridLines: false,
drawMajorBands: false,
labelStyle: { color: "#E8EEF8" }
});
// The skin (0 cm) is the top edge of the image, so it needs no label
depthAxis.labelProvider.formatLabel = (value) => (value - PROBE_RADIUS < 0.5 ? "" : `${Math.round(value - PROBE_RADIUS)} cm`);
sciChartSurface.xAxes.add(angleAxis);
sciChartSurface.yAxes.add(depthAxis);

// B-mode: brightness for echo strength, from black (no echo) to white (strongest), over DISPLAY_DB decibels
const rowsFor = (depth) => Math.round(depth / ROW_CM);
const makeRows = (n) => Array.from({ length: n }, () => new Float64Array(BEAMS)); // Float64Array rows copy into the chart faster
let shown = makeRows(rowsFor(depthCm)); // what is on screen
let target = makeRows(rowsFor(depthCm)); // the latest complete frame
const heatmapOptions = { xStart: -SECTOR_DEG / 2, xStep: SECTOR_DEG / BEAMS, yStart: PROBE_RADIUS, yStep: ROW_CM };
const bModeData = new UniformHeatmapDataSeries(wasmContext, { ...heatmapOptions, zValues: shown });
const bModeSeries = new PolarUniformHeatmapRenderableSeries(wasmContext, {
dataSeries: bModeData,
colorMap: new HeatmapColorMap({
minimum: 0,
maximum: DISPLAY_DB,
gradientStops: [
{ offset: 0, color: "#000000" },
{ offset: 1, color: "#FFFFFF" }
]
}),
fillValuesOutOfRange: true
});

// Colour Doppler: flow towards the probe in red to yellow, away in blue to cyan, no flow transparent.
// The colour is the direction relative to the probe, not artery or vein.
let flow = makeRows(rowsFor(depthCm));
const flowData = new UniformHeatmapDataSeries(wasmContext, { ...heatmapOptions, zValues: flow });
const flowSeries = new PolarUniformHeatmapRenderableSeries(wasmContext, {
dataSeries: flowData,
colorMap: new HeatmapColorMap({
minimum: -NYQUIST,
maximum: NYQUIST,
gradientStops: [
{ offset: 0, color: "#9FE8FF" },
{ offset: 0.25, color: "#1E50FF" },
{ offset: 0.46, color: "#0A1E8C" },
{ offset: 0.5, color: "#00000000" },
{ offset: 0.54, color: "#8C0A0A" },
{ offset: 0.75, color: "#FF2A1A" },
{ offset: 1, color: "#FFE14A" }
]
}),
fillValuesOutOfRange: true
});

// Slow motion: the current scan line, with a soft glow behind it (one polar column with a gradient fill)
const lineData = new XyDataSeries(wasmContext, { xValues: [0, 0], yValues: [PROBE_RADIUS, PROBE_RADIUS + depthCm] });
const scanLine = new PolarLineRenderableSeries(wasmContext, { dataSeries: lineData, stroke: "#7FE3FF", strokeThickness: 2 });
const glowData = new XyxDataSeries(wasmContext, { xValues: [-SWEEP_GLOW_DEG], x1Values: [0], yValues: [PROBE_RADIUS + depthCm] });
const scanGlow = new PolarColumnRenderableSeries(wasmContext, {
dataSeries: glowData,
columnXMode: EColumnMode.StartEnd, // x is where the glow starts, x1 where it ends (at the scan line)
defaultY1: PROBE_RADIUS, // the column starts at the probe face
strokeThickness: 0,
fillLinearGradient: new GradientParams(new Point(0, 0), new Point(1, 0), [
{ offset: 0, color: "#7FE3FF50" },
{ offset: 1, color: "#7FE3FF00" }
])
});
scanLine.isVisible = false;
scanGlow.isVisible = false;
sciChartSurface.renderableSeries.add(bModeSeries, flowSeries, scanGlow, scanLine);
sciChartSurface.chartModifiers.add(new PolarMouseWheelZoomModifier(), new PolarPanModifier(), new PolarZoomExtentsModifier());

// --- The image: received echo for the frequency, then gain, TGC and the depth shown ---
const settings = { gain: 0, tgc: 3.5, depth: 12, freq: 3.5, doppler: true, slow: false };
let echo = receivedEcho(settings.freq); // [beam][row], dB
// Display value = received echo + overall gain + time gain compensation (TGC), which adds more gain the deeper
// the echo, up to TGC_MAX_DB
function buildFrame() {
for (let i = 0; i < target.length; i++) {
const tgcDb = Math.min(TGC_MAX_DB, settings.tgc * (i + 0.5) * ROW_CM);
const row = target[i];
for (let b = 0; b < BEAMS; b++) row[b] = DISPLAY_DB / 2 + settings.gain + tgcDb + echo[b][i];
}
}
// Copy the scan lines from fromBeam up to toBeam onto the screen, dimmed by dimDb
function copyLines(fromBeam, toBeam, dimDb = 0) {
for (let i = 0; i < shown.length; i++) {
for (let b = fromBeam; b < toBeam; b++) shown[i][b] = target[i][b] - dimDb;
}
}

// The vessel's cells, for the Doppler overlay: where they are and which way their scan line points
const vesselCells = [];
for (let b = 0; b < BEAMS; b++) {
const theta = toRad(beamAngle(b));
for (let i = 0; i < MAX_ROWS; i++) {
if (material[b][i] !== MAT.BLOOD) continue;
const r = PROBE_RADIUS + (i + 0.5) * ROW_CM;
const d = vesselDistance(r * Math.sin(theta), r * Math.cos(theta) - PROBE_RADIUS);
// Flow runs along the vessel, left to right. Its speed towards the probe is minus its component along
// the scan line, which points away from the probe: (sin theta, cos theta).
const along = (Math.sin(theta) + VESSEL.slope * Math.cos(theta)) / Math.hypot(1, VESSEL.slope);
vesselCells.push({ b, i, profile: 1 - (d / VESSEL.radius) ** 2, towards: -along });
}
}
function updateFlow(seconds) {
const peak = peakVelocity(seconds);
for (const c of vesselCells) {
if (c.i >= flow.length) continue;
let v = settings.doppler ? peak * c.profile * c.towards : 0;
if (Math.abs(v) < 2) v = 0; // the wall filter removes very slow movement
flow[c.i][c.b] = Math.max(-NYQUIST, Math.min(NYQUIST, v));
}
flowData.setZValues(flow);
}

// Slow motion state: which scan line is being built
let scanBeam = 0;

// When the depth changes, the image has more or fewer rows and the fan keeps its proportions
function setDepth(depth) {
depthCm = depth;
settings.depth = depth;
shown = makeRows(rowsFor(depth));
target = makeRows(rowsFor(depth));
flow = makeRows(rowsFor(depth));
depthAxis.visibleRange = new NumberRange(PROBE_RADIUS, PROBE_RADIUS + depth);
depthAxis.innerRadius = PROBE_RADIUS / (PROBE_RADIUS + depth);
depthAxis.majorDelta = depth > 12 ? 4 : 2;
showScanLine(scanBeam);
}
function showScanLine(beam) {
const angle = -SECTOR_DEG / 2 + (beam / BEAMS) * SECTOR_DEG;
lineData.updateXy(0, angle, PROBE_RADIUS);
lineData.updateXy(1, angle, PROBE_RADIUS + depthCm);
glowData.updateXyz(0, Math.max(-SECTOR_DEG / 2, angle - SWEEP_GLOW_DEG), PROBE_RADIUS + depthCm, angle);
}
function refresh() {
buildFrame();
if (!settings.slow) {
copyLines(0, BEAMS);
bModeData.setZValues(shown);
}
updateFlow(performance.now() / 1000);
showReadout();
}

// --- Controls ---
const showControlText = () => {
ui.gainText.textContent = `${settings.gain > 0 ? "+" : ""}${settings.gain} dB`;
ui.tgcText.textContent = `${settings.tgc.toFixed(2)} dB/cm`;
ui.flowKey.style.visibility = settings.doppler ? "visible" : "hidden";
};
ui.gain.addEventListener("input", () => {
settings.gain = Number(ui.gain.value);
showControlText();
refresh();
});
ui.tgc.addEventListener("input", () => {
settings.tgc = Number(ui.tgc.value);
showControlText();
refresh();
});
ui.depth.addEventListener("change", () => {
setDepth(parseFloat(ui.depth.value));
if (settings.slow) scanBeam = 0;
refresh();
bModeData.setZValues(shown);
});
ui.freq.addEventListener("change", () => {
settings.freq = parseFloat(ui.freq.value);
// Like a scanner preset, TGC is reset to make up for the loss at this frequency: 2 x 0.5 dB/cm/MHz x f
settings.tgc = Math.min(8, 2 * ATTENUATION * settings.freq);
ui.tgc.value = String(settings.tgc);
echo = receivedEcho(settings.freq);
showControlText();
refresh();
});
ui.doppler.addEventListener("change", () => {
settings.doppler = ui.doppler.checked;
showControlText();
refresh();
});
ui.slow.addEventListener("change", () => {
settings.slow = ui.slow.checked;
scanLine.isVisible = settings.slow;
scanGlow.isVisible = settings.slow;
scanBeam = 0;
refresh();
if (settings.slow) copyLines(0, BEAMS, SLOW_DIM_DB);
});

// --- Readout: depth, echo time, brightness and what is there ---
let hover = null;
const defaultText = "Hover over the image to read the depth, the echo strength and what it shows.";
function showReadout() {
if (!hover) {
ui.readout.textContent = defaultText;
return;
}
const b = Math.floor(((hover.angle + SECTOR_DEG / 2) / SECTOR_DEG) * BEAMS);
const i = Math.floor((hover.r - PROBE_RADIUS) / ROW_CM);
if (b < 0 || b >= BEAMS || i < 0 || i >= shown.length) {
ui.readout.textContent = defaultText;
return;
}
const depth = (i + 0.5) * ROW_CM;
const micros = ((2 * depth) / 100 / SOUND_SPEED) * 1e6; // there and back
const level = Math.max(0, Math.min(DISPLAY_DB, shown[i][b]));
const kind =
level < 8
? "anechoic (black)"
: level < 22
? "hypoechoic (dark grey)"
: level < 40
? "mid-grey (intermediate echoes)"
: "hyperechoic (bright)";
const m = material[b][i];
let what = MAT_INFO[m].text;
if (label[b][i] === LABEL.SHADOW) what = "acoustic shadow: the stone above blocks the sound, so nothing comes back from here";
else if (label[b][i] === LABEL.ENHANCED && m !== MAT.BLOOD)
what += ", brighter than its neighbours because the sound crossed the cyst with little loss (posterior enhancement)";
else if (echo[b][i] < NOISE_DB + 3 && backscatter[b][i] > -30) what = "too deep for this frequency: the echoes are weaker than the scanner's own noise";
let text =
`Depth ${depth.toFixed(1)} cm (echo back after ${micros.toFixed(0)} µs), ` +
`brightness ${level.toFixed(0)} of ${DISPLAY_DB}: ${kind}. ${what[0].toUpperCase()}${what.slice(1)}.`;
const v = flow[i] ? flow[i][b] : 0;
if (settings.doppler && v !== 0) text += ` Flow ${Math.abs(v).toFixed(0)} cm/s ${v > 0 ? "towards the probe (red)" : "away from the probe (blue)"}.`;
ui.readout.textContent = text;
}
// A custom modifier turns the mouse position into angle and distance, with the polar axes' own transform
class ScanReadoutModifier extends CustomChartModifier2D {
// Tells the polar surface that this modifier works with polar charts
get modifierType() {
return EModifierType.Chart2DPolarModifier;
}
modifierMouseMove(args) {
super.modifierMouseMove(args);
const point = translateFromCanvasToSeriesViewRect(args.mousePoint, this.parentSurface.seriesViewRect);
hover = null;
if (point) {
const polar = angleAxis.reverseTransform(point.x, point.y);
const angle = angleAxis.getCurrentCoordinateCalculator().getDataValue(polar.x);
const r = depthAxis.getCurrentCoordinateCalculator().getDataValue(polar.y);
if (Math.abs(angle) <= SECTOR_DEG / 2 && r >= PROBE_RADIUS) hover = { angle, r };
}
showReadout();
}
modifierMouseLeave(args) {
super.modifierMouseLeave(args);
hover = null;
showReadout();
}
}
sciChartSurface.chartModifiers.add(new ScanReadoutModifier());

showControlText();
refresh();

// --- Animation: the pulsing flow and, in slow motion, the scan line moving across the fan ---
let lastTime = performance.now();
let sinceUpdate = 0; // ms since the heatmaps were last sent to the chart
function animate(now) {
// Stop when the chart is deleted (for example when a React component unmounts)
if (sciChartSurface.isDeleted) return;
const dt = Math.min(now - lastTime, 100);
lastTime = now;
sinceUpdate += dt;
if (settings.slow) {
// The scan line moves every frame; the heatmap is sent at most HEATMAP_UPDATES_PER_SECOND times a second
const next = scanBeam + (dt / 1000 / SLOW_SCAN_SECONDS) * BEAMS;
if (next >= BEAMS) {
// A new frame starts: dim the old one, so the new scan lines stand out as they are drawn
copyLines(0, BEAMS, SLOW_DIM_DB);
scanBeam = 0;
} else {
copyLines(Math.floor(scanBeam), Math.floor(next));
scanBeam = next;
}
showScanLine(scanBeam);
}
// Performance: every heatmap update makes SciChart re-process the whole grid, however few cells changed,
// so the image and the flow are sent HEATMAP_UPDATES_PER_SECOND times a second at most
if (sinceUpdate >= 1000 / HEATMAP_UPDATES_PER_SECOND) {
sinceUpdate = 0;
if (settings.slow) bModeData.setZValues(shown);
if (settings.doppler) updateFlow(now / 1000);
if (hover) showReadout();
}
requestAnimationFrame(animate);
}
requestAnimationFrame(animate);

Key points:

  • The image is a PolarUniformHeatmapRenderableSeries on a SciChartPolarSurface. The angular axis's startAngle and totalAngle limit it to a 60° fan pointing down, and the radial axis's innerRadius starts the image at the probe face, so the fan keeps its true proportions.
  • The radial axis holds distance from the fan's tip; its labelProvider subtracts the probe radius so the labels read depth below the skin.
  • Colour Doppler is a second polar heatmap on top, with a colour map that runs blue to transparent to red, so cells with no flow let the greyscale show through.
  • Gain and TGC only change the values sent to the chart, so the heatmap is updated with setZValues, at most 30 times a second while the flow pulses. The scan line in slow motion is a PolarLineRenderableSeries with a PolarColumnRenderableSeries gradient glow behind it.
  • A CustomChartModifier2D turns the mouse position into angle and depth with the polar axis's reverseTransform, for the readout.

See it in the demo app: JavaScript polar ultrasound heatmap · React polar ultrasound heatmap · Angular polar ultrasound heatmap. Related techniques: the React heatmap chart and React polar heatmap chart.

Go deeper: SciChart.js polar heatmap documentation, the uniform heatmap, and the learning center guides to sonar, the same pulse-echo idea underwater, non-destructive testing, with ultrasonic A-, B- and C-scans of metal parts, and the heatmap. For how SciChart is used in medical software, see SciChart for medical charts and dashboards.

Frequently asked questions​

How does ultrasound work?​

A probe on the skin sends short pulses of high-frequency sound, usually a few megahertz, into the body and listens for the echoes that bounce back from boundaries between tissues. The scanner assumes sound travels at about 1,540 metres per second in soft tissue, so the time each echo takes to return gives its depth: about 13 microseconds for every centimetre. The strength of each echo sets the brightness of a dot, and many scan lines side by side build a live greyscale picture.

How do you read an ultrasound image?​

Start with orientation: the top of the image is the skin where the probe sits, depth increases downwards, and a marker dot shows which side of the image matches the marked side of the probe. Then read the shades: black means no echoes, usually fluid; grey is soft tissue; bright white is a strong reflector such as bone, a stone or gas. Look below bright and black areas for shadows and brighter bands, and check the colour bar if Doppler colour is shown. A sonographer or doctor interprets the scan.

What do red and blue mean on a Doppler ultrasound?​

On colour Doppler, the colour shows the direction of blood flow relative to the probe, not whether the vessel is an artery or a vein. By the usual setting, red is flow towards the probe and blue is flow away from it, with brighter shades for faster flow. The colour bar on the screen shows which way round the scanner is set, and one vessel can show both colours if it curves or runs across the beam.

What does black mean on an ultrasound?​

Black, called anechoic, means no echoes came back from that place. Usually that is fluid that sound passes through without reflecting, such as urine in the bladder, blood in a vessel, bile in the gallbladder or amniotic fluid. A black area can also be an acoustic shadow behind bone, a stone or gas, where no sound reached, or a place too deep for the echoes to be detected.

What is the difference between ultrasound and MRI?​

Ultrasound makes pictures from echoes of sound, in real time, with a handheld probe, and is portable, widely available and less expensive. MRI uses a strong magnetic field and radio waves in a scanner, takes longer, and shows soft tissue in more detail through bone and gas, which ultrasound cannot see through. Neither uses ionising radiation. Which one is used depends on the body part and the question the doctor is asking.

How do I draw an ultrasound image in JavaScript?​

Store echo brightness in a 2D array with one row per depth step and one column per scan line, and draw it as a polar heatmap with the scan-line angle on the angular axis and depth on the radial axis, limited to the fan's angle. A greyscale colour map gives the B-mode image, and a second heatmap with a red-transparent-blue colour map can overlay colour Doppler. With SciChart.js, use PolarUniformHeatmapRenderableSeries on a SciChartPolarSurface.

Sources​

  • RadiologyInfo.org (RSNA and ACR), General Ultrasound (reviewed 2024), Obstetric Ultrasound, Body MRI and Body CT (reviewed 2026). How ultrasound is used and who interprets it, its limits with bone, gas and larger patients, its safety, and how it compares with MRI and CT.
  • National Institute of Biomedical Imaging and Bioengineering (NIH) (2023), Ultrasound. Piezoelectric transducers, megahertz frequencies, echo timing and Doppler.
  • US Food and Drug Administration (2024), Ultrasound Imaging. Heating, cavitation, ALARA and keepsake imaging.
  • American Institute of Ultrasound in Medicine (2020), Prudent Use and Safety of Diagnostic Ultrasound in Pregnancy. Doppler in early pregnancy, the thermal index and entertainment scans.
  • Au, A. and Zwank, M. (2020), Ultrasound Physics and Technical Facts for the Beginner. ACEP Sonoguide. Probe types, frequency and resolution, B-mode and M-mode, gain and TGC, and the common artefacts.
  • Habrat, D. (2025), How To Do Ultrasound. MSD Manual Professional Version. Probe frequencies and the orientation marker conventions.
  • Salomon, L. J. et al. (2019), ISUOG Practice Guidelines: ultrasound assessment of fetal biometry and growth. Ultrasound in Obstetrics & Gynecology, 53(6), 715–723. CRL before 14 weeks, then BPD, HC, AC and FL.
  • Hoskins, P. R., Martin, K. and Thrush, A. (eds) (2019), Diagnostic Ultrasound: Physics and Equipment, 3rd edition. CRC Press. Attenuation, reflection at boundaries, image formation, Doppler and artefacts.