Take the 2-minute tour ×
MathOverflow is a question and answer site for professional mathematicians. It's 100% free, no registration required.

Fluorescence correlation spectroscopy (FCS) is a common technique used by physicists, chemists, and biologists to experimentally characterize the dynamics of fluorescent species.

The key of the technique is the auto correlation function. The (temporal) autocorrelation function is the correlation of a time series with itself shifted by time τ, as a function of τ:

The formula is given by $$ G(\tau) = \frac{\langle \delta I(t) \delta I (t+\tau)\rangle}{\langle I(t)\rangle^2} = \frac{\langle I(t)I(t+\tau)\rangle}{\langle I(t)\rangle^2} - 1$$

where $$ \delta I(t) = I(t)-\langle I(t)\rangle $$ is the deviation from the mean intensity.

My question is:

Given a row vector of finite elements, what is the right way to calculate G(tau).

The matlab code below shows two methods giving two different result. Which one is the correct one?

rawdata = [1 2 3 4 5 6 7 8];

%the regular method.Result shown in the next line
%0.259259259    0.2 0.151515152 0.111111111 0.076923077 0.047619048 0.022222222
count = rawdata;
Ntime = length(count);
G = [];
for t = 0:Ntime-1 
    top = [];
    bottom = [];
    ai = [];
    bi = [];
    ai = count(1:end-t);
    bi = count(t+1:end);
    top = mean( (ai-mean(ai)) .* (bi-mean(bi)) );
    bottom = mean(ai) * mean(bi);
    %bottom = mean(count)^2;
    G = [G, top/bottom];
end

%The typical FFT method. Results shown in the next line
%0.259259259    0.086419753 -0.037037037    -0.111111111    -0.135802469    -0.111111111    -0.037037037    0.086419753
%NFFT euqals to the length of the input.
count = rawdata;
NFFT = 8;
tmpGfft = length(count) * ifft( fft(count,NFFT).*conj(fft(count,NFFT)))/sum(count)^2 - 1;

plot(G,'*');hold on; plot(tmpGfft,'o')

More reference on the technique itself, http://en.wikipedia.org/wiki/Fluorescence_correlation_spectroscopy

share|improve this question
    
forgive me for not showing the image. As a new user, I can't add image –  Peter Apr 2 '10 at 5:46
    
Can you also add the image too. Thanks –  Peter Apr 2 '10 at 6:17
    
I am not sure, but it seems like the FFT method uses all the data (in a cyclic way: a_{n+k} = a_k), while the first method only uses the right amount of available data. The FFT method does not look correct to me: but of course, if n >> tau, the two methods should give very similar results. For tau \approx n, the FFT is just totally wrong - but anyway, there are not enough data available to compute a reasonable approximation of the autocorrelation function for large \tau. –  Alekk Apr 2 '10 at 10:12
1  
Also, for future reference: I am not sure if this question fits completely within the scope of MathOverflow. It has rather limited interest for research mathematicians. –  Willie Wong Apr 2 '10 at 10:29
add comment

1 Answer

up vote 1 down vote accepted

I am not sure about my answer, as I am not completely fluent in MatLab. The "regular" method is self-evident enough that I can parse it. The FFT method, if I am interpreting it correctly, is by evaluating the mean $\langle I(t+\tau)I(t)\rangle $ via convolution as $I*I(\tau)$?

So of course the two answers are different: the main difference is that using the FFT method, you are extending the raw data to a periodic (in time) data of period 8, whereas using the regular data, you are extending the raw data to a pulsed-data so that before $t = 0$ the data is all 0, and after $t = 7$ the data is also all 0.

So in essence, you are feeding into the algorithm two different sets of data. So you get two different answers. If you change ai and bi in your regular method so that, instead of sub-arrays, you shift the array (fix ai = count, but bi = pop the first t elements off of count and push them to the end), you'll probably get then the same answer for the two methods.

I am also a bit troubled by the fact that you computed bottom as mean(ai) * mean(bi), that seems wrong to me. Your original mean(count)^2 which you commented out feels more right.

Of course, this all depends on what you mean by the auto-correlation of a finite time-sequence (whether you should extend the data periodically or impulsively). If the raw data you are processing is roughly periodic, then you should extend periodically, and then you should just use the FFT method. If the raw data you are processing is not periodic, personally I don't think the auto-correlation function makes much sense unless $\tau$ is much much smaller than your sample time-span (in which case you may as well assume the data is periodic since the error terms will be small). In that case, the easiest thing to do is to pre- and post-pad your data with as many zeroes as there are data points (if there were N data points to start with, pad N zeroes in front and N zeroes after), and do the FFT and read off the answer using positions N through 2N - 1 (okay, maybe up to a normalization...)

In any case, the MatLab code you wrote for the regular method is almost certainly wrong: all the places you write mean(ai) and mean(bi) should really be mean(count) for the expressions to make sense compared with the mathematical formula you wrote.

share|improve this answer
    
that is totally cool. Thanks. I know this doesn't really fit into the community. But I guess it is still a math related one. –  Peter Apr 2 '10 at 16:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.