vtkImageEMGenericClass.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: vtkImageEMGenericClass.h,v $
00010   Date:      $Date: 2006/12/08 23:28:24 $
00011   Version:   $Revision: 1.1 $
00012 
00013 =========================================================================auto=*/
00014 // .NAME vtkImageEMGenericClass
00015 // Definnition of all variables owned by both vtkImageEMSuperClass and vtkImageEMClass
00016 //                      vtkImageEMGenericClass
00017 //                        //                 //  
00018 //           vtkImageEMSuperClass <- - - vtkImageEMClass
00019 
00020 #ifndef __vtkImageEMGenericClass_h
00021 #define __vtkImageEMGenericClass_h 
00022   
00023 #include "vtkEMSegment.h"
00024 #include <iostream>
00025 #include "vtkImageMultipleInputFilter.h"
00026 #include "vtkImageData.h"
00027 #include "vtkOStreamWrapper.h"
00028 
00029 // #ifndef EM_VTK_OLD_SETTINGS
00030 // #if (VTK_MAJOR_VERSION == 4 && (VTK_MINOR_VERSION >= 3 || (VTK_MINOR_VERSION == 2 && VTK_BUILD_VERSION > 5)))
00031 //   #define EM_VTK_OLD_SETTINGS 0 
00032 // #else
00033 //   #define EM_VTK_OLD_SETTINGS 1
00034 // #endif
00035 // #endif
00036 
00037 // For Super Class and sub class
00038 enum classType {CLASS, SUPERCLASS};
00039 
00040 //BTX
00041 // Class for  capturing different protocols throughout the segmentation process
00042 class  VTK_EMSEGMENT_EXPORT ProtocolMessages {
00043 public:
00044   int GetFlag() {return this->Flag;}
00045   char* GetMessages();
00046   void ResetParameters();
00047   // This is for programs that use a constant char as input
00048   void AddMessage(const char* os);
00049 
00050   ~ProtocolMessages() { this->DeleteMessage();}
00051   ProtocolMessages() {this->Message = new vtkOStrStreamWrapper; this->Flag = 0;}
00052 
00053   vtkOStrStreamWrapper *Message;
00054   int Flag; 
00055 private: 
00056   void DeleteMessage();
00057 };
00058 
00059 // Needed for convenience so we can just enter things with << 
00060 
00061 #define vtkEMAddMessageNoOutput(MessageNoOutputPtr, xout)        \
00062    {                                                          \
00063      vtkOStreamWrapper::EndlType endl;                        \
00064      vtkOStreamWrapper::UseEndl(endl);                        \
00065      MessageNoOutputPtr->Message->rdbuf()->freeze(0);         \
00066      (*MessageNoOutputPtr->Message) <<  xout << "\n";         \
00067      MessageNoOutputPtr->Flag =  1;                           \
00068    }
00069 
00070 
00071 #define vtkEMAddMessage(output,MessagePtr, x)                 \
00072    {                                                          \
00073      vtkEMAddMessageNoOutput(MessagePtr, x)                   \
00074      output << "MESSAGE: In " __FILE__ ", line " << __LINE__ << "\n" << x << "\n";                    \
00075    }
00076 
00077 // Message is not printed out 
00078 #define vtkEMJustAddErrorMessage(x) {        \
00079    vtkEMAddMessageNoOutput((&this->ErrorMessage), x) ; \
00080  }
00081 
00082 #define vtkEMJustAddErrorMessageSelf(x) {        \
00083    vtkEMAddMessageNoOutput((self->GetErrorMessagePtr()), x) ; \
00084  }
00085 
00086 #define vtkEMJustAddWarningMessage(x) {        \
00087    vtkEMAddMessageNoOutput((&this->WarningMessage), x) ; \
00088  }
00089 
00090 #define vtkEMJustAddWarningMessageSelf(x) {        \
00091    vtkEMAddMessageNoOutput((self->GetWarningMessagePtr()), x) ; \
00092  }
00093 
00094 #ifdef _WIN32
00095 #define vtkEMAddErrorMessage(x) {\
00096    vtkEMAddMessage(std::cerr, (&this->ErrorMessage), "- ERROR: " << x) ; \
00097  }
00098 
00099 #else  
00100 #define vtkEMAddErrorMessage(x) {\
00101     vtkEMAddMessage(std::cerr, (&this->ErrorMessage), "- ERROR: " << x) ; \
00102   }
00103 #endif
00104 
00105 #ifdef _WIN32
00106 #define vtkEMAddErrorMessageSelf(x) {\
00107     vtkEMAddMessage(std::cerr,self->GetErrorMessagePtr(), "- ERROR: " << x); \
00108   }
00109 #else  
00110 #define vtkEMAddErrorMessageSelf(x) {\
00111     vtkEMAddMessage(std::cerr,self->GetErrorMessagePtr(), "- ERROR: " << x); \
00112   }
00113 #endif 
00114 
00115 #define vtkEMAddWarningMessage(x) {\
00116    vtkEMAddMessage(std::cerr, (&this->WarningMessage), "- WARNING: " << x) ; \
00117  }
00118 
00119 #define vtkEMAddWarningMessageSelf(x) {\
00120    vtkEMAddMessage(std::cerr,self->GetWarningMessagePtr(), "- WARNING: " << x); \
00121 }
00122 //ETX
00123 
00124 
00125 class VTK_EMSEGMENT_EXPORT vtkImageEMGenericClass : public vtkImageMultipleInputFilter
00126 {
00127   public:
00128   // -----------------------------------------------------
00129   // Genral Functions for the filter
00130   // -----------------------------------------------------
00131   static vtkImageEMGenericClass *New();
00132   vtkTypeMacro(vtkImageEMGenericClass,vtkObject);
00133   void PrintSelf(ostream& os, vtkIndent indent);
00134 
00135   // Description:
00136   // Global Tissue Probability
00137   vtkSetMacro(TissueProbability, double);
00138   vtkGetMacro(TissueProbability, double);
00139 
00140   // Description:
00141   // How much influence should the LocalPriorData have in the segmentation process 
00142   // 0   = no Probability data is used => if class is from type EMClass no ProbDataPtr will be loaded
00143   // 1.0 = complete trust is in ProbDataPtr => Whenever the ProbDataPtr = 0 => voxel will not be assigned to tissue class
00144   vtkSetMacro(ProbDataWeight,float);
00145   vtkGetMacro(ProbDataWeight,float);
00146 
00147   // Description
00148   // Scalar type of ProbData 
00149   vtkGetMacro(ProbDataScalarType,int);
00150 
00151   // Description:
00152   // Labels of classes. Please not that label for super classes are set automatically
00153   vtkGetMacro(Label,short);
00154 
00155   // Description:
00156   // Important for several input parameters such as size of LogCovariance
00157   // How much weight is given to each channel  
00158   // 0   = input is ignored 
00159   // 1.0 = input is fully considered  
00160   void SetInputChannelWeights(float val, int x);
00161   //BTX
00162   float* GetInputChannelWeights() {return this->InputChannelWeights;}
00163   //ETX
00164 
00165   // Description:
00166   // Number of input images for the segmentation - Has to be defined before defining any class specific setting 
00167   // Otherwise they get deleted
00168   // Be carefull: this is just the number of images not attlases, 
00169   // e.g. I have 5 tissue classes and 3 Inputs (T1, T2, SPGR) -> NumInputImages = 3
00170   void SetNumInputImages(int number);
00171   vtkGetMacro(NumInputImages,int);
00172 
00173   //Description:
00174   // Dimension of image Data 
00175   vtkGetVector3Macro(DataDim,int);
00176 
00177   //Description:
00178   // Spacing of image data
00179   vtkGetVector3Macro(DataSpacing, float);                 
00180 
00181   // Description:
00182   // Define the Segmentation areae.g. have the image of size 256x256x124
00183   // now you want to segment a box of 70x 70 x 70 around the center of the image
00184   // -> Define  SegmentationBoundaryMin((256-70)/2,(256-70)/2,(124-70)/2)
00185   //            SegmentationBoundaryMax((256+70)/2,(256+70)/2,(124+70)/2)  
00186   vtkSetVector3Macro(SegmentationBoundaryMin,int);
00187   vtkSetVector3Macro(SegmentationBoundaryMax,int);
00188 
00189   vtkGetVector3Macro(SegmentationBoundaryMin,int);
00190   vtkGetVector3Macro(SegmentationBoundaryMax,int);
00191 
00192   // Description:
00193   // Make sure older version get an error message
00194   void SetInputIndex(vtkImageData *, int )  {
00195     vtkErrorMacro(<< "In the new version SetInputIndex is disabled! Please look into vtkImageEM*Class.h to find out how to set the given parameters !");
00196     return;
00197   }
00198 
00199   // =============================
00200   // For Message Protocol
00201   // So we can also enter streams for functions outside vtk
00202   char* GetErrorMessages() {return this->ErrorMessage.GetMessages(); }
00203   int GetErrorFlag() {return  this->ErrorMessage.GetFlag();}
00204   void ResetErrorMessage() {this->ErrorMessage.ResetParameters();}
00205 
00206   //BTX
00207   ProtocolMessages* GetErrorMessagePtr(){return &this->ErrorMessage;}
00208   //ETX
00209 
00210   char* GetWarningMessages() {return this->WarningMessage.GetMessages(); }
00211   int GetWarningFlag() {return  this->WarningMessage.GetFlag();}
00212   void ResetWarningMessage() {this->WarningMessage.ResetParameters();}
00213 
00214   //BTX
00215   ProtocolMessages* GetWarningMessagePtr(){return &this->WarningMessage;}
00216   //ETX
00217 
00218   // Description:
00219   // Print out Weights (1 = Normal 2=as shorts normed to 1000)   
00220   vtkSetMacro(PrintWeights,int);
00221   vtkGetMacro(PrintWeights,int);
00222 
00223 protected:
00224   vtkImageEMGenericClass();
00225   ~vtkImageEMGenericClass(){
00226     this->DeleteVariables(); 
00227   } 
00228 
00229   // Disable this function
00230   // vtkImageData* GetOutput() {return NULL;}
00231 
00232   void DeleteVariables(); 
00233   //BTX
00234   void ThreadedExecute(vtkImageData **vtkNotUsed(inData),
00235                        vtkImageData *vtkNotUsed(outData),
00236                        int vtkNotUsed(outExt)[6], int vtkNotUsed(id)) {};
00237   //ETX
00238   
00239  
00240   // Checks if all the parameters are setrectly
00241   // We do not have any input here
00242   //void  ExecuteData(vtkDataObject *) {this->Execute();}
00243   //void  Execute();
00244   void  ExecuteData(vtkDataObject *) ;
00245 
00246   float  ProbDataWeight;              // How much influence should the LocalPriorData have in the segmentation process 
00247   int    ProbDataScalarType;          // Scalar Type of ProbData
00248 
00249   double TissueProbability;           // Global Tissue Probability
00250   short  Label;
00251   float* InputChannelWeights;         // You can define different weights of input channels
00252   int    NumInputImages;              // Important for several input parameters such as size of LogCovariance 
00253 
00254   int    DataDim[3];                  // Dimension of image Data 
00255   float  DataSpacing[3];              // Spacing of image data
00256   int    SegmentationBoundaryMin[3];  // Boundary Box for the area of interest for the segmentation
00257   int    SegmentationBoundaryMax[3];  // Boundary Box for the area of interest for the segmentation 
00258   
00259   ProtocolMessages ErrorMessage;      // Lists all the error messges -> allows them to be displayed in tcl too 
00260   ProtocolMessages WarningMessage;    // Lists all the error messges -> allows them to be displayed in tcl too 
00261 
00262   int PrintWeights;                   // Print out Weights (1 = Normal 2=as shorts normed to 1000)   
00263 private:
00264   vtkImageEMGenericClass(const vtkImageEMGenericClass&); // Not implemented
00265   void operator=(const vtkImageEMGenericClass&);  // Not implemented
00266 };
00267 
00268 #endif
00269 
00270 
00271 
00272 
00273 
00274 
00275 
00276 
00277 
00278 
00279 

Generated on 6 Apr 2011 for Slicer3 by  doxygen 1.6.1