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(
""))
73 connect(mServices->getPatientService().get(), SIGNAL(patientChanged()),
this, SLOT(patientChangedSlot()));
76 connect(acquisitionService.get(), SIGNAL(saveDataCompleted(QString)),
this, SLOT(selectData(QString)));
84 mRecordSessionWidget->setDescriptionVisibility(
false);
86 QVBoxLayout* topLayout =
new QVBoxLayout(
this);
89 QLabel* acqLabel =
new QLabel(
"<b>Acquisition</b>");
90 topLayout->addWidget(acqLabel);
92 topLayout->addWidget(mInfoLabel);
93 topLayout->addWidget(mRecordSessionWidget);
100 QLabel* calLabel =
new QLabel(
"<b>Calibration</b>");
101 topLayout->addWidget(calLabel);
105 connect(mFileSelectWidget, SIGNAL(fileSelected(QString)),
this, SLOT(selectData(QString)));
107 topLayout->addWidget(mFileSelectWidget);
109 mVerbose =
new QCheckBox(
"Save data to temporal_calib.txt");
110 topLayout->addWidget(mVerbose);
112 QPushButton* calibrateButton =
new QPushButton(
"Calibrate");
113 calibrateButton->setToolTip(
"Calculate the temporal shift for the selected acqusition."
114 "The shift is not applied in any way."
116 " The calculation takes a few seconds, and in this time the program will be unresponsive</p>");
118 connect(calibrateButton, SIGNAL(clicked()),
this, SLOT(calibrateSlot()));
119 topLayout->addWidget(calibrateButton);
121 mResult =
new QLineEdit;
122 mResult->setReadOnly(
true);
123 topLayout->addWidget(mResult);
125 topLayout->addStretch();
127 this->patientChangedSlot();
136 "<h3>Temporal Calibration.</h3>"
137 "<p><i>Calibrate the time shift between the tracking system and the video acquisition source.</i></br>"
138 "<p>Part 1, Acqusition: Move the probe in a sinusoidal pattern up and down in a water tank or similar."
139 "The <i>first</i> image should be a typical image, as it is used to correlate against all the others."
140 "<p>Part 2, Calibration: Press calibrate to calculate the temporal shift for the selected acquisition."
141 "The shift is not applied in any way. Refer to the log folder for the calibration curves."
142 "<p><b>NB:</b> Previous temporal calibration is applied to probe frames during acqusition.</p>"
151 void TemporalCalibrationWidget::patientChangedSlot()
154 QString filename = mServices->getPatientService()->getActivePatientFolder() +
"/US_Acq/";
155 mFileSelectWidget->
setPath(filename);
159 void TemporalCalibrationWidget::selectData(QString filename)
162 mAlgorithm->selectData(filename);
164 mResult->setText(
"");
170 void TemporalCalibrationWidget::calibrateSlot()
172 if (mVerbose->isChecked())
173 mAlgorithm->setDebugFolder(mServices->getPatientService()->getActivePatientFolder()+
"/Logs/");
175 mAlgorithm->setDebugFolder(
"");
178 double shift = mAlgorithm->calibrate(&success);
181 reportSuccess(QString(
"Completed temporal calibration, found shift %1 ms").arg(shift,0,
'f',0));
182 mResult->setText(QString(
"Shift = %1 ms").arg(shift, 0,
'f', 0));
186 reportError(QString(
"Temporal calibration failed"));
187 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()