The second step of spatial localization is called phase encoding. A magnetic gradient field is applied briefly in the direction of the columns (Oy). As the change in frequency is very brief, when the gradient is switched off, it causes a change in phase that is proportional to the distance. The protons in the same row have the same phase. The protons in the same column have different phases.
Spatial localization in the phase encoding direction requires many steps. In a standard spin echo, the number of phase-encoding steps is equal to the number of lines in the matrix. Each step is performed with an incremental change in the strength of the phase encoding gradient.
NB: In the following animation, the signals of each row are drawn separately to show the phase shift. The actual recorded signal is a mix of all these signals.