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

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

Diffusion Tensor Calculation

The first thing we need to do is to setup the G matrix given the diffusion encoding directions (and the b-value, if you want quantitative measures such as ADC).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
%% First we need to find out how many of the gradient
%% directions are all zero...
zeroi = find( sum(gradients')' == 0 );
nonzeroi = setdiff(  1:nrows(gradients),  zeroi );

gradients = gradients(  nonzeroi, : );

%%  Setup G
for ii=1:nrows(gradients)

    G(ii,:) = b_value * [ gradients(ii,:).*gradients(ii,:) ...
                              2*gradients(ii,1).*gradients(ii,2) ...
                              2*gradients(ii,1).*gradients(ii,3) ...
                              2*gradients(ii,2).*gradients(ii,2) ];
end

Ginv = pinv(G);

Now, given the G matrix, we want to calculate the diffusion tensor values given the gradient diffusion encoding, G, and the acquired signal y. tv is the tensor values (in vector form) and TV is the tensor matrix. Then we use singular value decomposition (svd) to compute the eigenvalues and eigenvectors of the tensor (per voxel).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
for ii=1:nrows(d)
    for jj=1:ncols(d)
        for sl=1:size(d,3)
 
            data = squeeze( d(ii,jj,sl,:) );
            data = data(nonzeroi) ./ mean(data(zeroi));
            data = - log( data );
 
            % tensor values
            tv = Ginv * data;
 
            TV=zeros(3,3);
            TV(1,1) = tv(1); TV(2,2) = tv(2); TV(3,3) = tv(3);
            TV(1,2) = tv(4); TV(2,1) = tv(4);
            TV(1,3) = tv(5); TV(3,1) = tv(5);
            TV(2,3) = tv(6); TV(3,2) = tv(6);
 
            [U,S,V] = svd(TV);
 
            dt(ii,jj,sl).evalues = diag(S);
            dt(ii,jj,sl).evector = U(:,1);
        end
    end
end

Now, given the eigenvalues values, evalues in Matlab, and corresponding eigenvectors, evector in Matlab, we can compute lots of different possible measures.

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