]> Creatis software - clitk.git/blob - segmentation/clitkExtractPatientGenericFilter.txx
add options
[clitk.git] / segmentation / clitkExtractPatientGenericFilter.txx
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
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.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17   ======================================================================-====*/
18
19 #include "clitkImageCommon.h"
20
21 //--------------------------------------------------------------------
22 template<class ArgsInfoType>
23 clitk::ExtractPatientGenericFilter<ArgsInfoType>::ExtractPatientGenericFilter():
24   ImageToImageGenericFilter<Self>("ExtractPatient") 
25 {
26   // Default values
27   cmdline_parser_clitkExtractPatient_init(&mArgsInfo);
28   InitializeImageType<3>();
29 }
30 //--------------------------------------------------------------------
31
32
33 //--------------------------------------------------------------------
34 template<class ArgsInfoType>
35 template<unsigned int Dim>
36 void clitk::ExtractPatientGenericFilter<ArgsInfoType>::InitializeImageType() 
37 {  
38   ADD_IMAGE_TYPE(Dim, short);
39   // ADD_IMAGE_TYPE(Dim, int);
40   // ADD_IMAGE_TYPE(Dim, float);
41 }
42 //--------------------------------------------------------------------
43   
44
45 //--------------------------------------------------------------------
46 template<class ArgsInfoType>
47 void clitk::ExtractPatientGenericFilter<ArgsInfoType>::SetArgsInfo(const ArgsInfoType & a) 
48 {
49   mArgsInfo=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);
54 }
55 //--------------------------------------------------------------------
56
57
58 //--------------------------------------------------------------------
59 template<class ArgsInfoType>
60 template<class FilterType>
61 void 
62 clitk::ExtractPatientGenericFilter<ArgsInfoType>::
63 SetOptionsFromArgsInfoToFilter(FilterType * f)
64 {
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);
70
71   f->SetAFDBFilename(mArgsInfo.afdb_arg);  
72   f->SetOutputPatientFilename(mArgsInfo.output_arg);
73
74   f->SetUpperThreshold(mArgsInfo.upper_arg);
75   f->SetLowerThreshold(mArgsInfo.lower_arg);
76
77   f->SetDecomposeAndReconstructDuringFirstStep(mArgsInfo.erode1_flag);
78
79   // Convert to SizeType
80   typename FilterType::InputImageSizeType s;
81   if (mArgsInfo.radius1_given) {
82     ConvertOptionMacro(mArgsInfo.radius1, s, 3, false);
83     f->SetRadius1(s);
84   }
85
86   f->SetMaximumNumberOfLabels1(mArgsInfo.max1_arg);
87   f->SetNumberOfNewLabels1(mArgsInfo.new1_arg);
88
89   f->SetDecomposeAndReconstructDuringSecondStep(mArgsInfo.erode2_flag);
90
91   // Convert to SizeType
92   if (mArgsInfo.radius2_given) {
93     ConvertOptionMacro(mArgsInfo.radius2, s, 3, false);
94     f->SetRadius2(s);
95   }
96
97   f->SetMaximumNumberOfLabels2(mArgsInfo.max2_arg);
98   f->SetNumberOfNewLabels2(mArgsInfo.new2_arg);
99   
100   f->SetFirstKeep(mArgsInfo.firstKeep_arg);
101   f->SetLastKeep(mArgsInfo.lastKeep_arg);
102
103   f->SetFinalOpenClose(mArgsInfo.openClose_flag);
104   f->SetAutoCrop(!mArgsInfo.noAutoCrop_flag);
105 }
106 //--------------------------------------------------------------------
107
108
109 //--------------------------------------------------------------------
110 // Update with the number of dimensions and the pixeltype
111 //--------------------------------------------------------------------
112 template<class ArgsInfoType>
113 template<class ImageType>
114 void clitk::ExtractPatientGenericFilter<ArgsInfoType>::UpdateWithInputImageType() 
115
116   // Output image type
117   typedef itk::Image<uchar, ImageType::ImageDimension> OutputImageType;
118
119   // Reading input
120   typename ImageType::Pointer input = this->template GetInput<ImageType>(0);
121
122   // Create filter
123   typedef clitk::ExtractPatientFilter<ImageType> FilterType;
124   typename FilterType::Pointer filter = FilterType::New();
125     
126   // Set the filter (needed for example for threaded monitoring)
127   this->SetFilterBase(filter);
128     
129   // Set global Options 
130   filter->SetInput(input);
131   SetOptionsFromArgsInfoToFilter<FilterType>(filter);
132
133   // Go !
134   filter->Update();
135
136   // Write/Save results
137   typename OutputImageType::Pointer output = filter->GetOutput();
138   this->template SetNextOutput<OutputImageType>(output); 
139 }
140 //--------------------------------------------------------------------
141
142