MRI uses strong magnetic fields and radio waves to produce detailed images of the inside of the body. Protons in the body align with the magnetic field, and radio waves excite the protons causing them to emit signals. The signals are detected by coils and used to construct an image on a computer. Different tissues can be distinguished based on proton density and relaxation times after excitation. Gradient fields are used to localize the source of the signals within the body.