A general formalism for the analysis of NMR relaxation measurements on systems with multiple degrees of freedom