Skip to content

Commit

Permalink
Update dialog boxes after removing iter argument to ExecuteSurf
Browse files Browse the repository at this point in the history
  • Loading branch information
JostMigenda committed Jul 11, 2024
1 parent ba8542d commit 21870a6
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 92 deletions.
2 changes: 1 addition & 1 deletion CemrgApp/Modules/CemrgAppModule/include/CemrgCommandLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class MITKCEMRGAPPMODULE_EXPORT CemrgCommandLine: public QObject {
QDialog* GetDialog();

//Execute Plugin Specific Functions
QString ExecuteSurf(QString dir, QString segPath, int iter = 1, float th = 0.5, int blur = 0, int smth = 10);
QString ExecuteSurf(QString dir, QString segPath, float th = 0.5, int blur = 0, int smth = 10);
QString ExecuteCreateCGALMesh(QString dir, QString outputName, QString paramsFullPath, QString segmentationName = "converted.inr");
void ExecuteTracking(QString dir, QString imgTimes, QString param, QString output = "tsffd.dof");
void ExecuteApplying(QString dir, QString inputMesh, double iniTime, QString dofin, int noFrames, int smooth);
Expand Down
2 changes: 1 addition & 1 deletion CemrgApp/Modules/CemrgAppModule/src/CemrgCommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ QDialog* CemrgCommandLine::GetDialog() {
****************** Execute Plugin Specific Functions **********************
***************************************************************************/

QString CemrgCommandLine::ExecuteSurf(QString dir, QString segPath, int iter, float thresh, int blur, int smooth) {
QString CemrgCommandLine::ExecuteSurf(QString dir, QString segPath, float thresh, int blur, int smooth) {
MITK_INFO << "[ATTENTION] SURFACE CREATION: Surface -> Smooth";

// Load input image into memory
Expand Down
8 changes: 3 additions & 5 deletions CemrgApp/Modules/CemrgAppModule/test/CemrgCommandLineTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,14 @@ void TestCemrgCommandLine::cleanupTestCase() {

void TestCemrgCommandLine::ExecuteSurf_data() {
QTest::addColumn<QString>("segPath");
QTest::addColumn<int>("iterations");
QTest::addColumn<float>("threshold");
QTest::addColumn<int>("blur");
QTest::addColumn<int>("smoothness");
QTest::addColumn<QString>("result");

const array<tuple<QString, QString, int, float, int, int, QString>, 2> surfData { {
{"sphere_initial.nii", 1, 0.5, 0, 10, "/surf_expected_1.vtk"},
{"sphere_shifted.nii", 1, 0.5, 0, 10, "/surf_expected_2.vtk"},
{"sphere_initial.nii", 0.5, 0, 10, "/surf_expected_1.vtk"},
{"sphere_shifted.nii", 0.5, 0, 10, "/surf_expected_2.vtk"},
} };

for (size_t i = 0; i < surfData.size(); i++)
Expand All @@ -140,13 +139,12 @@ void TestCemrgCommandLine::ExecuteSurf_data() {

void TestCemrgCommandLine::ExecuteSurf() {
QFETCH(QString, segPath);
QFETCH(int, iterations);
QFETCH(float, threshold);
QFETCH(int, blur);
QFETCH(int, smoothness);
QFETCH(QString, result);

QString surfOutput = cemrgCommandLine->ExecuteSurf(dataPath, segPath, iterations, threshold, blur, smoothness);
QString surfOutput = cemrgCommandLine->ExecuteSurf(dataPath, segPath, threshold, blur, smoothness);
QVERIFY2(EqualFiles(surfOutput, dataPath + result), "The function output is different from the expected output!");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ void AtrialFibresView::AutomaticAnalysis(){
std::unique_ptr<CemrgCommandLine> cmd(new CemrgCommandLine());
cmd->SetUseDockerContainers(true);

cmd->ExecuteSurf(directory, Path("prodClean.nii"), uiMesh_iter, uiMesh_th, uiMesh_bl, uiMesh_smth);
cmd->ExecuteSurf(directory, Path("prodClean.nii"), uiMesh_th, uiMesh_bl, uiMesh_smth);
atrium->ProjectTagsOnExistingSurface(tagAtriumAuto, directory, tagName+".vtk");

MITK_INFO << "[AUTOMATIC_PIPELINE] Add the mesh to storage";
Expand Down Expand Up @@ -673,7 +673,7 @@ void AtrialFibresView::IdentifyPV(){
std::unique_ptr<CemrgCommandLine> cmd(new CemrgCommandLine());
cmd->SetUseDockerContainers(true);

cmd->ExecuteSurf(directory, Path("prodClean.nii"), uiMesh_iter, uiMesh_th, uiMesh_bl, uiMesh_smth);
cmd->ExecuteSurf(directory, Path("prodClean.nii"), uiMesh_th, uiMesh_bl, uiMesh_smth);

//Add the mesh to storage
std::string meshName = segNode->GetName() + "-Mesh";
Expand Down Expand Up @@ -728,7 +728,7 @@ void AtrialFibresView::CreateLabelledMesh(){
std::unique_ptr<CemrgCommandLine> cmd(new CemrgCommandLine());
cmd->SetUseDockerContainers(true);

cmd->ExecuteSurf(directory, Path("prodClean.nii"), uiMesh_iter, uiMesh_th, uiMesh_bl, uiMesh_smth);
cmd->ExecuteSurf(directory, Path("prodClean.nii"), uiMesh_th, uiMesh_bl, uiMesh_smth);
atrium->ProjectTagsOnExistingSurface(pveins, directory, tagName+".vtk");

MITK_INFO << "Add the mesh to storage";
Expand Down Expand Up @@ -1996,7 +1996,6 @@ bool AtrialFibresView::GetUserMeshingInputs(){

if(userHasSetMeshingParams){
QString msg = "The parameters have been set already, change them?\n";
msg += "close iter= " + QString::number(uiMesh_iter) + '\n';
msg += "threshold= " + QString::number(uiMesh_th) + '\n';
msg += "blur= " + QString::number(uiMesh_bl) + '\n';
msg += "smooth iter= " + QString::number(uiMesh_smth);
Expand All @@ -2017,19 +2016,17 @@ bool AtrialFibresView::GetUserMeshingInputs(){
//Act on dialog return code
if (dialogCode == QDialog::Accepted) {

bool ok1, ok2, ok3, ok4;
bool ok1, ok2, ok3;
uiMesh_th= m_UIMeshing.lineEdit_1->text().toDouble(&ok1);
uiMesh_bl= m_UIMeshing.lineEdit_2->text().toDouble(&ok2);
uiMesh_smth= m_UIMeshing.lineEdit_3->text().toDouble(&ok3);
uiMesh_iter= m_UIMeshing.lineEdit_4->text().toDouble(&ok4);

//Set default values
if (!ok1 || !ok2 || !ok3 || !ok4)
if (!ok1 || !ok2 || !ok3)
QMessageBox::warning(NULL, "Attention", "Reverting to default parameters!");
if (!ok1) uiMesh_th=0.5;
if (!ok2) uiMesh_bl=0.0;
if (!ok3) uiMesh_smth=10;
if (!ok4) uiMesh_iter=0;

inputs->deleteLater();
userInputAccepted=true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ protected slots:
bool automaticPipeline, analysisOnLge, resurfaceMesh, userHasSetMeshingParams;

// user-defined parameters
double uiMesh_th, uiMesh_bl, uiMesh_smth, uiMesh_iter;
double uiMesh_th, uiMesh_bl, uiMesh_smth;
double uiRemesh_max, uiRemesh_avrg, uiRemesh_min, uiRemesh_surfcorr;
bool uiRemesh_isscalar, uiRemesh_extractParts, uiRemesh_cleanmesh;
int uiScar_minStep, uiScar_maxStep, uiScar_projectionMethod, uiScar_thresholdMethod, uiFormat_scale;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>222</width>
<height>196</height>
<height>160</height>
</rect>
</property>
<property name="sizePolicy">
Expand All @@ -19,13 +19,13 @@
<property name="minimumSize">
<size>
<width>0</width>
<height>196</height>
<height>160</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>196</height>
<height>160</height>
</size>
</property>
<property name="windowTitle">
Expand All @@ -45,13 +45,6 @@
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_4">
<property name="placeholderText">
<string>'Close' iterations (default=0)</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_1">
<property name="placeholderText">
Expand Down
20 changes: 9 additions & 11 deletions CemrgApp/Plugins/kcl.cemrgapp.mmcwplugin/src/internal/MmcwView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,25 +564,23 @@ void MmcwView::CreateSurf() {
//Act on dialog return code
if (dialogCode == QDialog::Accepted) {

bool ok1, ok2, ok3, ok4;
int iter = m_UIMeshing.lineEdit_1->text().toInt(&ok1);
float th = m_UIMeshing.lineEdit_2->text().toFloat(&ok2);
int blur = m_UIMeshing.lineEdit_3->text().toInt(&ok3);
int smth = m_UIMeshing.lineEdit_4->text().toInt(&ok4);
bool ok1, ok2, ok3;
float th = m_UIMeshing.lineEdit_1->text().toFloat(&ok1);
int blur = m_UIMeshing.lineEdit_2->text().toInt(&ok2);
int smth = m_UIMeshing.lineEdit_3->text().toInt(&ok3);

//Set default values
if (!ok1 || !ok2 || !ok3 || !ok4)
if (!ok1 || !ok2 || !ok3)
QMessageBox::warning(NULL, "Attention", "Reverting to default parameters!");
if (!ok1) iter = 1;
if (!ok2) th = 0.5;
if (!ok3) blur = 0;
if (!ok4) smth = 10;
if (!ok1) th = 0.5;
if (!ok2) blur = 0;
if (!ok3) smth = 10;
//_if

this->BusyCursorOn();
mitk::ProgressBar::GetInstance()->AddStepsToDo(3);
std::unique_ptr<CemrgCommandLine> cmd(new CemrgCommandLine());
QString output = cmd->ExecuteSurf(directory, path, iter, th, blur, smth);
QString output = cmd->ExecuteSurf(directory, path, th, blur, smth);
QMessageBox::information(NULL, "Attention", "Command Line Operations Finished!");
this->BusyCursorOff();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>216</width>
<height>196</height>
<height>160</height>
</rect>
</property>
<property name="sizePolicy">
Expand All @@ -19,13 +19,13 @@
<property name="minimumSize">
<size>
<width>0</width>
<height>196</height>
<height>160</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>196</height>
<height>160</height>
</size>
</property>
<property name="windowTitle">
Expand All @@ -50,30 +50,20 @@
<property name="text">
<string/>
</property>
<property name="placeholderText">
<string>Iteration (default = 1)</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_2">
<property name="placeholderText">
<string>Threshold (default = 0.5)</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_3">
<widget class="QLineEdit" name="lineEdit_2">
<property name="placeholderText">
<string>Blur (default = 0)</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_4">
<property name="text">
<string/>
</property>
<widget class="QLineEdit" name="lineEdit_3">
<property name="placeholderText">
<string>Smooth (default = 10)</string>
</property>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,28 +190,27 @@ void AtrialScarClipperView::iniPreSurf() {
//Act on dialog return code
if (dialogCode == QDialog::Accepted) {

bool ok1, ok2, ok3, ok4;
int iter = m_UIMeshing.lineEdit_1->text().toInt(&ok1);
float th = m_UIMeshing.lineEdit_2->text().toFloat(&ok2);
int blur = m_UIMeshing.lineEdit_3->text().toInt(&ok3);
int smth = m_UIMeshing.lineEdit_4->text().toInt(&ok4);
bool ok1, ok2, ok3;
// TODO: iter parameter is no longer used; remove from dialog box
float th = m_UIMeshing.lineEdit_1->text().toFloat(&ok1);
int blur = m_UIMeshing.lineEdit_2->text().toInt(&ok2);
int smth = m_UIMeshing.lineEdit_3->text().toInt(&ok3);
float ds = 0.1;

//Set default values
if (!ok1 || !ok2 || !ok3 || !ok4)
if (!ok1 || !ok2 || !ok3)
QMessageBox::warning(NULL, "Attention", "Reverting to default parameters!");
if (!ok1) iter = 1;
if (!ok2) th = 0.5;
if (!ok3) blur = 0;
if (!ok4) smth = 10;
if (!ok1) th = 0.5;
if (!ok2) blur = 0;
if (!ok3) smth = 10;
//_if

this->BusyCursorOn();
path = directory + "/temp.nii";
mitk::IOUtil::Save(image, path.toStdString());
mitk::ProgressBar::GetInstance()->AddStepsToDo(3);
std::unique_ptr<CemrgCommandLine> cmd(new CemrgCommandLine());
QString output = cmd->ExecuteSurf(directory, path, iter, th, blur, smth);
QString output = cmd->ExecuteSurf(directory, path, th, blur, smth);
QMessageBox::information(NULL, "Attention", "Command Line Operations Finished!");
this->BusyCursorOff();

Expand Down
26 changes: 12 additions & 14 deletions CemrgApp/Plugins/kcl.cemrgapp.scar/src/internal/AtrialScarView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ void AtrialScarView::AutomaticAnalysis() {
MITK_INFO << ("[...][3.1] Saved file: " + segCleanPath).toStdString();

MITK_INFO << "[AUTOMATIC_ANALYSIS][4] Vein clipping mesh";
QString output1 = cmd->ExecuteSurf(direct, segCleanPath, 1, .5, 0, 10);
QString output1 = cmd->ExecuteSurf(direct, segCleanPath, .5, 0, 10);
mitk::Surface::Pointer shell = mitk::IOUtil::Load<mitk::Surface>(output1.toStdString());
vtkSmartPointer<vtkDecimatePro> deci = vtkSmartPointer<vtkDecimatePro>::New();
deci->SetInputData(shell->GetVtkPolyData());
Expand Down Expand Up @@ -662,7 +662,7 @@ void AtrialScarView::AutomaticAnalysis() {
MITK_INFO << "[...][7.3] ClipVeinsImage finished .";

MITK_INFO << "[AUTOMATIC_ANALYSIS][8] Create a mesh from clipped segmentation of veins";
QString output2 = cmd->ExecuteSurf(direct, (direct + "/PVeinsCroppedImage.nii"), 1, .5, 0, 10);
QString output2 = cmd->ExecuteSurf(direct, (direct + "/PVeinsCroppedImage.nii"), .5, 0, 10);
mitk::Surface::Pointer LAShell = mitk::IOUtil::Load<mitk::Surface>(output2.toStdString());

MITK_INFO << "[AUTOMATIC_ANALYSIS][9] Clip the mitral valve";
Expand Down Expand Up @@ -693,7 +693,7 @@ void AtrialScarView::AutomaticAnalysis() {
mitk::IOUtil::Save(mitk::ImportItkImage(mvImage), (direct + "/prodMVI.nii").toStdString());

// Make vtk of prodMVI
QString mviShellPath = cmd->ExecuteSurf(direct, "prodMVI.nii", 1, 0.5, 0, 10);
QString mviShellPath = cmd->ExecuteSurf(direct, "prodMVI.nii", 0.5, 0, 10);
// Implement code from command line tool
mitk::Surface::Pointer ClipperSurface = mitk::IOUtil::Load<mitk::Surface>(mviShellPath.toStdString());
vtkSmartPointer<vtkImplicitPolyDataDistance> implicitFn = vtkSmartPointer<vtkImplicitPolyDataDistance>::New();
Expand Down Expand Up @@ -1176,19 +1176,17 @@ void AtrialScarView::CreateSurf() {
//Act on dialog return code
if (dialogCode == QDialog::Accepted) {

bool ok1, ok2, ok3, ok4;
int iter = m_UIMeshing.lineEdit_1->text().toInt(&ok1);
float th = m_UIMeshing.lineEdit_2->text().toFloat(&ok2);
int blur = m_UIMeshing.lineEdit_3->text().toInt(&ok3);
int smth = m_UIMeshing.lineEdit_4->text().toInt(&ok4);
bool ok1, ok2, ok3;
float th = m_UIMeshing.lineEdit_1->text().toFloat(&ok1);
int blur = m_UIMeshing.lineEdit_2->text().toInt(&ok2);
int smth = m_UIMeshing.lineEdit_3->text().toInt(&ok3);

//Set default values
if (!ok1 || !ok2 || !ok3 || !ok4)
if (!ok1 || !ok2 || !ok3)
QMessageBox::warning(NULL, "Attention", "Reverting to default parameters!");
if (!ok1) iter = 1;
if (!ok2) th = 0.5;
if (!ok3) blur = 0;
if (!ok4) smth = 10;
if (!ok1) th = 0.5;
if (!ok2) blur = 0;
if (!ok3) smth = 10;
//_if

this->BusyCursorOn();
Expand All @@ -1197,7 +1195,7 @@ void AtrialScarView::CreateSurf() {
mitk::ProgressBar::GetInstance()->AddStepsToDo(3);
std::unique_ptr<CemrgCommandLine> cmd(new CemrgCommandLine());
cmd->SetUseDockerContainers(_useDockerInPlugin);
path = cmd->ExecuteSurf(directory, pathTemp, iter, th, blur, smth);
path = cmd->ExecuteSurf(directory, pathTemp, th, blur, smth);
QMessageBox::information(NULL, "Attention", "Command Line Operations Finished!");
this->BusyCursorOff();

Expand Down
Loading

0 comments on commit 21870a6

Please sign in to comment.