wavelet denoising routine using the wden functions in matlab - matlab

I was reading a report today which looked at measuring heat storage of a lake from temperature measurements where to reduce the the impacts of temperature fluctuations that can confound estimates of short-term changes in heat storage, a wavelet de-noising routine was used (daubechies 4 wavelet, single rescaling, min/max thresholds used on the wden function in the wavelet toolbox) where 2 levels of wavelet filtering was applied. This technique results in smoother temporal variations in water temperature, while preserving patterns of diurnal heat gain and loss.
From this description, consider that my temperature measurements are similar to
load sumsin;
s = sumsin;
plot(s);
How would I apply the techniques described using the wden functions in matlab.
Apologies for the vagueness of this post, but seeing as I am clueless on how to complete this task I would be very greatfull for some advice.

I assume you're talking about de-noising by thresholding the detail coefficients of the wavelet transform. wden does do this. You've not specified however whether it is hard or soft thresholding.
For not wanting to reproduce matlab's help here,
help wden
Will give you what you need on how to use the function. Given the information you've provided, and the assumption that soft thresholding is appropriate; (as it is with most methods except Donoho's Visushrink, referred to by wden as 'sqtwolog')
[s_denoised, ~, ~] = wden(s, 'minimaxi', 's', 'sln', 2, 'db4');
Should give you what you want. This does also assume you're not interested in the decomposed wavelet tree

Related

MATLAB program to estimate the energy spectrum

MATLAB program to estimate the energy spectrum by non-parametric and parametric methods in the case of EEG signals from epilepsy patients with focal and non-focal area recordings
I have to do this and I have no idea where to start. I have this reference link, https://www.upf.edu/web/ntsa/downloads/-/asset_publisher/xvT6E4pczrBw/content/2012-nonrandomness-nonlinear-dependence-and-nonstationarity-of-electroencephalographic-recordings-from-epilepsy-patients?inheritRedirect=false&redirect=https%3A%2F%2Fwww.upf.edu%2Fweb%2Fntsa%2Fdownloads%3Fp_p_id%3D101_INSTANCE_xvT6E4pczrBw%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26p_p_col_id%3Dcolumn-1%26p_p_col_count%3D1#.X751wmUzaUk
If someone can give me some advice, please.
I have done both. The Signal Processing Toolbox and System Identification Toolbox documentation is very good on this topic.
Here is a paper I published on this topic. It is about point process rather than continuous signals, but it does have sections on parametric versus non-parametric spectrum analysis.
Non-parametric is the normal way. If your algorithm uses the fast Fourier transform, it is non-parametric.
Parametric means poles-and-zeroes type models. Spectra estimated non-parametrically tend to be a lot smoother than non-parametric. A key question that arises in parametric estimation which does not arise in non-parametric is what model structure to use and what model order. In non-paramtric, those questions do not arise. There are ways to answer those questions. The Akaike information criterion (AIC) is a standard way to answer the question about model order, although there are certainly alternatives to AIC which are better in some situations.
As you read the documentation, you will see numerous references to 'estimation'. This may seem strange at first, but it is a very important concept: wen you determine the spectrum from a signal, whether you do it parametrically or non-parametrically, you are estimating the true underlying spectrum, based on a sample of the process. The data you recorded is that sample.

Fourier transform and filtering the MD trajectory data instead of PCA for dimensionality reduction?

I was using PCA for dimensionality reduction of MD (molecular dynamics) trajectory data of some protein simulations. Basically my data is xyz coordinates of protein atoms which change with time (that means I have lot of frames of this xyz coordinates). The dimension of this data is something like 20000 frames of 200x3 (atoms by coordinates). I implemented PCA using princomp command in Matlab.
I was wondering if I can do FFT on my data. I have experience of doing FFT on audio signals (1D signal). Here my data has both time and space in picture. It must be theoretically possible to implement FFT on my data and then filter it using a LPF (low pass filter). But I am unsure.
Can someone give me some direction/code snippets/references towards implementing FFT on my data?
Why people are preferring PCA more often compared to FFT and filtering. Is it because of computational efficiency of algorithm or is it because of the statistical nature of underlying data?
For the first question "Can someone give me some direction/code snippets/references towards implementing FFT on my data?":
I should say fft is implemented in matlab and you do not need to implement it by your own. Also, for your case you should use fftn (fft documentation)to transform and after applying lowpass filtering by dessignfilt (design filter in matalab), the apply ifftn (inverse fft in matlab)to inverse the transform.
For the second question "Why people are preferring PCA more often compared to FFT and filtering ...":
I should say as the filtering in fft is done in signal space, after filtering you can't generalize it in time space. You can more details about this drawback in this article.
But, Fourier analysis has also some other
serious drawbacks. One of them may be that time
information is lost in transforming to the frequency
domain. When looking at a Fourier transform of a
signal, it is impossible to tell when a particular event
has taken place. If it is a stationary signal - this
drawback isn't very important. However, most
interesting signals contain numerous non-stationary or
transitory characteristics: drift, trends, abrupt changes,
and beginnings and ends of events. These
characteristics are often the most important part of the
signal, and Fourier analysis is not suitable in detecting
them.

