vtkEMSegmentLogic.h

Go to the documentation of this file.
00001 #ifndef __vtkEMSegmentLogic_h
00002 #define __vtkEMSegmentLogic_h
00003 
00004 #include "vtkSlicerModuleLogic.h"
00005 #include "vtkEMSegment.h"
00006 #include "vtkEMSegmentMRMLManager.h"
00007 
00008 class vtkImageEMLocalSegmenter;
00009 class vtkImageEMLocalGenericClass;
00010 class vtkImageEMLocalSuperClass;
00011 class vtkImageEMLocalClass;
00012 class vtkSlicerApplicationLogic;
00013 class vtkGridTransform;
00014 
00015 class VTK_EMSEGMENT_EXPORT vtkEMSegmentLogic : public vtkSlicerModuleLogic
00016 {
00017 public:
00018   static vtkEMSegmentLogic *New();
00019   vtkTypeMacro(vtkEMSegmentLogic,vtkSlicerModuleLogic);
00020 
00021   // Description: The name of the Module---this is used to construct
00022   // the proc invocations
00023   vtkGetStringMacro (ModuleName);
00024   vtkSetStringMacro (ModuleName);
00025 
00026   //
00027   // actions
00028   //
00029   virtual bool      StartPreprocessingInitializeInputData();
00030   //BTX
00031   vtkstd::string GetTclGeneralDirectory();
00032   //ETX
00033   
00034   // Used within StartSegmentation to copy data from the MRMLManager
00035   // to the segmenter algorithm.  Possibly useful for research
00036   // purposes.
00037   virtual void      CopyDataToSegmenter(vtkImageEMLocalSegmenter* segmenter);
00038 
00039   //
00040   // progress bar related functions: not currently used, likely to
00041   // change
00042   vtkGetStringMacro(ProgressCurrentAction);
00043   vtkGetMacro(ProgressGlobalFractionCompleted, double);
00044   vtkGetMacro(ProgressCurrentFractionCompleted, double);
00045 
00046   //
00047   // MRML Related Methods.  The collection of MRML nodes for the
00048   // EMSegmenter is complicated.  Therefore, the management of these
00049   // nodes are delegated to the vtkEMSegmentMRMLManager class.
00050   vtkGetObjectMacro(MRMLManager, vtkEMSegmentMRMLManager);
00051 
00052   //
00053   // Register all the nodes used by this module with the current MRML
00054   // scene.
00055   virtual void RegisterMRMLNodesWithScene()
00056       { 
00057       this->MRMLManager->RegisterMRMLNodesWithScene(); 
00058       }
00059 
00060   virtual void SetAndObserveMRMLScene(vtkMRMLScene* scene)
00061       {
00062       Superclass::SetAndObserveMRMLScene(scene);
00063       this->MRMLManager->SetMRMLScene(scene);
00064       }
00065 
00066   virtual void ProcessMRMLEvents ( vtkObject *caller, unsigned long event,
00067                                    void *callData )
00068       { 
00069       this->MRMLManager->ProcessMRMLEvents(caller, event, callData); 
00070       }
00071 
00072   // events to observe
00073   virtual vtkIntArray* NewObservableEvents();
00074 
00075   void StartPreprocessingResampleAndCastToTarget(vtkMRMLVolumeNode* movingVolumeNode, vtkMRMLVolumeNode* fixedVolumeNode, vtkMRMLVolumeNode* outputVolumeNode);
00076 
00077   static void TransferIJKToRAS(vtkMRMLVolumeNode* volumeNode, int ijk[3], double ras[3]);
00078   static void TransferRASToIJK(vtkMRMLVolumeNode* volumeNode, double ras[3], int ijk[3]);
00079 
00080 
00081   static double GuessRegistrationBackgroundLevel(vtkMRMLVolumeNode* volumeNode);
00082 
00083   static void 
00084   SlicerImageResliceWithGrid(vtkMRMLVolumeNode* inputVolumeNode,
00085                              vtkMRMLVolumeNode* outputVolumeNode,
00086                              vtkMRMLVolumeNode* outputVolumeGeometryNode,
00087                              vtkGridTransform* outputRASToInputRASTransform,
00088                              int iterpolationType,
00089                              double backgroundLevel);
00090 
00091 
00092   // utility---should probably go to general slicer lib at some point
00093   static void SlicerImageReslice(vtkMRMLVolumeNode* inputVolumeNode,
00094                                  vtkMRMLVolumeNode* outputVolumeNode,
00095                                  vtkMRMLVolumeNode* outputVolumeGeometryNode,
00096                                  vtkTransform* outputRASToInputRASTransform,
00097                                   int iterpolationType,
00098                                  double backgroundLevel);
00099 
00100   // Helper Classes for tcl 
00101   void PrintTextNoNewLine(char *TEXT);
00102   void PrintText(char *TEXT);
00103 
00104   void DefineValidSegmentationBoundary(); 
00105   void AutoCorrectSpatialPriorWeight(vtkIdType nodeID);
00106 
00107   vtkMRMLScalarVolumeNode* AddArchetypeScalarVolume (const char* filename, const char* volname, vtkSlicerApplicationLogic* appLogic,  vtkMRMLScene* mrmlScene);
00108 
00109 
00110   //BTX
00111   std::string GetErrorMessage() {return this->ErrorMsg;}
00112   //ETX 
00113 
00114   virtual void                              CreateOutputVolumeNode();
00115 
00116   void SubParcelateSegmentation(vtkImageData* segmentation, vtkIdType nodeID);
00117 
00118   // functions for packaging and writing intermediate results
00119   virtual void CreatePackageFilenames(vtkMRMLScene* scene, 
00120                                       const char* packageDirectoryName);
00121   virtual bool CreatePackageDirectories(const char* packageDirectoryName);
00122   virtual bool WritePackagedScene(vtkMRMLScene* scene);
00123 
00124 //BTX
00125   void AddDefaultTasksToList(const char* FilePath, std::vector<std::string> & DefaultTasksName,  std::vector<std::string> & DefaultTasksFile, 
00126                  std::vector<std::string> & DefinePreprocessingTasksName, std::vector<std::string>  & DefinePreprocessingTasksFile);
00127 //ETX
00128 
00129 protected: 
00130   // the mrml manager is created in the constructor
00131   vtkSetObjectMacro(MRMLManager, vtkEMSegmentMRMLManager);
00132 
00133   //BTX
00134   template <class T>
00135   static T GuessRegistrationBackgroundLevel(vtkImageData* imageData);
00136   //ETX
00137 
00138   static void
00139   ComposeGridTransform(vtkGridTransform* inGrid,
00140                        vtkMatrix4x4*     preMultiply,
00141                        vtkMatrix4x4*     postMultiply,
00142                        vtkGridTransform* outGrid);
00143 
00144   // Description:
00145   // Convenience method for determining if two volumes have same geometry
00146   static bool IsVolumeGeometryEqual(vtkMRMLVolumeNode* lhs,
00147                                     vtkMRMLVolumeNode* rhs);
00148 
00149   static void PrintImageInfo(vtkMRMLVolumeNode* volumeNode);
00150   static void PrintImageInfo(vtkImageData* image);
00151 
00152   // copy data from MRML to algorithm
00153   virtual void CopyAtlasDataToSegmenter(vtkImageEMLocalSegmenter* segmenter);
00154   virtual void CopyTargetDataToSegmenter(vtkImageEMLocalSegmenter* segmenter);
00155   virtual void CopyGlobalDataToSegmenter(vtkImageEMLocalSegmenter* segmenter);
00156   virtual void CopyTreeDataToSegmenter(vtkImageEMLocalSuperClass* node,
00157                                        vtkIdType nodeID);
00158   virtual void CopyTreeGenericDataToSegmenter(vtkImageEMLocalGenericClass* 
00159                                               node,
00160                                               vtkIdType nodeID);
00161   virtual void CopyTreeParentDataToSegmenter(vtkImageEMLocalSuperClass* node,
00162                                              vtkIdType nodeID);
00163   virtual void CopyTreeLeafDataToSegmenter(vtkImageEMLocalClass* node,
00164                                            vtkIdType nodeID);  
00165 
00166   //
00167   // convenience methods for translating enums between algorithm and
00168   // this module
00169   virtual int
00170     ConvertGUIEnumToAlgorithmEnumStoppingConditionType(int guiEnumValue);
00171   virtual int
00172     ConvertGUIEnumToAlgorithmEnumInterpolationType(int guiEnumValue);
00173 
00174 
00175   // not currently used
00176   vtkSetStringMacro(ProgressCurrentAction);
00177   vtkSetMacro(ProgressGlobalFractionCompleted, double);
00178   vtkSetMacro(ProgressCurrentFractionCompleted, double);
00179 
00180 
00181   //
00182   // because the mrml nodes are very complicated for this module, we
00183   // delegate the handeling of them to a MRML manager
00184   vtkEMSegmentMRMLManager* MRMLManager;
00185 
00186   char *ModuleName;
00187 
00188   //
00189   // information related to progress bars: this mechanism is not
00190   // currently implemented and might me best implemented elsewhere
00191   char*  ProgressCurrentAction;
00192   double ProgressGlobalFractionCompleted;
00193   double ProgressCurrentFractionCompleted;
00194   //BTX
00195   std::string ErrorMsg; 
00196   //ETX
00197   vtkEMSegmentLogic();
00198   ~vtkEMSegmentLogic();
00199 
00200 private:
00201   vtkEMSegmentLogic(const vtkEMSegmentLogic&);
00202   void operator=(const vtkEMSegmentLogic&);
00203 };
00204 
00205 #endif

Generated on 6 Apr 2011 for Slicer3 by  doxygen 1.6.1