16 #include <QVBoxLayout> 17 #include "boost/bind.hpp" 20 #include <vtkDoubleArray.h> 21 #include <vtkPointData.h> 30 #include "vtkImageCorrelation.h" 46 BaseWidget(parent,
"temporal_calibration_widget",
"Temporal Calibration"),
47 mInfoLabel(new QLabel(
""))
51 this->setToolTip(
"Temporal calibration from a vertical periodic movement of an US probe");
53 connect(mServices->patient().get(), SIGNAL(patientChanged()),
this, SLOT(patientChangedSlot()));
55 connect(acquisitionService.get(), SIGNAL(saveDataCompleted(QString)),
this, SLOT(selectData(QString)));
58 mRecordSessionWidget =
new RecordSessionWidget(acquisitionService,
this, context,
"temp_cal");
60 QVBoxLayout* topLayout =
new QVBoxLayout(
this);
63 QLabel* acqLabel =
new QLabel(
"<b>Acquisition</b>");
64 topLayout->addWidget(acqLabel);
65 acqLabel->setToolTip(this->toolTip());
66 topLayout->addWidget(mInfoLabel);
67 topLayout->addWidget(mRecordSessionWidget);
74 QLabel* calLabel =
new QLabel(
"<b>Calibration</b>");
75 topLayout->addWidget(calLabel);
76 calLabel->setToolTip(this->toolTip());
79 connect(mFileSelectWidget, SIGNAL(fileSelected(QString)),
this, SLOT(selectData(QString)));
81 topLayout->addWidget(mFileSelectWidget);
83 mVerbose =
new QCheckBox(
"Save data to temporal_calib.txt");
84 topLayout->addWidget(mVerbose);
86 QPushButton* calibrateButton =
new QPushButton(
"Calibrate");
87 calibrateButton->setToolTip(
"Calculate the temporal shift for the selected acqusition." 88 "The shift is not applied in any way." 90 " The calculation takes a few seconds, and in this time the program will be unresponsive</p>");
92 connect(calibrateButton, SIGNAL(clicked()),
this, SLOT(calibrateSlot()));
93 topLayout->addWidget(calibrateButton);
95 mResult =
new QLineEdit;
96 mResult->setReadOnly(
true);
97 topLayout->addWidget(mResult);
99 topLayout->addStretch();
101 this->patientChangedSlot();
112 void TemporalCalibrationWidget::patientChangedSlot()
114 QString filename = mServices->patient()->getActivePatientFolder() +
"/US_Acq/";
115 mFileSelectWidget->
setPath(filename);
118 void TemporalCalibrationWidget::selectData(QString filename)
120 mAlgorithm->selectData(filename, mServices->file());
122 mResult->setText(
"");
128 void TemporalCalibrationWidget::calibrateSlot()
130 if (mVerbose->isChecked())
131 mAlgorithm->setDebugFolder(mServices->patient()->getActivePatientFolder()+
"/Logs/");
133 mAlgorithm->setDebugFolder(
"");
136 double shift = mAlgorithm->calibrate(&success);
139 reportSuccess(QString(
"Completed temporal calibration, found shift %1 ms").arg(shift,0,
'f',0));
140 mResult->setText(QString(
"Shift = %1 ms").arg(shift, 0,
'f', 0));
144 reportError(QString(
"Temporal calibration failed"));
145 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)
Namespace for all CustusX production code.