Skip to content

Commit

Permalink
two main functionalities added: (1) load meshes as STL files; (2) tra…
Browse files Browse the repository at this point in the history
…nsformation of the table coordinates between system original DICOMs and framegrabber DICOMs implemented
  • Loading branch information
vernikouskaya committed May 4, 2021
1 parent a4508ae commit bbfe1e0
Show file tree
Hide file tree
Showing 11 changed files with 283 additions and 99 deletions.
2 changes: 2 additions & 0 deletions src/algorithms/gui/CrosscorrelationFilterWidget.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ void CrosscorrelationFilterWidget::loadFromSettings()
tplSizeY->setValue(settings.value("TplSiteY").toInt());
useROI->setChecked(settings.value("UseRoi").toBool());
roiSize->setValue(settings.value("RoiSize").toDouble());
restrictY->setChecked(settings.value("RestrictY").toBool());
useBasicTpl->setChecked(settings.value("UseBasicTpl").toBool());
useModelBasedTpl->setChecked(settings.value("UseModelBasedTpl").toBool());
numberOfRotations->setValue(settings.value("NumberOfRotations").toInt());
Expand All @@ -107,6 +108,7 @@ void CrosscorrelationFilterWidget::writeToSettings()
settings.setValue("TplSiteY", tplSizeY->value());
settings.setValue("UseRoi", useROI->isChecked());
settings.setValue("RoiSize", roiSize->value());
settings.setValue("RestrictY", restrictY->isChecked());
settings.setValue("UseBasicTpl", useBasicTpl->isChecked());
settings.setValue("UseModelBasedTpl", useModelBasedTpl->isChecked());
settings.setValue("NumberOfRotations", numberOfRotations->value());
Expand Down
18 changes: 17 additions & 1 deletion src/geometry/SystemGeometryDefinitions.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@ int SystemGeometryDefinitions::CROPPED_SIZE_Y = 1000;

int SystemGeometryDefinitions::DISTANCE_SOURCE_TO_PATIENT[2] = { {810}, {765}}; // DistanceSourceToPatient in mm
//int SystemGeometryDefinitions::DISTANCE_SOURCE_TO_PATIENT[2] = { 810, 765 }; // DistanceSourceToPatient in mm
int SystemGeometryDefinitions::ISOCENTER_SHIFT_Z = 12; //isocenter for the lateral C-arm is shifted about 12mm away compared to frontal C-arm
//isocenter for the lateral C-arm is shifted about 12mm away compared to frontal C-arm (as confirmed by KUGEL PHANTOM from 31.08.2018)
int SystemGeometryDefinitions::ISOCENTER_SHIFT_X = 0;
int SystemGeometryDefinitions::ISOCENTER_SHIFT_Y = 0;
int SystemGeometryDefinitions::ISOCENTER_SHIFT_Z = 12;
// For Phantom Wuerfel 20200627 experiment these values were
//int SystemGeometryDefinitions::ISOCENTER_SHIFT_X = -4;
//int SystemGeometryDefinitions::ISOCENTER_SHIFT_Y = 6;
//int SystemGeometryDefinitions::ISOCENTER_SHIFT_Z = 11;


//// default Tischposition for PHANTOM from 07.07.2018
//int SystemGeometryDefinitions::TABLE_POSITION_X = -110; // lat.
//int SystemGeometryDefinitions::TABLE_POSITION_Y = -760; // long.
Expand All @@ -38,6 +47,13 @@ int SystemGeometryDefinitions::TABLE_POSITION_X = 0; // lat.
int SystemGeometryDefinitions::TABLE_POSITION_Y = 0; // long.
int SystemGeometryDefinitions::TABLE_POSITION_Z = 0; //vert. = höhe

// shift der Referenzkoordinatensysteme der Tischposition (DICOM header - display)
// diff = sys-osd
// shift = ceil(diff_min + (diff_max-diff_min))
int SystemGeometryDefinitions::TABLE_SHIFT_CS_POSITION_X = 100; // lat.
int SystemGeometryDefinitions::TABLE_SHIFT_CS_POSITION_Y = 988; // long.
int SystemGeometryDefinitions::TABLE_SHIFT_CS_POSITION_Z = 956; //vert. = höhe

