MATLAB - Wavelet coefficient based QRS complex classifier - matlab

I am new to Wavelet field and I wanted to ask you for a help for an idea.
I am supposed to create QRS complex (certain part of ECG signal wave) wave morphology classifier based on Wavelets in other words, I am supposed to create classifier which will separate waves with similar wave shape to categories, like bins in statistics, but based on signal wavelet coefficients.
I tried MATLAB mdwtdec and used wavelet coefficients on certain level as an input for classifier which calculates distance from each QRS and according to threshold separates to classes.
This approach is rather naive and I guess in order to improve it, I need some other idea or hint.

Related

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.

Discriminant analysis method to classify data

my aim is to classify the data into two sections- upper and lower- finding the mid line of the peaks.
I would like to apply machine learning methods- i.e. Discriminant analysis.
Could you let me know how to do that in MATLAB?
It seems that what you are looking for is GMM (gaussian mixture model). With K=2 (number of mixtures) and dimension equal 1 this will be simple, fast method, which will give you a direct solution. Given components it is easy to analytically find a local minima (which is just a weighted average of means, with weights proportional to the std's).

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.

How to find the correlation between scatter data and theoretical formula MATLAB?

I'm working on my thesis project on financial mathematics. One problem I'm having is that I want to find out if there is some correlation between a theoretical curve and scatter point data.
Here is the scatter data and the theoretical curve that I have.
Is there some easy way of doing this?
Bivariate correlation (usually Pearson correlation) is a statistic that measures linear dependence between two sets of data. The theoretical curve of your link does not seem to consist of discrete data points, therefore it is not possible to calculate correlation between it a and some set of data.
Depending on the model and the research question you have, you might be interested in analyzing the fit of your data to the model, using multivariate regression analysis or general[ized] linear model. These MATLAB commands could be useful: regress (multiple linear regression), regstats (regression diagnostics), glmfit (generalized linear model regression) and glmval (generalized linear model values).

ROC curve from the result of a classification or clustering

Say that I've clustered a training dataset of 5 classes containing 1000 instances, to 5 clusters (centers) using for example k-means. Then I've constructed a confusion matrix by validating on a test dataset. I want then to use plot a ROC curve from this, how is it possible to do that ?
Roc Curves show trade-off between True Positive and False Positive Rate. In other words
ROC graphs are two-dimensional graphs in which TP rate is plotted on
the Y axis and FP rate is plotted on the X axis
ROC Graphs: Notes and Practical Considerations for Researchers
When you use a discrete classifier, that classifier produces only a single point in ROC Space. Normally you need a classifier which produces probabilities. You change your parameters in classifier so that your TP and FP rates change. After that you use this points to draw a ROC curve.
Lets say you use k-means. K-means give you cluster membership discretely. A point belongs to ClusterA or .. ClusterE. Therefore outputting ROC curve from k-means is not straightforward. Lee and Fujita
describes an algorithm for this. You should look to their paper. But algorithm is something like this.
Apply k-means
calculate TP and FP using test data.
change membership of data points from one cluster to second cluster.
calculate TP and FP using test data again.
As you see they get more points in ROC space and use these points to draw ROC curve