Denoising of non-stationary signals using optimized Karhunen-Loeve expansion