WRAP_GGO(clitkMIP_GGO_C clitkMIP.ggo)
ADD_EXECUTABLE(clitkMIP clitkMIP.cxx clitkMIPGenericFilter.cxx ${clitkMIP_GGO_C})
TARGET_LINK_LIBRARIES(clitkMIP clitkCommon ITKIO)
+
+ WRAP_GGO(clitkRelativePosition_GGO_C clitkRelativePosition.ggo)
+ ADD_EXECUTABLE(clitkRelativePosition clitkRelativePosition.cxx ${clitkRelativePosition_GGO_C})
+ TARGET_LINK_LIBRARIES(clitkRelativePosition clitkCommon ITKIO)
+
ENDIF(CLITK_BUILD_TOOLS)
--- /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
+======================================================================-====*/
+
+// clitk
+#include "clitkRelativePosition_ggo.h"
+#include "clitkRelativePositionGenericFilter.h"
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[]) {
+
+ // Init command line
+ GGO(clitkRelativePosition, args_info);
+ CLITK_INIT;
+
+ // Filter
+ typedef clitk::RelativePositionGenericFilter<args_info_clitkRelativePosition> FilterType;
+ FilterType::Pointer filter = FilterType::New();
+
+ filter->SetArgsInfo(args_info);
+
+ try {
+ filter->Update();
+ } catch(std::runtime_error e) {
+ std::cout << e.what() << std::endl;
+ }
+
+ return EXIT_SUCCESS;
+} // This is the end, my friend
+//--------------------------------------------------------------------
--- /dev/null
+#File clitkRelativePosition.ggo
+package "clitkRelativePosition"
+version "1.0"
+purpose "Constraint a given mask image relatively to another object and an orientation"
+
+section "General options"
+option "config" - "Config file" string no
+option "verbose" v "Verbose" flag off
+option "verboseStep" - "Verbose each step" flag off
+option "writeStep" w "Write image at each step" flag off
+option "verboseOption" - "Display options values" flag off
+option "imagetypes" - "Display allowed image types" flag off
+
+section "Input/Output"
+option "input" i "Input mask image filename" string yes
+option "object" j "Input mask object filename" string yes
+option "output" o "Output image filename" string yes
+
+section "Main options"
+option "orientation" r "L R A P I S (LeftRightAntPostInfSup)" string no default="L"
+option "angle1" a "Angle 1 (deg)" double no default="0"
+option "angle2" b "Angle 2 (deg)" double no default="0"
+option "spacing" s "Resample before (faster)" double no
+option "threshold" t "Fuzzy threshold" double no default="0.6"
+option "not" n "Not flag : inverse of the orientation" flag off
+option "noAutoCrop" c "No auto crop at the end if set" flag off
+
+section "Slice by slice processing"
+option "sliceBySlice" - "Slice by slice relative position" flag off
+option "direction" d "If SbS, indicate the slice direction" int no default="2"
+
+
+
+
+
--- /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 CLITKEXTRACTPATIENTGENERICFILTER_H
+#define CLITKEXTRACTPATIENTGENERICFILTER_H
+
+// clitk
+#include "clitkIO.h"
+#include "clitkImageToImageGenericFilter.h"
+#include "clitkAddRelativePositionConstraintToLabelImageFilter.h"
+#include "clitkSliceBySliceRelativePositionFilter.h"
+
+//--------------------------------------------------------------------
+namespace clitk
+{
+
+ template<class ArgsInfoType>
+ class ITK_EXPORT RelativePositionGenericFilter:
+ public ImageToImageGenericFilter<RelativePositionGenericFilter<ArgsInfoType> >
+ {
+ public:
+ //--------------------------------------------------------------------
+ RelativePositionGenericFilter();
+
+ //--------------------------------------------------------------------
+ typedef ImageToImageGenericFilter<RelativePositionGenericFilter<ArgsInfoType> > Superclass;
+ typedef RelativePositionGenericFilter Self;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ //--------------------------------------------------------------------
+ itkNewMacro(Self);
+ itkTypeMacro(RelativePositionGenericFilter, LightObject);
+
+ //--------------------------------------------------------------------
+ void SetArgsInfo(const ArgsInfoType & a);
+ template<class FilterType>
+ void SetOptionsFromArgsInfoToFilter(FilterType * f) ;
+
+ //--------------------------------------------------------------------
+ // Main function called each time the filter is updated
+ template<class ImageType>
+ void UpdateWithInputImageType();
+
+ protected:
+ template<unsigned int Dim> void InitializeImageType();
+ ArgsInfoType mArgsInfo;
+
+ private:
+ RelativePositionGenericFilter(const Self&); //purposely not implemented
+ void operator=(const Self&); //purposely not implemented
+
+ };// end class
+ //--------------------------------------------------------------------
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkRelativePositionGenericFilter.txx"
+#endif
+
+#endif // #define CLITKEXTRACTPATIENTGENERICFILTER_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://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
+ ======================================================================-====*/
+
+#include "clitkImageCommon.h"
+
+//--------------------------------------------------------------------
+template<class ArgsInfoType>
+clitk::RelativePositionGenericFilter<ArgsInfoType>::
+RelativePositionGenericFilter():
+ ImageToImageGenericFilter<Self>("RelativePosition")
+{
+ // Default values
+ cmdline_parser_clitkRelativePosition_init(&mArgsInfo);
+ InitializeImageType<3>();
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<class ArgsInfoType>
+template<unsigned int Dim>
+void clitk::RelativePositionGenericFilter<ArgsInfoType>::
+InitializeImageType()
+{
+ ADD_IMAGE_TYPE(Dim, uchar);
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<class ArgsInfoType>
+void clitk::RelativePositionGenericFilter<ArgsInfoType>::
+SetArgsInfo(const ArgsInfoType & a)
+{
+ mArgsInfo=a;
+ SetIOVerbose(mArgsInfo.verbose_flag);
+ if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes();
+ if (mArgsInfo.input_given) AddInputFilename(mArgsInfo.input_arg);
+ if (mArgsInfo.object_given) AddInputFilename(mArgsInfo.object_arg);
+ if (mArgsInfo.output_given) AddOutputFilename(mArgsInfo.output_arg);
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+// Update with the number of dimensions and the pixeltype
+//--------------------------------------------------------------------
+template<class ArgsInfoType>
+template<class FilterType>
+void clitk::RelativePositionGenericFilter<ArgsInfoType>::
+SetOptionsFromArgsInfoToFilter(FilterType * f)
+{
+ f->SetVerboseOption(mArgsInfo.verbose_flag);
+ f->SetVerboseStep(mArgsInfo.verboseStep_flag);
+ f->SetWriteStep(mArgsInfo.writeStep_flag);
+
+ if (mArgsInfo.orientation_given) {
+ f->SetOrientationTypeString(mArgsInfo.orientation_arg);
+ }
+
+ if (mArgsInfo.spacing_given) {
+ f->ResampleBeforeRelativePositionFilterOn();
+ f->SetIntermediateSpacing(mArgsInfo.spacing_arg);
+ }
+
+ f->SetFuzzyThreshold(mArgsInfo.threshold_arg);
+ f->SetNotFlag(mArgsInfo.not_flag);
+ f->SetAutoCropFlag(!mArgsInfo.noAutoCrop_flag);
+}
+
+//--------------------------------------------------------------------
+// Update with the number of dimensions and the pixeltype
+//--------------------------------------------------------------------
+template<class ArgsInfoType>
+template<class ImageType>
+void clitk::RelativePositionGenericFilter<ArgsInfoType>::
+UpdateWithInputImageType()
+{
+ // Reading input
+ typename ImageType::Pointer input = this->template GetInput<ImageType>(0);
+ typename ImageType::Pointer object = this->template GetInput<ImageType>(1);
+
+ if (mArgsInfo.sliceBySlice_flag) {
+ // Create filter
+ typedef clitk::SliceBySliceRelativePositionFilter<ImageType> FilterType;
+ typename FilterType::Pointer filter = FilterType::New();
+
+ // Set the filter (needed for example for threaded monitoring)
+ this->SetFilterBase(filter);
+
+ // Set global Options
+ filter->SetInput(input);
+ filter->SetInputObject(object);
+ SetOptionsFromArgsInfoToFilter<FilterType>(filter);
+ filter->SetDirection(mArgsInfo.direction_arg); // only for SliceBySliceRelativePositionFilter
+
+ // Go !
+ filter->Update();
+
+ // Write/Save results
+ typename ImageType::Pointer output = filter->GetOutput();
+ this->template SetNextOutput<ImageType>(output);
+ }
+ else {
+ // Create filter
+ typedef clitk::AddRelativePositionConstraintToLabelImageFilter<ImageType> FilterType;
+ typename FilterType::Pointer filter = FilterType::New();
+
+ // Set the filter (needed for example for threaded monitoring)
+ this->SetFilterBase(filter);
+
+ // Set global Options
+ filter->SetInput(input);
+ filter->SetInputObject(object);
+ filter->SetAngle1(mArgsInfo.angle1_arg);// only for this filter
+ filter->SetAngle2(mArgsInfo.angle2_arg);
+ SetOptionsFromArgsInfoToFilter<FilterType>(filter);
+
+ // Go !
+ filter->Update();
+
+ // Write/Save results
+ typename ImageType::Pointer output = filter->GetOutput();
+ this->template SetNextOutput<ImageType>(output);
+ }
+}
+//--------------------------------------------------------------------
+
+