--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>vvToolExtractLung</class>
+ <widget class="QWidget" name="vvToolExtractLung">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>412</width>
+ <height>384</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="mLabelInput">
+ <property name="font">
+ <font>
+ <pointsize>11</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="text">
+ <string>No selected image</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="mMaskLoaderBox">
+ <property name="title">
+ <string>GroupBox</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="1" column="0">
+ <widget class="vvLabelImageLoaderWidget" name="mPatientMaskInputWidget" native="true">
+ <zorder>mOptionsBox</zorder>
+ <zorder>mOptionsBox</zorder>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="mOptionsBox">
+ <property name="title">
+ <string>GroupBox</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_5">
+ <item>
+ <widget class="QCheckBox" name="mFullConnectivityCheckBox_2">
+ <property name="text">
+ <string>Resample before (faster)</string>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ <property name="tristate">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDoubleSpinBox" name="mSamplingSpinBox">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="dimensionStaticLabel_6">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>mm</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_5">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="2" column="2">
+ <widget class="vvIntensityValueSlider" name="mThresholdSlider2" native="true">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <zorder>mPatientMaskInputWidget</zorder>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Initial upper threshold for air</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="vvIntensityValueSlider" name="mThresholdSlider1" native="true"/>
+ </item>
+ <item row="2" column="1">
+ <widget class="QRadioButton" name="mRadioButtonLowerThan">
+ <property name="text">
+ <string>lower threshold for air</string>
+ </property>
+ <property name="autoExclusive">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <widget class="QLabel" name="dimensionStaticLabel_2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Min size</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="mMinSizeSpinBox">
+ <property name="maximum">
+ <number>999999</number>
+ </property>
+ <property name="value">
+ <number>100</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="mFullConnectivityCheckBox">
+ <property name="text">
+ <string>Full connectivity</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="tristate">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QLabel" name="dimensionStaticLabel_3">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Remove</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="mBackgroundValueSpinBox"/>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_4">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QLabel" name="dimensionStaticLabel_4">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>First Keep</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="mBackgroundValueSpinBox_2"/>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="dimensionStaticLabel_5">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Last Keep</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="mBackgroundValueSpinBox_3"/>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>vvIntensityValueSlider</class>
+ <extends>QWidget</extends>
+ <header>vvIntensityValueSlider.h</header>
+ <container>1</container>
+ </customwidget>
+ <customwidget>
+ <class>vvLabelImageLoaderWidget</class>
+ <extends>QWidget</extends>
+ <header>vvLabelImageLoaderWidget.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
+ <resources>
+ <include location="../vvIcons.qrc"/>
+ </resources>
+ <connections>
+ <connection>
+ <sender>mFullConnectivityCheckBox_2</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>mSamplingSpinBox</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>151</x>
+ <y>141</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>233</x>
+ <y>134</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>mFullConnectivityCheckBox_2</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>dimensionStaticLabel_6</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>73</x>
+ <y>141</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>287</x>
+ <y>143</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
--- /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://oncora1.lyon.fnclcc.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 "vvProgressDialog.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);
+ connect(mPatientMaskInputWidget, SIGNAL(accepted()), this, SLOT(PatientMaskInputIsSelected()));
+
+ // Default values
+ cmdline_parser_clitkExtractLung_init(&mArgsInfo);
+
+ // Create a new ExtractLung filter
+ mFilter = FilterType::New();
+
+ // Add input selector
+ AddInputSelector("Select 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);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolExtractLung::InputIsSelected(vvSlicerManager *m)
+{
+ DD("InputIsSelected");
+ // Hide selector
+ HideInputSelector(); // splitter
+ mToolInputSelectionWidget->hide();
+ mCurrentSlicerManager = m;
+ mCurrentImage = m->GetImage();
+ mMaskLoaderBox->setEnabled(true);
+ mLabelInput->setText(m->GetFileName().c_str());
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolExtractLung::PatientMaskInputIsSelected()
+{
+ DD("PatientMaskInputIsSelected");
+ mMaskLoaderBox->setEnabled(false);
+ mOptionsBox->setEnabled(true);
+
+ // Get Patient mask and BG value
+ mPatient = mPatientMaskInputWidget->GetImage();
+ mPatientBackgroundValue = mPatientMaskInputWidget->GetBackgroundValue();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolExtractLung::GetArgsInfoFromGUI()
+{
+ DD("GetArgsInfoFromGUI");
+ mArgsInfo.patientBG_arg = 0; //mPatientBackgroundValueSpinBox->value();
+ mArgsInfo.verboseOption_flag = true;
+ mArgsInfo.verboseStep_flag = true;
+ mArgsInfo.writeStep_flag = false;
+ mArgsInfo.input_given = 0;
+ mArgsInfo.patient_given = 0;
+ mArgsInfo.output_given = 0;
+ mArgsInfo.outputTrachea_given = 0;
+ mArgsInfo.remove1_given = 0;
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolExtractLung::apply()
+{
+ DD("apply");
+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+
+ GetArgsInfoFromGUI();
+
+ mFilter->SetIOVerbose(true);
+ mFilter->AddInputVVImage(mCurrentImage); // CT
+ mFilter->AddInputVVImage(mPatient); // patient mask
+ mFilter->SetArgsInfo(mArgsInfo);
+
+ DD("mfilter->Update");
+ // vvThreadedFilter a;
+ // a->SetFilter(mFilter)
+ // connect(a, SIGNAL(rejected()), this, SLOT(FilterHasBeenCanceled()));
+ // a->Update();
+ // if (a->HasError()) { DD(a->GetError()); return; }
+ mFilter->Update();
+
+ // Check error
+ if (mFilter->HasError()) {
+ QMessageBox::information(this,tr("*Error* while finding lung"), mFilter->GetLastError().c_str());
+ reject();
+ return;
+ }
+
+ // Get output
+ std::vector<vvImage::Pointer> output = mFilter->GetOutputVVImages();
+ DD(output.size());
+
+ // Set Lung into VV
+ DD("lung");
+ 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) {
+ DD("trachea");
+ 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();
+}
+//------------------------------------------------------------------------------
+
+
--- /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://oncora1.lyon.fnclcc.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();
+
+ //-----------------------------------------------------
+public slots:
+ virtual void apply();
+ virtual bool close();
+ void PatientMaskInputIsSelected();
+
+ //-----------------------------------------------------
+protected:
+ typedef args_info_clitkExtractLung ArgsInfoType;
+ ArgsInfoType mArgsInfo;
+ typedef clitk::ExtractLungGenericFilter<ArgsInfoType> FilterType;
+ FilterType::Pointer mFilter;
+ vvImage::Pointer mPatient;
+ double mPatientBackgroundValue;
+
+}; // end class vvToolExtractLung
+//------------------------------------------------------------------------------
+
+#endif
+