From: Romulo Pinho Date: Wed, 24 Oct 2012 20:50:13 +0000 (+0200) Subject: Merge branch 'master' of git.creatis.insa-lyon.fr:clitk X-Git-Tag: v1.4.0~283^2~1 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=83929af8ebcf2b66482a42e4d41091aa3830c710;hp=10f76b492bf9f39e19f47d2ac8f573c4091fccff;p=clitk.git Merge branch 'master' of git.creatis.insa-lyon.fr:clitk --- diff --git a/vv/CMakeLists.txt b/vv/CMakeLists.txt index b77a52c..8fb0ac5 100644 --- a/vv/CMakeLists.txt +++ b/vv/CMakeLists.txt @@ -89,8 +89,6 @@ SET(vv_SRCS vvMeshActor.cxx vvMeshReader.cxx vvMidPosition.cxx - vvImageMapToWLColors.cxx - vvThreadedFilter.cxx vvImageContour.cxx vvBinaryImageOverlayActor.cxx vvStructureSetActor.cxx @@ -114,7 +112,6 @@ QT4_WRAP_CPP(vv_SRCS vvHelpDialog.h vvQDicomSeriesSelector.h vvSlicerManager.h - vvThreadedFilter.h vvStructureSetActor.h vvROIActor.h vvToolCreatorBase.h diff --git a/vv/vvImageMapToWLColors.cxx b/vv/vvImageMapToWLColors.cxx deleted file mode 100644 index a553583..0000000 --- a/vv/vvImageMapToWLColors.cxx +++ /dev/null @@ -1,270 +0,0 @@ -/*========================================================================= - Program: vv http://www.creatis.insa-lyon.fr/rio/vv - - Authors belong to: - - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://www.centreleonberard.fr - - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the copyright notices for more information. - - It is distributed under dual licence - - - BSD See included LICENSE.txt file - - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -===========================================================================**/ -#include "vvImageMapToWLColors.h" -#include "clitkCommon.h" -#include "vtkDataArray.h" -#include "vtkImageData.h" -#include "vtkInformation.h" -#include "vtkInformationVector.h" -#include "vtkObjectFactory.h" -#include "vtkScalarsToColors.h" -#include "vtkPointData.h" -#include - -vtkStandardNewMacro(vvImageMapToWLColors); - -vvImageMapToWLColors::vvImageMapToWLColors() : - wl_mode(false) -{} - -template -void vtkImageMapToWindowLevelClamps ( vtkImageData *data, double w, - double l, T& lower, T& upper, - unsigned char &lower_val, - unsigned char &upper_val) -{ - double f_lower, f_upper, f_lower_val, f_upper_val; - double adjustedLower, adjustedUpper; - double range[2]; - - data->GetPointData()->GetScalars()->GetDataTypeRange( range ); - - f_lower = l - fabs(w) / 2.0; - f_upper = f_lower + fabs(w); - - // Set the correct lower value - if ( f_lower <= range[1]) { - if (f_lower >= range[0]) { - lower = static_cast(f_lower); - adjustedLower = f_lower; - } else { - lower = static_cast(range[0]); - adjustedLower = range[0]; - } - } else { - lower = static_cast(range[1]); - adjustedLower = range[1]; - } - - // Set the correct upper value - if ( f_upper >= range[0]) { - if (f_upper <= range[1]) { - upper = static_cast(f_upper); - adjustedUpper = f_upper; - } else { - upper = static_cast(range[1]); - adjustedUpper = range[1]; - } - } else { - upper = static_cast(range[0]); - adjustedUpper = range [0]; - } - - // now compute the lower and upper values - if (w >= 0) { - f_lower_val = 255.0*(adjustedLower - f_lower)/w; - f_upper_val = 255.0*(adjustedUpper - f_lower)/w; - } else { - f_lower_val = 255.0 + 255.0*(adjustedLower - f_lower)/w; - f_upper_val = 255.0 + 255.0*(adjustedUpper - f_lower)/w; - } - - if (f_upper_val > 255) { - upper_val = 255; - } else if (f_upper_val < 0) { - upper_val = 0; - } else { - upper_val = static_cast(f_upper_val); - } - - if (f_lower_val > 255) { - lower_val = 255; - } else if (f_lower_val < 0) { - lower_val = 0; - } else { - lower_val = static_cast(f_lower_val); - } -} - -template -void vvImageMapToWindowLevelColorsExecute( - vtkImageMapToWindowLevelColors *self, - vtkImageData *inData, T *inPtr, - vtkImageData *outData, - unsigned char *outPtr, - int outExt[6], int id, bool wl_mode) -{ - int idxX, idxY, idxZ; - int extX, extY, extZ; - vtkIdType inIncX, inIncY, inIncZ; - vtkIdType outIncX, outIncY, outIncZ; - unsigned long count = 0; - unsigned long target; - int dataType = inData->GetScalarType(); - int numberOfComponents,numberOfOutputComponents,outputFormat; - int rowLength; - vtkScalarsToColors *lookupTable = self->GetLookupTable(); - unsigned char *outPtr1; - T *inPtr1; - unsigned char *optr; - T *iptr; - double shift = self->GetWindow() / 2.0 - self->GetLevel(); - double scale = 255.0 / self->GetWindow(); - - T lower, upper; - unsigned char lower_val, upper_val, result_val; - vtkImageMapToWindowLevelClamps( inData, self->GetWindow(), - self->GetLevel(), - lower, upper, lower_val, upper_val ); - - // find the region to loop over - extX = outExt[1] - outExt[0] + 1; - extY = outExt[3] - outExt[2] + 1; - extZ = outExt[5] - outExt[4] + 1; - - target = static_cast(extZ*extY/50.0); - target++; - - // Get increments to march through data - inData->GetContinuousIncrements(outExt, inIncX, inIncY, inIncZ); - - outData->GetContinuousIncrements(outExt, outIncX, outIncY, outIncZ); - numberOfComponents = inData->GetNumberOfScalarComponents(); - numberOfOutputComponents = outData->GetNumberOfScalarComponents(); - outputFormat = self->GetOutputFormat(); - - rowLength = extX*numberOfComponents; - - // Loop through output pixels - outPtr1 = outPtr; - inPtr1 = inPtr; - for (idxZ = 0; idxZ < extZ; idxZ++) { - for (idxY = 0; !self->AbortExecute && idxY < extY; idxY++) { - if (!id) { - if (!(count%target)) { - self->UpdateProgress(count/(50.0*target)); - } - count++; - } - - iptr = inPtr1; - optr = outPtr1; - - if ( lookupTable ) { - lookupTable->MapScalarsThroughTable2( - inPtr1, - static_cast(outPtr1), - dataType,extX,numberOfComponents, - outputFormat); - if (wl_mode) { - unsigned short ushort_val; - for (idxX = 0; idxX < extX; idxX++) { - if (*iptr <= lower) { - ushort_val = lower_val; - } else if (*iptr >= upper) { - ushort_val = upper_val; - } else { - ushort_val = static_cast((*iptr + shift)*scale); - } - *optr = static_cast((*optr * ushort_val) >> 8); - switch (outputFormat) { - case VTK_RGBA: - *(optr+1) = static_cast( - (*(optr+1) * ushort_val) >> 8); - *(optr+2) = static_cast( - (*(optr+2) * ushort_val) >> 8); - *(optr+3) = 255; - break; - case VTK_RGB: - *(optr+1) = static_cast( - (*(optr+1) * ushort_val) >> 8); - *(optr+2) = static_cast( - (*(optr+2) * ushort_val) >> 8); - break; - case VTK_LUMINANCE_ALPHA: - *(optr+1) = 255; - break; - } - iptr += numberOfComponents; - optr += numberOfOutputComponents; - } - } - } else { - for (idxX = 0; idxX < extX; idxX++) { - if (*iptr <= lower) { - result_val = lower_val; - } else if (*iptr >= upper) { - result_val = upper_val; - } else { - result_val = static_cast((*iptr + shift)*scale); - } - *optr = result_val; - switch (outputFormat) { - case VTK_RGBA: - *(optr+1) = result_val; - *(optr+2) = result_val; - *(optr+3) = 255; - break; - case VTK_RGB: - *(optr+1) = result_val; - *(optr+2) = result_val; - break; - case VTK_LUMINANCE_ALPHA: - *(optr+1) = 255; - break; - } - iptr += numberOfComponents; - optr += numberOfOutputComponents; - } - } - outPtr1 += outIncY + extX*numberOfOutputComponents; - inPtr1 += inIncY + rowLength; - } - outPtr1 += outIncZ; - inPtr1 += inIncZ; - } -} - - -void vvImageMapToWLColors::ThreadedRequestData( - vtkInformation *vtkNotUsed(request), - vtkInformationVector **vtkNotUsed(inputVector), - vtkInformationVector *vtkNotUsed(outputVector), - vtkImageData ***inData, - vtkImageData **outData, - int outExt[6], int id) -{ - void *inPtr = inData[0][0]->GetScalarPointerForExtent(outExt); - void *outPtr = outData[0]->GetScalarPointerForExtent(outExt); - - switch (inData[0][0]->GetScalarType()) { - vtkTemplateMacro( - vvImageMapToWindowLevelColorsExecute(this, - inData[0][0], - static_cast(inPtr), - outData[0], - static_cast(outPtr), - outExt, - id,wl_mode)); - default: - vtkErrorMacro(<< "Execute: Unknown ScalarType"); - return; - } -} - - diff --git a/vv/vvImageMapToWLColors.h b/vv/vvImageMapToWLColors.h deleted file mode 100644 index 7b63e2b..0000000 --- a/vv/vvImageMapToWLColors.h +++ /dev/null @@ -1,42 +0,0 @@ -/*========================================================================= - Program: vv http://www.creatis.insa-lyon.fr/rio/vv - - Authors belong to: - - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://www.centreleonberard.fr - - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the copyright notices for more information. - - It is distributed under dual licence - - - BSD See included LICENSE.txt file - - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -===========================================================================**/ -#ifndef vvImageMapToWLColors_h -#define vvImageMapToWLColors_h -#include - -//This is mostly a copy of the vtk parent class, but with the option -//not to use the W/L when a LUT is set - -class vvImageMapToWLColors : public vtkImageMapToWindowLevelColors -{ -public: - static vvImageMapToWLColors * New(); - vvImageMapToWLColors(); - void SetWindowLevelMode(bool wl) {wl_mode=wl;} - void ThreadedRequestData(vtkInformation *request, - vtkInformationVector **inputVector, - vtkInformationVector *outputVector, - vtkImageData ***inData, vtkImageData **outData, - int extent[6], int id); - -protected: - bool wl_mode; - -}; - -#endif diff --git a/vv/vvSaveState.cxx b/vv/vvSaveState.cxx index ecf29da..894e8e4 100644 --- a/vv/vvSaveState.cxx +++ b/vv/vvSaveState.cxx @@ -172,7 +172,7 @@ void vvSaveState::SaveLink(const vvSlicerManager* vvManager) std::string my_id = vvManager->GetId(); m_XmlWriter->writeStartElement("LinkedFrom"); m_XmlWriter->writeAttribute("Id", my_id.c_str()); - typename LinkListType::iterator i; + LinkListType::iterator i; for (i = links.begin(); i != links.end(); i++) { std::string link_id = *i; m_XmlWriter->writeTextElement("LinkedTo", link_id.c_str()); diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index 9246322..a915a6b 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -21,7 +21,6 @@ #include "vvSlicerManagerCommand.h" #include "vvGlyphSource.h" #include "vvGlyph2D.h" -#include "vvImageMapToWLColors.h" #include #include @@ -137,9 +136,6 @@ vvSlicer::vvSlicer() this->GetRenderer()->AddActor(legend); showFusionLegend = false; - this->WindowLevel->Delete(); - this->WindowLevel = vvImageMapToWLColors::New(); - this->InstallPipeline(); mLinkOverlayWindowLevel = true; diff --git a/vv/vvSlicerManager.cxx b/vv/vvSlicerManager.cxx index 9331bf1..015409b 100644 --- a/vv/vvSlicerManager.cxx +++ b/vv/vvSlicerManager.cxx @@ -23,7 +23,6 @@ #include "vvInteractorStyleNavigator.h" #include "vvLandmarks.h" #include "vvMesh.h" -#include "vvImageMapToWLColors.h" #include "vvBlendImageActor.h" #include @@ -1305,15 +1304,11 @@ void vvSlicerManager::SetColorMap(int colormap) invLUT->SetSaturationRange(1,1); invLUT->SetHueRange(double((mOverlayColor+180)%360)/360,double((mOverlayColor+180)%360)/360); invLUT->Build(); - dynamic_cast(mSlicers[i]->GetWindowLevel()) - ->SetWindowLevelMode(true); mSlicers[i]->GetWindowLevel()->SetLookupTable(supLUT); mSlicers[i]->GetOverlayMapper()->SetLookupTable(invLUT); invLUT->Delete(); supLUT->Delete(); } else if (mSlicers[i]->GetOverlay()) { - //dynamic_cast(mSlicers[i]->GetWindowLevel()) - //->SetWindowLevelMode(false); mSlicers[i]->GetWindowLevel()->SetLookupTable(LUT); } else { mSlicers[i]->GetWindowLevel()->SetLookupTable(LUT); diff --git a/vv/vvThreadedFilter.cxx b/vv/vvThreadedFilter.cxx deleted file mode 100644 index 3504b92..0000000 --- a/vv/vvThreadedFilter.cxx +++ /dev/null @@ -1,111 +0,0 @@ -/*========================================================================= - Program: vv http://www.creatis.insa-lyon.fr/rio/vv - - Authors belong to: - - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://www.centreleonberard.fr - - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the copyright notices for more information. - - It is distributed under dual licence - - - BSD See included LICENSE.txt file - - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html - ===========================================================================**/ - -// vv -#include "vvThreadedFilter.h" -#include "vvProgressDialog.h" - -// Qt -#include - -//------------------------------------------------------------------------------ -vvThreadedFilter::vvThreadedFilter(): - QThread() -{ - m_Filter = NULL; -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -vvThreadedFilter::~vvThreadedFilter() -{ -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvThreadedFilter::SetFilter(clitk::ImageToImageGenericFilterBase * f) -{ - m_Filter = f; -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvThreadedFilter::Update() -{ - assert(m_Filter != NULL); - - // Show a progress bar while computing - vvProgressDialog progress("Computing ...",100); - progress.SetCancelButtonEnabled(true); - connect(&progress, SIGNAL(rejected()), this, SLOT(reject())); - this->start(); - this->setTerminationEnabled(true); - std::string temp; - while (this->isRunning()) { - // try { - m_FilterBase = m_Filter->GetFilterBase(); // get filterbase is only set after Update - if (m_FilterBase != NULL) { - progress.SetProgress(m_FilterBase->GetCurrentStepNumber(), - m_FilterBase->GetNumberOfSteps()); - if (temp != m_FilterBase->GetCurrentStepName()) { - progress.AddToText(m_FilterBase->GetCurrentStepName()); - } - temp = m_FilterBase->GetCurrentStepName(); - } - this->wait(200); // in miliseconds - qApp->processEvents(); - } -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvThreadedFilter::run() -{ - assert(m_Filter != NULL); - try { - m_Filter->Update(); - } - catch(clitk::ExceptionObject e) { - DD("vvThreadedFilter : exceptionobject handeled"); - DD(e.what()); - QApplication::restoreOverrideCursor(); - QMessageBox::information(new QWidget, tr("Error"), e.what()); - } - DD("end RUN"); -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvThreadedFilter::reject() -{ - // First, say the filter it must stop as soon as possible. We then - // wait that an exception occur in the main thread. - if (m_FilterBase != NULL) { - m_FilterBase->Cancel(); - } -} -//------------------------------------------------------------------------------ - - - - diff --git a/vv/vvThreadedFilter.h b/vv/vvThreadedFilter.h deleted file mode 100644 index b367d50..0000000 --- a/vv/vvThreadedFilter.h +++ /dev/null @@ -1,55 +0,0 @@ -/*========================================================================= - Program: vv http://www.creatis.insa-lyon.fr/rio/vv - - Authors belong to: - - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://www.centreleonberard.fr - - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the copyright notices for more information. - - It is distributed under dual licence - - - BSD See included LICENSE.txt file - - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -===========================================================================**/ - -#ifndef VVTHREADEDFILTER_H -#define VVTHREADEDFILTER_H - -// clitk -#include "clitkImageToImageGenericFilterBase.h" - -// qt -#include - -//------------------------------------------------------------------------------ -class vvThreadedFilter: public QThread -{ - Q_OBJECT - public: - vvThreadedFilter(); - ~vvThreadedFilter(); - - // Called from the main thread, runs the reader and displays the progress bar - void SetFilter(clitk::ImageToImageGenericFilterBase * f); - void Update(); - -public slots: - void reject(); - - signals: - void ThreadInterrupted(); - -protected: - void run(); - clitk::ImageToImageGenericFilterBase * m_Filter; - clitk::FilterBase * m_FilterBase; - -}; // end class vvThreadedFilter -//------------------------------------------------------------------------------ - -#endif - diff --git a/vv/vvToolExtractLung.cxx b/vv/vvToolExtractLung.cxx deleted file mode 100644 index 59b4133..0000000 --- a/vv/vvToolExtractLung.cxx +++ /dev/null @@ -1,259 +0,0 @@ -/*========================================================================= - Program: vv http://www.creatis.insa-lyon.fr/rio/vv - - Authors belong to: - - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://www.centreleonberard.fr - - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the copyright notices for more information. - - It is distributed under dual licence - - - BSD See included LICENSE.txt file - - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html - ===========================================================================**/ - -// vv -#include "vvToolExtractLung.h" -#include "vvToolStructureSetManager.h" -#include "vvSlicer.h" -#include "vvImageReader.h" -#include "vvImageWriter.h" -#include "vvLabelImageLoaderWidget.h" -#include "vvThreadedFilter.h" - -// Qt -#include - -//------------------------------------------------------------------------------ -// Create the tool and automagically (I like this word) insert it in -// the main window menu. -ADD_TOOL(vvToolExtractLung); -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -vvToolExtractLung::vvToolExtractLung(vvMainWindowBase * parent, Qt::WindowFlags f): - vvToolWidgetBase(parent,f), - vvToolBase(parent), - Ui::vvToolExtractLung() -{ - // GUI - Ui_vvToolExtractLung::setupUi(mToolWidget); - mMaskLoaderBox->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 - mFilter = new FilterType; // used in AddInputSelector - - // Add input selector - AddInputSelector("Select CT thorax image", mFilter); -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -vvToolExtractLung::~vvToolExtractLung() -{ -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolExtractLung::Initialize() { - SetToolName("ExtractLung"); - SetToolMenuName("Extract lungs"); - SetToolIconFilename(":/common/icons/lung-overlay.png"); - SetToolTip("Extract lung mask from thorax CT."); - SetToolExperimental(true); - // SetToolInMenu("Segmentation"); -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolExtractLung::InputIsSelected(vvSlicerManager *m) -{ - // Hide selector - HideInputSelector(); // splitter - mToolInputSelectionWidget->hide(); - mCurrentSlicerManager = m; - mCurrentImage = m->GetImage(); - mMaskLoaderBox->setEnabled(true); - mLabelInput->setText(m->GetFileName().c_str()); -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolExtractLung::PatientMaskInputIsSelected() -{ - // Get Patient mask and BG value - mPatient = mPatientMaskInputWidget->GetImage(); - mPatientBackgroundValue = mPatientMaskInputWidget->GetBackgroundValue(); - - // Check patient dimension - if (mPatient->GetNumberOfDimensions() != 3) { - QMessageBox::information(this,tr("*Error*"), "Mask image must be 3D"); - return; - } - - mMaskLoaderBox->setEnabled(false); - 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); - -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolExtractLung::GetArgsInfoFromGUI() -{ - // 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; -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolExtractLung::apply() -{ - // Change cursor to wait - QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); - - // 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; - mFilter = new FilterType; // needed when thread cancel the filter - // mFilter->StopOnErrorOff(); - // mFilter->SetIOVerbose(true); - mFilter->AddInputVVImage(mCurrentImage); // CT - mFilter->AddInputVVImage(mPatient); // patient mask - mFilter->SetArgsInfo(*mArgsInfo); - - // Created threaded execution - vvThreadedFilter thread; - connect(&thread, SIGNAL(ThreadInterrupted()), this, SLOT(ThreadInterrupted())); - thread.SetFilter(mFilter); - - try { - thread.Update(); - } - catch(std::runtime_error e) { - DD("Error exception handling"); - DD(m_IsThreadInterrupted); - // Check if the thread has been canceled. In this case, return - if (m_IsThreadInterrupted) { - m_IsThreadInterrupted = false; - QApplication::restoreOverrideCursor(); - return; - } - disconnect(&thread, SIGNAL(ThreadInterrupted()), this, SLOT(ThreadInterrupted())); - - // Check error during filter - // if (mFilter->HasError()) { - QApplication::restoreOverrideCursor(); - QMessageBox::information(this,tr("Error"), e.what());//mFilter->GetLastError().c_str()); - return; - // } - } // end exception - - // Get output - std::vector output = mFilter->GetOutputVVImages(); - if (output.size() == 0) { - std::cerr << "Error : no output ?" << std::endl; - QApplication::restoreOverrideCursor(); - close(); - return; - } - - // Set Lung into VV - vvImage::Pointer lung = output[0]; - std::ostringstream osstream; - osstream << "Lung_" << mCurrentSlicerManager->GetSlicer(0)->GetFileName() << ".mhd"; - vvSlicerManager * v = AddImage(lung,osstream.str()); - v->SetPreset(5); - vvToolStructureSetManager::AddImage(mCurrentSlicerManager, "Right lung", lung, 1, false); // Right is greater than Left - vvToolStructureSetManager::AddImage(mCurrentSlicerManager, "Left lung", lung, 2, false); - - // Set trachea into VV - if (output.size() == 2) { - vvImage::Pointer trachea = output[1]; - std::ostringstream osstream; - osstream << "Trachea_" << mCurrentSlicerManager->GetSlicer(0)->GetFileName() << ".mhd"; - vvSlicerManager * v = AddImage(trachea,osstream.str()); - v->SetPreset(5); - vvToolStructureSetManager::AddImage(mCurrentSlicerManager, "Trachea", trachea, 0); - } - - // End - QApplication::restoreOverrideCursor(); - close(); -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -bool vvToolExtractLung::close() -{ - return vvToolWidgetBase::close(); -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolExtractLung::ThreadInterrupted() -{ - m_IsThreadInterrupted = true; -} -//------------------------------------------------------------------------------ - diff --git a/vv/vvToolExtractLung.h b/vv/vvToolExtractLung.h deleted file mode 100644 index 5693ad4..0000000 --- a/vv/vvToolExtractLung.h +++ /dev/null @@ -1,73 +0,0 @@ -/*========================================================================= - Program: vv http://www.creatis.insa-lyon.fr/rio/vv - - Authors belong to: - - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://www.centreleonberard.fr - - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the copyright notices for more information. - - It is distributed under dual licence - - - BSD See included LICENSE.txt file - - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -===========================================================================**/ - -#ifndef VVTOOLEXTRACTLUNG_H -#define VVTOOLEXTRACTLUNG_H - -// clitk -#include "clitkExtractLungGenericFilter.h" -#include "../segmentation/clitkExtractLung_ggo.h" - -// vv -#include "ui_vvToolExtractLung.h" -#include "vvToolBase.h" -#include "vvToolWidgetBase.h" -#include "vvROIActor.h" - -// qt -#include - -//------------------------------------------------------------------------------ -class vvToolExtractLung: - public vvToolWidgetBase, - public vvToolBase, - private Ui::vvToolExtractLung -{ - Q_OBJECT - public: - vvToolExtractLung(vvMainWindowBase* parent=0, Qt::WindowFlags f=0); - ~vvToolExtractLung(); - - //----------------------------------------------------- - static void Initialize(); - virtual void InputIsSelected(vvSlicerManager *m); - void GetArgsInfoFromGUI(); - void SetGUIFromArgsInfo(); - - //----------------------------------------------------- -public slots: - virtual void apply(); - virtual bool close(); - void PatientMaskInputIsSelected(); - void ThreadInterrupted(); - - //----------------------------------------------------- -protected: - typedef args_info_clitkExtractLung ArgsInfoType; - ArgsInfoType * mArgsInfo; - typedef clitk::ExtractLungGenericFilter FilterType; - FilterType * mFilter; - vvImage::Pointer mPatient; - double mPatientBackgroundValue; - bool m_IsThreadInterrupted; - -}; // end class vvToolExtractLung -//------------------------------------------------------------------------------ - -#endif - diff --git a/vv/vvToolExtractPatient.cxx b/vv/vvToolExtractPatient.cxx deleted file mode 100644 index d81b123..0000000 --- a/vv/vvToolExtractPatient.cxx +++ /dev/null @@ -1,260 +0,0 @@ -/*========================================================================= - Program: vv http://www.creatis.insa-lyon.fr/rio/vv - - Authors belong to: - - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://www.centreleonberard.fr - - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the copyright notices for more information. - - It is distributed under dual licence - - - BSD See included LICENSE.txt file - - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html - ===========================================================================**/ - -// vv -#include "vvToolExtractPatient.h" -#include "vvToolStructureSetManager.h" -#include "vvSlicer.h" -#include "vvImageReader.h" -#include "vvImageWriter.h" -#include "vvLabelImageLoaderWidget.h" -#include "vvThreadedFilter.h" - -// Qt -#include - -//------------------------------------------------------------------------------ -// Create the tool and automagically (I like this word) insert it in -// the main window menu. -ADD_TOOL(vvToolExtractPatient); -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -vvToolExtractPatient::vvToolExtractPatient(vvMainWindowBase * parent, Qt::WindowFlags f): - vvToolWidgetBase(parent,f), - vvToolBase(parent), - Ui::vvToolExtractPatient() -{ - // GUI - Ui_vvToolExtractPatient::setupUi(mToolWidget); - mOptionsBox->setEnabled(true); - //connect(mPatientMaskInputWidget, SIGNAL(accepted()), this, SLOT(PatientMaskInputIsSelected())); - - // Default values - mArgsInfo = new ArgsInfoType; - cmdline_parser_clitkExtractPatient_init(mArgsInfo); - SetGUIFromArgsInfo(); - m_IsThreadInterrupted = false; - - // Create a new ExtractPatient filter - mFilter = new FilterType; // used in AddInputSelector - - // Add input selector - AddInputSelector("Select CT thorax image", mFilter); -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -vvToolExtractPatient::~vvToolExtractPatient() -{ -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolExtractPatient::Initialize() { - SetToolName("ExtractPatient"); - SetToolMenuName("Extract Patient"); - SetToolIconFilename(":/common/icons/Patient-overlay.png"); - SetToolTip("Extract Patient mask from thorax CT."); - SetToolExperimental(true); - // SetToolInMenu("Segmentation"); -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolExtractPatient::InputIsSelected(vvSlicerManager *m) -{ - // Hide selector - HideInputSelector(); // splitter - mToolInputSelectionWidget->hide(); - mCurrentSlicerManager = m; - mCurrentImage = m->GetImage(); - mLabelInput->setText(m->GetFileName().c_str()); -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -// void vvToolExtractPatient::PatientMaskInputIsSelected() -// { -// // Get Patient mask and BG value -// mPatient = mPatientMaskInputWidget->GetImage(); -// mPatientBackgroundValue = mPatientMaskInputWidget->GetBackgroundValue(); - -// // Check patient dimension -// if (mPatient->GetNumberOfDimensions() != 3) { -// QMessageBox::information(this,tr("*Error*"), "Mask image must be 3D"); -// return; -// } - -// mMaskLoaderBox->setEnabled(false); -// mOptionsBox->setEnabled(true); -// } -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolExtractPatient::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); - */ - -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolExtractPatient::GetArgsInfoFromGUI() -{ - //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; -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolExtractPatient::apply() -{ - // Change cursor to wait - QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); - - // 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; - DD("new filter"); - mFilter = new FilterType; // needed when thread cancel the filter - // mFilter->StopOnErrorOff(); - // mFilter->SetIOVerbose(true); - mFilter->AddInputVVImage(mCurrentImage); // CT -// mFilter->AddInputVVImage(mPatient); // patient mask - mFilter->SetArgsInfo(*mArgsInfo); - - // Created threaded execution - DD("thread"); - vvThreadedFilter thread; - connect(&thread, SIGNAL(ThreadInterrupted()), this, SLOT(ThreadInterrupted())); - thread.SetFilter(mFilter); - - try { - thread.Update(); - } - catch(std::runtime_error e) { - - // Check if the thread has been canceled. In this case, return - if (m_IsThreadInterrupted) { - m_IsThreadInterrupted = false; - QApplication::restoreOverrideCursor(); - return; - } - disconnect(&thread, SIGNAL(ThreadInterrupted()), this, SLOT(ThreadInterrupted())); - - // Check error during filter - // if (mFilter->HasError()) { - QApplication::restoreOverrideCursor(); - QMessageBox::information(this,tr("Error"), e.what());//mFilter->GetLastError().c_str()); - return; - // } - - } - - // Get output - std::vector output = mFilter->GetOutputVVImages(); - if (output.size() == 0) { - std::cerr << "Error : no output ?" << std::endl; - QApplication::restoreOverrideCursor(); - close(); - return; - } - - // Set Patient into VV - vvImage::Pointer Patient = output[0]; - std::ostringstream osstream; - osstream << "Patient_" << mCurrentSlicerManager->GetSlicer(0)->GetFileName() << ".mhd"; - vvSlicerManager * v = AddImage(Patient,osstream.str()); - v->SetPreset(5); - vvToolStructureSetManager::AddImage(mCurrentSlicerManager, "Right Patient", Patient, 1, false); // Right is greater than Left -// vvToolStructureSetManager::AddImage(mCurrentSlicerManager, "Left Patient", Patient, 2, false); - - // // Set trachea into VV -// if (output.size() == 2) { -// vvImage::Pointer trachea = output[1]; -// std::ostringstream osstream; -// osstream << "Trachea_" << mCurrentSlicerManager->GetSlicer(0)->GetFileName() << ".mhd"; -// vvSlicerManager * v = AddImage(trachea,osstream.str()); -// v->SetPreset(5); -// vvToolStructureSetManager::AddImage(mCurrentSlicerManager, "Trachea", trachea, 0); -// } - - // End - QApplication::restoreOverrideCursor(); - close(); -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -bool vvToolExtractPatient::close() -{ - return vvToolWidgetBase::close(); -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolExtractPatient::ThreadInterrupted() -{ - m_IsThreadInterrupted = true; -} -//------------------------------------------------------------------------------ - diff --git a/vv/vvToolExtractPatient.h b/vv/vvToolExtractPatient.h deleted file mode 100644 index b355d97..0000000 --- a/vv/vvToolExtractPatient.h +++ /dev/null @@ -1,73 +0,0 @@ -/*========================================================================= - Program: vv http://www.creatis.insa-lyon.fr/rio/vv - - Authors belong to: - - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://www.centreleonberard.fr - - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the copyright notices for more information. - - It is distributed under dual licence - - - BSD See included LICENSE.txt file - - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -===========================================================================**/ - -#ifndef VVTOOLEXTRACTPATIENT_H -#define VVTOOLEXTRACTPATIENT_H - -// clitk -#include "clitkExtractPatientGenericFilter.h" -#include "../segmentation/clitkExtractPatient_ggo.h" - -// vv -#include "ui_vvToolExtractPatient.h" -#include "vvToolBase.h" -#include "vvToolWidgetBase.h" -#include "vvROIActor.h" - -// qt -#include - -//------------------------------------------------------------------------------ -class vvToolExtractPatient: - public vvToolWidgetBase, - public vvToolBase, - private Ui::vvToolExtractPatient -{ - Q_OBJECT - public: - vvToolExtractPatient(vvMainWindowBase* parent=0, Qt::WindowFlags f=0); - ~vvToolExtractPatient(); - - //----------------------------------------------------- - static void Initialize(); - virtual void InputIsSelected(vvSlicerManager *m); - void GetArgsInfoFromGUI(); - void SetGUIFromArgsInfo(); - - //----------------------------------------------------- -public slots: - virtual void apply(); - virtual bool close(); - // void PatientMaskInputIsSelected(); - void ThreadInterrupted(); - - //----------------------------------------------------- -protected: - typedef args_info_clitkExtractPatient ArgsInfoType; - ArgsInfoType * mArgsInfo; - typedef clitk::ExtractPatientGenericFilter FilterType; - FilterType * mFilter; - vvImage::Pointer mPatient; - double mPatientBackgroundValue; - bool m_IsThreadInterrupted; - -}; // end class vvToolExtractPatient -//------------------------------------------------------------------------------ - -#endif -