Rss Feed
Tweeter button
Facebook button
Technorati button
Reddit button
Myspace button
Linkedin button
Webonews button
Delicious button
Digg button
Flickr button
Stumbleupon button
Newsvine button
Youtube button

Notes:

  • The site will be morphing over the next little while.
  • I am having some issues with tabs/spaces in the Python code. Sometimes they are correct, sometimes they get eaten. I am trying to figure it out.

Please feel free to leave a comment on a post if it interests you or if you have questions

T2 Curve Fitting – NNLS

White matter has been shown to consist of multiple exponential components related to different water compartments. A good way to fit signal intensity data for multi-exponential decay curves is to use the non-negative least squares algorithm (NNLS). Click runme_nnls.m for the whole matlab code.

Construct Test Data

First construct some test data with noise (gaussian distributed, not really what MR data is, but all right for now).

1
2
3
4
5
6
7
8
te = [10:10:320]';
y = 200 * exp(-te ./ 22 ) + 800 * exp(-te ./ 84) + 2.4;

noise_factor = 5;

e = noise_factor * randn(size(y));

y_e = y + e;

Plot the data

Plot the data..

1
2
3
4
5
6
figure(1),clf;
plot(te, y_e,'rx-');
title('Test Data');
xlabel('TE (ms)');
ylabel('Signal');
grid on;

Fit with NNLS

Now fit the data using the NNLS algorithm.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
% Construct the exponential kernel for NNLS

t2 = 10:10:2000;

A = exp( -kron(te, 1./ t2)  );

% Add a baseline component

A = [A ones(size(A,1), 1)];

% Solve it.

x = lsqnonneg(A, y_e);

baseline = x(end);

amplitudes = x(1:end-1);

Plot the T2 Spectrum

Plot the resulting T2 spectrum on a logarithmic scale.

1
2
3
4
5
6
7
8
figure(2),clf;

semilogx(t2, amplitudes);

xlabel('T2 (ms)');
ylabel('Amplitude (arb)');
title('T_2 Spectrum');
grid on;

Plot the Noisy Decay Curve and Fitted Line

Now reconstruct the signal intensities and plot back on top of the original data.

1
2
3
4
5
6
7
8
y_recon = A * x;

figure(1),clf; hold on;
plot(te, y_e', 'rx');
plot(te, y_recon, 'b-');
grid on;
xlabel('TE (ms)');
ylabel('Signal (arb)');

Then we can plot the residuals of the fitted curve (blue) and the measured points (red x’s):

There is actually a lot of information in the residuals plot. For one, we can look at the standard deviation of the points to determine the amount of noise. As well, we can see if there are trends in the residuals, for example, is there a trend for the residuals to increase or decrease as a function of TE.
References

1. C. L. Lawson and R. J. Hanson. Solving least square problems. Prentice Hall, Englewood Cliffs NJ, 1974
This is the book in which the algorithm is originally described. Theorems to show NNLS will stop in a finite number of steps and will arrive at the minimum L2 solution.
2. K.P. Whittall and A.L. MacKay. Quantitative interpretation of NMR relaxation data. J. Magn. Reson., 84:134-152, 1989.
One of the first papers in MRI to use the NNLS algorithm. Good discussion of regularization techniques as well.

One Response to “T2 Curve Fitting – NNLS”

  1. Dileep Kumar says:

    Dear Craig,

    First of all, i would like to appriciate your efforts to provide step by step discription for T2 curve fitting. Actually, I’m new to matlab eventhough i tried to run the above code in matlab and it works fine for sample data.

    Now, could you please let me know few things.

    Actually, I’ve got a series of MR images (Multi echo- spin echo with fix TR and different TE value). According to our literature to generate color coded map of T2 relaxations. we need to fit the signal intesities pixel by pixel using mono expenential curve fitting.
    Since, I’m new to Matlab. Coul du please let me know how to genereate signal intensities from that Image and after that. how to generate color coded map.

    i would be very thankful for your kind consideration to my query.

    Thanks & regards
    Dileep

Leave a Reply

(required)

(required)

Spam Protection by WP-SpamFree

© 2010 Math, Computing and Research Please leave a comment or contact me craig@mri.brechmos.org if you have any questions. Suffusion WordPress theme by Sayontan Sinha