I understand that the rank of a positive semi-definite matrix is equal to the number of non-zero singular values of the matrix.
$$\operatorname{rank}(M) = \{ \sigma \mid \sigma \ne 0 \}$$
This is somehow related to the spectral decomposition (or singular value decomposition, as some call it), but I cannot figure out how.
This question touches on that, but I cannot figure out the relationship:
How does the rank of a PSD matrix being equal to number of nonzero eigenvalues, follow from the spectral decomposition?