forked from mdqyy/MATLAB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotDTI.m
executable file
·105 lines (99 loc) · 4.29 KB
/
plotDTI.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
function plotDTI(D,delta)
%-fanDTasia ToolBox------------------------------------------------------------------
% This Matlab script is part of the fanDTasia ToolBox: a Matlab library for Diffusion
% Weighted MRI (DW-MRI) Processing, Diffusion Tensor (DTI) Estimation, High-order
% Diffusion Tensor Analysis, Tensor ODF estimation, Visualization and more.
%
% A Matlab Tutorial on DW-MRI can be found in:
% http://www.cise.ufl.edu/~abarmpou/lab/fanDTasia/tutorial.php
%
%-CITATION---------------------------------------------------------------------------
% If you use this software please cite the following work:
% A. Barmpoutis, B. C. Vemuri, T. M. Shepherd, and J. R. Forder "Tensor splines for
% interpolation and approximation of DT-MRI with applications to segmentation of
% isolated rat hippocampi", IEEE TMI: Transactions on Medical Imaging, Vol. 26(11),
% pp. 1537-1546
%
%-DESCRIPTION------------------------------------------------------------------------
% This function plots a 2D field of 3D tensors as ellipsoidal glyphs. The 3D tensors
% must be in the form of 3x3 symmetric positive definite matrices. The field can
% contain either a single tensor, or a row of tensors or a 2D field of tensors.
%
% NOTE: This function plots only 2nd-order tensors (i.e. traditional DTI). For higher
% order tensors (such as 4th-order tensor visualization) please use the plotTensors.m
%
%-USE--------------------------------------------------------------------------------
% example 1: plotDTI(D)
% where D is of size 3x3 or 3x3xN or 3x3xNxM
%
% example 2: plotDTI(D,delta)
% where delta is a scalar that controls the size
% of a voxel in the field. Default: delta=1
%
%-DISCLAIMER-------------------------------------------------------------------------
% You can use this source code for non commercial research and educational purposes
% only without licensing fees and is provided without guarantee or warrantee expressed
% or implied. You cannot repost this file without prior written permission from the
% authors. If you use this software please cite the following work:
% A. Barmpoutis, B. C. Vemuri, T. M. Shepherd, and J. R. Forder "Tensor splines for
% interpolation and approximation of DT-MRI with applications to segmentation of
% isolated rat hippocampi", IEEE TMI: Transactions on Medical Imaging, Vol. 26(11),
% pp. 1537-1546
%
%-AUTHOR-----------------------------------------------------------------------------
% Angelos Barmpoutis, PhD
% Computer and Information Science and Engineering Department
% University of Florida, Gainesville, FL 32611, USA
% abarmpou at cise dot ufl dot edu
%------------------------------------------------------------------------------------
if nargin==1
delta=1;
end
sz=size(D);
if length(sz)==2
nx=1;ny=1;
elseif length(sz)==3
nx=sz(3);ny=1;
elseif length(sz)==4
nx=sz(3);ny=sz(4);
end
n=size(D,3);
for i=1:nx
for j=1:ny
%if(D(3,3,i,j) ~= 0) %skips if the tensor is zero
[v,l]=eig(D(:,:,i,j));
[X,Y,Z]=ellipsoid(0,0,0,l(1,1),l(2,2),l(3,3),10);
sz=size(X);
for x=1:sz(1)
for y=1:sz(2)
A=[X(x,y) Y(x,y) Z(x,y)]';
A=(v/delta)*A; %added the /delta to reduce the sizes of the ellipsoids without changing the axis'
X(x,y)=A(1);Y(x,y)=A(2);Z(x,y)=A(3);
end
end
X=X+i; %*delta*2 in original script
Y=Y+j; %*delta*2 in original script
%h(i)=
if i==1 && j==1
hold
end
surf(X,Y,Z);
%end
end
end
axis equal
view([0 90]);
set(gca,'GridLineStyle','none')
%set(gca,'XTick',[])
%set(gca,'YTick',[])
%set(gca,'ZTick',[])
shading interp
%colormap([0.8 0.8 0.8])
lighting phong
light('Position',[0 0 1],'Style','infinite','Color',[ 1.000 0.584 0.000]);
hold
fprintf(1,'\nIf you use plotDTI.m please cite the following work:\n');
fprintf(1,'A. Barmpoutis, B. C. Vemuri, T. M. Shepherd, and J. R. Forder "Tensor splines for\n');
fprintf(1,'interpolation and approximation of DT-MRI with applications to segmentation of\n');
fprintf(1,'isolated rat hippocampi", IEEE TMI: Transactions on Medical Imaging, Vol. 26(11),\n');
fprintf(1,'pp. 1537-1546\n');