vtkTransRectalFiducialCalibrationAlgo.h

Go to the documentation of this file.
00001 /*=auto=========================================================================
00002 
00003   Portions (c) Copyright 2007 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: $
00010   Date:      $Date: $
00011   Version:   $Revision: $
00012 
00013 =========================================================================auto=*/
00014 // .NAME vtkTransRectalFiducialCalibrationAlgo - ...
00015 // .SECTION Description
00016 // vtkTransRectalFiducialCalibrationAlgo ... TODO: to be completed
00017 
00018 #ifndef __vtkTransRectalFiducialCalibrationAlgo_h
00019 #define __vtkTransRectalFiducialCalibrationAlgo_h
00020 
00021 #include "vtkObject.h"
00022 #include "vtkProstateNavWin32Header.h"
00023 
00024 class vtkMatrix4x4;
00025 class vtkImageData;
00026 class vtkProstateNavTargetDescriptor;
00027 struct NeedleDescriptorStruct;
00028 class vtkMRMLTRProstateBiopsyModuleNode;
00029 class vtkPoints;
00030 
00031 #include <vector>
00032 #include "itkPoint.h"
00033 
00034 const unsigned int CALIB_MARKER_COUNT=4;
00035 
00036 //BTX
00037 struct TRProstateBiopsyCalibrationFromImageInput
00038 {
00039   double MarkerInitialPositions[CALIB_MARKER_COUNT][3]; // in RAS coordinates
00040   double MarkerSegmentationThreshold[CALIB_MARKER_COUNT];
00041   double MarkerDimensionsMm[3];
00042   double MarkerRadiusMm;
00043   double RobotInitialAngle;
00044   vtkMatrix4x4 *VolumeIJKToRASMatrix;
00045   vtkImageData *VolumeImageData;
00046   std::string FoR; // frame of reference
00047 };
00048 
00049 struct TRProstateBiopsyCalibrationData
00050 {
00051   bool CalibrationValid;
00052   double AxesDistance;
00053   double RobotRegistrationAngleDegrees; // registration angle in degrees
00054   double AxesAngleDegrees; // angle alpha between two axes in degrees
00055   double I1[3];
00056   double I2[3]; 
00057   double v1[3];
00058   double v2[3];
00059   std::string FoR; // frame of reference UID
00060 };
00061 
00062 struct TRProstateBiopsyTargetingParams
00063 { 
00064   std::string GetReachableString() const
00065   { 
00066     if (this->IsOutsideReach) 
00067       return "No";
00068     else
00069       return "Yes";
00070   }
00071   
00073   bool TargetingParametersValid;
00074   double AxisRotation;    
00075   double NeedleAngle;     
00076   double DepthCM;         
00077   bool IsOutsideReach;    
00078   double HingePosition[3]; 
00079   
00080 };
00081 
00082 //ETX
00083 
00084 class VTK_PROSTATENAV_EXPORT vtkTransRectalFiducialCalibrationAlgo :
00085   public vtkObject
00086 {
00087 public:
00088 
00089   static vtkTransRectalFiducialCalibrationAlgo *New();
00090   vtkTypeRevisionMacro(vtkTransRectalFiducialCalibrationAlgo,vtkObject);
00091   void PrintSelf(ostream& os, vtkIndent indent);
00092 
00093   //BTX
00094   typedef itk::Point<double, 3> PointType;
00095 
00096   // Description
00097   // ... TODO: to be completed
00098   bool CalibrateFromImage(const TRProstateBiopsyCalibrationFromImageInput &input);  
00099   //ETX
00100 
00101   static bool FindTargetingParams(vtkProstateNavTargetDescriptor *target, const TRProstateBiopsyCalibrationData &calibrationData, NeedleDescriptorStruct *needle, TRProstateBiopsyTargetingParams *targetingParams);
00102 
00103   // Description
00104   // Return true if the i-th marker position is successfully detected
00105   bool GetMarkerFound(int i);
00106 
00107   // Description
00108   // Return the i-th marker position (in RAS coordinates)
00109   double* GetMarkerPositions(int i);
00110 
00111   vtkImageData *GetCalibMarkerPreProcOutput(int i);
00112   vtkMatrix4x4* GetCalibMarkerPreProcOutputIJKToRAS();
00113   void GetAxisCenterpoints(vtkPoints *points, int i);
00114 
00115   const TRProstateBiopsyCalibrationData& GetCalibrationData() { return this->CalibrationData; }
00116 
00117   // Description
00118   // Enable automatic adjustment of the clicked marker centerpoint position based on the
00119   // image contents. If disabled, then the manually defined marker positions considered to be
00120   // the centerpoints.
00121   // By default it is enabled.
00122   void SetEnableMarkerCenterpointAdjustment(bool enable);
00123 
00124 protected:
00125 
00126   static bool RotatePoint(double H_before[3], double rotation_rad, double alpha_rad, double mainaxis[3], double I[3], /*out*/double H_after[3]);
00127 
00128   //BTX
00129   void SegmentAxis(const double initPos1[3], const double initPos2[3], vtkMatrix4x4 *volumeIJKToRASMatrix, vtkImageData* calibVol,
00130     double thresh1, double thresh2, const double fidDimsMm[3], double radius, double initialAngle, 
00131     double P1[3], double v1[3], double finalPos1[3], double finalPos2[3], bool &found1, bool &found2, vtkImageData* img1, vtkImageData* img2, std::vector<PointType> *CoordinatesVectorAxis);
00132   // thresh: 0..100, binary threshold value (0 corresponds to min voxel value; 100 corresponds to max voxel value in the image)
00133   bool SegmentCircle(double markerCenterGuessRas[3],const double normalRas[3],  double thresh, const double fidDimsMm[3], double radius, vtkMatrix4x4 *ijkToRAS, vtkImageData *calibVol, std::vector<PointType> &CoordinatesVector, vtkImageData *preprocOutput=NULL);
00134   //ETX
00135   bool CalculateCircleCenter(vtkImageData *inData, unsigned int *tempStorage, int tempStorageSize, double nThersholdVal, double nRadius, double &gx, double &gy, int nVotedNeeded, bool lDebug);  
00136   bool CalculateCircleCenterMean(vtkImageData *inData, double nRadius, double threshold, double &gx, double &gy);  
00137   //BTX
00138   void RemoveOutliners(double P_[3], double v_[3], const double def1[3], const double def2[3], std::vector<PointType> &CoordinatesVector);
00139   //ETX
00140   bool FindProbe(const double P1[3], const double P2[3], double v1[3], double v2[3], 
00141     double I1[3], double I2[3], double &axesAngleDegrees, double &axesDistance);
00142   //BTX
00143   void Linefinder(double P_[3], double v_[3], std::vector<itk::Point<double,3> > CoordVector);
00144   //ETX
00145 
00146   void CropWithCylinder(vtkImageData* output, vtkImageData* input, const double linePoint_RAS[3],const double normal_RAS[3], vtkMatrix4x4 *ijkToRAS, double radiusMm);
00147 
00148   bool DoubleEqual(double val1, double val2);
00149 
00150   vtkTransRectalFiducialCalibrationAlgo();
00151   virtual ~vtkTransRectalFiducialCalibrationAlgo();
00152 
00153   //BTX
00154   std::vector<PointType> CoordinatesVectorAxis1;
00155   std::vector<PointType> CoordinatesVectorAxis2;
00156   std::vector<vtkImageData*> CalibMarkerPreProcOutput;
00157   vtkMatrix4x4* CalibMarkerPreProcOutputIJKToRAS;
00158   bool MarkerFound[CALIB_MARKER_COUNT];
00159   double MarkerPositions[CALIB_MARKER_COUNT][3]; // in RAS coordinates
00160   //ETX
00161 
00162   TRProstateBiopsyCalibrationData CalibrationData;
00163 
00164   bool EnableMarkerCenterpointAdjustment;
00165 
00166 private:
00167   vtkTransRectalFiducialCalibrationAlgo(const vtkTransRectalFiducialCalibrationAlgo&);  // Not implemented.
00168   void operator=(const vtkTransRectalFiducialCalibrationAlgo&);  // Not implemented.
00169 };
00170 
00171 #endif

Generated on 6 Apr 2011 for Slicer3 by  doxygen 1.6.1