From c5669e2c629b8248e22d8892c6576ada7a14cc25 Mon Sep 17 00:00:00 2001 From: dsarrut Date: Fri, 23 Jul 2010 14:13:35 +0000 Subject: [PATCH] check upper/lower threshold validity --- segmentation/clitkExtractLungFilter.txx | 13 ++++++-- vv/vvToolExtractLung.cxx | 42 ++++++++++++++++++++++--- vv/vvToolExtractLung.h | 1 + 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/segmentation/clitkExtractLungFilter.txx b/segmentation/clitkExtractLungFilter.txx index 55e9e6c..4baee45 100644 --- a/segmentation/clitkExtractLungFilter.txx +++ b/segmentation/clitkExtractLungFilter.txx @@ -164,8 +164,8 @@ void clitk::ExtractLungFilter:: GenerateOutputInformation() { - Superclass::GenerateOutputInformation(); // Needed ?? - this->GetOutput(0)->SetRequestedRegion(this->GetOutput(0)->GetLargestPossibleRegion()); + Superclass::GenerateOutputInformation(); + //this->GetOutput(0)->SetRequestedRegion(this->GetOutput(0)->GetLargestPossibleRegion()); // Get input pointers patient = dynamic_cast(itk::ProcessObject::GetInput(1)); @@ -187,6 +187,13 @@ GenerateOutputInformation() //-------------------------------------------------------------------- //-------------------------------------------------------------------- StartNewStepOrStop("Remove Air"); + // Check threshold + if (m_UseLowerThreshold) { + if (m_LowerThreshold > m_UpperThreshold) { + this->SetLastError("ERROR: lower threshold cannot be greater than upper threshold."); + return; + } + } // Threshold to get air typedef itk::BinaryThresholdImageFilter InputBinarizeFilterType; typename InputBinarizeFilterType::Pointer binarizeFilter=InputBinarizeFilterType::New(); @@ -458,7 +465,7 @@ GenerateOutputInformation() --it; } if (it.IsAtEnd()) { - this->SetLastError("ERROR: first point in the skeleton not found ! Abord"); + this->SetLastError("ERROR: first point in the skeleton not found ! Abort"); return; } DD(skeleton->GetLargestPossibleRegion().GetIndex()); diff --git a/vv/vvToolExtractLung.cxx b/vv/vvToolExtractLung.cxx index 1bf0d32..c976b8c 100644 --- a/vv/vvToolExtractLung.cxx +++ b/vv/vvToolExtractLung.cxx @@ -44,13 +44,14 @@ vvToolExtractLung::vvToolExtractLung(vvMainWindowBase * parent, Qt::WindowFlags // GUI Ui_vvToolExtractLung::setupUi(mToolWidget); mMaskLoaderBox->setEnabled(false); - //mOptionsBox->setEnabled(false); + mOptionsBox->setEnabled(false); mPatientMaskInputWidget->SetText("Patient mask"); connect(mPatientMaskInputWidget, SIGNAL(accepted()), this, SLOT(PatientMaskInputIsSelected())); // Default values mArgsInfo = new ArgsInfoType; cmdline_parser_clitkExtractLung_init(mArgsInfo); + SetGUIFromArgsInfo(); m_IsThreadInterrupted = false; // Create a new ExtractLung filter @@ -109,7 +110,25 @@ void vvToolExtractLung::PatientMaskInputIsSelected() } mMaskLoaderBox->setEnabled(false); - //mOptionsBox->setEnabled(true); + mOptionsBox->setEnabled(true); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolExtractLung::SetGUIFromArgsInfo() +{ + mAirUpperThresholdSlider->SetText("Upper threshold for air"); + mAirUpperThresholdSlider->SetMinimum(-1200); + mAirUpperThresholdSlider->SetMaximum(2000); + DD(mArgsInfo->upper_arg); + mAirUpperThresholdSlider->SetValue(mArgsInfo->upper_arg); + + mAirLowerThresholdSlider->SetText("Lower threshold for air"); + mAirLowerThresholdSlider->SetMinimum(-1200); + mAirLowerThresholdSlider->SetMaximum(2000); + mAirLowerThresholdSlider->SetValue(mArgsInfo->lower_arg); + } //------------------------------------------------------------------------------ @@ -117,15 +136,19 @@ void vvToolExtractLung::PatientMaskInputIsSelected() //------------------------------------------------------------------------------ void vvToolExtractLung::GetArgsInfoFromGUI() { - mArgsInfo->patientBG_arg = 0; //mPatientBackgroundValueSpinBox->value(); - mArgsInfo->verboseOption_flag = false; - mArgsInfo->verboseStep_flag = false; + mArgsInfo->patientBG_arg = mPatientMaskInputWidget->GetBackgroundValue(); + mArgsInfo->verboseOption_flag = true; // DEBUG. TO CHANGE + mArgsInfo->verboseStep_flag = true; // DEBUG. TO CHANGE mArgsInfo->writeStep_flag = false; mArgsInfo->input_given = 0; mArgsInfo->patient_given = 0; mArgsInfo->output_given = 0; mArgsInfo->outputTrachea_given = 0; mArgsInfo->remove1_given = 0; + + mArgsInfo->upper_arg = mAirUpperThresholdSlider->GetValue(); + mArgsInfo->lower_arg = mAirLowerThresholdSlider->GetValue(); + if (mRadioButtonLowerThan->isChecked()) mArgsInfo->lower_given = 1; } //------------------------------------------------------------------------------ @@ -138,6 +161,15 @@ void vvToolExtractLung::apply() // Read options from GUI and put it in the ArgsInfo struct GetArgsInfoFromGUI(); + + // Check options + if (mArgsInfo->lower_given) { + if (mArgsInfo->lower_arg > mArgsInfo->upper_arg) { + QApplication::restoreOverrideCursor(); + QMessageBox::information(this,tr("Error"), "Lower threshold cannot be greater than upper threshold."); + return; + } + } // Create new filter if (mFilter) delete mFilter; diff --git a/vv/vvToolExtractLung.h b/vv/vvToolExtractLung.h index 6ea8010..24d81d5 100644 --- a/vv/vvToolExtractLung.h +++ b/vv/vvToolExtractLung.h @@ -47,6 +47,7 @@ class vvToolExtractLung: static void Initialize(); virtual void InputIsSelected(vvSlicerManager *m); void GetArgsInfoFromGUI(); + void SetGUIFromArgsInfo(); //----------------------------------------------------- public slots: -- 2.47.1