int SystemGeometryDefinitions::FIELD_DISTANCE = 25;
double SystemGeometryDefinitions::DETECTOR_SIZE = 174.98; //174.98 mm - Detector size at FD = 25 cm;
//double SystemGeometryDefinitions::DETECTOR_SIZE = 132.902; //132.902 mm - Detector size at FD = 19 cm;
Expand Down
6 changes: 6 additions & 0 deletions src/geometry/SystemGeometryDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@ struct SystemGeometryDefinitions {
static double SOURCE_DETECTOR_DISTANCE; /// im millimeters
//static int DISTANCE_SOURCE_TO_PATIENT; // in millimeters
static int DISTANCE_SOURCE_TO_PATIENT[2]; // in millimeters
static int ISOCENTER_SHIFT_X; // in millimeters
static int ISOCENTER_SHIFT_Y; // in millimeters
static int ISOCENTER_SHIFT_Z; // in millimeters

static int DISTANCE_SOURCE_TO_PATIENT_FRONTAL; // in millimeters
static int DISTANCE_SOURCE_TO_PATIENT_LATERAL; // in millimeters

static int TABLE_SHIFT_CS_POSITION_X; // lat.
static int TABLE_SHIFT_CS_POSITION_Y; // long.
static int TABLE_SHIFT_CS_POSITION_Z; // vert.

static int TABLE_POSITION_X; // lat.
static int TABLE_POSITION_Y; // long.
Expand Down
11 changes: 10 additions & 1 deletion src/geometry/XRayGeometry.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ void XRayGeometry::setTablePosition(double lateralPos, double longitudinalPos, d
tablePosition[0] = lateralPos;
tablePosition[1] = longitudinalPos;
tablePosition[2] = verticalPos;

}

void XRayGeometry::getTablePosition(double& positionX, double& positionY, double& positionZ)
Expand Down Expand Up @@ -441,9 +442,17 @@ void XRayGeometry::getDetectorPosition(double& x, double& y, double& z) const

void XRayGeometry::getTablePositionInWC(double& x, double& y, double& z) const
{

x = tablePosition[0] - SystemGeometryDefinitions::TABLE_POSITION_X;
y = tablePosition[1] - SystemGeometryDefinitions::TABLE_POSITION_Y;
z = tablePosition[2] - SystemGeometryDefinitions::TABLE_POSITION_Z;
z = tablePosition[2] - SystemGeometryDefinitions::TABLE_POSITION_Z;
if (isFramegrabber)
{
// shift = sys-osd -> sys = osd+shift
x += SystemGeometryDefinitions::TABLE_SHIFT_CS_POSITION_X; // lat
y += SystemGeometryDefinitions::TABLE_SHIFT_CS_POSITION_Y; // long
z += SystemGeometryDefinitions::TABLE_SHIFT_CS_POSITION_Z; // vert
}

}

Expand Down
19 changes: 10 additions & 9 deletions src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,15 +521,13 @@ void MainWindow::saveScene(const char* file)
geometry->mainSystem.saveParametersAsAnglesAndDistancesFile(qPrintable(saveFile));
settings.setValue("SID_MAIN", geometry->mainSystem.getSourceDetectorDistance());*/

}


}

