How to Read an MRI Scan
What is an MRI scan?
An MRI scan (magnetic resonance imaging) is a medical image made with a strong magnetic field and radio waves instead of X-rays. The scanner measures signals from hydrogen nuclei in water and fat, and builds a stack of thin slices through the body that can be viewed in three planes: axial, sagittal and coronal.

Axial, coronal and sagittal slices of a T1-weighted brain MRI template, with linked crosshairs and labels. Try the interactive version.
This guide explains how MRI images are made and how to find your way around them. It is for learning only and isn't medical advice. Only a radiologist, a doctor trained to interpret medical images, can read a scan for diagnosis; their report, discussed with your own doctor, is what counts.
- An MRI is a stack of slices. Each slice is a grid of voxels, small boxes of tissue, and the same volume can be shown in axial, coronal and sagittal planes.
- In axial and coronal views the patient's right is on the viewer's left. Check the orientation letters before deciding which side anything is on.
- T1 makes fat bright and fluid dark; T2 makes fluid bright. Look at the fluid in the ventricles to tell them apart, and use FLAIR to see bright tissue water next to dark fluid.
- MRI brightness has no fixed units, so judge tissues against each other on the same image, and adjust window and level instead of trusting brightness alone.
- Artefacts from movement, metal or a too-small field of view can look like disease. Read the radiologist's report.
How does MRI make an image?
An MRI scanner works with the hydrogen nuclei, single protons, in the water and fat that make up most of the body. Each proton behaves like a tiny magnet. The scanner's main magnet, usually 1.5 or 3 tesla in hospitals and tens of thousands of times stronger than the Earth's magnetic field, lines a small surplus of them up along its field.
A scan then repeats four steps, hundreds of times:
- Excitation. A short radio-frequency (RF) pulse tips the protons' combined magnetisation away from the field. The pulse has to match the protons' resonant frequency, about 42.6 MHz for every tesla of field, so about 64 MHz at 1.5 T and 128 MHz at 3 T.
- Signal. As the tipped magnetisation spins around the field, it induces a small radio signal in receiver coils placed around the head.
- Relaxation. The signal fades and the protons return to alignment. How fast depends on the tissue around them, and that difference is what makes tissues look different.
- Spatial encoding. Gradient coils add small, controlled changes to the field across the body, so protons in different places give slightly different frequencies and phases. A Fourier transform turns the recorded signals into an image. Switching the gradients on and off makes the loud knocking during a scan.
Two time constants describe relaxation:
| What it measures | Long in | Short in | |
|---|---|---|---|
| T1 (longitudinal relaxation) | How fast magnetisation recovers along the main field: T1 is the time to get back about 63% | Water and cerebrospinal fluid (CSF) | Fat |
| T2 (transverse relaxation) | How fast the signal from the tipped magnetisation decays: T2 is the time for it to fall to about 37% | Water and CSF | Dense, ordered tissue such as tendon |
Two settings choose which one the image shows. The repetition time (TR) is the gap between excitations; the echo time (TE) is how long after excitation the signal is read. A short TR and short TE give a T1-weighted image. A long TR and long TE give a T2-weighted image. The tissue doesn't change between the two; only the timing does.
Voxels, slices and the three planes
An MRI scan is a three-dimensional grid of numbers. Each number is the signal from one voxel, a small box of tissue, typically 1 mm or less across within a slice and from about 1 mm to several millimetres thick. A slice is one layer of voxels, and a series is the whole stack.
| Plane | Cuts the body into | You see | Also called |
|---|---|---|---|
| Axial | Top and bottom | Horizontal slices, as if looking up from the feet | Transverse, transaxial |
| Coronal | Front and back | Face-on slices, as if facing the patient | Frontal |
| Sagittal | Left and right | Side-on slices; the midline one is the midsagittal slice |
Each sequence is acquired in one plane, and a clinical exam usually includes sequences in two or three different planes. A 3D sequence with small, equal-sided voxels can be resliced into any plane afterwards with little loss; reslicing a stack of thick 2D slices gives blurred, blocky images in the other planes.
How to orient yourself: the radiological convention
Medical images follow the radiological convention: the patient's right is on the viewer's left in axial and coronal views. An axial slice is shown as if you were standing at the patient's feet looking up, and a coronal slice as if you were facing the patient. Sagittal slices are usually shown with the face to the left.
Viewers print orientation letters at the edges of each view: R and L (right, left), A and P (anterior, posterior), S and I (superior, inferior), and sometimes H and F (head, foot). Read them first. Some research software displays brain images in the neurological convention instead, with the patient's left on the viewer's left, so the same image can appear mirrored between programs.
T1 vs T2 vs FLAIR: what's bright and what's dark
Each MRI sequence makes different tissues bright, so a radiologist reads several sequences of the same area side by side. These are the three you'll meet first in a brain MRI.
| Tissue | T1-weighted | T2-weighted | FLAIR |
|---|---|---|---|
| Water and CSF (ventricles, the fluid around the brain) | Dark | Bright | Dark (the fluid signal is cancelled) |
| Fat (scalp, bone marrow, the eye socket) | Bright | Bright on most modern (fast spin-echo) T2 | Bright |
| White matter | Brighter than grey matter | Darker than grey matter | Darker than grey matter |
| Grey matter (cortex, deep nuclei) | Darker than white matter | Brighter than white matter | Brighter than white matter |
| Cortical bone and air | Dark | Dark | Dark |
| Tissue holding extra water (oedema, many lesions) | Darker, or no different | Bright | Bright, and easy to see next to dark CSF |
FLAIR (fluid-attenuated inversion recovery) is a T2-weighted sequence with an extra inversion pulse timed so that free fluid gives no signal. Tissue water stays bright while CSF goes dark, so changes next to the ventricles or the brain surface stand out.
Other sequences you may see listed:
- Proton density (PD): long TR and short TE, so the image mostly shows how many protons each tissue holds; common in joint imaging.
- Diffusion-weighted imaging (DWI): shows how freely water molecules move; tissue where movement is restricted looks bright.
- Susceptibility-weighted (SWI) and T2* gradient-echo: sensitive to iron, blood products and calcium, which look dark.
- STIR: an inversion-recovery sequence that cancels fat.
How to tell if an MRI image is T1 or T2
Look at the fluid first. In a brain MRI, find the lateral ventricles, the two fluid-filled spaces in the middle of the brain.
- Dark fluid and white matter brighter than grey matter: T1.
- Bright fluid and grey matter brighter than white matter: T2.
- Dark fluid but grey matter brighter than white matter: FLAIR.
A memory aid some students use is "World War II": water is white on T2. The series name in the viewer (for example "SAG T1", "AX T2", "AX FLAIR") or the image information also says which sequence it is.
A worked example with real numbers
The viewer on this page shows the T1 and T2 signal of every voxel under the mouse, so you can check the table above. These are typical readings in its template brain, on a 0 to 255 scale that has no physical units:
| Point in the brain | T1 signal | T2 signal |
|---|---|---|
| CSF in a lateral ventricle | about 65 | about 255 |
| Vitreous fluid in the eye | about 75 | about 250 |
| Cortex (grey matter) | about 175 | about 170 |
| Thalamus (deep grey matter) | about 190 | about 145 |
| White matter | about 240 | about 125 |
On T1, white matter reads about a third brighter than the cortex (240 against 175) and CSF about a quarter of white matter's value. On T2 the order flips: white matter reads about a quarter darker than the cortex, and CSF is the brightest thing in the head. The ratios are what you read, not the numbers. A different scanner, coil or setting gives different numbers for the same tissue.
Is T1 or T2 better?
Neither: they answer different questions, which is why a routine brain MRI includes both, usually with FLAIR and diffusion. T1 shows anatomy clearly and is the sequence used before and after a contrast injection. T2 and FLAIR show water, and most disease processes, such as inflammation, oedema and many tumours, change the amount of water in tissue.
Radiologists describe what they see by signal, not by colour: hyperintense (brighter than the reference tissue), hypointense (darker) and isointense (the same). "A T2 hyperintense lesion" means a spot that is brighter than its surroundings on T2. That description alone isn't a diagnosis; many different causes look alike on one sequence.
Contrast agents: gadolinium
Some MRI exams include an injection of a contrast agent, usually a gadolinium-based contrast agent given into a vein. Gadolinium changes the magnetic behaviour of the water molecules around it and shortens their T1, so tissue that takes it up looks brighter on a T1-weighted image.
In the brain, the blood–brain barrier normally keeps the agent inside the blood vessels. Where the barrier is damaged, as in some tumours and areas of active inflammation, it leaks into the tissue, which then "enhances": it is brighter on the T1 image taken after the injection than on the one taken before. That is why contrast scans are read as a pair, pre-contrast and post-contrast T1.
Gadolinium agents are widely used and serious reactions are uncommon. Allergic-type reactions are rare. Nephrogenic systemic fibrosis, a thickening of the skin and organs, is a rare complication in people with severe kidney disease, so the agent may be withheld in some of them. Traces of gadolinium can stay in the body, including the brain, after an exam; no harmful effects from these traces have been shown, and radiologists take retention into account when choosing an agent. The decision to use contrast belongs to the radiology team.
Window and level: contrast and brightness
A scanner records more shades than a screen shows. The window (width) and level (centre) choose which part of the signal range fills the screen's black-to-white scale:
- Everything below level − window ÷ 2 is shown black.
- Everything above level + window ÷ 2 is shown white.
- Values in between are spread over the grey scale.
A narrow window gives high contrast, which helps separate grey matter from white matter; a wide window shows everything with less contrast. With a window of 120 and a level of 170, signal values from 110 to 230 fill the grey scale and the rest are clipped. In most viewers you drag the mouse with a button held to change them.
MRI and CT differ here. CT values are Hounsfield units, a fixed scale on which water is 0 and air is −1000, so radiologists use standard window presets such as "brain" or "bone". MRI signal has no absolute scale: the same tissue gives different numbers on different scanners, coils and settings, and even across one image. So MRI windows are set by eye for each series, and brightness is only meaningful when compared with other tissue in the same image.
How to look at a brain MRI step by step
This is how to find your way around a brain MRI from a CD or an online portal. It helps you follow the radiologist's report; it doesn't replace it.
- Check what you are looking at: the patient name, the date and the series list, such as "AX T2", "SAG T1", "AX FLAIR", "AX T1 +C" (after contrast).
- Find the plane and the orientation. Use the letters at the edges. In axial and coronal views, the patient's right is on your left.
- Work out the sequence. Look at the ventricles: dark fluid on T1 and FLAIR, bright on T2.
- Scroll through the whole series, top to bottom or front to back. A single slice can't show a structure's shape; scrolling shows how it continues from slice to slice.
- Use the other planes. Find the same spot in a second plane. Most viewers link the views with crosshairs.
- Compare left with right. The brain is roughly symmetrical, so the ventricles, the deep grey nuclei and the folds on each side should look alike. A small difference is often normal: the head may be slightly tilted in the scanner.
- Look at the landmarks. The midline should be straight; check the size of the ventricles, the boundary between grey and white matter, the corpus callosum, the brainstem and the cerebellum.
- Adjust window and level, rather than judging a tissue from its brightness on the default setting.
- Read the report and ask your doctor. Normal variants, partial-volume effects (one voxel holding two tissues) and artefacts all look like abnormalities to an untrained eye.
Common MRI artefacts
An artefact is something in the image that isn't in the patient. These are the ones people most often mistake for disease.
| Artefact | What it looks like | Cause |
|---|---|---|
| Motion | Blurring, or faint copies (ghosts) of the head or of pulsing vessels repeated across the image | The patient moving, breathing, swallowing; blood and CSF pulsing. Ghosts repeat along the phase-encoding direction |
| Susceptibility | A black hole with a bright, distorted rim; stretched or squashed anatomy | Metal (dental work, clips, implants) and air–bone boundaries such as the sinuses and ear canals distort the magnetic field. Worse on gradient-echo and diffusion images and at 3 T |
| Wrap-around (aliasing) | Part of the head, or the nose or shoulders, folded over onto the opposite side of the image | Anatomy outside the field of view, in the phase-encoding direction |
| Chemical shift | A thin bright or dark band at the edge between fat and water | Fat protons resonate at a slightly different frequency from water protons, so fat is shifted along one direction |
| Truncation (Gibbs ringing) | Fine parallel lines next to a sharp edge, such as in the spinal cord | Too few samples to describe a sharp change in signal |
Radiographers repeat or adjust a sequence when an artefact hides what needs to be seen, for example with a larger field of view to stop wrap-around.
MRI vs CT
CT and MRI both make cross-sectional slices, but they measure different things.
| MRI | CT | |
|---|---|---|
| How it works | Magnetic field and radio waves; signal from hydrogen in water and fat | X-rays passed through the body from many angles |
| Ionising radiation | None | Yes, a small dose |
| Scan time | Usually tens of minutes for a full exam | Seconds to a few minutes |
| Best for | Soft tissue: brain, spinal cord, nerves, joints, many tumours | Emergencies and trauma, bleeding, bone, the lungs |
| Image values | Signal in arbitrary units; brightness depends on the sequence | Hounsfield units: a fixed scale, water 0, air −1000 |
| Comfort | Loud, enclosed, sensitive to movement | Quick, open ring, less affected by movement |
| Implants and metal | Must be checked first; some devices rule MRI out or need special settings | An implant doesn't prevent a scan |
In practice, a suspected stroke or head injury usually gets a CT first because it is fast and shows bleeding; MRI follows to show the brain in detail. For how ultrasound compares with both, see the ultrasound guide.
MRI file formats: DICOM and NIfTI
- DICOM is the international standard for medical images and the information that goes with them (ISO 12052). Scanners, hospital archives and patient CDs use it. A series is usually many files, one per slice, each with a header that holds the patient's details, the scanner settings and the slice's position. Remove those details before sharing images.
- NIfTI (
.niior.nii.gz) is the format most neuroimaging research software uses. A.niifile holds the whole volume and a transform that maps voxel indices to positions in millimetres, which is how software knows which way is left. Research datasets are often defaced, with the face removed from the image, because a 3D head scan can be rendered as a recognisable face.
Common mistakes when reading MRI images
- Mixing up left and right. In axial and coronal views the patient's right is on your left, and some software mirrors it. Read the orientation letters every time.
- Judging a tissue by its brightness alone. MRI numbers vary between scanners and settings. Compare against tissue in the same image, such as the fluid, white matter and grey matter.
- Reading "bright" as "abnormal". Fat, fluid and flowing blood are bright on some sequences in every healthy scan. A finding means something only on the right sequence, compared with the sequences around it.
- Looking at one slice. A round spot on one slice may be a vessel or a fold that runs on through the next slices. Scroll, and check other planes.
- Leaving the window too wide or too narrow. Too wide hides subtle differences in contrast; too narrow clips real tissue to black or white.
- Mistaking an artefact for a lesion. Check whether it repeats across the image, follows a metal object or a sinus, or appears on only one sequence.
- Diagnosing from the images yourself. Many conditions look alike, and normal anatomy varies. The radiologist's report, read with your doctor, is the answer.
How to build an MRI viewer in JavaScript, React or Angular
Medical imaging viewers redraw large images instantly as the user scrolls through slices, changes contrast or moves a crosshair. SciChart.js draws each slice as a GPU-accelerated heatmap, so a viewer can stack an image and overlays, link several views and add annotations while staying responsive. This demo loads two real MRI volumes, a T1-weighted and a T2-weighted scan of the same head, and shows them as three linked views. The data is the MNI ICBM 152 2009a template, converted from NIfTI to a compact image format that loads in the browser. The template is an average of brain scans from 152 adults, so it shows no individual person; it is smoother than a single scan and has no artefacts.
Click or drag in any view to move the crosshair; the other two views jump to that point. Scroll over a view, or use the slider under it, to step through its slices. Switch between T1-weighted and T2-weighted to compare the same voxels, and drag Window and Level to change contrast and brightness. Threshold overlay colours every voxel whose signal falls between the two sliders, a simple form of segmentation. Drag either end of the Ruler on the axial view to measure in millimetres. Hover anywhere to read a voxel's position and its T1 and T2 signal.
Here is the code for this viewer. Loading the volume is plain JavaScript; SciChart.js draws the slices, overlays, crosshairs and labels.
- JavaScript
- React
- Angular
// A brain MRI viewer: axial, coronal and sagittal slices of one volume as layered heatmaps (the greyscale image,
// plus a coloured threshold overlay), with linked crosshairs, window/level, labels, a ruler and a voxel readout
const {
SciChartSurface,
NumericAxis,
NumberRange,
EAutoRange,
UniformHeatmapDataSeries,
UniformHeatmapRenderableSeries,
HeatmapColorMap,
HorizontalLineAnnotation,
VerticalLineAnnotation,
LineAnnotation,
TextAnnotation,
ECoordinateMode,
EHorizontalAnchorPoint,
EVerticalAnchorPoint,
CustomChartModifier2D,
translateFromCanvasToSeriesViewRect,
Thickness,
SciChartJsNavyTheme
} = SciChart;
// or, for npm, import { SciChartSurface, ... } from "scichart"
const volumes = { t1: await decodeVolume(T1_WEBP), t2: await decodeVolume(T2_WEBP) };
const { size, voxelMm, origin } = VOLUME;
const stride = [1, size[0], size[0] * size[1]];
const state = {
sequence: "t1",
cursor: [46, 51, 41], // voxel indices: the crosshair position, and the slice each view shows
window: 255, // width of the intensity range mapped from black to white
level: 128, // centre of that range
overlay: false,
low: 200,
high: 255
};
const mm = (axis, index) => origin[axis] + index * voxelMm;
const signed = (value) => (value < 0 ? "−" : "+") + Math.abs(value).toFixed(1);
// Greyscale for the image; a warm colour map for the overlay
const greyStops = [
{ offset: 0, color: "#000000" },
{ offset: 1, color: "#FFFFFF" }
];
const overlayStops = [
{ offset: 0, color: "#FFD000" },
{ offset: 1, color: "#FF3D00" }
];
const views = [];
for (const plane of PLANES) {
const [u, v] = plane.axes;
const { sciChartSurface, wasmContext } = await SciChartSurface.create(ui.views[plane.key].chartDiv, {
theme: new SciChartJsNavyTheme(),
padding: Thickness.fromNumber(0)
});
const axisOptions = { isVisible: false, autoRange: EAutoRange.Never, drawMajorGridLines: false, drawMinorGridLines: false };
const xAxis = new NumericAxis(wasmContext, { ...axisOptions, flippedCoordinates: plane.flipX });
const yAxis = new NumericAxis(wasmContext, axisOptions);
sciChartSurface.xAxes.add(xAxis);
sciChartSurface.yAxes.add(yAxis);
// Layer 1, the MRI slice. One Float64Array per row of voxels; x and y are in millimetres, each cell one voxel.
const cells = { xStart: mm(u, -0.5), xStep: voxelMm, yStart: mm(v, -0.5), yStep: voxelMm };
const imageRows = Array.from({ length: size[v] }, () => new Float64Array(size[u]));
const imageData = new UniformHeatmapDataSeries(wasmContext, { ...cells, zValues: imageRows });
const imageColors = new HeatmapColorMap({ minimum: 0, maximum: 255, gradientStops: greyStops });
const imageSeries = new UniformHeatmapRenderableSeries(wasmContext, {
dataSeries: imageData,
colorMap: imageColors,
fillValuesOutOfRange: true, // below the window is black, above it white
useLinearTextureFiltering: true // smooth between voxel centres
});
// Layer 2, the overlay: voxels inside the threshold band keep their value, the rest are NaN (not drawn)
const overlayRows = Array.from({ length: size[v] }, () => new Float64Array(size[u]).fill(NaN));
const overlayData = new UniformHeatmapDataSeries(wasmContext, { ...cells, zValues: overlayRows });
overlayData.hasNaNs = true;
const overlayColors = new HeatmapColorMap({ minimum: state.low, maximum: state.high, gradientStops: overlayStops });
const overlaySeries = new UniformHeatmapRenderableSeries(wasmContext, {
dataSeries: overlayData,
colorMap: overlayColors,
fillValuesOutOfRange: true,
opacity: 0.55,
isVisible: false
});
sciChartSurface.renderableSeries.add(imageSeries, overlaySeries);
// Crosshair: where the other two planes cut this one, in their colours
const others = PLANES.filter((p) => p !== plane);
const lineFor = (other) => others.find((p) => p.axes[2] === other);
const vertical = new VerticalLineAnnotation({ x1: 0, stroke: lineFor(u).color, strokeThickness: 1, strokeDashArray: [4, 3] });
const horizontal = new HorizontalLineAnnotation({ y1: 0, stroke: lineFor(v).color, strokeThickness: 1, strokeDashArray: [4, 3] });
// Orientation letters at the edges of the view
const letter = (text, x, y, h, vAnchor) =>
new TextAnnotation({
text,
x1: x,
y1: y,
xCoordinateMode: ECoordinateMode.Relative,
yCoordinateMode: ECoordinateMode.Relative,
horizontalAnchorPoint: h,
verticalAnchorPoint: vAnchor,
fontSize: 14,
fontWeight: "bold",
textColor: "#FFFFFFCC"
});
sciChartSurface.annotations.add(
vertical,
horizontal,
letter(plane.letters[0], 0.01, 0.5, EHorizontalAnchorPoint.Left, EVerticalAnchorPoint.Center),
letter(plane.letters[1], 0.99, 0.5, EHorizontalAnchorPoint.Right, EVerticalAnchorPoint.Center),
letter(plane.letters[2], 0.5, 0.01, EHorizontalAnchorPoint.Center, EVerticalAnchorPoint.Top),
letter(plane.letters[3], 0.5, 0.92, EHorizontalAnchorPoint.Center, EVerticalAnchorPoint.Bottom)
);
// Structure labels: a dot at the point and the name beside it
const labels = STRUCTURES.filter((s) => s.views.includes(plane.key)).map((s) => {
const annotation = new TextAnnotation({
text: s.side === "right" ? `● ${s.name}` : `${s.name} ●`,
x1: s.at[u],
y1: s.at[v],
horizontalAnchorPoint: s.side === "right" ? EHorizontalAnchorPoint.Left : EHorizontalAnchorPoint.Right,
verticalAnchorPoint: EVerticalAnchorPoint.Center,
fontSize: 12,
textColor: "#FFFFFF",
background: "#00000099"
});
sciChartSurface.annotations.add(annotation);
return { structure: s, annotation };
});
const view = { plane, sciChartSurface, xAxis, yAxis, imageRows, imageData, imageSeries, overlayRows, overlayData, overlaySeries, vertical, horizontal, labels };
views.push(view);
sciChartSurface.chartModifiers.add(createViewModifier(view));
// Keep 1 mm the same size across and down, and leave room at the bottom for the watermark
sciChartSurface.layoutMeasured.subscribe(() => fitView(view));
const slider = ui.views[plane.key].slider;
slider.min = "0";
slider.max = String(size[plane.axes[2]] - 1);
slider.addEventListener("input", () => {
const cursor = [...state.cursor];
cursor[plane.axes[2]] = Number(slider.value);
moveCursor(cursor);
});
}
// A ruler on the axial view: drag either end to measure a distance in millimetres
const axial = views[0];
const ruler = new LineAnnotation({ x1: 45, y1: -76, x2: -45, y2: -76, stroke: "#FF4081", strokeThickness: 2, isEditable: true });
const rulerText = new TextAnnotation({
x1: 0,
y1: -76,
horizontalAnchorPoint: EHorizontalAnchorPoint.Center,
verticalAnchorPoint: EVerticalAnchorPoint.Bottom,
fontSize: 12,
textColor: "#FF80AB",
background: "#00000099"
});
function updateRuler() {
rulerText.x1 = (ruler.x1 + ruler.x2) / 2;
rulerText.y1 = Math.max(ruler.y1, ruler.y2) + 2;
rulerText.text = `${Math.hypot(ruler.x2 - ruler.x1, ruler.y2 - ruler.y1).toFixed(0)} mm`;
}
ruler.dragDelta.subscribe(updateRuler);
updateRuler();
axial.sciChartSurface.annotations.add(ruler, rulerText);
// --- Drawing: the heatmaps are refilled only when the slice, the sequence or the overlay band changes ---
function fillSlice(view) {
const [u, v, n] = view.plane.axes;
const volume = volumes[state.sequence];
const sliceStart = state.cursor[n] * stride[n];
for (let b = 0; b < size[v]; b++) {
const rowStart = sliceStart + b * stride[v];
const imageRow = view.imageRows[b];
const overlayRow = view.overlayRows[b];
for (let a = 0; a < size[u]; a++) {
const value = volume[rowStart + a * stride[u]];
imageRow[a] = value;
if (state.overlay) overlayRow[a] = value >= state.low && value <= state.high && value > 0 ? value : NaN;
}
}
view.imageData.setZValues(view.imageRows);
if (state.overlay) view.overlayData.setZValues(view.overlayRows);
}
function updateCrosshairAndLabels(view) {
const [u, v, n] = view.plane.axes;
view.vertical.x1 = mm(u, state.cursor[u]);
view.horizontal.y1 = mm(v, state.cursor[v]);
const slicePosition = mm(n, state.cursor[n]);
for (const { structure, annotation } of view.labels) {
annotation.isHidden = !ui.labels.checked || Math.abs(structure.at[n] - slicePosition) > 6;
}
const { plane } = view;
ui.views[plane.key].title.textContent =
`${plane.title} · ${AXIS_NAMES[n]} ${signed(slicePosition)} mm · slice ${state.cursor[n] + 1} of ${size[n]}`;
ui.views[plane.key].slider.value = String(state.cursor[n]);
}
function moveCursor(cursor) {
const previous = state.cursor;
state.cursor = cursor;
for (const view of views) {
const n = view.plane.axes[2];
if (cursor[n] !== previous[n]) fillSlice(view);
updateCrosshairAndLabels(view);
}
}
// Window/level: the colour map spans level ± window / 2, so only the colours change, not the data
function applyWindowLevel() {
for (const view of views) {
view.imageSeries.colorMap.minimum = state.level - state.window / 2;
view.imageSeries.colorMap.maximum = state.level + state.window / 2;
}
ui.windowValue.textContent = String(state.window);
ui.levelValue.textContent = String(state.level);
}
function applyOverlay() {
ui.bandValue.textContent = `${state.low}–${state.high}`;
for (const view of views) {
view.overlaySeries.isVisible = state.overlay;
view.overlaySeries.colorMap.minimum = state.low;
view.overlaySeries.colorMap.maximum = Math.max(state.high, state.low + 1);
if (state.overlay) fillSlice(view);
}
}
// Keep the image undistorted: the same number of millimetres per pixel across and down
function fitView(view) {
const rect = view.sciChartSurface.seriesViewRect;
if (!rect || rect.width < 2 || rect.height < 2) return;
const [u, v] = view.plane.axes;
const widthMm = size[u] * voxelMm;
const heightMm = size[v] * voxelMm;
const bottomMargin = 0.1; // the share of the height kept clear for the watermark
const mmPerPixel = Math.max(widthMm / rect.width, heightMm / (rect.height * (1 - bottomMargin)));
const centreX = mm(u, (size[u] - 1) / 2);
const centreY = mm(v, (size[v] - 1) / 2);
const halfWidth = (mmPerPixel * rect.width) / 2;
const usedHeight = mmPerPixel * rect.height * (1 - bottomMargin);
const xRange = new NumberRange(centreX - halfWidth, centreX + halfWidth);
const yRange = new NumberRange(centreY - usedHeight / 2 - mmPerPixel * rect.height * bottomMargin, centreY + usedHeight / 2);
const differs = (a, b) => Math.abs(a.min - b.min) > 0.01 || Math.abs(a.max - b.max) > 0.01;
if (differs(view.xAxis.visibleRange, xRange)) view.xAxis.visibleRange = xRange;
if (differs(view.yAxis.visibleRange, yRange)) view.yAxis.visibleRange = yRange;
}
// --- Mouse: click or drag to move the crosshair, scroll to step through slices, hover to read a voxel ---
function voxelUnderMouse(view, args) {
const point = translateFromCanvasToSeriesViewRect(args.mousePoint, view.sciChartSurface.seriesViewRect);
if (!point) return null;
const [u, v] = view.plane.axes;
const a = Math.round((view.xAxis.getCurrentCoordinateCalculator().getDataValue(point.x) - origin[u]) / voxelMm);
const b = Math.round((view.yAxis.getCurrentCoordinateCalculator().getDataValue(point.y) - origin[v]) / voxelMm);
if (a < 0 || a >= size[u] || b < 0 || b >= size[v]) return null;
const voxel = [...state.cursor];
voxel[u] = a;
voxel[v] = b;
return voxel;
}
function showReadout(view, voxel) {
if (!voxel) {
ui.readout.textContent = "Hover over a view to read a voxel. Click or drag to move the crosshair; scroll over a view to change its slice.";
return;
}
const index = voxel[0] * stride[0] + voxel[1] * stride[1] + voxel[2] * stride[2];
const [x, y, z] = [0, 1, 2].map((axis) => mm(axis, voxel[axis]));
const side = Math.abs(x) < 1.5 ? "midline" : x > 0 ? "patient's right" : "patient's left";
ui.readout.textContent =
`${view.plane.title} view · voxel (${voxel.join(", ")}) · x ${signed(x)}, y ${signed(y)}, z ${signed(z)} mm (${side}) · ` +
`T1 signal ${volumes.t1[index]}, T2 signal ${volumes.t2[index]} (0–255, arbitrary units)`;
}
function createViewModifier(view) {
let dragging = false;
class SliceViewModifier extends CustomChartModifier2D {
modifierMouseDown(args) {
super.modifierMouseDown(args);
const voxel = voxelUnderMouse(view, args);
if (voxel && args.button === 0) {
dragging = true;
moveCursor(voxel);
args.handled = true;
}
}
modifierMouseMove(args) {
super.modifierMouseMove(args);
const voxel = voxelUnderMouse(view, args);
if (dragging && voxel) moveCursor(voxel);
showReadout(view, voxel);
}
modifierMouseUp(args) {
super.modifierMouseUp(args);
dragging = false;
}
modifierMouseWheel(args) {
super.modifierMouseWheel(args);
const n = view.plane.axes[2];
const cursor = [...state.cursor];
cursor[n] = Math.min(size[n] - 1, Math.max(0, cursor[n] + (args.mouseWheelDelta > 0 ? -1 : 1)));
moveCursor(cursor);
showReadout(view, voxelUnderMouse(view, args));
args.handled = true;
if (args.nativeEvent) args.nativeEvent.preventDefault();
}
modifierMouseLeave(args) {
super.modifierMouseLeave(args);
dragging = false;
showReadout(view, null);
}
}
return new SliceViewModifier();
}
// --- Controls ---
for (const input of ui.sequenceInputs) {
input.addEventListener("change", () => {
state.sequence = input.value;
views.forEach(fillSlice);
});
}
ui.window.addEventListener("input", () => {
state.window = Number(ui.window.value);
applyWindowLevel();
});
ui.level.addEventListener("input", () => {
state.level = Number(ui.level.value);
applyWindowLevel();
});
ui.reset.addEventListener("click", () => {
state.window = 255;
state.level = 128;
ui.window.value = "255";
ui.level.value = "128";
applyWindowLevel();
});
ui.overlay.addEventListener("change", () => {
state.overlay = ui.overlay.checked;
applyOverlay();
});
for (const input of [ui.low, ui.high]) {
input.addEventListener("input", () => {
state.low = Math.min(Number(ui.low.value), Number(ui.high.value));
state.high = Math.max(Number(ui.low.value), Number(ui.high.value));
applyOverlay();
});
}
ui.labels.addEventListener("change", () => views.forEach(updateCrosshairAndLabels));
ui.ruler.addEventListener("change", () => {
ruler.isHidden = rulerText.isHidden = !ui.ruler.checked;
});
views.forEach(fillSlice);
views.forEach(updateCrosshairAndLabels);
applyWindowLevel();
showReadout(null, null);
import { SciChartReact } from "scichart-react";
import {
SciChartSurface,
NumericAxis,
NumberRange,
EAutoRange,
UniformHeatmapDataSeries,
UniformHeatmapRenderableSeries,
HeatmapColorMap,
SciChartJsNavyTheme
} from "scichart";
// One axial slice of a volume, drawn as a greyscale heatmap with a window and level
const initAxialSlice = async (rootElement: string | HTMLDivElement) => {
const { sciChartSurface, wasmContext } = await SciChartSurface.create(rootElement, {
theme: new SciChartJsNavyTheme()
});
// Your volume: voxel values, size [nx, ny, nz], voxel size in mm, and the slice to show
const { voxels, size, voxelMm, slice } = getYourVolume();
const [nx, ny] = size;
const rows = Array.from({ length: ny }, (_, j) =>
Float64Array.from({ length: nx }, (_, i) => voxels[i + j * nx + slice * nx * ny])
);
// Radiological convention: flip x so the patient's right is on the viewer's left
sciChartSurface.xAxes.add(
new NumericAxis(wasmContext, {
isVisible: false,
flippedCoordinates: true,
autoRange: EAutoRange.Never,
visibleRange: new NumberRange(0, nx * voxelMm)
})
);
sciChartSurface.yAxes.add(
new NumericAxis(wasmContext, { isVisible: false, autoRange: EAutoRange.Never, visibleRange: new NumberRange(0, ny * voxelMm) })
);
const level = 128;
const window = 255;
sciChartSurface.renderableSeries.add(
new UniformHeatmapRenderableSeries(wasmContext, {
dataSeries: new UniformHeatmapDataSeries(wasmContext, { xStart: 0, xStep: voxelMm, yStart: 0, yStep: voxelMm, zValues: rows }),
colorMap: new HeatmapColorMap({
minimum: level - window / 2,
maximum: level + window / 2,
gradientStops: [
{ offset: 0, color: "#000000" },
{ offset: 1, color: "#FFFFFF" }
]
}),
fillValuesOutOfRange: true,
useLinearTextureFiltering: true
})
);
return { sciChartSurface };
};
// Keep the container's width:height equal to the slice's (nx:ny) so the image isn't stretched
export const MriSlice = () => <SciChartReact initChart={initAxialSlice} style={{ width: 400, height: 470 }} />;
import { Component } from "@angular/core";
import { ScichartAngularComponent } from "scichart-angular";
import {
SciChartSurface,
NumericAxis,
NumberRange,
EAutoRange,
UniformHeatmapDataSeries,
UniformHeatmapRenderableSeries,
HeatmapColorMap,
SciChartJsNavyTheme
} from "scichart";
// One axial slice of a volume, drawn as a greyscale heatmap with a window and level
const initAxialSlice = async (rootElement: string | HTMLDivElement) => {
const { sciChartSurface, wasmContext } = await SciChartSurface.create(rootElement, {
theme: new SciChartJsNavyTheme()
});
// Your volume: voxel values, size [nx, ny, nz], voxel size in mm, and the slice to show
const { voxels, size, voxelMm, slice } = getYourVolume();
const [nx, ny] = size;
const rows = Array.from({ length: ny }, (_, j) =>
Float64Array.from({ length: nx }, (_, i) => voxels[i + j * nx + slice * nx * ny])
);
// Radiological convention: flip x so the patient's right is on the viewer's left
sciChartSurface.xAxes.add(
new NumericAxis(wasmContext, {
isVisible: false,
flippedCoordinates: true,
autoRange: EAutoRange.Never,
visibleRange: new NumberRange(0, nx * voxelMm)
})
);
sciChartSurface.yAxes.add(
new NumericAxis(wasmContext, { isVisible: false, autoRange: EAutoRange.Never, visibleRange: new NumberRange(0, ny * voxelMm) })
);
const level = 128;
const window = 255;
sciChartSurface.renderableSeries.add(
new UniformHeatmapRenderableSeries(wasmContext, {
dataSeries: new UniformHeatmapDataSeries(wasmContext, { xStart: 0, xStep: voxelMm, yStart: 0, yStep: voxelMm, zValues: rows }),
colorMap: new HeatmapColorMap({
minimum: level - window / 2,
maximum: level + window / 2,
gradientStops: [
{ offset: 0, color: "#000000" },
{ offset: 1, color: "#FFFFFF" }
]
}),
fillValuesOutOfRange: true,
useLinearTextureFiltering: true
})
);
return { sciChartSurface };
};
@Component({
selector: "app-mri-slice",
standalone: true,
imports: [ScichartAngularComponent],
// Keep the container's width:height equal to the slice's (nx:ny) so the image isn't stretched
template: `<scichart-angular [initChart]="initChart" style="display: block; width: 400px; height: 470px"></scichart-angular>`
})
export class MriSliceComponent {
initChart = initAxialSlice;
}
Key points:
- Each view is a
UniformHeatmapRenderableSeries: oneFloat64Arrayper row of voxels, withxStepandyStepset to the voxel size, so the axes are in millimetres. Slices are copied into the same arrays and sent withsetZValuesonly when the slice, the sequence or the overlay changes. - Window and level are the
minimumandmaximumof theHeatmapColorMap(level ± window ÷ 2) withfillValuesOutOfRange, so changing contrast recolours the image without touching the data. - The overlay is a second heatmap on top, partly transparent, with NaN for voxels outside the threshold band, which aren't drawn.
- A custom chart modifier turns mouse positions into voxel indices for the crosshair, the scroll-through-slices behaviour and the readout. Crosshairs, labels and the editable ruler are
VerticalLineAnnotation,HorizontalLineAnnotation,TextAnnotationandLineAnnotation. The x-axis is flipped (flippedCoordinates) for the radiological convention, and the axis ranges are refitted on layout so a millimetre is the same size across and down.
See it in the demo app: JavaScript heatmap chart · React heatmap chart · Angular heatmap chart.
Go deeper: SciChart.js heatmap documentation, heatmap colour maps, annotations and custom chart modifiers. For what a heatmap is and how to read one, see the heatmap guide. For how medical device makers and researchers use SciChart, see SciChart for medical charts and dashboards.
Frequently asked questions
How do you read an MRI scan?
Find the plane and the orientation markers first: in axial and coronal views the patient's right is on the viewer's left. Then work out the sequence from the fluid in the ventricles, which is dark on T1 and bright on T2. Scroll through every slice, compare left with right, and check the same spot in the other planes. Only a radiologist interprets a scan for diagnosis, so read the radiologist's report with your doctor.
What is the difference between T1 and T2 MRI?
T1-weighted and T2-weighted images are two settings of the same scanner that make different tissues bright. On T1, fat is bright and water is dark, and white matter is brighter than grey matter, so it is good for anatomy and for gadolinium contrast. On T2, water and fluid are bright, so it shows oedema, cysts and most changes that add water to tissue.
How can you tell if an MRI image is T1 or T2?
Look at the cerebrospinal fluid in the ventricles in the middle of the brain. Dark fluid with white matter brighter than grey matter means T1. Bright fluid with grey matter brighter than white matter means T2. Dark fluid with grey matter brighter than white matter usually means FLAIR, a T2-weighted sequence that cancels the fluid signal. The series name in the viewer, such as AX T2 FLAIR, also says.
What do axial, sagittal and coronal mean on an MRI?
They are the three planes a scan is sliced in. Axial slices are horizontal and separate the top of the body from the bottom. Sagittal slices are vertical and separate left from right, giving a side view. Coronal slices are vertical and separate front from back, giving a face-on view.
What is the difference between MRI and CT?
CT uses X-rays, which are ionising radiation, and takes seconds to a few minutes; it is the usual first test in emergencies because it shows bleeding, fractures and bone quickly. MRI uses a magnetic field and radio waves with no ionising radiation, takes longer and is noisier, and shows soft tissue such as the brain and spinal cord in more detail. Some implants rule out MRI but not CT.
How do I display MRI slices in JavaScript?
Load the volume as an array of voxel intensities, copy one slice into a 2D array of rows, and draw it as a heatmap with a greyscale colour map whose minimum and maximum set the window and level. Keep the millimetres per pixel equal on both axes so the image isn't stretched. SciChart.js does this with UniformHeatmapRenderableSeries and HeatmapColorMap, and can add overlays, annotations and linked views.
Sources
- RadiologyInfo.org (RSNA and ACR), Magnetic resonance imaging (MRI) – head (reviewed 2026). How a brain MRI is made, no ionising radiation, implants, and the radiologist's report.
- RadiologyInfo.org (RSNA and ACR), Contrast materials (reviewed 2024). How gadolinium works, allergic-type reactions, nephrogenic systemic fibrosis and retention.
- RadiologyInfo.org (RSNA and ACR), Computed tomography (CT) – head (reviewed 2026). CT's speed, its use for bleeding in emergencies, and implants.
- National Institute of Biomedical Imaging and Bioengineering (NIH), Magnetic resonance imaging (MRI). Protons, the RF pulse, relaxation and contrast agents.
- US Food and Drug Administration, MRI (magnetic resonance imaging). Signal mainly from protons in fat and water.
- Plewes, D. B. and Kucharczyk, W. (2012), Physics of MRI: a primer. Journal of Magnetic Resonance Imaging, 35(5). Resonance, T1 and T2 relaxation, gradients, spatial encoding and image contrast.
- Bitar, R. et al. (2006), MR pulse sequences: what every radiologist wants to know but is afraid to ask. RadioGraphics, 26(2). TR, TE, T1 and T2 weighting, proton density, inversion recovery (FLAIR, STIR) and gradient-echo sequences.
- Zhuo, J. and Gullapalli, R. P. (2006), MR artifacts, safety, and quality control. RadioGraphics, 26(1). Motion, susceptibility, wrap-around, chemical shift and truncation artefacts.
- Gulani, V. et al. (2017), Gadolinium deposition in the brain: summary of evidence and recommendations. The Lancet Neurology, 16(7).
- Nyúl, L. G. and Udupa, J. K. (1999), On standardizing the MR image intensity scale. Magnetic Resonance in Medicine, 42(6). MRI intensities have no standard scale.
- NiBabel documentation, Radiological vs neurological conventions. How the two display conventions differ.
- DICOM Standards Committee, About DICOM; NIfTI Data Format Working Group, NIfTI-1 data format.
- Fonov, V. et al. (2011), Unbiased average age-appropriate atlases for pediatric studies. NeuroImage, 54(1); and the ICBM 152 nonlinear 2009 templates (McConnell Brain Imaging Centre, McGill University), the data in the viewer.