DSPRelated.com
Forums

Finding the percentage of similiarity of two signals in matlab

Started by ryan81 September 1, 2005
Hi all,
 
I understand the subject of similiarity of signals has dsicuss many of
times in this forum however i still need some valuable advice and help.

My problem is that i am trying to find the percentage of similiarity of 2
signals using matlab? 

Say in matlab i have just a variable called signal1 and signal2 both of
size [1 by 5000] these signal 1 and signal 2 are EEG signals. I just want
to know how similiar these two EEG signals are with each other on a sclae
of 0% to 100%. 

I do not think matlab commands corrcoef and xcorr are of relevance to me
because i want to maintain the length of [1 by 5000] as i need the same
array length to plot against the time and freq which are both of [1 by
5000] too. xcorr gives 2N + 1 array and the process is a convolution kind
except one part of the signal is not reversed. I believe that the
convoluted results will not aid me at all, am i right?

Further more, coffcoef just gives the coefficient and this not useful to
me at all.

I have seen someone mentioning that we need to find the coeffcients using
LPC and then to do a threshold testing. How does this LPC works as i know
they are used in audio processing, is this releveant to my EEG signals?
 
Pls if u have any idea or methods, kindly pls tell me what to do to enable
me to do the similiarity analysis. I thank you all for reading my thread
and would hope to get some positive answers. 
 
 
Ryan
		
This message was sent using the Comp.DSP web interface on
www.DSPRelated.com
ryan81 wrote:
> Hi all, > > I understand the subject of similiarity of signals has dsicuss many of > times in this forum however i still need some valuable advice and help.
I have yet to meet somebody who seeks unvaluable advice... invaluable, some times, but never unvaluable. Sorry for the digression.
> My problem is that i am trying to find the percentage of similiarity of 2 > signals using matlab? > > Say in matlab i have just a variable called signal1 and signal2 both of > size [1 by 5000] these signal 1 and signal 2 are EEG signals. I just want > to know how similiar these two EEG signals are with each other on a sclae > of 0% to 100%.
The term "cross correlation" comes to mind...
> I do not think matlab commands corrcoef and xcorr are of relevance to me > because i want to maintain the length of [1 by 5000] as i need the same > array length to plot against the time and freq which are both of [1 by > 5000] too. xcorr gives 2N + 1 array and the process is a convolution kind > except one part of the signal is not reversed. I believe that the > convoluted results will not aid me at all, am i right?
This last paragraph threw me off. From the question, as stated above, it appears that you want one number to measure the similarity. Now you ask for a vector. Do you want to compare the signals on a per-sample basis? If so, could you use the mere difference between samples?
> Further more, coffcoef just gives the coefficient and this not useful to > me at all.
Again, I have a hard time following your question. Exactly what do you want, and why? What are you going to use the number(s) for?
> I have seen someone mentioning that we need to find the coeffcients using > LPC and then to do a threshold testing. How does this LPC works as i know > they are used in audio processing, is this releveant to my EEG signals?
Again, your question is too vague to attempt an answer. My hunch, though, is that LPCs will not be useful to you.
> Pls if u have any idea or methods, kindly pls tell me what to do to enable > me to do the similiarity analysis. I thank you all for reading my thread > and would hope to get some positive answers.
Please post a description of your application, the objective of your analysis and a description of what you want to achieve by the analysis. It is not easy to see what you are trying to do, and thus it is not easy to attempt to answer your question. Rune
"ryan81" <alligatorpenguin@hotmail.com> writes:

> [...] > My problem is that i am trying to find the percentage of similiarity of 2 > signals using matlab? > > Say in matlab i have just a variable called signal1 and signal2 both of > size [1 by 5000] these signal 1 and signal 2 are EEG signals. I just want > to know how similiar these two EEG signals are with each other on a sclae > of 0% to 100%. > > I do not think matlab commands corrcoef and xcorr are of relevance to me > because i want to maintain the length of [1 by 5000] as i need the same > array length to plot against the time and freq which are both of [1 by > 5000] too. xcorr gives 2N + 1 array and the process is a convolution kind > except one part of the signal is not reversed.
xcorr is the matlab cross correlation function. It measures similarity between two given signals, as a function of the relative time-shift between them. (The length of the result is 2N - 1 (minus, not plus).) As Rune said, it is not clear what it is you really want, so you should try to describe your problem better. -- Asbj&#4294967295;rn S&#4294967295;b&#4294967295;, post.doc. Centre for Quantifiable Quality of Service in Communication Systems Norwegian University of Science and Technology <URL: http://www.q2s.ntnu.no/ >
Considering the requirement to find to what percent of similarity two
signals have, cant we simply use a mean square error of the values of
the two signals. Take a sum of them and normalize over the number of
points considered.

