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->getPatientService().get(), SIGNAL(patientChanged()),
this, SLOT(patientChangedSlot()));
76 connect(acquisitionService.get(), SIGNAL(saveDataCompleted(QString)),
this, SLOT(selectData(QString)));
80 mRecordSessionWidget->setDescriptionVisibility(
false);
82 QVBoxLayout* topLayout =
new QVBoxLayout(
this);
85 QLabel* acqLabel =
new QLabel(
"<b>Acquisition</b>");
86 topLayout->addWidget(acqLabel);
87 acqLabel->setToolTip(this->toolTip());
88 topLayout->addWidget(mInfoLabel);
89 topLayout->addWidget(mRecordSessionWidget);
96 QLabel* calLabel =
new QLabel(
"<b>Calibration</b>");
97 topLayout->addWidget(calLabel);
98 calLabel->setToolTip(this->toolTip());
101 connect(mFileSelectWidget, SIGNAL(fileSelected(QString)),
this, SLOT(selectData(QString)));
103 topLayout->addWidget(mFileSelectWidget);
105 mVerbose =
new QCheckBox(
"Save data to temporal_calib.txt");
106 topLayout->addWidget(mVerbose);
108 QPushButton* calibrateButton =
new QPushButton(
"Calibrate");
109 calibrateButton->setToolTip(
"Calculate the temporal shift for the selected acqusition."
110 "The shift is not applied in any way."
112 " The calculation takes a few seconds, and in this time the program will be unresponsive</p>");
114 connect(calibrateButton, SIGNAL(clicked()),
this, SLOT(calibrateSlot()));
115 topLayout->addWidget(calibrateButton);
117 mResult =
new QLineEdit;
118 mResult->setReadOnly(
true);
119 topLayout->addWidget(mResult);
121 topLayout->addStretch();
123 this->patientChangedSlot();
134 void TemporalCalibrationWidget::patientChangedSlot()
136 QString filename = mServices->getPatientService()->getActivePatientFolder() +
"/US_Acq/";
137 mFileSelectWidget->
setPath(filename);
140 void TemporalCalibrationWidget::selectData(QString filename)
142 mAlgorithm->selectData(filename);
144 mResult->setText(
"");
150 void TemporalCalibrationWidget::calibrateSlot()
152 if (mVerbose->isChecked())
153 mAlgorithm->setDebugFolder(mServices->getPatientService()->getActivePatientFolder()+
"/Logs/");
155 mAlgorithm->setDebugFolder(
"");
158 double shift = mAlgorithm->calibrate(&success);
161 reportSuccess(QString(
"Completed temporal calibration, found shift %1 ms").arg(shift,0,
'f',0));
162 mResult->setText(QString(
"Shift = %1 ms").arg(shift, 0,
'f', 0));
166 reportError(QString(
"Temporal calibration failed"));
167 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()