MRI works based on the principles of nuclear magnetic resonance (NMR). When a patient is placed inside an MRI machine, the magnetic field aligns the protons in the body's hydrogen atoms. Radio waves are then pulsed through the body, causing these protons to produce signals. The MRI machine detects these signals and a computer processes them to create detailed images.