Spatio-temopral wavelet analysis - matlab

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.

Related

feature extraction for machine learning

Looking for some advice. I am playing around with an accelerometer, combined with the machine learning app in matlab. Clearly there are many ways to extract features from the received data, both in time and frequency domains. However, I have recently come across time-frequency analysis, specifically using wavelets.
Has anyone got any advice on using wavelet analysis for classifying accelerometer (or similar) data and the benefits of using it ? Or if indeed this would be a valid way of extracting features ? I'm not too sure what sort of data I should be extracting using this method ?
Thanks in advance.
Few points to note,
1)You can transform a number of samples (should be a dyadic number and depends on your sampling frequency) into wavelet domain and classify that data. (eg. if you transform 64 accelerometer samples then you also have 64 points in wavelet domain).
2) Apart from time-frequency information from wavelet transformation, wavelet transformation has sparsity property
(https://en.wikipedia.org/wiki/Sparse_approximation) that would be useful for your classification model.
3) Also, you can try different wavelet basis functions (mother wavelets),
and try to figure out which basis is most suitable for your data. Maybe you can start with Haar basis function as it is more suitable to capture the singular behaviour of your data.

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.

Statistical features of wavelet transform

Please could anyone explain what is meant by the following, and how I can find this using MATLAB? Any help would be appreciated.
Statistical features of wavelet transform
Statistical features can be any statistical value like mean, entropy, power, power over frequency band. This statement means using a wavelet transform calculate statistical feature of signal.
An example of it would be like generating a wavelet transform for transient detection. Now transient is a jump in signal it can be from custom statistical feature like change_in_amplitude/change_in_frequency.

wavelet denoising routine using the wden functions in 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

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.