]> Creatis software - clitk.git/blobdiff - segmentation/clitkExtractMediastinumGenericFilter.txx
Moved from repository clitk to clitk.private/tests_dav
[clitk.git] / segmentation / clitkExtractMediastinumGenericFilter.txx
index 8632222cbec0b974a1926566e8d8018344a7a652..679fb36cc22deb0f372b21fe5966bbc414b3cc7f 100644 (file)
@@ -3,7 +3,7 @@
 
   Authors belong to: 
   - University of LYON              http://www.universite-lyon.fr/
-  - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
+  - Léon Bérard cancer center       http://www.centreleonberard.fr
   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
 
   This software is distributed WITHOUT ANY WARRANTY; without even
@@ -14,7 +14,7 @@
 
   - BSD        See included LICENSE.txt file
   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
-  ======================================================================-====*/
+  ===========================================================================**/
 
 #ifndef CLITKEXTRACTMEDIASTINUMSGENERICFILTER_TXX
 #define CLITKEXTRACTMEDIASTINUMSGENERICFILTER_TXX
@@ -23,7 +23,8 @@
   
 //--------------------------------------------------------------------
 template<class ArgsInfoType>
-clitk::ExtractMediastinumGenericFilter<ArgsInfoType>::ExtractMediastinumGenericFilter():
+clitk::ExtractMediastinumGenericFilter<ArgsInfoType>::
+ExtractMediastinumGenericFilter():
   ImageToImageGenericFilter<Self>("ExtractMediastinum") 
 {
   // Default values
@@ -36,32 +37,55 @@ clitk::ExtractMediastinumGenericFilter<ArgsInfoType>::ExtractMediastinumGenericF
 //--------------------------------------------------------------------
 template<class ArgsInfoType>
 template<unsigned int Dim>
-void clitk::ExtractMediastinumGenericFilter<ArgsInfoType>::InitializeImageType() 
+void 
+clitk::ExtractMediastinumGenericFilter<ArgsInfoType>::
+InitializeImageType() 
 {  
-  ADD_IMAGE_TYPE(Dim, uchar);
-  // ADD_IMAGE_TYPE(Dim, short);
-  // ADD_IMAGE_TYPE(Dim, int);
-  // ADD_IMAGE_TYPE(Dim, float);
+  ADD_IMAGE_TYPE(Dim, short);
 }
 //--------------------------------------------------------------------
   
 
 //--------------------------------------------------------------------
 template<class ArgsInfoType>
-void clitk::ExtractMediastinumGenericFilter<ArgsInfoType>::SetArgsInfo(const ArgsInfoType & a) 
+void 
+clitk::ExtractMediastinumGenericFilter<ArgsInfoType>::
+SetArgsInfo(const ArgsInfoType & a) 
 {
   mArgsInfo=a;
   SetIOVerbose(mArgsInfo.verbose_flag);
   if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes();
-  if (mArgsInfo.patient_given) AddInputFilename(mArgsInfo.patient_arg);
-  if (mArgsInfo.lung_given) AddInputFilename(mArgsInfo.lung_arg);
-  if (mArgsInfo.bones_given) AddInputFilename(mArgsInfo.bones_arg);
-  if (mArgsInfo.trachea_given) AddInputFilename(mArgsInfo.trachea_arg);
+  if (mArgsInfo.input_given) AddInputFilename(mArgsInfo.input_arg);
   if (mArgsInfo.output_given)  AddOutputFilename(mArgsInfo.output_arg);
 }
 //--------------------------------------------------------------------
 
 
+//--------------------------------------------------------------------
+template<class ArgsInfoType>
+template<class FilterType>
+void 
+clitk::ExtractMediastinumGenericFilter<ArgsInfoType>::
+SetOptionsFromArgsInfoToFilter(FilterType * f)
+{
+  f->SetVerboseOptionFlag(mArgsInfo.verbose_flag);
+  f->SetVerboseStepFlag(mArgsInfo.verboseStep_flag);
+  f->SetWriteStepFlag(mArgsInfo.writeStep_flag);
+  f->SetAFDBFilename(mArgsInfo.afdb_arg);  
+  f->SetOutputMediastinumFilename(mArgsInfo.output_arg);
+  f->SetVerboseMemoryFlag(mArgsInfo.verboseMemory_flag);
+
+  f->SetDistanceMaxToAnteriorPartOfTheVertebralBody(mArgsInfo.maxAntSpine_arg);
+  f->SetUseBones(mArgsInfo.useBones_flag);
+
+  // Set RelativePositionList filenames
+  for(uint i=0; i<mArgsInfo.relpos_given; i++) {
+    f->AddRelativePositionListFilename(mArgsInfo.relpos_arg[i]);
+  }
+}
+//--------------------------------------------------------------------
+
+
 //--------------------------------------------------------------------
 // Update with the number of dimensions and the pixeltype
 //--------------------------------------------------------------------
@@ -70,35 +94,22 @@ template<class ImageType>
 void clitk::ExtractMediastinumGenericFilter<ArgsInfoType>::UpdateWithInputImageType() 
 { 
   // Reading input
-  typename ImageType::Pointer patient = this->template GetInput<ImageType>(0);
-  typename ImageType::Pointer lung    = this->template GetInput<ImageType>(1);
-  typename ImageType::Pointer bones   = this->template GetInput<ImageType>(2);
-  typename ImageType::Pointer trachea = this->template GetInput<ImageType>(3);
+  typename ImageType::Pointer input = this->template GetInput<ImageType>(0);
 
   // Create filter
   typedef clitk::ExtractMediastinumFilter<ImageType> FilterType;
   typename FilterType::Pointer filter = FilterType::New();
     
   // Set global Options 
-  filter->SetInputPatientLabelImage(patient, mArgsInfo.patientBG_arg);
-  filter->SetInputLungLabelImage(lung, mArgsInfo.lungBG_arg, mArgsInfo.lungRight_arg, mArgsInfo.lungLeft_arg);
-  filter->SetInputBonesLabelImage(bones, mArgsInfo.bonesBG_arg);
-  filter->SetInputTracheaLabelImage(trachea, mArgsInfo.tracheaBG_arg);
-  filter->SetArgsInfo(mArgsInfo);
+  filter->SetInput(input);
+  SetOptionsFromArgsInfoToFilter<FilterType>(filter);
 
   // Go !
   filter->Update();
-  
-  // Check if error
-  if (filter->HasError()) {
-    SetLastError(filter->GetLastError());
-    // No output
-    return;
-  }
 
   // Write/Save results
-  typename ImageType::Pointer output = filter->GetOutput();
-  this->template SetNextOutput<ImageType>(output); 
+  typename FilterType::MaskImageType::Pointer output = filter->GetOutput();
+  this->template SetNextOutput<typename FilterType::MaskImageType>(output); 
 }
 //--------------------------------------------------------------------