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
00022
00023 vtkGetStringMacro (ModuleName);
00024 vtkSetStringMacro (ModuleName);
00025
00026
00027
00028
00029 virtual bool StartPreprocessingInitializeInputData();
00030
00031 vtkstd::string GetTclGeneralDirectory();
00032
00033
00034
00035
00036
00037 virtual void CopyDataToSegmenter(vtkImageEMLocalSegmenter* segmenter);
00038
00039
00040
00041
00042 vtkGetStringMacro(ProgressCurrentAction);
00043 vtkGetMacro(ProgressGlobalFractionCompleted, double);
00044 vtkGetMacro(ProgressCurrentFractionCompleted, double);
00045
00046
00047
00048
00049
00050 vtkGetObjectMacro(MRMLManager, vtkEMSegmentMRMLManager);
00051
00052
00053
00054
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
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
00093 static void SlicerImageReslice(vtkMRMLVolumeNode* inputVolumeNode,
00094 vtkMRMLVolumeNode* outputVolumeNode,
00095 vtkMRMLVolumeNode* outputVolumeGeometryNode,
00096 vtkTransform* outputRASToInputRASTransform,
00097 int iterpolationType,
00098 double backgroundLevel);
00099
00100
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
00111 std::string GetErrorMessage() {return this->ErrorMsg;}
00112
00113
00114 virtual void CreateOutputVolumeNode();
00115
00116 void SubParcelateSegmentation(vtkImageData* segmentation, vtkIdType nodeID);
00117
00118
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
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
00128
00129 protected:
00130
00131 vtkSetObjectMacro(MRMLManager, vtkEMSegmentMRMLManager);
00132
00133
00134 template <class T>
00135 static T GuessRegistrationBackgroundLevel(vtkImageData* imageData);
00136
00137
00138 static void
00139 ComposeGridTransform(vtkGridTransform* inGrid,
00140 vtkMatrix4x4* preMultiply,
00141 vtkMatrix4x4* postMultiply,
00142 vtkGridTransform* outGrid);
00143
00144
00145
00146 static bool IsVolumeGeometryEqual(vtkMRMLVolumeNode* lhs,
00147 vtkMRMLVolumeNode* rhs);
00148
00149 static void PrintImageInfo(vtkMRMLVolumeNode* volumeNode);
00150 static void PrintImageInfo(vtkImageData* image);
00151
00152
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
00168
00169 virtual int
00170 ConvertGUIEnumToAlgorithmEnumStoppingConditionType(int guiEnumValue);
00171 virtual int
00172 ConvertGUIEnumToAlgorithmEnumInterpolationType(int guiEnumValue);
00173
00174
00175
00176 vtkSetStringMacro(ProgressCurrentAction);
00177 vtkSetMacro(ProgressGlobalFractionCompleted, double);
00178 vtkSetMacro(ProgressCurrentFractionCompleted, double);
00179
00180
00181
00182
00183
00184 vtkEMSegmentMRMLManager* MRMLManager;
00185
00186 char *ModuleName;
00187
00188
00189
00190
00191 char* ProgressCurrentAction;
00192 double ProgressGlobalFractionCompleted;
00193 double ProgressCurrentFractionCompleted;
00194
00195 std::string ErrorMsg;
00196
00197 vtkEMSegmentLogic();
00198 ~vtkEMSegmentLogic();
00199
00200 private:
00201 vtkEMSegmentLogic(const vtkEMSegmentLogic&);
00202 void operator=(const vtkEMSegmentLogic&);
00203 };
00204
00205 #endif