a, Schematic of sensor assemblies comprising two parallel disks magnetized by applied MRI field (blue arrow) and separated by stimuli-responsive hydrogel spacers (yellow). Resulting magnetic fields (gray curves) are uniform between the disks and locally shift NMR frequencies of water passing through proportionally to the field magnitude, which depends on disk spacing, d. Different frequency shifts represent different effective RF “colours”. b, Scanning electron micrograph (SEM) of sensors. (Interspersed features are non-magnetic residual topography from the microfabrication process). c, Theoretical precession frequency (or equivalently, field) histograms, mimicking NMR spectra, for 60-nm thick, 1-μm radii nickel disk pairs with disk spacings indicated. Background water appears at zero offset; shifted peaks result from uniform field regions between the disks. Inset: frequency offset versus disk spacing for nickel and iron disks with thicknesses shown. Dashed black curves are analytic approximations (text eq. 1); red curves result from numerical field simulations. d, Experimental NMR z-spectra for nickel (top) and iron (bottom) sensors with hydrogel spacers in compressed and expanded states. e, Experimental pH-dependent NMR shifts for nickel-based sensors containing pH-sensitive hydrogel spacers designed to shrink (expand) at low (high) pH with peak sensitivity in the physiological pH range.