A more general and statistically robust spectral analysis method