The diffusion-weighted magnetic resonance imaging (dMRI) signal measured in vivo arises from multiple diffusion domains, including hindered and restricted water pools, free water and blood pseudo-diffusion. Not accounting for the correct number of components can bias metrics obtained from model fitting because of partial volume effects that are present in, for instance, diffusion tensor imaging (DTI) and diffusion kurtosis imaging (DKI). Approaches that aim to overcome this shortcoming generally make assumptions about the number of considered components, which are not likely to hold for all voxels. The spectral analysis of the dMRI signal has been proposed to relax assumptions on the number of components. However, it currently requires a clinically challenging signal-to-noise ratio (SNR) and accounts only for two diffusion processes defined by hard thresholds. In this work, we developed a method to automatically identify the number of components in the spectral analysis, and enforced its robustness to noise, including outlier rejection and a data-driven regularization term. Furthermore, we showed how this method can be used to take into account partial volume effects in DTI and DKI fitting. The proof of concept and performance of the method were evaluated through numerical simulations and in vivo MRI data acquired at 3 T. With simulations our method reliably decomposed three diffusion components from SNR = 30. Biases in metrics derived from DTI and DKI were considerably reduced when components beyond hindered diffusion were taken into account. With the in vivo data our method determined three macro-compartments, which were consistent with hindered diffusion, free water and pseudo-diffusion. Taking free water and pseudo-diffusion into account in DKI resulted in lower mean diffusivity and higher fractional anisotropy values in both gray and white matter. In conclusion, the proposed method allows one to determine co-existing diffusion compartments without prior assumptions on their number, and to account for undesired signal contaminations within clinically achievable SNR levels.