MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
QmitkUltrasoundCalibration.h
Go to the documentation of this file.
1/*============================================================================
2
3The Medical Imaging Interaction Toolkit (MITK)
4
5Copyright (c) German Cancer Research Center (DKFZ)
6All rights reserved.
7
8Use of this source code is governed by a 3-clause BSD license that can be
9found in the LICENSE file.
10
11============================================================================*/
12
13#ifndef QmitkUltrasoundCalibration_h
14#define QmitkUltrasoundCalibration_h
15
16#include <berryISelectionListener.h>
17
18#include <QmitkAbstractView.h>
19
20// MITK
21#include <mitkIGTLClient.h>
24#include <mitkPointSet.h>
25#include <mitkPointSetDifferenceStatisticsCalculator.h>
27
28// Microservices
29#include "ui_QmitkUltrasoundCalibrationControls.h"
30
31#include <vtkLandmarkTransform.h>
32#include <vtkPolyData.h>
33#include <vtkSmartPointer.h>
34
35#include <ctkServiceEvent.h>
36
44class QmitkUltrasoundCalibration : public QmitkAbstractView
45{
46 Q_OBJECT
47
48public:
51
52 static const std::string VIEW_ID;
53
54 void CreateQtPartControl(QWidget *parent) override;
55
56 void OnUSDepthChanged(const std::string &, const std::string &);
57
58protected slots:
59
64 void OnTabSwitch(int index);
65
70 void OnDeviceSelected();
71 void OnDeviceDeselected();
72
77 void OnAddCalibPoint();
78
83 void OnCalibration();
84
91
98
102 void OnSaveEvaluation();
103
107 void OnSaveCalibration();
108
112 void OnReset();
113
118 void Update();
119
123 void SwitchFreeze();
124
129
134
136
140 void OnStartStreaming();
141
142 void OnNewConnection();
143
148
153 void ProcessPlusCalibration(igtl::Matrix4x4 &imageToTracker);
154
156
161
163
164 void OnStartVerification();
165
167
168 void OnDeviceServiceEvent(const ctkServiceEvent event);
169
170 void OnFreezeClicked();
171
172 void OnAddSpacingPoint();
173
174 void OnCalculateSpacing();
175
176 /*
177 * \brief load the configuration of the phantom fiducials which have to be saved as points in the sensor coordinate
178 * system of the tracking sensor attached to the phantom
179 */
181 /*
182 * \brief match the annotation pointset with the geometry of the phantom configuration
183 */
185 /*
186 * \brief move the annotation pointset up
187 */
189 /*
190 * \brief move the annotation pointset down
191 */
193 /*
194 * \brief move the annotation pointset left
195 */
197 /*
198 * \brief move the annotation pointset right
199 */
201 /*
202 * \brief rotate the annotation pointset right
203 */
205 /*
206 * \brief rotate the annotation pointset left
207 */
209
210 /*
211 * \brief add a calibration point to be used for phantom based calibration
212 */
214 /*
215 * \brief perform phantom based calibration
216 */
218
219signals:
225
226protected:
227 void SetFocus() override;
228
229 void OnSelectionChanged(berry::IWorkbenchPart::Pointer source, const QList<mitk::DataNode::Pointer> &nodes) override;
230
234 void TranslatePhantomAnnotations(double tx, double ty, double tz);
237 void RotatePhantomAnnotations(double angle);
238
239 Ui::QmitkUltrasoundCalibrationControls m_Controls;
240
244 void ShowNeedlePath();
245
250
251 void OnPlusConnected();
252
256 mitk::AbstractUltrasoundTrackerDevice::Pointer m_CombinedModality;
257
262 mitk::NavigationDataSource::Pointer m_Tracker;
263
264 QTimer *m_Timer;
265
266 mitk::DataNode::Pointer m_Node;
267 mitk::DataNode::Pointer m_CalibNode;
268 mitk::DataNode::Pointer m_WorldNode;
269
270 // IGTL Servers and Devices needed for the communication with PLUS
271 mitk::IGTLServer::Pointer m_USServer;
272 mitk::IGTLMessageProvider::Pointer m_USMessageProvider;
273 mitk::ImageToIGTLMessageFilter::Pointer m_USImageToIGTLMessageFilter;
274
275 mitk::IGTLServer::Pointer m_TrackingServer;
276 mitk::IGTLMessageProvider::Pointer m_TrackingMessageProvider;
277 mitk::NavigationDataToIGTLMessageFilter::Pointer m_TrackingToIGTLMessageFilter;
278
279 mitk::IGTLClient::Pointer m_TransformClient;
280 mitk::IGTLDeviceSource::Pointer m_TransformDeviceSource;
281
283
285
289 mitk::Image::Pointer m_Image;
293 mitk::Point3D m_FreezePoint;
294
298 mitk::PointSet::Pointer m_CalibPointsImage;
302 mitk::PointSet::Pointer m_CalibPointsTool;
303 mitk::PointSet::Pointer
308 mitk::PointSet::Pointer m_EvalPointsProjected;
312 mitk::PointSet::Pointer m_EvalPointsImage;
316 mitk::PointSet::Pointer m_EvalPointsTool;
317
321 mitk::PointSet::Pointer m_VerificationReferencePoints;
323
325 std::vector<mitk::Point3D> m_allReferencePoints;
326 std::vector<double> m_allErrors;
327
331 mitk::NeedleProjectionFilter::Pointer m_NeedleProjectionFilter;
336
338
343 mitk::PointSetDifferenceStatisticsCalculator::Pointer m_ProjectionStatistics;
348 mitk::PointSetDifferenceStatisticsCalculator::Pointer m_EvaluationStatistics;
353 mitk::PointSetDifferenceStatisticsCalculator::Pointer m_CalibrationStatistics;
354
358 mitk::AffineTransform3D::Pointer m_Transformation;
359
364 vtkSmartPointer<vtkPolyData> ConvertPointSetToVtkPolyData(mitk::PointSet::Pointer PointSet);
365
366 double ComputeFRE(mitk::PointSet::Pointer imageFiducials,
367 mitk::PointSet::Pointer realWorldFiducials,
368 vtkSmartPointer<vtkLandmarkTransform> transform = nullptr);
369
370 void ApplyTransformToPointSet(mitk::PointSet::Pointer pointSet, vtkSmartPointer<vtkAbstractTransform> transform);
371
372 mitk::PointSet::Pointer m_SpacingPoints;
373 mitk::DataNode::Pointer m_SpacingNode;
375
376private:
377 mitk::MessageDelegate2<QmitkUltrasoundCalibration, const std::string &, const std::string &> m_USDeviceChanged;
378};
379
380#endif
QmitkUltrasoundCalibration.
void CreateQtPartControl(QWidget *parent) override
mitk::PointSet::Pointer m_CalibPointsImage
Pointset containing all tool points.
mitk::PointSetDifferenceStatisticsCalculator::Pointer m_CalibrationStatistics
StatisticsRegarding Calibration Accuracy. (Compares m_CalibPointsTool to a transformed copy of m_Cali...
mitk::NavigationDataSource::Pointer m_Tracker
NavigationDataSource used for tracking data. This will be gotten by the combined modality.
mitk::PointSetDifferenceStatisticsCalculator::Pointer m_EvaluationStatistics
StatisticsRegarding Evaluation Accuracy. (Compares m_EvalPointsTool to m_EvalPointsImage)
mitk::PointSet::Pointer m_EvalPointsTool
Pointset containing tracked evaluation points.
void OnStartPlusCalibration()
Method to use the PLUS-Toolkoit for Calibration of EchoTrack.
mitk::Image::Pointer m_Image
The current Ultrasound Image.
mitk::PointSet::Pointer m_SpacingPoints
void OnReset()
Triggered when the user clicks "Run Next Round". Also used as a reset mechanism.
void OnSaveEvaluation()
Triggered when the user clicks "Save Results" in the Evaluation tab.
void SwitchFreeze()
Freezes or unfreezes the image.
mitk::AffineTransform3D::Pointer m_Transformation
Result of the Calibration.
Ui::QmitkUltrasoundCalibrationControls m_Controls
void OnUSDepthChanged(const std::string &, const std::string &)
void NewConnectionSignal()
used for thread separation, the worker thread must not call OnNewConnection directly....
mitk::DataNode::Pointer m_VerificationReferencePointsDataNode
void OnDeviceServiceEvent(const ctkServiceEvent event)
void TranslatePhantomAnnotations(double tx, double ty, double tz)
translate the annotated image feature m_CalibPoints image by the specified translation vector
void ApplyTransformToPointSet(mitk::PointSet::Pointer pointSet, vtkSmartPointer< vtkAbstractTransform > transform)
mitk::PointSet::Pointer m_EvalPointsProjected
Pointset containing Projected Points (aka "where we thought the needle was gonna land")
std::vector< mitk::Point3D > m_allReferencePoints
double ComputeFRE(mitk::PointSet::Pointer imageFiducials, mitk::PointSet::Pointer realWorldFiducials, vtkSmartPointer< vtkLandmarkTransform > transform=nullptr)
void RotatePhantomAnnotations(double angle)
rotate the annotated image feature m_CalibPoints image by the specified angle
mitk::IGTLServer::Pointer m_USServer
void OnAddCalibPoint()
Triggered, when the user clicks "Add Point".
mitk::PointSet::Pointer m_PhantomConfigurationPointSet
pointset holding the feature position of the phantom in tool coordinates
mitk::PointSet::Pointer m_CalibPointsTool
Pointset containing corresponding points on the image.
void OnAddEvalProjectedPoint()
Triggered, when the user clicks "Add Point".
mitk::IGTLMessageProvider::Pointer m_TrackingMessageProvider
mitk::IGTLMessageProvider::Pointer m_USMessageProvider
mitk::AbstractUltrasoundTrackerDevice::Pointer m_CombinedModality
The combined modality used for imaging and tracking.
void OnTabSwitch(int index)
Triggered, whenever the user switches Tabs.
void OnCalibration()
Triggered, when the user clicks "Calibrate".
void ClearTemporaryMembers()
Clears all member attributes which are holding intermediate results for the calibration.
vtkSmartPointer< vtkPolyData > ConvertPointSetToVtkPolyData(mitk::PointSet::Pointer PointSet)
mitk::IGTLClient::Pointer m_TransformClient
mitk::ImageToIGTLMessageFilter::Pointer m_USImageToIGTLMessageFilter
int m_CalibPointsCount
Total number of calibration points set.
void OnSelectionChanged(berry::IWorkbenchPart::Pointer source, const QList< mitk::DataNode::Pointer > &nodes) override
mitk::IGTLDeviceSource::Pointer m_TransformDeviceSource
mitk::NeedleProjectionFilter::Pointer m_NeedleProjectionFilter
Creates a Pointset that projects the needle's path.
mitk::PointSet::Pointer m_VerificationReferencePoints
Pointset containing tracked evaluation points.
void ProcessPlusCalibration(igtl::Matrix4x4 &imageToTracker)
void OnDeviceSelected()
Triggered, when the user has clicked "select Devices".
void OnAddEvalTargetPoint()
Triggered, when the user clicks "Add Target Points".
mitk::PointSetDifferenceStatisticsCalculator::Pointer m_ProjectionStatistics
StatisticsRegarding Projection Accuracy. (Compares m_EvalPointsProjected to m_EvalPointsImage)
void Update()
Triggered in regular intervals by a timer, when live view is enabled.
void OnSaveCalibration()
Triggered when the user clicks "Save Calibration" in the Calibration tab.
void ShowNeedlePath()
Internal function that activates display of the needle path.
mitk::Point3D m_FreezePoint
Current point when the image was last frozen.
mitk::PointSet::Pointer m_EvalPointsImage
Pointset containing the evaluated points on the image.
mitk::NavigationDataToIGTLMessageFilter::Pointer m_TrackingToIGTLMessageFilter
void UpdatePhantomAnnotationPointVisualization(int index=-1)
mitk::IGTLServer::Pointer m_TrackingServer