1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
19 #include "clitkImageCommon.h"
21 //--------------------------------------------------------------------
22 template<class ArgsInfoType>
23 clitk::ExtractPatientGenericFilter<ArgsInfoType>::ExtractPatientGenericFilter():
24 ImageToImageGenericFilter<Self>("ExtractPatient")
27 cmdline_parser_clitkExtractPatient_init(&mArgsInfo);
28 InitializeImageType<3>();
30 //--------------------------------------------------------------------
33 //--------------------------------------------------------------------
34 template<class ArgsInfoType>
35 template<unsigned int Dim>
36 void clitk::ExtractPatientGenericFilter<ArgsInfoType>::InitializeImageType()
38 ADD_IMAGE_TYPE(Dim, short);
39 // ADD_IMAGE_TYPE(Dim, int);
40 // ADD_IMAGE_TYPE(Dim, float);
42 //--------------------------------------------------------------------
45 //--------------------------------------------------------------------
46 template<class ArgsInfoType>
47 void clitk::ExtractPatientGenericFilter<ArgsInfoType>::SetArgsInfo(const ArgsInfoType & a)
50 SetIOVerbose(mArgsInfo.verbose_flag);
51 if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes();
52 if (mArgsInfo.input_given) SetInputFilename(mArgsInfo.input_arg);
53 if (mArgsInfo.output_given) AddOutputFilename(mArgsInfo.output_arg);
55 //--------------------------------------------------------------------
58 //--------------------------------------------------------------------
59 template<class ArgsInfoType>
60 template<class FilterType>
62 clitk::ExtractPatientGenericFilter<ArgsInfoType>::
63 SetOptionsFromArgsInfoToFilter(FilterType * f)
65 f->SetVerboseOptionFlag(mArgsInfo.verbose_flag);
66 f->SetVerboseStepFlag(mArgsInfo.verboseStep_flag);
67 f->SetWriteStepFlag(mArgsInfo.writeStep_flag);
68 f->SetVerboseWarningFlag(!mArgsInfo.verboseWarningOff_flag);
69 f->SetVerboseMemoryFlag(mArgsInfo.verboseMemory_flag);
71 if (mArgsInfo.afdb_given)
72 f->SetAFDBFilename(mArgsInfo.afdb_arg);
74 f->SetOutputPatientFilename(mArgsInfo.output_arg);
76 f->SetUpperThreshold(mArgsInfo.upper_arg);
77 f->SetLowerThreshold(mArgsInfo.lower_arg);
79 f->SetDecomposeAndReconstructDuringFirstStep(mArgsInfo.erode1_flag);
81 // Convert to SizeType
82 typename FilterType::InputImageSizeType s;
83 if (mArgsInfo.radius1_given) {
84 ConvertOptionMacro(mArgsInfo.radius1, s, 3, false);
88 f->SetMaximumNumberOfLabels1(mArgsInfo.max1_arg);
89 f->SetNumberOfNewLabels1(mArgsInfo.new1_arg);
91 f->SetDecomposeAndReconstructDuringSecondStep(mArgsInfo.erode2_flag);
93 // Convert to SizeType
94 if (mArgsInfo.radius2_given) {
95 ConvertOptionMacro(mArgsInfo.radius2, s, 3, false);
99 f->SetMaximumNumberOfLabels2(mArgsInfo.max2_arg);
100 f->SetNumberOfNewLabels2(mArgsInfo.new2_arg);
102 f->SetFirstKeep(mArgsInfo.firstKeep_arg);
103 f->SetLastKeep(mArgsInfo.lastKeep_arg);
105 f->SetFinalOpenClose(mArgsInfo.openClose_flag);
106 f->SetAutoCrop(!mArgsInfo.noAutoCrop_flag);
108 //--------------------------------------------------------------------
111 //--------------------------------------------------------------------
112 // Update with the number of dimensions and the pixeltype
113 //--------------------------------------------------------------------
114 template<class ArgsInfoType>
115 template<class ImageType>
116 void clitk::ExtractPatientGenericFilter<ArgsInfoType>::UpdateWithInputImageType()
119 typedef itk::Image<uchar, ImageType::ImageDimension> OutputImageType;
122 typename ImageType::Pointer input = this->template GetInput<ImageType>(0);
125 typedef clitk::ExtractPatientFilter<ImageType> FilterType;
126 typename FilterType::Pointer filter = FilterType::New();
128 // Set the filter (needed for example for threaded monitoring)
129 this->SetFilterBase(filter);
131 // Set global Options
132 filter->SetInput(input);
133 SetOptionsFromArgsInfoToFilter<FilterType>(filter);
138 // Write/Save results
139 typename OutputImageType::Pointer output = filter->GetOutput();
140 this->template SetNextOutput<OutputImageType>(output);
142 //--------------------------------------------------------------------