Go to the documentation of this file.00001
00002 #ifndef __itkDiffusionQballGeneralizedFaImageFilter_txx
00003 #define __itkDiffusionQballGeneralizedFaImageFilter_txx
00004
00005 #include <time.h>
00006 #include <stdio.h>
00007 #include <stdlib.h>
00008 #include <math.h>
00009
00010 #include "itkImageRegionConstIterator.h"
00011 #include "itkImageRegionConstIteratorWithIndex.h"
00012 #include "itkImageRegionIterator.h"
00013 #include "itkArray.h"
00014 #include "vnl/vnl_vector.h"
00015 #include "itkOrientationDistributionFunction.h"
00016
00017 namespace itk {
00018
00019
00020
00021 template< class TOdfPixelType,
00022 class TGfaPixelType,
00023 int NrOdfDirections>
00024 DiffusionQballGeneralizedFaImageFilter< TOdfPixelType,
00025 TGfaPixelType, NrOdfDirections>
00026 ::DiffusionQballGeneralizedFaImageFilter() :
00027 m_ComputationMethod(GFA_STANDARD)
00028 {
00029
00030
00031 this->SetNumberOfRequiredInputs( 1 );
00032 }
00033
00034 template< class TOdfPixelType,
00035 class TGfaPixelType,
00036 int NrOdfDirections>
00037 void DiffusionQballGeneralizedFaImageFilter< TOdfPixelType,
00038 TGfaPixelType, NrOdfDirections>
00039 ::BeforeThreadedGenerateData()
00040 {
00041 }
00042
00043 template< class TOdfPixelType,
00044 class TGfaPixelType,
00045 int NrOdfDirections>
00046 void DiffusionQballGeneralizedFaImageFilter< TOdfPixelType,
00047 TGfaPixelType, NrOdfDirections>
00048 ::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
00049 int )
00050 {
00051 typename OutputImageType::Pointer outputImage =
00052 static_cast< OutputImageType * >(this->ProcessObject::GetOutput(0));
00053
00054 ImageRegionIterator< OutputImageType > oit(outputImage, outputRegionForThread);
00055 oit.GoToBegin();
00056
00057 typedef itk::OrientationDistributionFunction<TOdfPixelType,NrOdfDirections> OdfType;
00058 typedef ImageRegionConstIterator< InputImageType > InputIteratorType;
00059 typedef typename InputImageType::PixelType OdfVectorType;
00060 typename InputImageType::Pointer inputImagePointer = NULL;
00061 inputImagePointer = static_cast< InputImageType * >(
00062 this->ProcessObject::GetInput(0) );
00063
00064 InputIteratorType git(inputImagePointer, outputRegionForThread );
00065 git.GoToBegin();
00066 while( !git.IsAtEnd() )
00067 {
00068 OdfVectorType b = git.Get();
00069 TGfaPixelType outval = -1;
00070
00071 switch( m_ComputationMethod )
00072 {
00073 case GFA_STANDARD:
00074 {
00075 OdfType odf = b.GetDataPointer();
00076 outval = odf.GetGeneralizedFractionalAnisotropy();
00077 break;
00078 }
00079 case GFA_QUANTILES_HIGH_LOW:
00080 {
00081 vnl_vector_fixed<TOdfPixelType,NrOdfDirections> sorted;
00082 for(int i=0; i<NrOdfDirections; i++)
00083 {
00084 sorted[i] = b[i];
00085 }
00086 std::sort( sorted.begin(), sorted.end() );
00087 double q60 = sorted[floor(0.6*(double)NrOdfDirections+0.5)];
00088 double q95 = sorted[floor(0.95*(double)NrOdfDirections+0.5)];
00089 outval = q95/q60 - 1.0;
00090 break;
00091 }
00092 case GFA_QUANTILE_HIGH:
00093 {
00094 vnl_vector_fixed<TOdfPixelType,NrOdfDirections> sorted;
00095 for(int i=0; i<NrOdfDirections; i++)
00096 {
00097 sorted[i] = b[i];
00098 }
00099 std::sort( sorted.begin(), sorted.end() );
00100
00101 double q95 = sorted[floor(0.95*(double)NrOdfDirections+0.5)];
00102 outval = q95;
00103 break;
00104 }
00105 case GFA_MAX_ODF_VALUE:
00106 {
00107 outval = b.GetVnlVector().max_value();
00108 break;
00109 }
00110 case GFA_DECONVOLUTION_COEFFS:
00111 {
00112 break;
00113 }
00114 case GFA_MIN_MAX_NORMALIZED_STANDARD:
00115 {
00116 OdfType odf = b.GetDataPointer();
00117 odf = odf.MinMaxNormalize();
00118 outval = odf.GetGeneralizedFractionalAnisotropy();
00119 break;
00120 }
00121 case GFA_NORMALIZED_ENTROPY:
00122 {
00123 OdfType odf = b.GetDataPointer();
00124 outval = odf.GetNormalizedEntropy();
00125 break;
00126 }
00127 case GFA_NEMATIC_ORDER_PARAMETER:
00128 {
00129 OdfType odf = b.GetDataPointer();
00130 outval = odf.GetNematicOrderParameter();
00131 break;
00132 }
00133 case GFA_QUANTILE_LOW:
00134 {
00135 vnl_vector_fixed<TOdfPixelType,NrOdfDirections> sorted;
00136 for(int i=0; i<NrOdfDirections; i++)
00137 {
00138 sorted[i] = b[i];
00139 }
00140 std::sort( sorted.begin(), sorted.end() );
00141
00142 double q05 = sorted[floor(0.05*(double)NrOdfDirections+0.5)];
00143 outval = q05;
00144 break;
00145 }
00146 case GFA_MIN_ODF_VALUE:
00147 {
00148 outval = b.GetVnlVector().min_value();
00149 break;
00150 }
00151 case GFA_QUANTILES_LOW_HIGH:
00152 {
00153 vnl_vector_fixed<TOdfPixelType,NrOdfDirections> sorted;
00154 for(int i=0; i<NrOdfDirections; i++)
00155 {
00156 sorted[i] = b[i];
00157 }
00158 std::sort( sorted.begin(), sorted.end() );
00159 double q05 = sorted[floor(0.05*(double)NrOdfDirections+0.5)];
00160 double q40 = sorted[floor(0.4*(double)NrOdfDirections+0.5)];
00161 outval = q40/q05 - 1.0;
00162 break;
00163 }
00164 case GFA_STD_BY_MAX:
00165 {
00166 OdfType odf = b.GetDataPointer();
00167 outval = odf.GetStdDevByMaxValue();
00168 break;
00169 }
00170 case GFA_PRINCIPLE_CURVATURE:
00171 {
00172 OdfType odf = b.GetDataPointer();
00173 outval = odf.GetPrincipleCurvature(m_Param1, m_Param2, 0);
00174 break;
00175 }
00176 case GFA_GENERALIZED_GFA:
00177 {
00178 OdfType odf = b.GetDataPointer();
00179 outval = odf.GetGeneralizedGFA(m_Param1, m_Param2);
00180 break;
00181 }
00182 }
00183
00184 oit.Set( outval );
00185
00186 ++oit;
00187 ++git;
00188 }
00189
00190 std::cout << "One Thread finished calculation" << std::endl;
00191 }
00192
00193 template< class TOdfPixelType,
00194 class TGfaPixelType,
00195 int NrOdfDirections>
00196 void DiffusionQballGeneralizedFaImageFilter< TOdfPixelType,
00197 TGfaPixelType, NrOdfDirections>
00198 ::PrintSelf(std::ostream& os, Indent indent) const
00199 {
00200 Superclass::PrintSelf(os,indent);
00201 }
00202
00203 }
00204
00205 #endif // __itkDiffusionQballGeneralizedFaImageFilter_txx