Orfeo Toolbox  3.16
itkDiffusionTensor3D.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkDiffusionTensor3D.txx,v $
5  Language: C++
6  Date: $Date: 2010-03-17 16:34:47 $
7  Version: $Revision: 1.9 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkDiffusionTensor3D_txx
18 #define __itkDiffusionTensor3D_txx
19 
20 #include "itkDiffusionTensor3D.h"
21 #include "itkNumericTraits.h"
22 
23 namespace itk
24 {
25 
26 
30 template<class T>
33 {
34 }
35 
36 
40 template<class T>
43 {
44 }
45 
46 
50 template<class T>
53 {
54 }
55 
56 
60 template<class T>
63 {
64 }
65 
66 
70 template<class T>
74 {
75  Superclass::operator=(r);
76  return *this;
77 }
78 
79 
83 template<class T>
87 {
88  Superclass::operator=(r);
89  return *this;
90 }
91 
92 
96 template<class T>
100 {
101  Superclass::operator=(r);
102  return *this;
103 }
104 
105 
121 template<class T>
124 ::GetTrace() const
125 {
126  AccumulateValueType trace = (*this)[0];
127  trace += (*this)[3];
128  trace += (*this)[5];
129  return trace;
130 }
131 
132 
136 template<class T>
140 {
141  // Computed as
142  // FA = vcl_sqrt(1.5*sum(sum(N.*N))/sum((sum(D.*D))))
143  // where N = D - ((1/3)*trace(D)*eye(3,3))
144  // equation (28) in http://lmi.bwh.harvard.edu/papers/pdfs/2002/westinMEDIA02.pdf
145  const RealValueType isp = this->GetInnerScalarProduct();
146 
147  if( isp > 0.0 )
148  {
149  const RealValueType trace = this->GetTrace();
150  const RealValueType anisotropy = 3.0 * isp - trace * trace;
151  const RealValueType fractionalAnisotropy =
152  static_cast< RealValueType >( vcl_sqrt(anisotropy / ( 2.0 * isp ) ) );
153  return fractionalAnisotropy;
154  }
155 
156  return 0.0;
157 }
158 
159 
163 template<class T>
167 {
168  const RealValueType trace = this->GetTrace();
169  const RealValueType isp = this->GetInnerScalarProduct();
170 
171  // Avoid negative trace and traces small enough to look like a division by
172  // zero.
174  {
176  }
177 
178  const RealValueType anisotropy = 3.0 * isp - trace * trace;
179 
180  if( anisotropy < NumericTraits< RealValueType >::Zero )
181  {
183  }
184 
185  const RealValueType relativeAnisotropySquared =
186  static_cast< RealValueType >( anisotropy / ( vcl_sqrt(3.0 ) * trace ) );
187 
188  const RealValueType relativeAnisotropy =
189  static_cast< RealValueType >( vcl_sqrt(relativeAnisotropySquared ) );
190 
191  return relativeAnisotropy;
192 }
193 
194 
198 template<class T>
202 {
203 
204  const RealValueType xx = (*this)[0];
205  const RealValueType xy = (*this)[1];
206  const RealValueType xz = (*this)[2];
207  const RealValueType yy = (*this)[3];
208  const RealValueType yz = (*this)[4];
209  const RealValueType zz = (*this)[5];
210 
211  return ( xx*xx + yy*yy + zz*zz + 2.0*(xy*xy + xz*xz + yz*yz) );
212 
213 }
214 
215 
216 } // end namespace itk
217 
218 #endif

Generated at Sat May 18 2013 23:36:25 for Orfeo Toolbox with doxygen 1.8.3.1