37 mAvarageAccuracyLabel =
new QLabel(QString(
" "),
this);
47 return QString(
"<b>Matrix fMm from moving to fixed image</b>");
49 return "<Invalid matrix>";
54 return mServices->registration()->getMovingData() &&
mServices->registration()->getFixedData();
60 return Transform3D::Identity();
68 if(!history->getData().empty())
69 init_rMd = history->getData().front().mValue;
71 init_rMd = Transform3D::Identity();
73 Transform3D current_rMd = history->getCurrentRegistration().mValue;
74 fMm = current_rMd * init_rMd.inv();
90 if(!history->getData().empty())
91 init_rMd = history->getData().front().mValue;
93 init_rMd = Transform3D::Identity();
98 mServices->registration()->addImage2ImageRegistration(delta,
"Manual Image");
99 this->updateAverageAccuracyLabel();
105 std::map<QString, LandmarkProperty> props =
mServices->patient()->getLandmarkProperties();
108 numActiveLandmarks = 0;
109 std::map<QString, LandmarkProperty>::iterator it = props.begin();
110 for (; it != props.end(); ++it)
112 if (!it->second.getActive())
114 QString uid = it->first;
115 double val = this->getAccuracy(uid);
119 numActiveLandmarks++;
122 if (numActiveLandmarks == 0)
124 return (sqrt(sum / (
double)numActiveLandmarks));
127 double ManualImage2ImageRegistrationWidget::getAccuracy(QString uid)
136 Landmark masterLandmark = fixedData->getLandmarks()->getLandmarks()[uid];
137 Landmark targetLandmark = movingData->getLandmarks()->getLandmarks()[uid];
138 if (masterLandmark.
getUid().isEmpty() || targetLandmark.
getUid().isEmpty())
146 Vector3D p_target_r = rMtarget.coord(p_target_target);
147 Vector3D p_master_r = rMmaster.coord(p_master_master);
149 double targetPoint[3];
150 double masterPoint[3];
151 targetPoint[0] = p_target_r[0];
152 targetPoint[1] = p_target_r[1];
153 targetPoint[2] = p_target_r[2];
154 masterPoint[0] = p_master_r[0];
155 masterPoint[1] = p_master_r[1];
156 masterPoint[2] = p_master_r[2];
158 return (vtkMath::Distance2BetweenPoints(targetPoint, masterPoint));
161 void ManualImage2ImageRegistrationWidget::updateAverageAccuracyLabel()
165 DataPtr fixedData = boost::dynamic_pointer_cast<
Data>(
mServices->registration()->getFixedData());
166 DataPtr movingData = boost::dynamic_pointer_cast<
Data>(
mServices->registration()->getMovingData());
168 fixedName = fixedData->
getName();
170 movingName = movingData->getName();
172 int numberOfActiveLandmarks = 0;
173 if(this->isAverageAccuracyValid(numberOfActiveLandmarks))
175 mAvarageAccuracyLabel->setText(tr(
"Root mean square accuracy (Landmarks) %1 mm, calculated in %2 landmarks").
176 arg(this->
getAverageAccuracy(numberOfActiveLandmarks), 0,
'f', 2).arg(numberOfActiveLandmarks));
177 mAvarageAccuracyLabel->setToolTip(QString(
"Root Mean Square landmark accuracy from target [%1] to fixed [%2].").
178 arg(movingName).arg(fixedName));
182 mAvarageAccuracyLabel->setText(
" ");
183 mAvarageAccuracyLabel->setToolTip(
"");
187 bool ManualImage2ImageRegistrationWidget::isAverageAccuracyValid(
int& numberOfActiveLandmarks)
189 int numActiveLandmarks = 0;
191 if(numActiveLandmarks < 1)
boost::shared_ptr< class RegistrationHistory > RegistrationHistoryPtr
One landmark, or fiducial, coordinate.
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
boost::shared_ptr< class Data > DataPtr
boost::shared_ptr< class StringPropertyBase > StringPropertyBasePtr
virtual QString getName() const
boost::shared_ptr< class RegServices > RegServicesPtr
Vector3D getCoord() const
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Superclass for all data objects.
bool similar(const CameraInfo &lhs, const CameraInfo &rhs, double tol)
Namespace for all CustusX production code.