Finding inverse cross-correlation

10 visualizaciones (últimos 30 días)
S.K.
S.K. el 26 de Mzo. de 2016
Comentada: Star Strider el 26 de Mzo. de 2016
Hello,
I am trying to compute the inverse cross-correlation of two signals ; that is, I have two signal A and B such that A should reach its positive peak when B hits its negative peak, and I want to find the delay between the two. How can I do this in Matlab?
If it helps, I am working with respiratory data, specifically co2 and 02 volume concentrations. Our respirometer starts collecting co2 data about 1-2 seconds before it starts with the o2 - hence the delay we are trying to account for.
edit: I have enclosed a graph of some sample data to be corrected - the blue signal is oxygen concentration and the orange signal is co2 concentration. As you can see, the o2 concentration is delayed (in this case) by about 1.5 seconds, which is caused entirely by our instrumentation. The goal would be to have a function which could calculate the maximal inverse cross-correlation, so that the maxima of one signal match up with the minima of the other.
Thank you!

Respuesta aceptada

Image Analyst
Image Analyst el 26 de Mzo. de 2016
Although often true, and maybe true for your signals, the best signal overlap is not guaranteed to occur when the cross correlation is maximum. That is a very common misconception. A simple thought experiment should reveal why. That is why I never use it and use normalized cross correlation instead. There is a function for that in the Image Processing Toolbox called normxcorr2(), however it should work for 1-D signals also I believe. I'm attaching a 2D pattern recognition demo (sorry I don't have any 1-D signal demo for it all ready to go).
  4 comentarios
Ced
Ced el 26 de Mzo. de 2016
Great demo, thanks! Seems quite obvious when put like that ^^. One more reason to careful filter the result.
S.K.
S.K. el 26 de Mzo. de 2016
Thank you for your suggestion, Image Analyst - I will try computing normalized cross correlation and see if it gives a result appreciably different to the maximum cross-correlation. Unfortunately, I still don't know how to compute the inverse cross correlation, normalized or otherwise ...

Iniciar sesión para comentar.

Más respuestas (2)

Ced
Ced el 26 de Mzo. de 2016
If I interpret your description of "inverse cross-correlation" correctly, wouldn't that just be the cross-correlation with one of the signals flipped?
[ r, lag ] = xcorr(A,-B)
  2 comentarios
S.K.
S.K. el 26 de Mzo. de 2016
Editada: S.K. el 26 de Mzo. de 2016
Hi Ced, thank you for your help!
I don't think so - the values returned by finddelay(A,B) = finddelay(A,-B), for instance, where finddelay is a matlab function which estimates delay by finding maximum cross-correlation ... I think the issue is that our signals are entirely positive, and sinusoidal about a positive axis (e.g. o2 concentration varies from 13% - 25%).
Does that make sense? I have also appended a picture of the data to the original question; hopefully that makes things clearer.
Ced
Ced el 26 de Mzo. de 2016
Ah, I just saw the figure. Yes, you should remove the mean beforehand and normalize their magnitude. Have a look at ImageAnalysts response, I was not familiar with that method. Sounds interesting.

Iniciar sesión para comentar.


Star Strider
Star Strider el 26 de Mzo. de 2016
I’ve not worked with respirometry data with the sort of instrumentation you describe. Does it collect the O2 and CO2 simultaneously and there is a lag because of your experimental set-up (the O2 signal lags the CO2 signal), or is the lag in the instrumentation itself? If the instrumentation analyses the signals simultaneously and lags in the output, you could just shift them. Otherwise, from your description, the easiest way do assess the lags would be to negate one signal and then just use the Signal Processing Toolbox xcorr function, for example, on both the unchanged O2 signal and negated CO2 signal. Assuming that I understand your Question correctly, that’s how I would do it.
  3 comentarios
Image Analyst
Image Analyst el 26 de Mzo. de 2016
Attaching actual data - numbers in a .mat file or something - would be also useful in case someone wants to try something with it.
Star Strider
Star Strider el 26 de Mzo. de 2016
The problem is that ‘respiration’ exists on the cellular level so I didn’t know if you meant cellular or ventilatory ‘respiration’.
This is an instrumentation problem going back at least a half century. Going to the literature, for example ‘Time delay technique in respiratory instrumentation’ Respiration Physiology Volume 7, Issue 3, October 1969, Pages 399–402 and PubMed (with 146 related articles, such as ‘A computer-based instrumentation system for measurement of breath-by-breath oxygen consumption and carbon dioxide production’ Biomed Sci Instrum. 1994;30:1-8) can be beneficial. They’re not all free, but you should be able to get most of them from your university library.

Iniciar sesión para comentar.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by