CT and MRI lab
CT reconstruction from scratch (projections, sinograms, Poisson noise, back-projection, FBP and SART), Hounsfield units with window/level, k-space masking, MRI spin-echo contrast, and how a segmentation threshold moves a measured dimension.
Added
How to use it
Educational — not a medical device. Not for diagnosis, treatment, monitoring or dosing. Simulation only. Every image here is a synthetic phantom. To practise on real scans, use public, de-identified data such as The Cancer Imaging Archive (TCIA) or the sample data in 3D Slicer; an image you load in the k-space tab is processed only in your browser and never uploaded.
Companion to Chapter 16 (diagnostic devices) and Chapter 15 (measurement and imaging) of Human Biology for the Medical Maker. The book calls a CT reconstruction from scratch one of its three best projects; the first three tabs are that project.
How to use it
-
Projection puzzle — the book’s hand exercise. Edit the 3 × 3 grid of digits; the tool shows the row and column sums, the corner diagonals, and every diagonal ray, then counts how many of the 10⁹ possible grids fit each set of measurements (rows and columns alone usually allow dozens to hundreds). Hide the object gives you only the sums to rebuild it from, and checks your guess against each set.
-
Sinogram — choose a phantom (modified Shepp–Logan head, a water disc with low-contrast inserts, resolution bars and dots, a single point, or water with two metal pins), the number of projection angles over 180°, and the photons per ray. Each reading is an exact line integral through the shapes; Beer–Lambert gives the expected count, a Poisson draw the measured one, and −ln(N/I₀) the noisy line integral. Tap a sinogram row to plot that projection.
-
Reconstruction — unfiltered back-projection (a 1/r blur), filtered back-projection with Ram–Lak, Shepp–Logan, cosine or Hann filters, and SART (iterative: project the current guess, compare, correct, one angle at a time). All three shows them side by side. You get the error image, a profile through any row, RMS error and the noise σ. Measure noise against counts reconstructs nine noisy sinograms from 10³ to 10⁷ photons per ray and fits the slope on a log–log plot: about −½, the √N law.
-
Hounsfield units — HU = 1000 × (μ − μwater) / (μwater − μair) with μ for water, air and cortical bone from NIST; the DICOM rescale (stored × slope + intercept); the book’s HU table (Show tints the pixels in that band); and a window/level viewer on synthetic head and chest slices with the book’s presets — brain 40/80, soft tissue 40/400, lung −600/1500, bone 400/2000. The probe reads stored HU, a 5 × 5 mean ± SD, and the grey level the window happens to show; the histogram shows the window as a ramp over the stored values.
-
k-space — a 2-D FFT of a phantom, a test pattern, or your own image; keep everything, the centre only, the edges only, every other line (aliasing), or random lines, and see what is left.
-
MRI — the Larmor frequency f = 42.58 MHz/T × B₀, and spin-echo contrast S ∝ PD (1 − e−TR/T1) e−TE/T2 for the book’s T1/T2 table with TR and TE sliders, signal-against-TE and signal-against-TR curves, and a synthetic brain slice. Where the book gives a range (white and grey matter T1), the signal is shown as a range.
-
Segmentation threshold — a slab of bone (+1200 HU) in soft tissue (+40 HU), blurred by the scanner and averaged into voxels. Move the threshold, voxel size, blur and grid position and watch the measured width move; the width-against-threshold plot and the three-threshold table give the spread the chapter 15 exit criterion asks for, and a claim check repeats the book’s rule: a 5 mm slice cannot support a 0.5 mm claim.
⛶ Full screen (or F) gives the images of the Sinogram, Reconstruction and k-space tabs the
whole screen — the browser’s full screen where it is allowed, otherwise a full-window layer (iPhone);
each image is scaled to fit and taps still land on the right pixel. ◫ Panels shows or hides the tab’s
settings (hidden at first, so the images get the room). Escape leaves.
Links open a tab directly with the hash, for example #recon, #sinogram, #hu, #kspace, #mri, #seg or #puzzle.
Where the numbers come from
-
Hounsfield table, window presets, T1/T2 table, γ̄ = 42.58 MHz/T, the √N law and the worked examples (3 T → 128 MHz; +50 HU soft tissue, −80 HU fat, +1200 HU cortical bone): Chapter 16.
-
μ/ρ for water (0.2059 cm²/g at 60 keV, 0.1707 at 100 keV), dry air (0.1875, 0.1541) and cortical bone, ICRU-44 (0.3148, 0.1855): NIST X-ray mass attenuation coefficients (Hubbell and Seltzer), times density (air 1.205 × 10⁻³, bone 1.92 g/cm³).
-
Grey matter 40 HU and white matter 30 HU in the synthetic head: Radiopaedia, “Hounsfield unit”.
-
Phantom: the modified (higher-contrast) Shepp–Logan head phantom, read as μ in cm⁻¹ across a 20 cm field of view.
-
Filters: the band-limited ramp in Kak and Slaney’s spatial-domain form (Principles of Computerized Tomographic Imaging), times a window.
Limits
-
Parallel-beam, monoenergetic, 2-D. No fan beam, helical scanning, scatter, beam hardening or detector blur; the only noise is Poisson counting noise.
-
A ray that loses every photon is read as half a count, so metal streaks appear but are not modelled in detail.
-
The HU and MRI phantoms are cartoons with textbook values, not anatomy. The MRI signal is a single spin echo with no noise, coil, or field effects; proton densities default to 1 because the book gives none.
-
The segmentation model is one-dimensional with a Gaussian blur; real surfaces are 3-D and the blur differs in-plane and through the slice.
-
Values in the tables are orientation only. Nothing here labels a person’s tissue or a real scan.
Related: spectrum analyser (1-D FFTs and windows), Fourier series, ultrasound, Doppler and dose numbers (√N counting noise, Beer–Lambert), statistics.
Feedback is a gift. Something to improve, a feature to add, or a bug? Tell me.
Runs entirely in your browser; nothing you type leaves this page.