vtkImageEMLocalSuperClass.h

Go to the documentation of this file.
00001 /*=auto=========================================================================
00002 
00003   Portions (c) Copyright 2005 Brigham and Women's Hospital (BWH) All Rights Reserved.
00004 
00005   See Doc/copyright/copyright.txt
00006   or http://www.slicer.org/copyright/copyright.txt for details.
00007 
00008   Program:   3D Slicer
00009   Module:    $RCSfile: vtkImageEMLocalSuperClass.h,v $
00010   Date:      $Date: 2006/12/08 23:28:23 $
00011   Version:   $Revision: 1.1 $
00012 
00013 =========================================================================auto=*/
00014 // .NAME vtkImageEMLocalSuperClass
00015 #ifndef __vtkImageEMLocalSuperClass_h
00016 #define __vtkImageEMLocalSuperClass_h 
00017   
00018 #include "vtkEMSegment.h"
00019 
00020 #include "vtkImageEMLocalClass.h"
00021 #include "EMLocalInterface.h" 
00022 
00023 class VTK_EMSEGMENT_EXPORT vtkImageEMLocalSuperClass : public vtkImageEMLocalGenericClass
00024 {
00025   public:
00026   // -----------------------------------------------------
00027   // Genral Functions for the filter
00028   // -----------------------------------------------------
00029   static vtkImageEMLocalSuperClass *New();
00030   vtkTypeMacro(vtkImageEMLocalSuperClass,vtkObject);
00031   void PrintSelf(ostream& os, vtkIndent indent);
00032 
00033   int           GetNumClasses() {return this->NumClasses;}
00034 
00035   // Description:
00036   // Defines the tissue class interaction matrix MrfParams(k,i,j)
00037   // where k = direction [1...6], 
00038   //       i = class of the current pixel t+1 
00039   //       j = class of neighbouring pixel t 
00040   void          SetMarkovMatrix(double value, int k, int j, int i);
00041 
00042   // Has any subclass PCA*Ptr defined or not 
00043   int           GetPCAPtrFlag();
00044  
00045   // Returns the list with the PCAShape pointer 
00046   int           GetPCAParametersPtr(void** PCAMeanShapePtr, void*** PCAEigenVectorPtr, int index, int BoundaryType);
00047   int           GetPCAParameters(float **ShapeParametersList, int *PCAMeanShapeIncY, int *PCAMeanShapeIncZ, 
00048                                  int **PCAEigenVectorIncY, int **PCAEigenVectorIncZ, double **PCAEigenValues, 
00049                                  float *PCALogisticSlope, float *PCALogisticBoundary, float *PCALogisticMin, float *PCALogisticMax, int index, int BoundaryType);
00050 
00051   int           GetTotalNumberOfEigenModes();
00052   int           GetTotalNumberOfProbDataPtr();
00053   void          GetPCANumberOfEigenModes(int *NumberOfEigenModesList);
00054 
00055   // Has any subclass ProbDataPtr defined or not 
00056   int           GetProbDataPtrFlag();
00057   // Which classes should be considered for the normalization of the spatial priors 
00058   int           GetProbImageDataCount(char *list, int index);
00059 
00060   int           GetProbDataPtrList(void **PointerList,int index, int BoundaryType); 
00061   int           GetProbDataIncYandZ(int* ProbDataIncY,int* ProbDataIncZ,int index,int BoundaryType);
00062 
00063   void          SetProbDataWeight(float value) {this->ProbDataWeight = value;}
00064   float         GetProbDataWeight(){return this->ProbDataWeight;} 
00065 
00066   int           GetTotalNumberOfClasses(bool flag); // if flag is set => includes subclasses of type SUPERCLASS
00067   int           GetAllLabels(short *LabelList, int result,int Max); // Gets all labels from the Substructures
00068   int          LabelAllSuperClasses(short *TakenLabelList, int Result, int Max);
00069 
00070   //BTX
00071   void**        GetClassList() {return this->ClassList;}
00072   void*         GetClassListEntry(int i) {return this->ClassList[i];}
00073   
00074   classType*    GetClassListType() {return this->ClassListType;}
00075   classType     GetClassType(void* active);
00076   //ETX
00077 
00078   vtkImageEMLocalSuperClass* GetParentClass() {return this->ParentClass;}
00079 
00080   int           GetTissueDefinition(int *LabelList, double** LogMu, double ***InvLogCov, int index);
00081 
00082   double        GetMrfParams(int k,int j,int i) {return this->MrfParams[k][j][i];}
00083   //BTX
00084   double***     GetMrfParams() {return this->MrfParams;}
00085   //ETX
00086 
00087   void AddSubClass(vtkImageEMLocalClass* ClassData, int index) {this->AddSubClass((void*) ClassData, CLASS, index); }
00088   void AddSubClass(vtkImageEMLocalSuperClass* ClassData, int index) {
00089     ClassData->ParentClass = this; this->AddSubClass((void*) ClassData, SUPERCLASS, index);}
00090   
00091 
00092   // Print Functions 
00093   // Description:
00094   // Print out the result after how many steps  (-1 == just last result, 0 = No Printing, i> 0 => every i-th slice )
00095   vtkGetMacro(PrintFrequency, int);
00096   vtkSetMacro(PrintFrequency, int);
00097 
00098   vtkGetMacro(PrintBias, int);
00099   vtkSetMacro(PrintBias, int);
00100 
00101   vtkGetMacro(PrintLabelMap, int);
00102   vtkSetMacro(PrintLabelMap, int);  
00103 
00104 
00105   // Description:
00106   // Prints out the number of voxels changed from last to this EM iteration
00107   vtkGetMacro(PrintEMLabelMapConvergence, int);  
00108   vtkSetMacro(PrintEMLabelMapConvergence, int);  
00109 
00110   // Description:
00111   // Prints out the difference in percent 
00112   vtkGetMacro(PrintEMWeightsConvergence, int);
00113   vtkSetMacro(PrintEMWeightsConvergence, int);
00114 
00115   // Description:
00116   // Prints out the number of voxels changed from last to this MFA iteration
00117   vtkGetMacro(PrintMFALabelMapConvergence, int);  
00118   vtkSetMacro(PrintMFALabelMapConvergence, int);  
00119 
00120   // Description:
00121   // Prints out the difference in percent 
00122   vtkGetMacro(PrintMFAWeightsConvergence, int);
00123   vtkSetMacro(PrintMFAWeightsConvergence, int);
00124 
00125   // Description:
00126   // Prints out the shape cost at each voxel 
00127   vtkGetMacro(PrintShapeSimularityMeasure, int);
00128   vtkSetMacro(PrintShapeSimularityMeasure, int);
00129 
00130 
00131   // Description:  
00132   // After which criteria should be stopped   
00133   // 0 = Fixed iterations (defined by  StopEMMaxIter)
00134   // 1 = Labelmap measure  (Calculate difference measure by comparing Labelmaps between iterations)  
00135   // 2 = Weight measure (Calculate difference measure by comparing Weights between iterations)  
00136   vtkGetMacro(StopEMType,int); 
00137   vtkSetMacro(StopEMType,int); 
00138   void SetStopEMTypeToFixed()    {this->StopEMType = EMSEGMENT_STOP_FIXED;}
00139   void SetStopEMTypeToLabelmap() {this->StopEMType = EMSEGMENT_STOP_LABELMAP;}
00140   void SetStopEMTypeToWeights()  {this->StopEMType = EMSEGMENT_STOP_WEIGHTS;}
00141   
00142   // Description:  
00143   // What is the value at which the EM iteration should stop in percent (DifferenceMeasure/ Number of Voxels), (so 1% => set StopEMValue to 0.01)
00144   // Note if the number of iterations extend StopEMMaxIter than stops than
00145   vtkGetMacro(StopEMValue,float);      
00146   vtkSetMacro(StopEMValue,float);      
00147 
00148   // Description:  
00149   // Number of maximum iterations 
00150   vtkGetMacro(StopEMMaxIter,int);      
00151   vtkSetMacro(StopEMMaxIter,int);      
00152 
00153 
00154   // Description:
00155   // You can stop the bias calculation after a certain number of iterations
00156   // By default it is set to -1 which means it never stops
00157   vtkGetMacro(StopBiasCalculation,int); 
00158   vtkSetMacro(StopBiasCalculation,int); 
00159 
00160   // Description:  
00161   // After which criteria should be stopped   
00162   // 0 = fixed iterations 
00163   // 1 = Absolute measure 
00164   // 2 = Relative measure 
00165   vtkGetMacro(StopMFAType,int); 
00166   vtkSetMacro(StopMFAType,int); 
00167   void SetStopMFATypeToFixed()    {this->StopEMType = EMSEGMENT_STOP_FIXED;}
00168   void SetStopMFATypeToLabelmap() {this->StopEMType = EMSEGMENT_STOP_LABELMAP;}
00169   void SetStopMFATypeToWeights()  {this->StopEMType = EMSEGMENT_STOP_WEIGHTS;}
00170   
00171 
00172   // Description:  
00173   // What is the obundary value, note if the number of iterations 
00174   // extend MFAiter than stops than
00175   vtkGetMacro(StopMFAValue,float);      
00176   vtkSetMacro(StopMFAValue,float);      
00177 
00178   // Description:  
00179   // Number of maximum iterations 
00180   vtkGetMacro(StopMFAMaxIter,int);      
00181   vtkSetMacro(StopMFAMaxIter,int);      
00182 
00183   // Description:  
00184   // What type of registration is wanted 
00185   // 0 = No registration
00186   // 1 = Apply transformation but do not reiterate for better parameters 
00187   // 2 = Only do global registration 
00188   // 3 = Do structure specific registration
00189   // 4 = Do both structure  specifc and global registration simultaneously
00190   // 5 = Do both structure  specifc and global registration sequentially
00191   vtkGetMacro(RegistrationType,int);      
00192   vtkSetMacro(RegistrationType,int);  
00193   void SetRegistrationTypeToDisabled()       {this->RegistrationType = EMSEGMENT_REGISTRATION_DISABLED;} 
00194   void SetRegistrationTypeToApply()          {this->RegistrationType = EMSEGMENT_REGISTRATION_APPLY;} 
00195   void SetRegistrationTypeToGlobalOnly()     {this->RegistrationType = EMSEGMENT_REGISTRATION_GLOBAL_ONLY;} 
00196   void SetRegistrationTypeToClassOnly()      {this->RegistrationType = EMSEGMENT_REGISTRATION_CLASS_ONLY;} 
00197   void SetRegistrationTypeToSimultaneous()   {this->RegistrationType = EMSEGMENT_REGISTRATION_SIMULTANEOUS;} 
00198   void SetRegistrationTypeToSequential()     {this->RegistrationType = EMSEGMENT_REGISTRATION_SEQUENTIAL;} 
00199 
00200   // Desciption:
00201   // If the flag is defined the spatial distribution of the first class will be automatically generated. 
00202   // In specifics the spatial distribution at voxel x is defined as 
00203   // spd(x) = NumberOfTrainingSamples - sum_{all other srructures dependent on the supercals} spd_struct(x) 
00204   vtkGetMacro(GenerateBackgroundProbability,int);      
00205   vtkSetMacro(GenerateBackgroundProbability,int);      
00206   vtkBooleanMacro(GenerateBackgroundProbability,int);
00207 
00208 
00209   // Desciption:
00210   // This flag is for the registration cost function. By default all subclasses are seen as one. 
00211   // In some cases this causes a loss of contrast within the cost function so that the registration is not as reliable, 
00212   // e.g. when we define two SuperClasses (FG and BG) which are defined as outside the brain as BG and everything inside the brain as FG, 
00213   // than we cannot use the ventricles wont be used for the alignment. Hoewever in many cases this structure drives the registration soley so that 
00215   vtkGetMacro(RegistrationIndependentSubClassFlag,int);      
00216   vtkSetMacro(RegistrationIndependentSubClassFlag,int);      
00217   vtkBooleanMacro(RegistrationIndependentSubClassFlag,int);
00218 
00219   // Description:
00220   // Setting of the immidiate subclasses
00221   
00222   void GetRegistrationClassSpecificParameterList(int *RegistrationIndependentSubClassFlag, int *RegistrationClassSpecificRegistrationFlag, int &NumParaSets);
00223 
00224   // Description:
00225   // If all structures are defined by different PCA models that this flag has to be set.
00226   // Kilian: Currently this is not fully integrated into hierarchical framework
00227   // in other words all substructers must all be independently modelled or not 
00228   // If set to zero than all structures are defined by the same PCA model
00229   vtkGetMacro(PCAShapeModelType,int); 
00230   vtkSetMacro(PCAShapeModelType,int); 
00231   // Each structure has its own PCA model defined 
00232   void SetPCAShapeModelTypeToClassIndependent() {this->PCAShapeModelType = EMSEGMENT_PCASHAPE_INDEPENDENT;} 
00233   // The PCA Model is generated over all structures together
00234   void SetPCAShapeModelTypeToClassDependent() {this->PCAShapeModelType = EMSEGMENT_PCASHAPE_DEPENDENT;} 
00235   // Do not maximize over the shape setting  - just use the current setting  
00236   void SetPCAShapeModelTypeToApply() {this->PCAShapeModelType = EMSEGMENT_PCASHAPE_APPLY;} 
00237  
00238   vtkSetMacro(Alpha, double);
00239   vtkGetMacro(Alpha, double);
00240 
00241 protected:
00242   vtkImageEMLocalSuperClass() {this->CreateVariables();}
00243   ~vtkImageEMLocalSuperClass() {this->DeleteSuperClassVariables();}
00244   void DeleteSuperClassVariables();
00245   void CreateVariables();
00246 
00247   void ExecuteData(vtkDataObject *);   
00248 
00249   void AddSubClass(void* ClassData, classType initType, int index);
00250   int  GetPCANumberOfEigenModesList(int *NumberOfEigenModesList, int index);
00251 
00252   int           NumClasses;             // Number of Sub classes -> Importan for dim of Class List
00253   void **       ClassList;              // List of Sub Classes
00254   classType*    ClassListType;
00255   vtkImageEMLocalSuperClass* ParentClass;    // The parent of this super class if ParentClass == NULL => does not have a parent 
00256   double***     MrfParams;              // Markov Model Parameters: Matrix3D mrfparams(this->NumClasses,this->NumClasses,4);
00257 
00258   int PrintFrequency;    // Print out the result after how many steps  (-1 == just last result, 0 = No Printing, i> 0 => every i-th slice )
00259   int PrintBias;         // Should the bias be printed too (Only works for GE)
00260   int PrintLabelMap;     // Print out inbetween label map   
00261 
00262   int PrintEMLabelMapConvergence;  // Prints out the number of voxels changed from last to this iteration
00263   int PrintEMWeightsConvergence; // Prints out the difference in percent 
00264 
00265   double Alpha;                     // 0 <= alpha <= 1. Be carefull - has great influence over outcome 
00266 
00267   int StopEMType;       // After which criteria should be stopped   
00268                         // 0 = fixed iterations 
00269                         // 1 = Absolute measure 
00270                         // 2 = Relative measure
00271   float StopEMValue;    // What is the obundary value, note if the number of iterations 
00272                         // extend EMiter than stops than
00273                         // if (StopEMType = 1) than it is percent
00274 
00275   int StopEMMaxIter; // Maximum number of iterations  if StopEMValue is not  is not reached 
00276 
00277 
00278   // Same as EM
00279   int PrintMFALabelMapConvergence;  
00280   int PrintMFAWeightsConvergence; 
00281   int   StopMFAType;      
00282   float StopMFAValue;     // What is the obundary value, note if the number of iterations 
00283                           // extend MFAiter than stops than
00284                           // if (StopMFAType = 1) than it is percent
00285   int   StopMFAMaxIter;   // Maximum number of iterations by the MFA if StopEMValue is not reached 
00286 
00287   int StopBiasCalculation;
00288   int RegistrationType; 
00289 
00290   int GenerateBackgroundProbability;
00291   
00292   int PrintShapeSimularityMeasure;
00293 
00294   int RegistrationIndependentSubClassFlag;
00295 
00296   // If all structures are defined by different PCA models that this flag has to be set. 
00297   int PCAShapeModelType; 
00298 private:
00299   vtkImageEMLocalSuperClass(const vtkImageEMLocalSuperClass&);
00300   void operator=(const vtkImageEMLocalSuperClass&);
00301 };
00302 #endif
00303 
00304 
00305 
00306 
00307 
00308 
00309 
00310 
00311 
00312 
00313 

Generated on 6 Apr 2011 for Slicer3 by  doxygen 1.6.1