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, unsigned short);
40 ADD_IMAGE_TYPE(Dim, float);
41 // ADD_IMAGE_TYPE(Dim, int);
42 // ADD_IMAGE_TYPE(Dim, float);
44 //--------------------------------------------------------------------
47 //--------------------------------------------------------------------
48 template<class ArgsInfoType>
49 void clitk::ExtractPatientGenericFilter<ArgsInfoType>::SetArgsInfo(const ArgsInfoType & a)
52 this->SetIOVerbose(mArgsInfo.verbose_flag);
53 if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes();
54 if (mArgsInfo.input_given) this->SetInputFilename(mArgsInfo.input_arg);
55 if (mArgsInfo.output_given) this->AddOutputFilename(mArgsInfo.output_arg);
57 //--------------------------------------------------------------------
60 //--------------------------------------------------------------------
61 template<class ArgsInfoType>
62 template<class FilterType>
64 clitk::ExtractPatientGenericFilter<ArgsInfoType>::
65 SetOptionsFromArgsInfoToFilter(FilterType * f)
67 f->SetVerboseOptionFlag(mArgsInfo.verbose_flag);
68 f->SetVerboseStepFlag(mArgsInfo.verboseStep_flag);
69 f->SetWriteStepFlag(mArgsInfo.writeStep_flag);
70 f->SetVerboseWarningFlag(!mArgsInfo.verboseWarningOff_flag);
71 f->SetVerboseMemoryFlag(mArgsInfo.verboseMemory_flag);
73 if (mArgsInfo.afdb_given)
74 f->SetAFDBFilename(mArgsInfo.afdb_arg);
76 f->SetOutputPatientFilename(mArgsInfo.output_arg);
78 f->SetUpperThreshold(mArgsInfo.upper_arg);
79 f->SetLowerThreshold(mArgsInfo.lower_arg);
80 f->SetPrimaryOpeningRadius(mArgsInfo.openingRadius_arg);
82 f->SetDecomposeAndReconstructDuringFirstStep(mArgsInfo.erode1_flag);
84 // Convert to SizeType
85 typename FilterType::InputImageSizeType s;
86 if (mArgsInfo.radius1_given) {
87 ConvertOptionMacro(mArgsInfo.radius1, s, 3, false);
91 f->SetMaximumNumberOfLabels1(mArgsInfo.max1_arg);
92 f->SetNumberOfNewLabels1(mArgsInfo.new1_arg);
94 f->SetDecomposeAndReconstructDuringSecondStep(mArgsInfo.erode2_flag);
96 // Convert to SizeType
97 if (mArgsInfo.radius2_given) {
98 ConvertOptionMacro(mArgsInfo.radius2, s, 3, false);
102 f->SetMaximumNumberOfLabels2(mArgsInfo.max2_arg);
103 f->SetNumberOfNewLabels2(mArgsInfo.new2_arg);
105 f->SetFirstKeep(mArgsInfo.firstKeep_arg);
106 f->SetLastKeep(mArgsInfo.lastKeep_arg);
108 f->SetFinalOpenClose(mArgsInfo.openClose_flag);
109 f->SetAutoCrop(!mArgsInfo.noAutoCrop_flag);
111 //--------------------------------------------------------------------
114 //--------------------------------------------------------------------
115 // Update with the number of dimensions and the pixeltype
116 //--------------------------------------------------------------------
117 template<class ArgsInfoType>
118 template<class ImageType>
119 void clitk::ExtractPatientGenericFilter<ArgsInfoType>::UpdateWithInputImageType()
122 typedef itk::Image<uchar, ImageType::ImageDimension> OutputImageType;
125 typename ImageType::Pointer input = this->template GetInput<ImageType>(0);
128 typedef clitk::ExtractPatientFilter<ImageType> FilterType;
129 typename FilterType::Pointer filter = FilterType::New();
131 // Set the filter (needed for example for threaded monitoring)
132 this->SetFilterBase(filter);
134 // Set global Options
135 filter->SetInput(input);
136 SetOptionsFromArgsInfoToFilter<FilterType>(filter);
141 // Write/Save results
142 typename OutputImageType::Pointer output = filter->GetOutput();
143 this->template SetNextOutput<OutputImageType>(output);
145 //--------------------------------------------------------------------