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());
103 this->useLocalRegistration(mOptions.
getElement());
104 this->createMaxLocalRegistrationDistance(mOptions.
getElement());
108 mVerticalLayout->addWidget(
new CheckBoxWidget(
this, mUseSubsetOfGenerations));
109 mVerticalLayout->addWidget(
createDataWidget(mServices->view(), mServices->patient(),
this, mMaxNumberOfGenerations));
110 mVerticalLayout->addWidget(mProcessCenterlineButton);
111 mVerticalLayout->addWidget(
new CheckBoxWidget(
this, mUseEBUSProbe));
112 mVerticalLayout->addWidget(mRecordTrackingWidget);
113 mVerticalLayout->addWidget(
new CheckBoxWidget(
this, mUseLocalRegistration));
114 mVerticalLayout->addWidget(
createDataWidget(mServices->view(), mServices->patient(),
this, mMaxLocalRegistrationDistance));
115 mVerticalLayout->addWidget(mRegisterButton);
117 mVerticalLayout->addStretch();
125 void BronchoscopyRegistrationWidget::initializeTrackingService()
131 void BronchoscopyRegistrationWidget::processCenterlineSlot()
133 this->initializeTrackingService();
135 if(!mSelectMeshWidget->getMesh())
140 vtkPolyDataPtr centerline = mSelectMeshWidget->getMesh()->getVtkPolyData();
141 Transform3D rMd = mSelectMeshWidget->getMesh()->get_rMd();
143 if (mUseSubsetOfGenerations->getValue())
144 processedCenterline = mBronchoscopyRegistration->processCenterline(centerline, rMd, mMaxNumberOfGenerations->getValue());
146 processedCenterline = mBronchoscopyRegistration->processCenterline(centerline, rMd);
150 QString uid = mSelectMeshWidget->getMesh()->getUid() +
"_cl%1";
151 QString name = mSelectMeshWidget->getMesh()->getName()+
" cl_processed%1";
152 std::cout <<
"name: " << name << std::endl;
153 std::cout <<
"uid: " << uid << std::endl;
154 mMesh = mServices->patient()->createSpecificData<
Mesh>(uid, name);
156 mMesh->setVtkPolyData(processedCenterline);
157 mMesh->setColor(QColor(0, 0, 255, 255));
158 mServices->patient()->insertData(mMesh);
159 mServices->view()->autoShowData(mMesh);
162 void BronchoscopyRegistrationWidget::registerSlot()
164 if(!mBronchoscopyRegistration->isCenterlineProcessed())
170 Transform3D old_rMpr = mServices->patient()->get_rMpr();
175 if(mUseEBUSProbe->getValue())
180 if(trackerRecordedData.empty())
188 if(mUseLocalRegistration->getValue()){
189 std::cout <<
"Running local registration with max distance " << mMaxLocalRegistrationDistance->getValue() <<
" mm." << std::endl;
190 new_rMpr =
Transform3D(mBronchoscopyRegistration->runBronchoscopyRegistration(trackerRecordedData,old_rMpr,mMaxLocalRegistrationDistance->getValue()));
193 std::cout <<
"Running global registration." << std::endl;
194 new_rMpr =
Transform3D(mBronchoscopyRegistration->runBronchoscopyRegistration(trackerRecordedData,old_rMpr,0));
197 new_rMpr = new_rMpr*old_rMpr;
198 mServices->registration()->addPatientRegistration(new_rMpr,
"Bronchoscopy centerline to tracking data");
200 Eigen::Matrix4d display_rMpr = Eigen::Matrix4d::Identity();
201 display_rMpr = new_rMpr*display_rMpr;
202 std::cout <<
"New prMt: " << std::endl;
203 for (
int i = 0; i < 4; i++)
204 std::cout << display_rMpr.row(i) << std::endl;
210 void BronchoscopyRegistrationWidget::createMaxNumberOfGenerations(QDomElement root)
213 "Set max number of generations centerline", 4,
DoubleRange(0, 10, 1), 0,
218 void BronchoscopyRegistrationWidget::selectSubsetOfBranches(QDomElement root)
221 "Select branch generations to be used in registration",
false,
225 void BronchoscopyRegistrationWidget::useEBUSprobe(QDomElement root)
228 "Select if EBUS probe is used registration (using prMs to exclude probe calibration)",
false,
232 void BronchoscopyRegistrationWidget::useLocalRegistration(QDomElement root)
235 "Use local registration",
false,
239 void BronchoscopyRegistrationWidget::createMaxLocalRegistrationDistance(QDomElement root)
242 "Set max distance for local registration in mm", 30,
DoubleRange(1, 200, 1), 0,
247 void BronchoscopyRegistrationWidget::clearDataOnNewPatient()
cxResource_EXPORT ProfilePtr profile()
static BoolPropertyPtr initialize(const QString &uid, QString name, QString help, bool value, QDomNode root=QDomNode())
void reportError(QString msg)
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
Utility class for describing a bounded numeric range.
QDomElement getElement()
return the current element
QWidget * createDataWidget(ViewServicePtr viewService, PatientModelServicePtr patientModelService, QWidget *parent, PropertyPtr data, QGridLayout *gridLayout, int row)
Create a widget capable of displaying the input data.
boost::shared_ptr< class RegServices > RegServicesPtr
vtkSmartPointer< vtkPolyData > vtkPolyDataPtr
static DoublePropertyPtr initialize(const QString &uid, QString name, QString help, double value, DoubleRange range, int decimals, QDomNode root=QDomNode())
static StringPropertySelectMeshPtr New(PatientModelServicePtr patientModelService)
std::map< double, Transform3D > TimedTransformMap
XmlOptionFile descend(QString element) const
step one level down in the xml tree
Namespace for all CustusX production code.