NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
cxLandmarkImage2ImageRegistrationWidget.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
12 
13 #include <sstream>
14 #include <QVBoxLayout>
15 #include <QPushButton>
16 #include <QTableWidget>
17 #include <QTableWidgetItem>
18 #include <QHeaderView>
19 #include <QLabel>
20 #include <QSlider>
21 #include <QCheckBox>
22 #include <vtkDoubleArray.h>
23 #include <vtkImageData.h>
24 
26 #include "cxSettings.h"
27 #include "cxLandmarkRep.h"
28 #include "cxView.h"
30 #include "cxRegistrationService.h"
31 #include "cxViewService.h"
32 #include "cxRepContainer.h"
33 #include "cxLandmarkListener.h"
34 
35 namespace cx
36 {
37 LandmarkImage2ImageRegistrationWidget::LandmarkImage2ImageRegistrationWidget(RegServicesPtr services,
38  QWidget* parent, QString objectName, QString windowTitle) :
39  LandmarkRegistrationWidget(services, parent, objectName, windowTitle)
40 {
41  mLandmarkTableWidget->hide();
42 
43  mLandmarkListener->useI2IRegistration();
44 
45  mFixedProperty.reset(new StringPropertyRegistrationFixedImage(services->registration(), services->patient()));
46  mMovingProperty.reset(new StringPropertyRegistrationMovingImage(services->registration(), services->patient()));
47 
48  mTranslationCheckBox = new QCheckBox("Translation only", this);
49  mTranslationCheckBox->setChecked(settings()->value("registration/I2ILandmarkTranslation", false).toBool());
50  connect(mTranslationCheckBox, SIGNAL(toggled(bool)), this, SLOT(translationCheckBoxChanged()));
51 
52  mRegisterButton = new QPushButton("Register", this);
53  mRegisterButton->setToolTip("Perform registration");
54  connect(mRegisterButton, SIGNAL(clicked()), this, SLOT(registerSlot()));
55 
60 
61  QHBoxLayout* regLayout = new QHBoxLayout;
62  regLayout->addWidget(mRegisterButton);
63  mVerticalLayout->addLayout(regLayout);
64  mVerticalLayout->addStretch();
65 }
66 
68 {
69  settings()->setValue("registration/I2ILandmarkTranslation", mTranslationCheckBox->isChecked());
70 }
71 
73 {
74  this->performRegistration();
75 }
76 
78 {
79 }
80 
82 {
83  return "<html>"
84  "<h3>Landmark based image to image registration.</h3>"
85  "<p>Register moving image to fixed image. </p>"
86  "</html>";
87 }
88 
90 {
91  mServices->view()->setRegistrationMode(rsIMAGE_REGISTRATED);
93 }
94 
96 {
97  mServices->view()->setRegistrationMode(rsNOT_REGISTRATED);
99 }
100 
102 {
103 }
104 
106 {
107  ImagePtr moving = boost::dynamic_pointer_cast<Image>(mServices->registration()->getMovingData());
108 
109  if (moving)
110  return moving->getLandmarks()->getLandmarks();
111  else
112  return LandmarkMap();
113 }
114 
116 {
117  mServices->registration()->doImageRegistration(mTranslationCheckBox->isChecked());
119 }
120 
125 {
126  if (!mServices->registration()->getMovingData())
127  return Transform3D::Identity();
128  return mServices->registration()->getMovingData()->get_rMd();
129 }
130 
132 {
133  ImagePtr image = boost::dynamic_pointer_cast<Image>(mServices->registration()->getMovingData());
134  if (!image)
135  return;
136  image->getLandmarks()->setLandmark(Landmark(uid, p_target));
137 }
138 
140 {
141  DataPtr image = mServices->registration()->getMovingData();
142  if (!image)
143  return "None";
144  return image->getName();
145 }
146 
147 
148 }//namespace cx
149 
cx::LabeledComboBoxWidget
Composite widget for string selection.
Definition: cxLabeledComboBoxWidget.h:36
cx::LandmarkRegistrationWidget
Definition: cxLandmarkRegistrationWidget.h:45
cx::LandmarkImage2ImageRegistrationWidget::translationCheckBoxChanged
void translationCheckBoxChanged()
Definition: cxLandmarkImage2ImageRegistrationWidget.cpp:67
cx::LandmarkRegistrationWidget::mLandmarkListener
LandmarkListenerPtr mLandmarkListener
Definition: cxLandmarkRegistrationWidget.h:92
cx::LandmarkImage2ImageRegistrationWidget::getTargetLandmarks
virtual LandmarkMap getTargetLandmarks() const
Definition: cxLandmarkImage2ImageRegistrationWidget.cpp:105
cx::LandmarkImage2ImageRegistrationWidget::hideEvent
virtual void hideEvent(QHideEvent *event)
Definition: cxLandmarkImage2ImageRegistrationWidget.cpp:95
cxLandmarkImage2ImageRegistrationWidget.h
rsNOT_REGISTRATED
rsNOT_REGISTRATED
Definition: cxDefinitions.h:128
cx::LandmarkImage2ImageRegistrationWidget::mTranslationCheckBox
QCheckBox * mTranslationCheckBox
Definition: cxLandmarkImage2ImageRegistrationWidget.h:69
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::LandmarkImage2ImageRegistrationWidget::getTargetName
virtual QString getTargetName() const
Definition: cxLandmarkImage2ImageRegistrationWidget.cpp:139
cx::LandmarkImage2ImageRegistrationWidget::setTargetLandmark
virtual void setTargetLandmark(QString uid, Vector3D p_target)
Definition: cxLandmarkImage2ImageRegistrationWidget.cpp:131
cx::LandmarkImage2ImageRegistrationWidget::registerSlot
void registerSlot()
Definition: cxLandmarkImage2ImageRegistrationWidget.cpp:72
cx::LandmarkImage2ImageRegistrationWidget::mMovingProperty
StringPropertyRegistrationMovingImagePtr mMovingProperty
Definition: cxLandmarkImage2ImageRegistrationWidget.h:66
cx::LandmarkImage2ImageRegistrationWidget::~LandmarkImage2ImageRegistrationWidget
virtual ~LandmarkImage2ImageRegistrationWidget()
empty
Definition: cxLandmarkImage2ImageRegistrationWidget.cpp:77
cx::LandmarkMap
std::map< QString, class Landmark > LandmarkMap
Definition: cxLandmarkRegistrationWidget.h:31
cxLabeledComboBoxWidget.h
cx::LandmarkImage2ImageRegistrationWidget::getTargetTransform
virtual Transform3D getTargetTransform() const
Definition: cxLandmarkImage2ImageRegistrationWidget.cpp:124
cx::LandmarkImage2ImageRegistrationWidget::mFixedProperty
StringPropertyRegistrationFixedImagePtr mFixedProperty
Definition: cxLandmarkImage2ImageRegistrationWidget.h:65
cx::LandmarkRegistrationWidget::mLandmarkTableWidget
QTableWidget * mLandmarkTableWidget
the table widget presenting the landmarks
Definition: cxLandmarkRegistrationWidget.h:86
cx::StringPropertyRegistrationMovingImage
Definition: cxRegistrationProperties.h:51
cxLandmarkListener.h
cx::LandmarkRegistrationWidget::mAvarageAccuracyLabel
QLabel * mAvarageAccuracyLabel
label showing the average accuracy
Definition: cxLandmarkRegistrationWidget.h:87
cx::Landmark
One landmark, or fiducial, coordinate.
Definition: cxLandmark.h:40
cx::RegistrationBaseWidget::mServices
RegServicesPtr mServices
Definition: cxRegistrationBaseWidget.h:35
cx::LandmarkImage2ImageRegistrationWidget::performRegistration
virtual void performRegistration()
Definition: cxLandmarkImage2ImageRegistrationWidget.cpp:115
cx::Transform3D
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
Definition: cxLandmarkPatientRegistrationWidget.h:33
cxViewService.h
cx::LandmarkRegistrationWidget::mVerticalLayout
QVBoxLayout * mVerticalLayout
vertical layout is used
Definition: cxLandmarkRegistrationWidget.h:85
cxRepContainer.h
cx::DataPtr
boost::shared_ptr< class Data > DataPtr
Definition: cxRegistrationApplicator.h:22
cxView.h
cx::LandmarkImage2ImageRegistrationWidget::mRegisterButton
QPushButton * mRegisterButton
Definition: cxLandmarkImage2ImageRegistrationWidget.h:68
cx::LandmarkImage2ImageRegistrationWidget::showEvent
virtual void showEvent(QShowEvent *event)
updates internal info before showing the widget
Definition: cxLandmarkImage2ImageRegistrationWidget.cpp:89
cx::ImagePtr
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:27
cx::LandmarkRegistrationWidget::showEvent
virtual void showEvent(QShowEvent *event)
updates internal info before showing the widget
Definition: cxLandmarkRegistrationWidget.cpp:100
cxSettings.h
cx::LandmarkRegistrationWidget::updateAverageAccuracyLabel
void updateAverageAccuracyLabel()
Definition: cxLandmarkRegistrationWidget.cpp:312
cx::RegServicesPtr
boost::shared_ptr< class RegServices > RegServicesPtr
Definition: cxRegServices.h:20
cxRegistrationProperties.h
cx::StringPropertyRegistrationFixedImage
Definition: cxRegistrationProperties.h:31
cx::LandmarkRegistrationWidget::hideEvent
virtual void hideEvent(QHideEvent *event)
Definition: cxLandmarkRegistrationWidget.cpp:133
cx::LandmarkImage2ImageRegistrationWidget::defaultWhatsThis
virtual QString defaultWhatsThis() const
Definition: cxLandmarkImage2ImageRegistrationWidget.cpp:81
cxLandmarkRep.h
cx::LandmarkImage2ImageRegistrationWidget::prePaintEvent
virtual void prePaintEvent()
populates the table widget
Definition: cxLandmarkImage2ImageRegistrationWidget.cpp:101
cx::Settings::setValue
void setValue(const QString &key, const QVariant &value)
Definition: cxSettings.cpp:58
cxRegistrationService.h
cx::Vector3D
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42
rsIMAGE_REGISTRATED
rsIMAGE_REGISTRATED
Definition: cxDefinitions.h:129
cx::settings
Settings * settings()
Shortcut for accessing the settings instance.
Definition: cxSettings.cpp:21