It gives a value ranging from 0 to 1.

Im not sure if there is something wrong with the method. So please do
correct me where ive gone wrong!!!

--
Jag

Sorry if i was unclear in my post. I am now doing a similiarity check of
different EEG signals. I have taken only a short segment of a occurring
EEG seizure of [1 by 5000 samples] out of the whole signal length.

And i have broken up all the remaining parts of the EEG signals into many
segments of each [1 by 5000 samples]. So i want to compare segment by
segment when the occurring seizure will reoccur in the remaining whole of
the duration.

Yes, i am doing a comparison in sample by sample basic, i do not want a
single number, instead what i am aiming to do is to create a vector of the
similiarity measure of the same size as the 5000 segment vector.

The reason i mentioned matlab commands xcorr and coffcoef is that i have
tried these commands and they don't seem to be relevant to me. Pls correct
me if i am wrong as i am also learning. Like i mentioned xcorr is a
convolution result and the 2 vectors are added, i dont see how this is
helpful to me.

I hope my problem is slightly clearer to all of u now..And thanks for the
replies..



>ryan81 wrote: >> Hi all, >> >> I understand the subject of similiarity of signals has dsicuss many of >> times in this forum however i still need some valuable advice and
help.
> >I have yet to meet somebody who seeks unvaluable advice... invaluable, >some times, but never unvaluable. Sorry for the digression. > >> My problem is that i am trying to find the percentage of similiarity of
2
>> signals using matlab? >> >> Say in matlab i have just a variable called signal1 and signal2 both
of
>> size [1 by 5000] these signal 1 and signal 2 are EEG signals. I just
want
>> to know how similiar these two EEG signals are with each other on a
sclae
>> of 0% to 100%. > >The term "cross correlation" comes to mind... > >> I do not think matlab commands corrcoef and xcorr are of relevance to
me
>> because i want to maintain the length of [1 by 5000] as i need the
same
>> array length to plot against the time and freq which are both of [1 by >> 5000] too. xcorr gives 2N + 1 array and the process is a convolution
kind
>> except one part of the signal is not reversed. I believe that the >> convoluted results will not aid me at all, am i right? > >This last paragraph threw me off. From the question, as stated >above, it appears that you want one number to measure the similarity. >Now you ask for a vector. Do you want to compare the signals on >a per-sample basis? If so, could you use the mere difference >between samples? > >> Further more, coffcoef just gives the coefficient and this not useful
to
>> me at all. > >Again, I have a hard time following your question. Exactly what >do you want, and why? What are you going to use the number(s) for? > >> I have seen someone mentioning that we need to find the coeffcients
using
>> LPC and then to do a threshold testing. How does this LPC works as i
know
>> they are used in audio processing, is this releveant to my EEG
signals?
> >Again, your question is too vague to attempt an answer. My hunch, >though, is that LPCs will not be useful to you. > >> Pls if u have any idea or methods, kindly pls tell me what to do to
enable
>> me to do the similiarity analysis. I thank you all for reading my
thread
>> and would hope to get some positive answers. > >Please post a description of your application, the objective of >your analysis and a description of what you want to achieve by the >analysis. It is not easy to see what you are trying to do, and >thus it is not easy to attempt to answer your question. > >Rune > >
This message was sent using the Comp.DSP web interface on www.DSPRelated.com
ryan81 wrote:
> Sorry if i was unclear in my post. I am now doing a similiarity check of > different EEG signals. I have taken only a short segment of a occurring > EEG seizure of [1 by 5000 samples] out of the whole signal length. > > And i have broken up all the remaining parts of the EEG signals into many > segments of each [1 by 5000 samples]. So i want to compare segment by > segment when the occurring seizure will reoccur in the remaining whole of > the duration. > > Yes, i am doing a comparison in sample by sample basic, i do not want a > single number, instead what i am aiming to do is to create a vector of the > similiarity measure of the same size as the 5000 segment vector.
OK, what you could do, then, is to use your one seizure as a matched filter and run the rest of the signal through it. In matlab: % s holds the one seizure, x holds the remaining data. % Both are column vectors. mf = flipud(s); d = filter(mf,1,x); This will give some sort of similarity measure between the refernce seizure and the remains. To get it in the range [0 100%] requires some sort of normalization factors to be introduced. For the filter, the normalization equals nf=sqrt(s'*s); but it is not obvious how to normalize the data. Check out the above and see if that's close to what you want, and come back for normalization factor if you need them. Rune