vvMeshActor.cxx
vvMeshReader.cxx
vvMidPosition.cxx
- vvImageMapToWLColors.cxx
- vvThreadedFilter.cxx
vvImageContour.cxx
vvBinaryImageOverlayActor.cxx
vvStructureSetActor.cxx
vvHelpDialog.h
vvQDicomSeriesSelector.h
vvSlicerManager.h
- vvThreadedFilter.h
vvStructureSetActor.h
vvROIActor.h
vvToolCreatorBase.h
+++ /dev/null
-/*=========================================================================
- 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 <vtkObjectFactory.h>
-
-vtkStandardNewMacro(vvImageMapToWLColors);
-
-vvImageMapToWLColors::vvImageMapToWLColors() :
- wl_mode(false)
-{}
-
-template <class T>
-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<T>(f_lower);
- adjustedLower = f_lower;
- } else {
- lower = static_cast<T>(range[0]);
- adjustedLower = range[0];
- }
- } else {
- lower = static_cast<T>(range[1]);
- adjustedLower = range[1];
- }
-
- // Set the correct upper value
- if ( f_upper >= range[0]) {
- if (f_upper <= range[1]) {
- upper = static_cast<T>(f_upper);
- adjustedUpper = f_upper;
- } else {
- upper = static_cast<T>(range[1]);
- adjustedUpper = range[1];
- }
- } else {
- upper = static_cast<T>(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<unsigned char>(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<unsigned char>(f_lower_val);
- }
-}
-
-template <class T>
-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<unsigned long>(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<unsigned char *>(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<unsigned char>((*iptr + shift)*scale);
- }
- *optr = static_cast<unsigned char>((*optr * ushort_val) >> 8);
- switch (outputFormat) {
- case VTK_RGBA:
- *(optr+1) = static_cast<unsigned char>(
- (*(optr+1) * ushort_val) >> 8);
- *(optr+2) = static_cast<unsigned char>(
- (*(optr+2) * ushort_val) >> 8);
- *(optr+3) = 255;
- break;
- case VTK_RGB:
- *(optr+1) = static_cast<unsigned char>(
- (*(optr+1) * ushort_val) >> 8);
- *(optr+2) = static_cast<unsigned char>(
- (*(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<unsigned char>((*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<VTK_TT *>(inPtr),
- outData[0],
- static_cast<unsigned char *>(outPtr),
- outExt,
- id,wl_mode));
- default:
- vtkErrorMacro(<< "Execute: Unknown ScalarType");
- return;
- }
-}
-
-
+++ /dev/null
-/*=========================================================================
- 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 <vtkImageMapToWindowLevelColors.h>
-
-//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
#include "vvSlicerManagerCommand.h"
#include "vvGlyphSource.h"
#include "vvGlyph2D.h"
-#include "vvImageMapToWLColors.h"
#include <vtkTextProperty.h>
#include <vtkTextActor.h>
this->GetRenderer()->AddActor(legend);
showFusionLegend = false;
- this->WindowLevel->Delete();
- this->WindowLevel = vvImageMapToWLColors::New();
-
this->InstallPipeline();
mLinkOverlayWindowLevel = true;
#include "vvInteractorStyleNavigator.h"
#include "vvLandmarks.h"
#include "vvMesh.h"
-#include "vvImageMapToWLColors.h"
#include "vvBlendImageActor.h"
#include <vtkImageActor.h>
invLUT->SetSaturationRange(1,1);
invLUT->SetHueRange(double((mOverlayColor+180)%360)/360,double((mOverlayColor+180)%360)/360);
invLUT->Build();
- dynamic_cast<vvImageMapToWLColors*>(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<vvImageMapToWLColors*>(mSlicers[i]->GetWindowLevel())
- //->SetWindowLevelMode(false);
mSlicers[i]->GetWindowLevel()->SetLookupTable(LUT);
} else {
mSlicers[i]->GetWindowLevel()->SetLookupTable(LUT);
+++ /dev/null
-/*=========================================================================
- 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 <QMessageBox>
-
-//------------------------------------------------------------------------------
-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();
- }
-}
-//------------------------------------------------------------------------------
-
-
-
-
+++ /dev/null
-/*=========================================================================
- 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 <QThread>
-
-//------------------------------------------------------------------------------
-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
-
+++ /dev/null
-/*=========================================================================
- 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 <QMessageBox>
-
-//------------------------------------------------------------------------------
-// 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<vvToolExtractLung>(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<vvImage::Pointer> 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;
-}
-//------------------------------------------------------------------------------
-
+++ /dev/null
-/*=========================================================================
- 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 <QtDesigner/QDesignerExportWidget>
-
-//------------------------------------------------------------------------------
-class vvToolExtractLung:
- public vvToolWidgetBase,
- public vvToolBase<vvToolExtractLung>,
- 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<ArgsInfoType> FilterType;
- FilterType * mFilter;
- vvImage::Pointer mPatient;
- double mPatientBackgroundValue;
- bool m_IsThreadInterrupted;
-
-}; // end class vvToolExtractLung
-//------------------------------------------------------------------------------
-
-#endif
-
+++ /dev/null
-/*=========================================================================
- 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 <QMessageBox>
-
-//------------------------------------------------------------------------------
-// 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<vvToolExtractPatient>(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<vvImage::Pointer> 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;
-}
-//------------------------------------------------------------------------------
-
+++ /dev/null
-/*=========================================================================
- 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 <QtDesigner/QDesignerExportWidget>
-
-//------------------------------------------------------------------------------
-class vvToolExtractPatient:
- public vvToolWidgetBase,
- public vvToolBase<vvToolExtractPatient>,
- 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<ArgsInfoType> FilterType;
- FilterType * mFilter;
- vvImage::Pointer mPatient;
- double mPatientBackgroundValue;
- bool m_IsThreadInterrupted;
-
-}; // end class vvToolExtractPatient
-//------------------------------------------------------------------------------
-
-#endif
-