Final answer:
Gradient coils are used for spatial encoding in an MRI machine by varying the main magnetic field to alter proton resonant frequencies for location mapping.
Step-by-step explanation:
The coils that are used in the spatial encoding of an MR image are B) Gradient coils. These coils are essential in an MRI machine as they are specifically designed to vary the main magnetic field at different locations within the scanner. This variation allows the magnetic resonance of protons to be spatially encoded, which is crucial for creating an image that can map out tissue structures. The varying magnetic fields alter the resonant frequency of protons in the body depending on their position, allowing for precise location information to be gathered when the protons reemit absorbed radio waves.