14#include <berryISelectionService.h>
15#include <berryIWorkbenchWindow.h>
25#include <QmitkServiceListWidget.h>
28#include <mitkVector.h>
29#include "mitkIOUtil.h"
30#include <mitkBaseData.h>
31#include <mitkImageGenerator.h>
32#include <mitkNodePredicateDataType.h>
33#include <mitkNodePredicateNot.h>
34#include <mitkNodePredicateProperty.h>
35#include <mitkPointSet.h>
36#include <mitkPointSetDataInteractor.h>
37#include <mitkPointSetShapeProperty.h>
38#include <mitkSceneIO.h>
41#include <usServiceReference.h>
44#include <vtkLandmarkTransform.h>
45#include <vtkMatrix4x4.h>
48#include <vtkSphereSource.h>
49#include <vtkTransform.h>
51#include <vtkVertexGlyphFilter.h>
62 : m_PhantomConfigurationPointSet(nullptr),
70 pluginContext->connectServiceListener(
this,
71 "OnDeviceServiceEvent",
72 QString::fromStdString(
"(" + us::ServiceConstants::OBJECTCLASS() +
"=" +
73 us_service_interface_iid<mitk::USDevice>() +
")"));
79 m_Controls.m_CombinedModalityManagerWidget->blockSignals(
true);
80 mitk::AbstractUltrasoundTrackerDevice::Pointer combinedModality;
81 combinedModality =
m_Controls.m_CombinedModalityManagerWidget->GetSelectedCombinedModality();
82 if (combinedModality.IsNotNull())
84 combinedModality->GetUltrasoundDevice()->RemovePropertyChangedListener(m_USDeviceChanged);
92 mitk::DataNode::Pointer node = this->GetDataStorage()->GetNamedNode(
"Needle Path");
94 this->GetDataStorage()->Remove(node);
115 m_Controls.m_CombinedModalityManagerWidget->SetCalibrationLoadedNecessary(
false);
120 m_Controls.m_SpacingBtnFreeze->setEnabled(
true);
121 m_Controls.m_SpacingAddPoint->setEnabled(
false);
122 m_Controls.m_CalculateSpacing->setEnabled(
false);
148 m_Controls.m_CalibTrackingStatus->ShowStatusLabels();
149 m_Controls.m_EvalTrackingStatus->ShowStatusLabels();
162 connect(
m_Controls.m_CalibBtnLoadPhantomConfiguration,
166 connect(
m_Controls.m_CalibBtnMatchAnnotationToPhantomConfiguration,
177 connect(
m_Controls.m_CalibBtnPerformPhantomCalibration,
181 connect(
m_Controls.m_CalibBtnSavePhantomCalibration,
214 connect(
m_Controls.m_CombinedModalityManagerWidget,
215 SIGNAL(SignalNoLongerReadyForNextStep()),
220 connect(
m_Controls.m_CalibBtnRestartCalibration, SIGNAL(clicked()),
this, SLOT(
OnReset()));
224 connect(
m_Controls.m_AddCurrentPointerTipForVerification,
231 m_Controls.m_ReferencePointsComboBox->SetDataStorage(this->GetDataStorage());
232 m_Controls.m_ReferencePointsComboBox->SetAutoSelectNewItems(
true);
233 m_Controls.m_ReferencePointsComboBox->SetPredicate(mitk::NodePredicateDataType::New(
"PointSet"));
253 const QList<mitk::DataNode::Pointer> & )
273 mitk::AbstractUltrasoundTrackerDevice::Pointer combinedModality;
274 combinedModality =
m_Controls.m_CombinedModalityManagerWidget->GetSelectedCombinedModality();
275 if (combinedModality.IsNotNull())
277 combinedModality->GetUltrasoundDevice()->AddPropertyChangedListener(m_USDeviceChanged);
279 m_Controls.m_StartCalibrationButton->setEnabled(
true);
280 m_Controls.m_StartPlusCalibrationButton->setEnabled(
true);
281 m_Controls.m_ToolBox->setItemEnabled(1,
true);
282 m_Controls.m_ToolBox->setItemEnabled(2,
true);
288 mitk::AbstractUltrasoundTrackerDevice::Pointer combinedModality;
289 combinedModality =
m_Controls.m_CombinedModalityManagerWidget->GetSelectedCombinedModality();
290 if (combinedModality.IsNotNull())
292 combinedModality->GetUltrasoundDevice()->RemovePropertyChangedListener(m_USDeviceChanged);
294 m_Controls.m_StartCalibrationButton->setEnabled(
false);
295 m_Controls.m_StartPlusCalibrationButton->setEnabled(
false);
297 m_Controls.m_ToolBox->setItemEnabled(1,
false);
298 m_Controls.m_ToolBox->setItemEnabled(2,
false);
303 if (
m_Controls.m_VerificationPointerChoser->GetSelectedNavigationDataSource().IsNull() ||
304 (
m_Controls.m_VerificationPointerChoser->GetSelectedToolID() == -1))
306 MITK_WARN <<
"No tool selected, aborting";
309 mitk::NavigationData::Pointer currentPointerData =
310 m_Controls.m_VerificationPointerChoser->GetSelectedNavigationDataSource()->GetOutput(
311 m_Controls.m_VerificationPointerChoser->GetSelectedToolID());
312 mitk::Point3D currentTipPosition = currentPointerData->GetPosition();
319 mitk::PointSet::Pointer selectedPointSet =
320 dynamic_cast<mitk::PointSet *
>(
m_Controls.m_ReferencePointsComboBox->GetSelectedNode()->GetData());
322 QString::number(selectedPointSet->GetSize()));
325 for (
int i = 0; i < selectedPointSet->GetSize(); i++)
335 MITK_WARN <<
"Cannot add point";
338 if (
m_Controls.m_VerificationPointerChoser->GetSelectedNavigationDataSource().IsNull() ||
339 (
m_Controls.m_VerificationPointerChoser->GetSelectedToolID() == -1))
341 MITK_WARN <<
"No tool selected, aborting";
344 mitk::NavigationData::Pointer currentPointerData =
345 m_Controls.m_VerificationPointerChoser->GetSelectedNavigationDataSource()->GetOutput(
346 m_Controls.m_VerificationPointerChoser->GetSelectedToolID());
347 mitk::Point3D currentTipPosition = currentPointerData->GetPosition();
350 MITK_INFO <<
"Current Error: " << currentError <<
" mm";
361 double meanError = 0;
362 for (std::size_t i = 0; i <
m_allErrors.size(); ++i)
368 QString result =
"Finished verification! \n Verification of " + QString::number(
m_allErrors.size()) +
369 " points, mean error: " + QString::number(meanError) +
" mm";
370 m_Controls.m_ResultsTextEdit->setText(result);
371 MITK_INFO << result.toStdString();
378 m_Node =
dynamic_cast<mitk::DataNode*
>(this->GetDataStorage()->GetNamedNode(
"US Viewing Stream - Image 0")->CreateAnother().GetPointer());
379 m_Node->SetName(
"US Calibration Viewing Stream");
380 this->GetDataStorage()->Add(
m_Node);
407 QApplication::setOverrideCursor(Qt::WaitCursor);
417 QApplication::restoreOverrideCursor();
422 std::string probeName =
m_CombinedModality->GetUltrasoundDevice()->GetCurrentProbe()->GetName();
425 mitk::DataNode::Pointer usNode = this->GetDataStorage()->GetNamedNode(
"US Viewing Stream - Image 0");
426 if (usNode.IsNotNull())
428 this->GetDataStorage()->Remove(usNode);
435 m_Controls.m_ToolBox->setItemEnabled(1,
true);
451 mitk::IGTLServer::Pointer
m_USServer = mitk::IGTLServer::New(
true);
452 m_USServer->SetName(
"EchoTrack Image Source");
478 typedef itk::SimpleMemberCommand<QmitkUltrasoundCalibration> CurCommandType;
480 CurCommandType::Pointer newConnectionCommand = CurCommandType::New();
483 this->
m_TrackingServer->AddObserver(mitk::NewClientConnectionEvent(), newConnectionCommand);
488 MITK_INFO <<
"US Server opened its connection successfully";
493 MITK_INFO <<
"US Server could not open its connection";
497 MITK_INFO <<
"Tracking Server opened its connection successfully";
502 MITK_INFO <<
"Tracking Server could not open its connection";
506 m_Controls.m_StartPlusCalibrationButton->setEnabled(
false);
507 m_Controls.m_GetCalibrationFromPLUS->setEnabled(
true);
508 m_Controls.m_StartStreaming->setEnabled(
false);
509 m_Controls.m_SavePlusCalibration->setEnabled(
false);
510 m_Controls.m_SetupStatus->setStyleSheet(
"QLabel { color : green; }");
511 m_Controls.m_SetupStatus->setText(
"Setup successful you can now connect PLUS");
515 m_Controls.m_SetupStatus->setStyleSheet(
"QLabel { color : red; }");
516 m_Controls.m_SetupStatus->setText(
"Something went wrong. Please try again");
549 m_Controls.m_GotCalibrationLabel->setText(
"");
552 m_Controls.m_StartPlusCalibrationButton->setEnabled(
true);
564 m_Controls.m_StartStreaming->setEnabled(
true);
565 m_Controls.m_ConnectionStatus->setStyleSheet(
"QLabel { color : green; }");
566 m_Controls.m_ConnectionStatus->setText(
"Connection successful you can now start streaming");
579 m_Controls.m_StartStreaming->setEnabled(
false);
594 MITK_INFO <<
"successfully connected";
598 MITK_INFO <<
"communication started";
599 mitk::IGTLMessage::Pointer receivedMessage;
600 bool condition =
false;
601 igtl::Matrix4x4 transformPLUS;
602 while (!(receivedMessage.IsNotNull() && receivedMessage->IsDataValid()))
604 std::this_thread::sleep_for(std::chrono::milliseconds(50));
607 igtl::TransformMessage::Pointer msg =
609 if (msg ==
nullptr || msg.IsNull())
611 MITK_INFO <<
"Received message could not be casted to TransformMessage. Skipping...";
616 if (std::strcmp(msg->GetDeviceName(),
"ImageToTracker") != 0)
618 MITK_INFO <<
"Was not Image to Tracker Transform. Skipping...";
623 msg->GetMatrix(transformPLUS);
635 m_Controls.m_GotCalibrationLabel->setStyleSheet(
"QLabel { color : red; }");
636 m_Controls.m_GotCalibrationLabel->setText(
"Something went wrong. Please try again");
641 MITK_INFO <<
" no connection";
642 m_Controls.m_GotCalibrationLabel->setStyleSheet(
"QLabel { color : red; }");
643 m_Controls.m_GotCalibrationLabel->setText(
"Something went wrong. Please try again");
648 m_Controls.m_GotCalibrationLabel->setStyleSheet(
"QLabel { color : red; }");
649 m_Controls.m_GotCalibrationLabel->setText(
"Something went wrong. Please try again");
655 mitk::AffineTransform3D::Pointer imageToTrackerTransform = mitk::AffineTransform3D::New();
656 itk::Matrix<mitk::ScalarType, 3, 3> rotationFloat = itk::Matrix<mitk::ScalarType, 3, 3>();
657 itk::Vector<mitk::ScalarType, 3> translationFloat = itk::Vector<mitk::ScalarType, 3>();
659 rotationFloat[0][0] = imageToTracker[0][0];
660 rotationFloat[0][1] = imageToTracker[0][1];
661 rotationFloat[0][2] = imageToTracker[0][2];
662 rotationFloat[1][0] = imageToTracker[1][0];
663 rotationFloat[1][1] = imageToTracker[1][1];
664 rotationFloat[1][2] = imageToTracker[1][2];
665 rotationFloat[2][0] = imageToTracker[2][0];
666 rotationFloat[2][1] = imageToTracker[2][1];
667 rotationFloat[2][2] = imageToTracker[2][2];
668 translationFloat[0] = imageToTracker[0][3];
669 translationFloat[1] = imageToTracker[1][3];
670 translationFloat[2] = imageToTracker[2][3];
672 imageToTrackerTransform->SetTranslation(translationFloat);
673 imageToTrackerTransform->SetMatrix(rotationFloat);
676 m_Controls.m_ToolBox->setItemEnabled(2,
true);
677 m_Controls.m_SavePlusCalibration->setEnabled(
true);
678 m_Controls.m_GotCalibrationLabel->setStyleSheet(
"QLabel { color : green; }");
679 m_Controls.m_GotCalibrationLabel->setText(
"Received Calibration from PLUS you can now save it");
688 this->GetDataStorage()->Remove(
m_Node);
707 ctkServiceReference service =
event.getServiceReference();
720 auto world = this->GetRenderWindowPart(mitk::WorkbenchUtil::OPEN)->GetSelectedPosition();
726 text =
"Point " + text;
727 this->
m_Controls.m_CalibPointList->addItem(text);
750 transform->SetModeToSimilarity();
754 transform->SetModeToRigidBody();
760 transform->SetModeToRigidBody();
763 transform->Modified();
767 itk::Matrix<mitk::ScalarType, 3, 3> rotationFloat = itk::Matrix<mitk::ScalarType, 3, 3>();
768 itk::Vector<mitk::ScalarType, 3> translationFloat = itk::Vector<mitk::ScalarType, 3>();
770 rotationFloat[0][0] = m->GetElement(0, 0);
771 rotationFloat[0][1] = m->GetElement(0, 1);
772 rotationFloat[0][2] = m->GetElement(0, 2);
773 rotationFloat[1][0] = m->GetElement(1, 0);
774 rotationFloat[1][1] = m->GetElement(1, 1);
775 rotationFloat[1][2] = m->GetElement(1, 2);
776 rotationFloat[2][0] = m->GetElement(2, 0);
777 rotationFloat[2][1] = m->GetElement(2, 1);
778 rotationFloat[2][2] = m->GetElement(2, 2);
779 translationFloat[0] = m->GetElement(0, 3);
780 translationFloat[1] = m->GetElement(1, 3);
781 translationFloat[2] = m->GetElement(2, 3);
785 mitk::DataNode::Pointer CalibPointsImageTransformed =
786 this->GetDataStorage()->GetNamedNode(
"Calibration Points Image (Transformed)");
787 if (CalibPointsImageTransformed.IsNull())
789 CalibPointsImageTransformed = mitk::DataNode::New();
790 CalibPointsImageTransformed->SetName(
"Calibration Points Image (Transformed)");
791 this->GetDataStorage()->Add(CalibPointsImageTransformed);
793 CalibPointsImageTransformed->SetData(ImagePointsTransformed);
801 mitk::SlicedGeometry3D::Pointer sliced3d =
dynamic_cast<mitk::SlicedGeometry3D *
>(
m_Node->GetData()->GetGeometry());
803 mitk::PlaneGeometry::Pointer plane =
const_cast<mitk::PlaneGeometry *
>(sliced3d->GetPlaneGeometry(0));
809 m_Controls.m_ToolBox->setItemEnabled(2,
true);
816 mitk::PointSet::Pointer p1 =
822 mitk::PointSet::Pointer p2 = mitk::PointSet::New();
832 MITK_INFO <<
"Calibration FRE: " << text.toStdString().c_str();
833 m_Controls.m_EvalLblCalibrationFRE->setText(text);
835 m_Node->SetStringProperty(
"Calibration FRE", text.toStdString().c_str());
837 m_Controls.m_CalibBtnSaveCalibration->setEnabled(
true);
845 m_Controls.m_CalibBtnMatchAnnotationToPhantomConfiguration->setEnabled(
false);
846 m_Controls.m_RefinePhantomAnnotationsGroupBox->setEnabled(
false);
847 m_Controls.m_CalibBtnPerformPhantomCalibration->setEnabled(
false);
848 m_Controls.m_CalibBtnSavePhantomCalibration->setEnabled(
false);
851 QString fileName = QFileDialog::getOpenFileName(
nullptr,
"Load phantom configuration",
"",
"*.mps");
854 if (fileName.isNull())
862 mitk::NavigationData::Pointer currentSensorData = this->
m_Tracker->GetOutput(0)->Clone();
867 mitk::Point3D transformedPoint = currentSensorData->TransformPoint(phantomPoint);
872 mitk::PointSetDataInteractor::Pointer imageCalibrationPointSetInteractor = mitk::PointSetDataInteractor::New();
873 imageCalibrationPointSetInteractor->LoadStateMachine(
"PointSet.xml");
874 imageCalibrationPointSetInteractor->SetEventConfig(
"PointSetConfig.xml");
875 imageCalibrationPointSetInteractor->SetDataNode(
m_WorldNode);
878 itk::SimpleMemberCommand<QmitkUltrasoundCalibration>::Pointer pointAddedCommand =
879 itk::SimpleMemberCommand<QmitkUltrasoundCalibration>::New();
884 m_WorldNode->ReplaceProperty(
"point 2D size", mitk::FloatProperty::New(10.0));
893 this->GetDataStorage()->Remove(this->GetDataStorage()->GetNamedNode(
"NextPointIndicator"));
894 if (currentIndex < m_CalibPointsTool->GetSize() - 1)
896 float distanceToNextPoint =
899 vtkHelperSphere->SetCenter(currentImagePoint[0], currentImagePoint[1], currentImagePoint[2]);
900 vtkHelperSphere->SetRadius(distanceToNextPoint);
901 vtkHelperSphere->SetPhiResolution(40);
902 vtkHelperSphere->SetThetaResolution(40);
903 vtkHelperSphere->Update();
904 mitk::Surface::Pointer helperSphere = mitk::Surface::New();
905 helperSphere->SetVtkPolyData(vtkHelperSphere->GetOutput());
906 mitk::DataNode::Pointer helperSphereNode = mitk::DataNode::New();
907 helperSphereNode->SetName(
"NextPointIndicator");
908 helperSphereNode->SetData(helperSphere);
909 helperSphereNode->SetColor(0.0, 1.0, 0.0);
910 this->GetDataStorage()->Add(helperSphereNode);
914 m_Controls.m_CalibBtnMatchAnnotationToPhantomConfiguration->setEnabled(
true);
922 std::stringstream pointName;
923 pointName <<
"Point";
925 this->GetDataStorage()->Remove(this->GetDataStorage()->GetNamedNode(pointName.str()));
927 vtkPointSphere->SetCenter(currentImagePoint[0], currentImagePoint[1], currentImagePoint[2]);
928 vtkPointSphere->SetRadius(5.0);
929 vtkPointSphere->SetPhiResolution(40);
930 vtkPointSphere->SetThetaResolution(40);
931 vtkPointSphere->Update();
932 mitk::Surface::Pointer pointSphere = mitk::Surface::New();
933 pointSphere->SetVtkPolyData(vtkPointSphere->GetOutput());
934 mitk::DataNode::Pointer sphereNode = mitk::DataNode::New();
935 sphereNode->SetName(pointName.str());
936 sphereNode->SetData(pointSphere);
937 sphereNode->SetColor(1.0, 1.0, 0.0);
938 this->GetDataStorage()->Add(sphereNode);
945 transform->SetModeToRigidBody();
947 transform->SetSourceLandmarks(toolLandmarks);
952 transform->TransformPoints(toolLandmarks, transformedToolLandmarks);
953 for (
int i = 0; i < transformedToolLandmarks->GetNumberOfPoints(); i++)
958 m_Controls.m_RefinePhantomAnnotationsGroupBox->setEnabled(
true);
959 m_Controls.m_CalibBtnPerformPhantomCalibration->setEnabled(
true);
965 transform->Translate(tx, ty, tz);
968 transform->TransformPoints(currentPoints, transformedPoints);
969 for (
int i = 0; i < transformedPoints->GetNumberOfPoints(); i++)
979 transform->RotateZ(angle);
982 transform->TransformPoints(currentPoints, transformedPoints);
983 for (
int i = 0; i < transformedPoints->GetNumberOfPoints(); i++)
1012 mitk::BoundingBox::PointType centerOfPointSet =
m_CalibPointsImage->GetGeometry()->GetBoundingBox()->GetCenter();
1020 mitk::BoundingBox::PointType centerOfPointSet =
m_CalibPointsImage->GetGeometry()->GetBoundingBox()->GetCenter();
1030 m_Controls.m_CalibBtnSavePhantomCalibration->setEnabled(
true);
1035 auto world = this->GetRenderWindowPart(mitk::WorkbenchUtil::OPEN)->GetSelectedPosition();
1041 this->
m_Controls.m_EvalLblNumTargetPoints->setText(text);
1049 mitk::PointSet::Pointer p1 =
1057 m_Controls.m_EvalLblEvaluationFRE->setText(evalText);
1058 m_Controls.m_EvalLblProjectionFRE->setText(projText);
1065 MITK_WARN <<
"Projection Evaluation may currently be inaccurate.";
1070 this->
m_Controls.m_EvalLblNumProjectionPoints->setText(text);
1076 QString filename =
m_Controls.m_EvalFilePath->text() +
"//" +
m_Controls.m_EvalFilePrefix->text();
1078 MITK_WARN <<
"CANNOT SAVE, ABORTING!";
1105 m_Controls.m_GotCalibrationLabel->setText(
"");
1107 QFileDialog::getSaveFileName(QApplication::activeWindow(),
"Save Calibration",
"",
"Calibration files *.cal");
1109 QFile file(filename);
1110 if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate))
1112 MITK_WARN <<
"Cannot open file '" << filename.toStdString() <<
"' for writing.";
1118 QTextStream outStream(&file);
1119 outStream << QString::fromStdString(calibrationSerialization);
1122 if (
m_Controls.m_saveAdditionalCalibrationLog->isChecked())
1124 mitk::SceneIO::Pointer mySceneIO = mitk::SceneIO::New();
1125 QString filenameScene = filename +
"_mitkScene.mitk";
1126 mitk::NodePredicateNot::Pointer isNotHelperObject =
1127 mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New(
"helper object", mitk::BoolProperty::New(
true)));
1128 mitk::DataStorage::SetOfObjects::ConstPointer nodesToBeSaved = this->GetDataStorage()->GetSubset(isNotHelperObject);
1129 mySceneIO->SaveScene(nodesToBeSaved, this->GetDataStorage(), filenameScene.toStdString().c_str());
1143 if (
m_Node.IsNotNull() && (
m_Node->GetData() !=
nullptr) && (
m_Node->GetData()->GetGeometry() !=
nullptr))
1145 mitk::SlicedGeometry3D::Pointer sliced3d =
dynamic_cast<mitk::SlicedGeometry3D *
>(
m_Node->GetData()->GetGeometry());
1146 mitk::PlaneGeometry::Pointer plane =
const_cast<mitk::PlaneGeometry *
>(sliced3d->GetPlaneGeometry(0));
1151 this->
m_Controls.m_EvalLblNumTargetPoints->setText(text1);
1153 this->
m_Controls.m_EvalLblNumProjectionPoints->setText(text2);
1159 std::vector<mitk::NavigationData::Pointer> *datas =
new std::vector<mitk::NavigationData::Pointer>();
1160 datas->push_back(
m_Tracker->GetOutput());
1161 m_Controls.m_CalibTrackingStatus->SetNavigationDatas(datas);
1163 m_Controls.m_EvalTrackingStatus->SetNavigationDatas(datas);
1172 if (image.IsNotNull() &&
m_Node->GetData() != image.GetPointer() && image->IsInitialized())
1181 this->RequestRenderWindowUpdate(mitk::RenderingManager::REQUEST_UPDATE_2DWINDOWS);
1186 m_Controls.m_CalibBtnAddPoint->setEnabled(
false);
1204 std::vector<mitk::NavigationData::Pointer> datas;
1205 datas.push_back(
m_Tracker->GetOutput());
1206 m_Controls.m_CalibTrackingStatus->SetNavigationDatas(&datas);
1207 m_Controls.m_CalibTrackingStatus->ShowStatusLabels();
1210 m_Controls.m_EvalTrackingStatus->SetNavigationDatas(&datas);
1211 m_Controls.m_EvalTrackingStatus->ShowStatusLabels();
1215 m_Timer->setInterval(interval);
1220 else if (this->
m_Tracker->GetOutput(0)->IsDataValid())
1226 m_Controls.m_CalibBtnAddPoint->setEnabled(
true);
1238 mitk::DataNode::Pointer node = this->GetDataStorage()->GetNamedNode(
"Needle Path");
1241 node = mitk::DataNode::New();
1242 node->SetName(
"Needle Path");
1244 node->SetBoolProperty(
"show contour",
true);
1245 this->GetDataStorage()->Add(node);
1270 for (
int i = 0; i < PointSet->GetSize(); i++)
1272 double point[3] = {PointSet->GetPoint(i)[0], PointSet->GetPoint(i)[1], PointSet->GetPoint(i)[2]};
1273 points->InsertNextPoint(point);
1276 temp->SetPoints(points);
1279 vertexFilter->SetInputData(temp);
1280 vertexFilter->Update();
1282 returnValue->ShallowCopy(vertexFilter->GetOutput());
1288 mitk::PointSet::Pointer realWorldFiducials,
1291 if (imageFiducials->GetSize() != realWorldFiducials->GetSize())
1294 for (
int i = 0; i < imageFiducials->GetSize(); ++i)
1296 itk::Point<double> current_image_fiducial_point = imageFiducials->GetPoint(i);
1297 if (transform !=
nullptr)
1299 current_image_fiducial_point = transform->TransformPoint(
1300 imageFiducials->GetPoint(i)[0], imageFiducials->GetPoint(i)[1], imageFiducials->GetPoint(i)[2]);
1302 double cur_error_squared = current_image_fiducial_point.SquaredEuclideanDistanceTo(realWorldFiducials->GetPoint(i));
1303 FRE += cur_error_squared;
1306 FRE = sqrt(FRE / (
double)imageFiducials->GetSize());
1314 for (
int i = 0; i < pointSet->GetSize(); ++i)
1316 itk::Point<double> current_point_transformed = itk::Point<double>();
1317 current_point_transformed =
1318 transform->TransformPoint(pointSet->GetPoint(i)[0], pointSet->GetPoint(i)[1], pointSet->GetPoint(i)[2]);
1319 pointSet->SetPoint(i, current_point_transformed);
1338 m_Controls.m_SpacingAddPoint->setEnabled(
false);
1342 m_Controls.m_SpacingAddPoint->setEnabled(
true);
1349 auto point = this->GetRenderWindowPart(mitk::WorkbenchUtil::OPEN)->GetSelectedPosition();
1354 text =
"Point " + text;
1356 this->
m_Controls.m_SpacingPointsList->addItem(text);
1362 m_Controls.m_SpacingAddPoint->setEnabled(
false);
1363 m_Controls.m_CalculateSpacing->setEnabled(
true);
1364 m_Controls.m_SpacingBtnFreeze->setEnabled(
false);
1376 double xDistance = horizontalOne.EuclideanDistanceTo(horizontalTwo);
1377 double yDistance = verticalOne.EuclideanDistanceTo(verticalTwo);
1380 double xSpacing = 30 / xDistance;
1381 double ySpacing = 20 / yDistance;
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.
unsigned long m_NewConnectionObserverTag
mitk::Image::Pointer m_Image
The current Ultrasound Image.
mitk::PointSet::Pointer m_SpacingPoints
void OnAddCurrentTipPositionForVerification()
void OnPhantomBasedCalibration()
void OnReset()
Triggered when the user clicks "Run Next Round". Also used as a reset mechanism.
mitk::DataNode::Pointer m_Node
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.
void OnPhantomCalibPointsChanged()
Ui::QmitkUltrasoundCalibrationControls m_Controls
void OnUSDepthChanged(const std::string &, const std::string &)
void OnMovePhantomAnnotationsUp()
void NewConnectionSignal()
used for thread separation, the worker thread must not call OnNewConnection directly....
void OnStreamingTimerTimeout()
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)
void OnMatchAnnotationToPhantomConfiguration()
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
~QmitkUltrasoundCalibration() override
void OnStartVerification()
void OnAddCurrentTipPositionToReferencePoints()
void OnStartCalibrationProcess()
void OnAddCalibPoint()
Triggered, when the user clicks "Add Point".
mitk::DataNode::Pointer m_WorldNode
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.
QTimer * m_StreamingTimer
mitk::DataNode::Pointer m_SpacingNode
void OnAddEvalProjectedPoint()
Triggered, when the user clicks "Add Point".
void OnGetPlusCalibration()
mitk::IGTLMessageProvider::Pointer m_TrackingMessageProvider
QmitkUltrasoundCalibration()
void OnLoadPhantomConfiguration()
mitk::IGTLMessageProvider::Pointer m_USMessageProvider
void OnStopCalibrationProcess()
mitk::AbstractUltrasoundTrackerDevice::Pointer m_CombinedModality
The combined modality used for imaging and tracking.
void OnTabSwitch(int index)
Triggered, whenever the user switches Tabs.
void OnMovePhantomAnnotationsDown()
void OnCalibration()
Triggered, when the user clicks "Calibrate".
static const std::string VIEW_ID
void OnRotatePhantomAnnotationsRight()
void ClearTemporaryMembers()
Clears all member attributes which are holding intermediate results for the calibration.
vtkSmartPointer< vtkPolyData > ConvertPointSetToVtkPolyData(mitk::PointSet::Pointer PointSet)
void OnRotatePhantomAnnotationsLeft()
mitk::IGTLClient::Pointer m_TransformClient
void OnDeviceDeselected()
mitk::ImageToIGTLMessageFilter::Pointer m_USImageToIGTLMessageFilter
int m_CalibPointsCount
Total number of calibration points set.
void OnStopPlusCalibration()
void OnSelectionChanged(berry::IWorkbenchPart::Pointer source, const QList< mitk::DataNode::Pointer > &nodes) override
mitk::IGTLDeviceSource::Pointer m_TransformDeviceSource
std::vector< double > m_allErrors
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 OnCalculateSpacing()
void ProcessPlusCalibration(igtl::Matrix4x4 &imageToTracker)
void OnDeviceSelected()
Triggered, when the user has clicked "select Devices".
void OnMovePhantomAnnotationsLeft()
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::DataNode::Pointer m_CalibNode
void OnMovePhantomAnnotationsRight()
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
static mitk::USDevice::PropertyKeys GetPropertyKeys()
static ctkPluginContext * GetContext()