vector<const char*> meshFiles = theOverlayScene->getMeshFileNames();
vector<std::string> meshFiles = theOverlayScene->getMeshFileNames();
settings.setValue("MESH_SIZE", meshFiles.size());
QString param("MESH_%1");
for (unsigned int i = 0; i < meshFiles.size(); ++i) {
settings.setValue(param.arg(i), QString(meshFiles[i]));
settings.setValue(param.arg(i), QString(meshFiles[i].c_str()));

double c[3];
theOverlayScene->getMeshColor(c, i);
Expand Down Expand Up @@ -648,7 +646,8 @@ void MainWindow::loadScene(const char* file)

if (!frameGrabber)
{
theOverlayScene->alreadyConstructedPipelineDICOM[0] = theOverlayScene->alreadyConstructedPipelineDICOM[1] = false; // to update 3D reconstruction depending on initial table pos
theOverlayScene->alreadyConstructedPipelineDICOM[0] = theOverlayScene->alreadyConstructedPipelineDICOM[1] = false; // to update 3D reconstruction depending on initial table pos

if (!RAWstrings.empty() && (RAWstrings[0] != NULL && RAWstrings[0][0] != '\0'))
cout << "loading XRAYs... " << endl;
{
Expand All @@ -658,7 +657,8 @@ void MainWindow::loadScene(const char* file)
double primAngle, secAngle;

value = settings.value(frame.arg(i)).toInt();
//theXRayViewer->setSliderValue(i, value);
//theXRayViewer->setSliderValue(i, value);
theXRayViewer->resetCounters(true); // 0 - for FG; 1 - for system
theOverlayScene->setInputToFile(RAWstrings[i], i); //HERE correct
theXRayViewer->activateGui(value, (char*)strings[i].c_str(), i);
theOverlayScene->getDICOMAnglesToWindowRef(i, primAngle, secAngle);
Expand All @@ -680,9 +680,10 @@ void MainWindow::loadScene(const char* file)
stringsNew.push_back(strings[i].substr(0, strings[i].find("\\", 0)));

value = settings.value(frame.arg(i)).toInt();
theXRayViewer->activateGui(value, (char*)stringsNew[i].c_str(), i);
//theXRayViewer->setSliderValue(i, value);
theXRayViewer->resetCounters(false); // 0 - for FG; 1 - for system
//theXRayViewer->setSliderValue(i, value);
theOverlayScene->playReferenceStream(value, (char*)stringsNew[i].c_str(), i);
theXRayViewer->activateGui(value, (char*)stringsNew[i].c_str(), i);
theXRayViewer->clearTextActors(i);
theOverlayScene->getDICOMAnglesToWindowRef(i, primAngle, secAngle);
theXRayViewer->displayAngleInWindow(i, primAngle, secAngle);
Expand Down
6 changes: 3 additions & 3 deletions src/gui/MeshesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void MeshesDialog::update()

void MeshesDialog::on_addMeshButton_clicked()
{
QString fileFormats("Mesh File (*.vtk)");
QString fileFormats({ "Mesh File (*.vtk);; Mesh File (*.stl)" });
QStringList fileNames = QFileDialog::getOpenFileNames(this, "Select overlay file(s)", lastDirectory, fileFormats);
if (fileNames.empty()) return; // user cancelled

Expand Down Expand Up @@ -78,13 +78,13 @@ void MeshesDialog::on_removeMeshButton_clicked()

void MeshesDialog::updateList()
{
vector<const char*> fileNamesMeshes = scene->getMeshFileNames();
vector<std::string> fileNamesMeshes = scene->getMeshFileNames();

// copy fileNames to QStringList
QStringList files;
for (unsigned int i = 0; i < fileNamesMeshes.size(); ++i)
{
files << fileNamesMeshes[i];
files << fileNamesMeshes[i].c_str();
//files << QString::fromStdString(fileNamesMeshes[i]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/UsageDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ How to start:
If you have access to provided test data ('PHANTOM' folder), proceed like this:
- go to 'File | Load scene...' and choose .ini configuration file ('scene\AP_90.ini') to load complete 3D scene
- use the options in the 'Display' menu
- press 'Registration' button in the 'Registration' panel of the 'NavigationGUI&quot; to perform 3D-3D registration
- press 'Registration' button in the 'Registration' panel of the '3D-XGuide&quot; to perform 3D-3D registration
- press 'Load Run' button in 'Reference 1' and/or 'Reference 2' windows to choose any of available XR image series from folder 'XRAY'

Alternatively you can load all data separately:
Expand Down
113 changes: 105 additions & 8 deletions src/gui/XRayViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ XRayViewer::XRayViewer(QWidget *parent, OverlayScene* scene) :
QMainWindow(parent), previousMeshWindow(-1), txtActors{ NULL, NULL, NULL }/*, distanceWidget(0), inputIsFromFile(false)*/, run(0), isButtonPlayMainClickedFirst(0),
isPause(false), recordMode(0), biplaneSystem(false), monoplaneView(false), startPlay(false), biplaneTemplateSet{ false, false }, biplaneStartAgain{ false, false, false, false, false, false, false, false, false, false, false, false }
{

count_FG = count_FG = 0;
count_sys = count_sys = 0;
lastDirectory = "B:\\NAVIGATION\\data";
/*patientDirectory = "..\\Patientname";*/
//patientDirectoryChar = "..\\Patientname\\";
Expand Down Expand Up @@ -1233,6 +1236,23 @@ int XRayViewer::getSliderValue(int index)
//
//}

void XRayViewer::resetCounters(bool system)
{
if (system)
{
count_sys = 1;
scene->switchSystems_sys = true;
scene->switchSystems_FG = false;
}
else
{
count_FG = 1;
scene->switchSystems_sys = false;
scene->switchSystems_FG = true;
}
}


void XRayViewer::setSliderValue(int index, int value)
{
QString QValue = QString::number(value);
Expand Down Expand Up @@ -1352,7 +1372,7 @@ void XRayViewer::activateGui(int framenumber, char* dir, int index)
buttonPlay->setEnabled(true);
sliderBufferedFrame->setEnabled(true);
buttonLoadECG->setEnabled(true);
ButtonLoadRunFirst->setEnabled(false);
ButtonLoadRunFirst->setEnabled(true);

labelCurrentFrame->setText(QValue);
sliderBufferedFrame->setValue(framenumber);
Expand All @@ -1366,7 +1386,7 @@ void XRayViewer::activateGui(int framenumber, char* dir, int index)
buttonPlaySecondStream->setEnabled(true);
sliderBufferedFrameSecondStream->setEnabled(true);
buttonLoadECGSecondStream->setEnabled(true);
ButtonLoadRunSecond->setEnabled(false);
ButtonLoadRunSecond->setEnabled(true);

labelCurrentFrameSecondStream->setText(QValue);
sliderBufferedFrameSecondStream->setValue(framenumber);
Expand Down Expand Up @@ -1516,10 +1536,31 @@ void XRayViewer::on_actionSelectXRayReferenceFirst_triggered()
sliderBufferedFrameMainStream->setEnabled(true);
/*---------------------------------------------------------------------------------------------------------------*/
streamPlayerMainStream->stop();
scene->alreadyConstructedPipelineDICOM[1] = false;
scene->loadDefaultMeshPositionBool = true;
//scene->alreadyConstructedPipelineDICOM[1] = false;
//scene->loadDefaultMeshPositionBool = true;
}

scene->isFramegrabber = false;
if (count_FG == 0)
{
count_sys += 1;
if (count_sys == 1)
{
scene->switchSystems_sys = true;
}
else
{
scene->switchSystems_sys = false;
}
}
else
{
scene->switchSystems_sys = false;
scene->switchSystems_FG = false;
}

//scene->alreadyConstructedPipeline[0] = false;
scene->loadDefaultMeshPositionBool = true;
QByteArray file;
//vector<string> files;

Expand Down Expand Up @@ -1592,10 +1633,30 @@ void XRayViewer::on_actionSelectXRayReferenceSecond_triggered()
sliderBufferedFrameMainStream->setEnabled(true);
/*---------------------------------------------------------------------------------------------------------------*/
streamPlayerMainStream->stop();
scene->alreadyConstructedPipelineDICOM[0] = false;
scene->loadDefaultMeshPositionBool = true;
//scene->alreadyConstructedPipelineDICOM[0] = false;
//scene->loadDefaultMeshPositionBool = true;
}
scene->isFramegrabber = false;
//scene->alreadyConstructedPipeline[1] = false;
if (count_FG == 0)
{
count_sys += 1;
if (count_sys == 1)
{
scene->switchSystems_sys = true;
}
else
{
scene->switchSystems_sys = false;
}
}
else
{
scene->switchSystems_sys = false;
scene->switchSystems_FG = false;
}

scene->loadDefaultMeshPositionBool = true;
QByteArray file;

QString fileFormats("All files (*);; Image files (*.dcm)");
Expand Down Expand Up @@ -2329,7 +2390,25 @@ void XRayViewer::on_ButtonLoadRunFirst_clicked()
//=============================================================================================
scene->isFramegrabber = 1; // zum Testen ohne Geraet
//=============================================================================================

scene->loadDefaultMeshPositionBool = true;
if (count_sys == 0)
{
count_FG += 1;
if (count_FG == 1)
{
scene->switchSystems_FG = true;
}
else
{
scene->switchSystems_FG = false;
}
}
else
{
scene->switchSystems_sys = false;
scene->switchSystems_FG = false;
}

// select directory
QString path = QFileDialog::getExistingDirectory(this, "Select run directory", patientDirectory);
if (path.isNull()) return;
Expand Down Expand Up @@ -2383,7 +2462,25 @@ void XRayViewer::on_ButtonLoadRunSecond_clicked()
//=============================================================================================
scene->isFramegrabber = 1; // zum Testen ohne Geraet
//=============================================================================================

scene->loadDefaultMeshPositionBool = true;
if (count_sys == 0)
{
count_FG += 1;
if (count_FG == 1)
{
scene->switchSystems_FG = true;
}
else
{
scene->switchSystems_FG = false;
}
}
else
{
scene->switchSystems_sys = false;
scene->switchSystems_FG = false;
}

// select directory
QString path = QFileDialog::getExistingDirectory(this, "Select run directory", patientDirectory);
if (path.isNull()) return;
Expand Down
5 changes: 5 additions & 0 deletions src/gui/XRayViewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class XRayViewer : public QMainWindow, protected Ui::XRayViewer, public vtkComma
void clearTextActors(int index);
void enableMarkerMenu();

void resetCounters(bool system);

//std::vector<int> GeometryLiveNew;
//std::vector<int> GeometryLive;

Expand Down Expand Up @@ -195,6 +197,9 @@ class XRayViewer : public QMainWindow, protected Ui::XRayViewer, public vtkComma

int startClock(char* txt);
void stopClock(int startTime);

int count_FG;
int count_sys;
//===========================================================
};

Expand Down
Loading

0 comments on commit bbfe1e0

Please sign in to comment.