From: schaerer Date: Tue, 26 Oct 2010 12:37:54 +0000 (+0000) Subject: MIP tool using David's framework X-Git-Tag: v1.2.0~305 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=b7fc1156967b4af59750b0f2023e4ec7781b723b;p=clitk.git MIP tool using David's framework --- diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index ce3d09e..ce1d706 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -3,7 +3,8 @@ INCLUDE(${PROJECT_SOURCE_DIR}/cmake/common.cmake) #========================================================= #Add your ggo files to this list if they are used by vv FOREACH(clitkTool clitkAffineTransform clitkBinarizeImage clitkImageArithm - clitkMedianImageFilter clitkImageConvert clitkImageResample clitkCropImage) + clitkMedianImageFilter clitkImageConvert clitkImageResample clitkCropImage + clitkMIP) WRAP_GGO(${clitkTool}_GGO_C ${clitkTool}.ggo) SET(GGO_C_FILES ${GGO_C_FILES} ${${clitkTool}_GGO_C}) ENDFOREACH(clitkTool) @@ -16,6 +17,7 @@ ADD_LIBRARY(clitkImageConvertLib clitkImageConvertGenericFilter.cxx) ADD_LIBRARY(clitkImageResampleLib clitkImageResampleGenericFilter.cxx) ADD_LIBRARY(clitkBinarizeImageLib clitkBinarizeImageGenericFilter.cxx) ADD_LIBRARY(clitkImageArithmImageLib clitkImageArithmGenericFilter.cxx) +ADD_LIBRARY(clitkMIPLib clitkMIPGenericFilter.cxx) TARGET_LINK_LIBRARIES(clitkBinarizeImageLib clitkToolsGgoLib) diff --git a/tools/clitkBinarizeImageGenericFilter.cxx b/tools/clitkBinarizeImageGenericFilter.cxx index c5cb445..005a534 100644 --- a/tools/clitkBinarizeImageGenericFilter.cxx +++ b/tools/clitkBinarizeImageGenericFilter.cxx @@ -63,8 +63,10 @@ void BinarizeImageGenericFilter::InitializeImageType() void BinarizeImageGenericFilter::SetArgsInfo(const args_info_type & a) { mArgsInfo=a; - SetIOVerbose(mArgsInfo.verbose_flag); - if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes(); + if (mArgsInfo.verbose_given) + SetIOVerbose(mArgsInfo.verbose_flag); + if (mArgsInfo.imagetypes_given && mArgsInfo.imagetypes_flag) + this->PrintAvailableImageTypes(); if (mArgsInfo.input_given) { SetInputFilename(mArgsInfo.input_arg); diff --git a/tools/clitkMIPGenericFilter.cxx b/tools/clitkMIPGenericFilter.cxx index 1cfd41b..fcb4cfb 100644 --- a/tools/clitkMIPGenericFilter.cxx +++ b/tools/clitkMIPGenericFilter.cxx @@ -62,8 +62,8 @@ void MIPGenericFilter::SetArgsInfo(const args_info_type & a) { mArgsInfo=a; SetIOVerbose(mArgsInfo.verbose_flag); - if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes(); - + if (mArgsInfo.imagetypes_given && mArgsInfo.imagetypes_flag) + this->PrintAvailableImageTypes(); if (mArgsInfo.input_given) { SetInputFilename(mArgsInfo.input_arg); } diff --git a/vv/CMakeLists.txt b/vv/CMakeLists.txt index b140869..39a5e0a 100644 --- a/vv/CMakeLists.txt +++ b/vv/CMakeLists.txt @@ -18,6 +18,7 @@ SET(vv_TOOLS vvToolResample vvToolExtractPatient vvToolExtractLung + vvToolMIP vvToolConvert ## with dummy vvToolConvert.ui ## these ones are for tests (not working) @@ -28,6 +29,7 @@ SET(vv_TOOLS ) # dependencies of the tools # Future issues : when tool depend on other tools ... how to manage that ? +# >> add the relevant $_LIBS variable to the tool that has dependencies? SET(vvToolRigidReg_LIBS clitkAffineRegistrationLib clitkRegistrationGgoLib) SET(vvToolBinarize_LIBS clitkBinarizeImageLib) SET(vvToolResample_LIBS clitkImageResampleLib) @@ -35,6 +37,7 @@ SET(vvToolConvert_LIBS clitkImageConvertLib) SET(vvToolExtractPatient_LIBS clitkSegmentationGgoLib) SET(vvToolExtractLung_LIBS clitkSegmentationGgoLib) SET(vvToolCropImage_LIBS clitkToolsGgoLib) +SET(vvToolMIP_LIBS clitkMIPLib clitkToolsGgoLib) #========================================================= # List of vv source files diff --git a/vv/qt_ui/vvToolMIP.ui b/vv/qt_ui/vvToolMIP.ui new file mode 100644 index 0000000..10cb99c --- /dev/null +++ b/vv/qt_ui/vvToolMIP.ui @@ -0,0 +1,31 @@ + + + vvToolMIP + + + + 0 + 0 + 319 + 86 + + + + Form + + + + + + Projection Dimension + + + + + + + + + + + diff --git a/vv/vvToolMIP.cxx b/vv/vvToolMIP.cxx new file mode 100644 index 0000000..970ad35 --- /dev/null +++ b/vv/vvToolMIP.cxx @@ -0,0 +1,104 @@ +/*========================================================================= + + Program: vv + Module: $RCSfile: vvToolMIP.cxx,v $ + Language: C++ + Date: $Date: 2010/10/26 12:37:58 $ + Version: $Revision: 1.1 $ + Author : Bharath Navalpakkam (Bharath.Navalpakkam@creatis.insa-lyon.fr) + + Copyright (C) 2010 + Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + CREATIS http://www.creatis.insa-lyon.fr + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, version 3 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + =========================================================================*/ + +#include +#include +#include +#include + +#include "vvToolMIP.h" +#include "vvSlicerManager.h" +#include "vvSlicer.h" +#include "vvToolInputSelectorWidget.h" +#include "clitkMIPGenericFilter.h" + +//------------------------------------------------------------------------------ +// Create the tool and automagically +ADD_TOOL(vvToolMIP); +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +vvToolMIP::vvToolMIP(vvMainWindowBase * parent, Qt::WindowFlags f) + :vvToolWidgetBase(parent,f), + vvToolBase(parent), + Ui::vvToolMIP() +{ + // Setup the UI + Ui_vvToolMIP::setupUi(mToolWidget); + //mFilter=clitk::MIPGenericFilter::New(); //Causes a segfault. Why? (joel 26/10/2010) + mFilter=new clitk::MIPGenericFilter; + + // Main filter + // Set how many inputs are needed for this tool + //AddInputSelector("Select one image", mFilter); + AddInputSelector("Select one image"); +} + +//------------------------------------------------------------------------------ +vvToolMIP::~vvToolMIP() +{ + delete mFilter; +} +//------------------------------------------------------------------------------ +void vvToolMIP::Initialize() +{ + SetToolName("MIP"); + SetToolMenuName("Maximum Intensity Projection"); + SetToolIconFilename(":common/icons/ducky.png"); + SetToolTip("Compute the maximum intensity projection of an image."); + SetToolExperimental(true); +} +//------------------------------------------------------------------------------ + +void vvToolMIP::apply() +{ + if (!mCurrentSlicerManager) close(); + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + // Main filter + clitk::MIPGenericFilter::args_info_type args_info; + cmdline_parser_clitkMIP_init(&args_info); + args_info.dimension_arg=this->dimensionSpinBox->value(); + args_info.dimension_given=true; + clitk::MIPGenericFilter* filter= dynamic_cast(mFilter); + filter->SetArgsInfo(args_info); + filter->SetInputVVImage(mCurrentImage); + filter->Update(); + vvImage::Pointer output = filter->GetOutputVVImage(); + std::ostringstream osstream; + osstream << "MIPed_" << mCurrentSlicerManager->GetSlicer(0)->GetFileName() << ".mhd"; + AddImage(output,osstream.str()); + QApplication::restoreOverrideCursor(); + close(); +} +//------------------------------------------------------------------------------ +void vvToolMIP::InputIsSelected(vvSlicerManager *m) +{ + mCurrentSlicerManager =m; + this->dimensionSpinBox->setMaximum(m->GetDimension()-1); +} + +//----------------------------------------------------------------------------- diff --git a/vv/vvToolMIP.h b/vv/vvToolMIP.h new file mode 100644 index 0000000..1689880 --- /dev/null +++ b/vv/vvToolMIP.h @@ -0,0 +1,65 @@ +/*========================================================================= + +Program: vv +Module: $RCSfile: vvToolMIP.h,v $ +Language: C++ +Date: $Date: 2010/10/26 12:37:59 $ +Version: $Revision: 1.1 $ +Author : Joel Schaerer (joel.schaerer@gmail.com) + +Copyright (C) 2010 +Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr +CREATIS http://www.creatis.insa-lyon.fr + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, version 3 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +=========================================================================*/ + +#ifndef VVTOOLMIP_H +#define VVTOOLMIP_H + +#include + +#include +#include "vvToolBase.h" +#include "QWidget" +#include "vvToolWidgetBase.h" +#include "ui_vvToolMIP.h" + + +//------------------------------------------------------------------------------ +class vvToolMIP: + public vvToolWidgetBase, + public vvToolBase, + private Ui::vvToolMIP +{ + Q_OBJECT + public: + vvToolMIP(vvMainWindowBase* parent=0, Qt::WindowFlags f=0); + ~vvToolMIP(); + + static void Initialize(); + virtual void InputIsSelected(vvSlicerManager * m); + virtual void apply(); + protected: + + template void Update_WithDimAndPixelType(vvImage::Pointer); + template void Update_WithPixelType(vvImage::Pointer); + + Ui::vvToolMIP ui; + +}; // end class vvToolMIP +//------------------------------------------------------------------------------ + +#endif +