13 #include <vtkPolyData.h>
52 "Bronchoscopy Registration"),
55 mRecordTrackingWidget(NULL)
57 mVerticalLayout =
new QVBoxLayout(
this);
62 if (!mRecordTrackingWidget)
68 void BronchoscopyRegistrationWidget::setup()
70 mOptions =
profile()->getXmlSettings().descend(
"bronchoscopyregistrationwidget");
73 mSelectMeshWidget->setValueName(
"Centerline: ");
79 mProcessCenterlineButton =
new QPushButton(
"Process centerline");
80 connect(mProcessCenterlineButton, SIGNAL(clicked()),
this, SLOT(processCenterlineSlot()));
86 mRegisterButton =
new QPushButton(
"Register");
87 connect(mRegisterButton, SIGNAL(clicked()),
this, SLOT(registerSlot()));
91 mServices->acquisition(), mServices,
94 mRecordTrackingWidget->
getSessionSelector()->setHelp(
"Select bronchoscope path for registration");
97 mVerticalLayout->setMargin(0);
98 mVerticalLayout->addWidget(
new DataSelectWidget(mServices->view(), mServices->patient(),
this, mSelectMeshWidget));
100 this->selectSubsetOfBranches(mOptions.
getElement());
101 this->createMaxNumberOfGenerations(mOptions.
getElement());
102 this->useLocalRegistration(mOptions.
getElement());
103 this->createMaxLocalRegistrationDistance(mOptions.
getElement());
107 mVerticalLayout->addWidget(
new CheckBoxWidget(
this, mUseSubsetOfGenerations));
108 mVerticalLayout->addWidget(
createDataWidget(mServices->view(), mServices->patient(),
this, mMaxNumberOfGenerations));
109 mVerticalLayout->addWidget(mProcessCenterlineButton);
110 mVerticalLayout->addWidget(mRecordTrackingWidget);
111 mVerticalLayout->addWidget(
new CheckBoxWidget(
this, mUseLocalRegistration));
112 mVerticalLayout->addWidget(
createDataWidget(mServices->view(), mServices->patient(),
this, mMaxLocalRegistrationDistance));
113 mVerticalLayout->addWidget(mRegisterButton);
115 mVerticalLayout->addStretch();
123 void BronchoscopyRegistrationWidget::initializeTrackingService()
129 void BronchoscopyRegistrationWidget::processCenterlineSlot()
131 this->initializeTrackingService();
133 if(!mSelectMeshWidget->getMesh())
138 vtkPolyDataPtr centerline = mSelectMeshWidget->getMesh()->getVtkPolyData();
139 Transform3D rMd = mSelectMeshWidget->getMesh()->get_rMd();
141 if (mUseSubsetOfGenerations->getValue())
142 processedCenterline = mBronchoscopyRegistration->processCenterline(centerline, rMd, mMaxNumberOfGenerations->getValue());
144 processedCenterline = mBronchoscopyRegistration->processCenterline(centerline, rMd);
148 QString uid = mSelectMeshWidget->getMesh()->getUid() +
"_cl%1";
149 QString name = mSelectMeshWidget->getMesh()->getName()+
" cl_processed%1";
150 std::cout <<
"name: " << name << std::endl;
151 std::cout <<
"uid: " << uid << std::endl;
152 mMesh = mServices->patient()->createSpecificData<Mesh>(uid, name);
154 mMesh->setVtkPolyData(processedCenterline);
155 mMesh->setColor(QColor(0, 0, 255, 255));
156 mServices->patient()->insertData(mMesh);
157 mServices->view()->autoShowData(mMesh);
160 void BronchoscopyRegistrationWidget::registerSlot()
162 if(!mBronchoscopyRegistration->isCenterlineProcessed())
168 Transform3D old_rMpr = mServices->patient()->get_rMpr();
174 if(trackerRecordedData_prMt.empty())
182 if(mUseLocalRegistration->getValue()){
183 std::cout <<
"Running local registration with max distance " << mMaxLocalRegistrationDistance->getValue() <<
" mm." << std::endl;
184 new_rMpr =
Transform3D(mBronchoscopyRegistration->runBronchoscopyRegistration(trackerRecordedData_prMt,old_rMpr,mMaxLocalRegistrationDistance->getValue()));
187 std::cout <<
"Running global registration." << std::endl;
188 new_rMpr =
Transform3D(mBronchoscopyRegistration->runBronchoscopyRegistration(trackerRecordedData_prMt,old_rMpr,0));
191 new_rMpr = new_rMpr*old_rMpr;
192 mServices->registration()->addPatientRegistration(new_rMpr,
"Bronchoscopy centerline to tracking data");
194 Eigen::Matrix4d display_rMpr = Eigen::Matrix4d::Identity();
195 display_rMpr = new_rMpr*display_rMpr;
196 std::cout <<
"New prMt: " << std::endl;
197 for (
int i = 0; i < 4; i++)
198 std::cout << display_rMpr.row(i) << std::endl;
204 void BronchoscopyRegistrationWidget::createMaxNumberOfGenerations(QDomElement root)
207 "Set max number of generations centerline", 4, DoubleRange(0, 10, 1), 0,
212 void BronchoscopyRegistrationWidget::selectSubsetOfBranches(QDomElement root)
215 "Select branch generations to be used in registration",
false,
219 void BronchoscopyRegistrationWidget::useLocalRegistration(QDomElement root)
222 "Use local registration",
false,
226 void BronchoscopyRegistrationWidget::createMaxLocalRegistrationDistance(QDomElement root)
229 "Set max distance for local registration in mm", 30, DoubleRange(1, 200, 1), 0,
234 void BronchoscopyRegistrationWidget::clearDataOnNewPatient()