37 #include <QVBoxLayout>
38 #include "boost/bind.hpp"
41 #include <vtkDoubleArray.h>
42 #include <vtkPointData.h>
51 #include "vtkImageCorrelation.h"
67 BaseWidget(parent,
"TemporalCalibrationWidget",
"Temporal Calibration"),
68 mInfoLabel(new QLabel(
""))
72 this->setToolTip(
"Temporal calibration from a vertical periodic movement of an US probe");
74 connect(mServices->patient().get(), SIGNAL(patientChanged()),
this, SLOT(patientChangedSlot()));
76 connect(acquisitionService.get(), SIGNAL(saveDataCompleted(QString)),
this, SLOT(selectData(QString)));
79 mRecordSessionWidget =
new RecordSessionWidget(acquisitionService,
this, context,
"temp_cal");
81 QVBoxLayout* topLayout =
new QVBoxLayout(
this);
84 QLabel* acqLabel =
new QLabel(
"<b>Acquisition</b>");
85 topLayout->addWidget(acqLabel);
86 acqLabel->setToolTip(this->toolTip());
87 topLayout->addWidget(mInfoLabel);
88 topLayout->addWidget(mRecordSessionWidget);
95 QLabel* calLabel =
new QLabel(
"<b>Calibration</b>");
96 topLayout->addWidget(calLabel);
97 calLabel->setToolTip(this->toolTip());
100 connect(mFileSelectWidget, SIGNAL(fileSelected(QString)),
this, SLOT(selectData(QString)));
102 topLayout->addWidget(mFileSelectWidget);
104 mVerbose =
new QCheckBox(
"Save data to temporal_calib.txt");
105 topLayout->addWidget(mVerbose);
107 QPushButton* calibrateButton =
new QPushButton(
"Calibrate");
108 calibrateButton->setToolTip(
"Calculate the temporal shift for the selected acqusition."
109 "The shift is not applied in any way."
111 " The calculation takes a few seconds, and in this time the program will be unresponsive</p>");
113 connect(calibrateButton, SIGNAL(clicked()),
this, SLOT(calibrateSlot()));
114 topLayout->addWidget(calibrateButton);
116 mResult =
new QLineEdit;
117 mResult->setReadOnly(
true);
118 topLayout->addWidget(mResult);
120 topLayout->addStretch();
122 this->patientChangedSlot();
133 void TemporalCalibrationWidget::patientChangedSlot()
135 QString filename = mServices->patient()->getActivePatientFolder() +
"/US_Acq/";
136 mFileSelectWidget->
setPath(filename);
139 void TemporalCalibrationWidget::selectData(QString filename)
141 mAlgorithm->selectData(filename);
143 mResult->setText(
"");
149 void TemporalCalibrationWidget::calibrateSlot()
151 if (mVerbose->isChecked())
152 mAlgorithm->setDebugFolder(mServices->patient()->getActivePatientFolder()+
"/Logs/");
154 mAlgorithm->setDebugFolder(
"");
157 double shift = mAlgorithm->calibrate(&success);
160 reportSuccess(QString(
"Completed temporal calibration, found shift %1 ms").arg(shift,0,
'f',0));
161 mResult->setText(QString(
"Shift = %1 ms").arg(shift, 0,
'f', 0));
165 reportError(QString(
"Temporal calibration failed"));
166 mResult->setText(QString(
"failed"));
void reportError(QString msg)
boost::shared_ptr< class AcquisitionService > AcquisitionServicePtr
boost::shared_ptr< class VisServices > VisServicesPtr
static DoublePropertyBasePtr New(TrackingServicePtr trackingService)
static StringPropertyActiveProbeConfigurationPtr New(TrackingServicePtr trackingService)
void reportSuccess(QString msg)
cxLogicManager_EXPORT AcquisitionServicePtr acquisitionService()