added detrend and spectral estimation