NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
SeansVesselReg.hxx
Go to the documentation of this file.
1 #ifndef SeansVesselSegmentation_hxx
2 #define SeansVesselSegmentation_hxx
3 
4 #include "cxResourceExport.h"
5 
8 #include "cxTransform3D.h"
9 #include "vtkSmartPointer.h"
10 
11 namespace cx
12 {
30 class cxResource_EXPORT SeansVesselReg
31 {
32 public:
36  struct cxResource_EXPORT Context
37  {
41 
42  vtkPolyDataPtr getMovingPoints();
43  vtkPolyDataPtr getFixedPoints();
44  vtkPolyDataPtr getDifferenceLines();
45 
48 
51  double mMetric;
52 
53  double mLtsRatio;
54 
55  //---------------------------------------------------------------------------
56  //TODO non-linear needs to handle this!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
58  //---------------------------------------------------------------------------
59  };
60  typedef boost::shared_ptr<Context> ContextPtr;
61 
63  ~SeansVesselReg();
64 
65  bool initialize(DataPtr source, DataPtr target, QString logPath);
66  bool isValid() const;
67  bool execute();
68  bool performOneRegistration();
69 
70  Transform3D getLinearResult(ContextPtr context=ContextPtr());
71  double getResultMetric(ContextPtr context=ContextPtr());
72  double getResultLtsRatio(ContextPtr context=ContextPtr());
73  Transform3D getNonLinearTransform();
74  void checkQuality(Transform3D linearTransform);
75 // ImagePtr loadMinc(char* source_file);
76  void setDebugOutput(bool on)
77  {
78  mt_verbose = on;
79  }
80  vtkPolyDataPtr getDifferenceLines();
81  void notifyPreRegistrationWarnings();
82 
83 
87  double mt_lambda;
88  double mt_sigma;
90 // bool mt_doStepping;
94  bool mt_verbose;
96  double margin;
97  QString m_logPath;
98 
99  // debug interface:
100  ContextPtr createContext(DataPtr source, DataPtr target);
101  void performOneRegistration(ContextPtr context, bool linear);
102  void computeDistances(ContextPtr context = ContextPtr());
103  static vtkPolyDataPtr convertToPolyData(vtkPointsPtr input);
104 
112  static vtkPolyDataPtr extractPolyData(ImagePtr image, int p_neighborhoodFilterThreshold,
113  double p_BoundingBox[6]);
114 private:
115  Transform3D getLinearTransform(vtkGeneralTransformPtr concatenation);
116 
117 protected:
118  bool runAlgorithm(ContextPtr context, vtkGeneralTransformPtr myConcatenation, int largeSteps, double fraction);
119  void printOutResults(QString fileNamePrefix, vtkGeneralTransformPtr myConcatenation);
120  vtkAbstractTransformPtr linearRegistration(vtkPointsPtr sortedSourcePoints, vtkPointsPtr sortedTargetPoints);
121  vtkAbstractTransformPtr nonLinearRegistration(vtkPointsPtr sortedSourcePoints, vtkPointsPtr sortedTargetPoints);
122  vtkPolyDataPtr convertToPolyData(DataPtr data, QString id);
124  vtkPointsPtr createSortedPoints(vtkIdListPtr sortedIDList, vtkPointsPtr unsortedPoints, int numPoints);
125  vtkPolyDataPtr crop(vtkPolyDataPtr input, vtkPolyDataPtr fixed, double margin);
126  ContextPtr linearRefineAllLTS(ContextPtr context);
127  void linearRefine(ContextPtr context);
128  SeansVesselReg::ContextPtr splitContext(ContextPtr context);
129 
130  void print(vtkPointsPtr points);
131  void print(vtkPolyDataPtr data);
132 
133 
134 
135 // Transform3D mLinearTransformResult;
137 
138 // //---------------------------------------------------------------------------
139 // //TODO non-linear needs to handle this!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
140 // bool mInvertedTransform; ///< the calculated registration goes from target to source instead of source to target
141 // //---------------------------------------------------------------------------
142 };
143 }//namespace cx
144 #endif
cx::SeansVesselReg::Context::mSortedTargetPoints
vtkPointsPtr mSortedTargetPoints
source points projected onto the target points (closest points) mSortedSourcePoints==mSortedTargetPoi...
Definition: SeansVesselReg.hxx:47
cx::SeansVesselReg::Context::mSortedSourcePoints
vtkPointsPtr mSortedSourcePoints
source points sorted according to distance to target, mSortedSourcePoints==mSortedTargetPoints
Definition: SeansVesselReg.hxx:46
cx::SeansVesselReg::mt_doOnlyLinear
bool mt_doOnlyLinear
Definition: SeansVesselReg.hxx:89
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::print
void print(QString header, QRect r)
Definition: cxSecondaryViewLayoutWindow.cpp:35
cxForwardDeclarations.h
cx::SeansVesselReg::setDebugOutput
void setDebugOutput(bool on)
Definition: SeansVesselReg.hxx:76
cx::SeansVesselReg::mLastRun
ContextPtr mLastRun
result from last run of execute()
Definition: SeansVesselReg.hxx:136
cx::SeansVesselReg::Context::mConcatenation
vtkGeneralTransformPtr mConcatenation
output: concatenation of all transforms so far
Definition: SeansVesselReg.hxx:49
vtkCellLocatorPtr
vtkSmartPointer< class vtkCellLocator > vtkCellLocatorPtr
Definition: vtkForwardDeclarations.h:42
cx::SeansVesselReg::Context::mLtsRatio
double mLtsRatio
local copy of the lts ratio, can be changed for current iteration.
Definition: SeansVesselReg.hxx:53
cx::SeansVesselReg::mt_auto_lts
bool mt_auto_lts
Definition: SeansVesselReg.hxx:84
vtkAbstractTransformPtr
vtkSmartPointer< class vtkAbstractTransform > vtkAbstractTransformPtr
Definition: vtkForwardDeclarations.h:29
cx::SeansVesselReg::mt_verbose
bool mt_verbose
Definition: SeansVesselReg.hxx:94
cx::SeansVesselReg::mt_maximumDurationSeconds
double mt_maximumDurationSeconds
Definition: SeansVesselReg.hxx:95
cx::SeansVesselReg::mt_singlePointThreshold
int mt_singlePointThreshold
Definition: SeansVesselReg.hxx:92
cx::SeansVesselReg::m_logPath
QString m_logPath
Definition: SeansVesselReg.hxx:97
cx::Transform3D
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
Definition: cxLandmarkPatientRegistrationWidget.h:33
cx::SeansVesselReg::Context
Definition: SeansVesselReg.hxx:36
cx::vtkPointsPtr
vtkSmartPointer< vtkPoints > vtkPointsPtr
Definition: cxCenterlineRegistration.h:41
cx::DataPtr
boost::shared_ptr< class Data > DataPtr
Definition: cxRegistrationApplicator.h:22
cx::SeansVesselReg::mt_distanceDeltaStopThreshold
double mt_distanceDeltaStopThreshold
Definition: SeansVesselReg.hxx:86
vtkIdListPtr
vtkSmartPointer< class vtkIdList > vtkIdListPtr
Definition: vtkForwardDeclarations.h:62
vtkForwardDeclarations.h
cx::ImagePtr
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:27
cx::SeansVesselReg::mt_maximumNumberOfIterations
int mt_maximumNumberOfIterations
Definition: SeansVesselReg.hxx:93
cx::vtkPolyDataPtr
vtkSmartPointer< vtkPolyData > vtkPolyDataPtr
Definition: cxCenterlineRegistration.h:42
cx::SeansVesselReg::mt_lambda
double mt_lambda
Definition: SeansVesselReg.hxx:87
cx::SeansVesselReg::Context::mMetric
double mMetric
output: mean least squares from BEFORE last iteration.
Definition: SeansVesselReg.hxx:51
cx::SeansVesselReg::mt_ltsRatio
int mt_ltsRatio
Definition: SeansVesselReg.hxx:85
cx::SeansVesselReg::Context::mSourcePoints
vtkPointsPtr mSourcePoints
input: current source data, modified according to last iteration
Definition: SeansVesselReg.hxx:40
cx::transform
DoubleBoundingBox3D transform(const Transform3D &m, const DoubleBoundingBox3D &bb)
Definition: cxTransform3D.cpp:150
cx::SeansVesselReg::mt_sampleRatio
int mt_sampleRatio
Definition: SeansVesselReg.hxx:91
cxTransform3D.h
cx::SeansVesselReg::Context::mTransform
vtkAbstractTransformPtr mTransform
output: transform from last iteration
Definition: SeansVesselReg.hxx:50
cx::SeansVesselReg
Definition: SeansVesselReg.hxx:30
cx::SeansVesselReg::Context::mTargetPoints
vtkPolyDataPtr mTargetPoints
input: target data
Definition: SeansVesselReg.hxx:39
vtkGeneralTransformPtr
vtkSmartPointer< class vtkGeneralTransform > vtkGeneralTransformPtr
Definition: vtkForwardDeclarations.h:59
cx::SeansVesselReg::Context::mTargetPointLocator
vtkCellLocatorPtr mTargetPointLocator
input: target data wrapped in a locator
Definition: SeansVesselReg.hxx:38
cx::SeansVesselReg::margin
double margin
Definition: SeansVesselReg.hxx:96
cx::SeansVesselReg::ContextPtr
boost::shared_ptr< Context > ContextPtr
Definition: SeansVesselReg.hxx:60
cx::SeansVesselReg::mt_sigma
double mt_sigma
Definition: SeansVesselReg.hxx:88
cx::SeansVesselReg::Context::mInvertedTransform
bool mInvertedTransform
the calculated registration goes from target to source instead of source to target
Definition: SeansVesselReg.hxx:57