Implemeting low-pass Daubechies wavelet filters in matlab

I have been trying to implement these two filters in MATLAB:
Daubechies 4 undecimated wavelet 3.75 Hz e wavelet 7.5Hz
Daubechies 4 undecimated filter bank 7.5 Hz
I have massively researched the wavelet toolbox and I still can't figure out what is the correct implementation of the algorithm, as well as the definition of the cut-off frequencies.
Does someone have experience with this?
What I tried was:
movementOut = movementIn;
% Set Daubechies wavelet name.
wname = strcat('db',num2str(order));
% Compute the corresponding scaling filter.
daubechies=dbwavf(wname);
movementOut = filter(daubechies,1,coordinates_values);
%movementOut = filtfilt(daubechies,1,coordinates_values);
I tried both filter and filtfilt but the output result seems pretty much similar. I am processing Kinect Z data (varying from 4.5m to 1.0m and then again to 4.5m) but I don't seem to see any difference using wavelets. In state-of-art approaches, the db4 wavelets are being often used.
Doubts:
is this implementation correct?
how can I set the cut-off frequency?
how to implement the filter bank?
Thanks in advance.
It's not super clear to me what you want to do but you need to use wavelet filters in wavelet algorithms. Do you have the wavelet toolbox? It has good documentation!
Wavelet transforms do band-pass filtering, so you may want to use another algorithm for your purpose. To see what would be 3.75 Hz or 7.50 Hz in your signal, you can compute the upper and lower bounds, if you know the sampling rate of your input.
Have a look at this post, which provides some links to matlab scripts for fast wavelet transforms (a sequence of filtering and up-/downsampling combinations) you can use if you don't have the wavelet toolbox.
Mind you, the fast wavelet transform does use downsampling so it is not 'undecimated'. There are a number of ways to do that, in the wavelet toolbox, in WaveLab and other places (see this paper for an overview). Some more reading may be a good idea, the references in that paper should do the trick.
One final warning: the name db4 is sometimes used for the filters with 4 coefficients (2 vanishing moments), and sometimes for the filters with 4 vanishing moments (8 coefficients)! Google "Daubechies 4" and you'll find both.

Spatio-temopral wavelet analysis

Am quite new to wavelet analysis as well as stackoverflow and would wold like some help. I am performing a spatio-temporal analysis of rainfall data.
With PCA, I can reduce the dimension of the rainfall data into a few leading modes, yielding EOFs (which explain spatial variability)
and principal components (explaining temporal variability).
I would like to perform a similar analysis with wavelets using Matlab Wavelet Toolbox. As of now, I am able to decompose a 2D data (spatial decomposition)
but unable to take into account the temporal variability in the data.
My first course of action has been to first compress the data with PCA and then perform wavelet decomposition of the leading modes in both the
spatial (EOFs) and temporal (PCs) domain.
I am wondering if this is the right way to perform such an analysis and would like suggestions as to how to proceed.
Thanks alot.

Power spectrum from autocorrelation function with MATLAB

I have some dynamic light scattering data. The machine pumps out the autocorrelation function, and a count-rate.
I can do a simple fit to the ACF
ACF = exp(-D*q^2*t)
and obtain the diffusion coefficient.
I want to obtain the same D from the power spectrum. I have been able to create a power spectrum in two ways -- from the Fourier transform of the ACF, and from the count rate. Both agree, but the power spectrum does not look like in the one in the books, so I'm not sure how to use it to work out the line width.
Attached is an image from a PDF that shows what you should get, and what I get from MATLAB. Can anyone make sense of whats going on?
I have used the code of answer #3 on this question. The resulting autocorrelation comes out exactly the same as
the machine gives me and
using MATLAB's autocorr command on the photoncount data.
Thank you for your time.
When you compute the Fourier transform from short sequences of data it often looks very noisy. There are a number of reasons for this. One reason is that the statistics of individual Fourier components are not Gaussian, and so averaging the spectra across multiple samples of data will only slowly improve the quality of the estimate.
Another causes of "noisiness" in empirical spectra behavior is that you are applying (to a finite data sample) a transform which involves a pathological sinc function and which assumes an infinite length signal. To diminish this problem, it helps to apply a "windowing-function" to your data before computing the Fourier transform. One of the more complicated but also more powerful windowing approaches is the use of so-called 'Slepian tapers'.
MATLAB conveniently implements well-known windows in functions such as hamming and hann.