]> Creatis software - clitk.git/blobdiff - segmentation/clitkExtractLymphStationsGenericFilter.txx
Unitialized variable was causing crash at startup on Windows
[clitk.git] / segmentation / clitkExtractLymphStationsGenericFilter.txx
index fb6d4dae8705c385ae83a03c13daf96e938efcd9..ffa6c3c87e6a668373182b87b629a3a47040fd75 100644 (file)
@@ -28,7 +28,7 @@ clitk::ExtractLymphStationsGenericFilter<ArgsInfoType>::ExtractLymphStationsGene
 {
   // Default values
   cmdline_parser_clitkExtractLymphStations_init(&mArgsInfo);
-  InitializeImageType<3>();
+  InitializeImageType<3>(); // Only for 3D images
 }
 //--------------------------------------------------------------------
 
@@ -38,10 +38,7 @@ template<class ArgsInfoType>
 template<unsigned int Dim>
 void clitk::ExtractLymphStationsGenericFilter<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); // Can add float later
 }
 //--------------------------------------------------------------------
   
@@ -53,9 +50,86 @@ void clitk::ExtractLymphStationsGenericFilter<ArgsInfoType>::SetArgsInfo(const A
   mArgsInfo=a;
   SetIOVerbose(mArgsInfo.verbose_flag);
   if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes();
-  if (mArgsInfo.mediastinum_given) AddInputFilename(mArgsInfo.mediastinum_arg);
-  if (mArgsInfo.trachea_given) AddInputFilename(mArgsInfo.trachea_arg);
-  if (mArgsInfo.output_given)  AddOutputFilename(mArgsInfo.output_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::ExtractLymphStationsGenericFilter<ArgsInfoType>::
+SetOptionsFromArgsInfoToFilter(FilterType * f)
+{
+  f->SetVerboseOptionFlag(mArgsInfo.verbose_flag);
+  f->SetVerboseStepFlag(mArgsInfo.verboseStep_flag);
+  f->SetWriteStepFlag(mArgsInfo.writeStep_flag);
+  f->SetVerboseMemoryFlag(mArgsInfo.verboseMemory_flag);
+  f->SetAFDBFilename(mArgsInfo.afdb_arg);  
+
+  // Station 8
+  f->SetDistanceMaxToAnteriorPartOfTheSpine(mArgsInfo.maxAntSpine_arg);
+  f->SetFuzzyThreshold("8", "Esophagus", mArgsInfo.tS8_Esophagus_arg);
+  f->SetInjectedThresholdForS8(mArgsInfo.injectedThresholdForS8_arg);
+
+  // Check multiple options for radius dilatation
+  /*
+    typename FilterType::MaskImagePointType p;
+    SetMultipleOptionMacro(mArgsInfo, esophagusDilatation, 3, p);
+    default ? = set before
+    exception if fail
+   */
+  typename FilterType::MaskImagePointType p;
+  p[0] = 7; p[1] = 5; p[2] = 0; // default value
+  if (mArgsInfo.esophagusDilatationForAnt_given == 3) {
+    for(uint i=0; i<3; i++)
+      p[i] = mArgsInfo.esophagusDilatationForAnt_arg[i];
+  }
+  else {
+    if (mArgsInfo.esophagusDilatationForAnt_given == 1) {
+      for(uint i=0; i<3; i++)
+        p[i] = mArgsInfo.esophagusDilatationForAnt_arg[0];
+    }
+  }
+  f->SetEsophagusDiltationForAnt(p);
+  
+  p[0] = 5; p[1] = 10; p[2] = 1; // default value
+  if (mArgsInfo.esophagusDilatationForRight_given == 3) {
+    for(uint i=0; i<3; i++)
+      p[i] = mArgsInfo.esophagusDilatationForRight_arg[i];
+  }
+  else {
+    if (mArgsInfo.esophagusDilatationForRight_given == 1) {
+      for(uint i=0; i<3; i++)
+        p[i] = mArgsInfo.esophagusDilatationForRight_arg[0];
+    }
+  }
+  f->SetEsophagusDiltationForRight(p);  
+  
+  for(uint i=0; i<mArgsInfo.station_given; i++)
+    f->AddComputeStation(mArgsInfo.station_arg[i]);
+
+  // Station 7
+  f->SetFuzzyThreshold("7", "Bronchi", mArgsInfo.tS7_Bronchi_arg);
+  f->SetFuzzyThreshold("7", "LeftSuperiorPulmonaryVein", mArgsInfo.tS7_LeftSuperiorPulmonaryVein_arg);
+  f->SetFuzzyThreshold("7", "RightSuperiorPulmonaryVein", mArgsInfo.tS7_RightSuperiorPulmonaryVein_arg);
+  f->SetFuzzyThreshold("7", "RightPulmonaryArtery", mArgsInfo.tS7_RightPulmonaryArtery_arg);
+  f->SetFuzzyThreshold("7", "LeftPulmonaryArtery", mArgsInfo.tS7_LeftPulmonaryArtery_arg);
+  f->SetFuzzyThreshold("7", "SVC", mArgsInfo.tS7_SVC_arg);
+
+  // Station 3A
+  f->SetFuzzyThreshold("3A", "Sternum", mArgsInfo.tS3A_Sternum_arg);
+  f->SetFuzzyThreshold("3A", "SubclavianArtery", mArgsInfo.tS3A_SubclavianArtery_arg);
+  
+  // Station 2RL
+  f->SetFuzzyThreshold("2RL", "CommonCarotidArtery", mArgsInfo.tS2RL_CommonCarotidArtery_arg);
+  f->SetFuzzyThreshold("2RL", "BrachioCephalicTrunk", mArgsInfo.tS2RL_BrachioCephalicTrunk_arg);
+  f->SetFuzzyThreshold("2RL", "BrachioCephalicVein", mArgsInfo.tS2RL_BrachioCephalicVein_arg);
+  f->SetFuzzyThreshold("2RL", "Aorta", mArgsInfo.tS2RL_Aorta_arg);
+  f->SetFuzzyThreshold("2RL", "SubclavianArteryLeft", mArgsInfo.tS2RL_SubclavianArteryLeft_arg);
+  f->SetFuzzyThreshold("2RL", "SubclavianArteryRight", mArgsInfo.tS2RL_SubclavianArteryRight_arg);
 }
 //--------------------------------------------------------------------
 
@@ -68,34 +142,24 @@ template<class ImageType>
 void clitk::ExtractLymphStationsGenericFilter<ArgsInfoType>::UpdateWithInputImageType() 
 { 
   // Reading input
-  typename ImageType::Pointer mediastinum = this->template GetInput<ImageType>(0);
-  typename ImageType::Pointer trachea = this->template GetInput<ImageType>(1);
+  typename ImageType::Pointer input = this->template GetInput<ImageType>(0);
 
   // Create filter
   typedef clitk::ExtractLymphStationsFilter<ImageType> FilterType;
   typename FilterType::Pointer filter = FilterType::New();
     
   // Set global Options 
-  filter->SetInputMediastinumLabelImage(mediastinum, 0); // change 0 with BG 
-  filter->SetInputTracheaLabelImage(trachea, 0); // change 0 with BG 
-  filter->SetArgsInfo(mArgsInfo);
+  filter->SetInput(input);
+  SetOptionsFromArgsInfoToFilter<FilterType>(filter);
 
   // Go !
-  // try {
-    filter->Update();
-  // }
-  // catch(std::runtime_error e) {
-  
-  // // Check if error
-  // if (filter->HasError()) {
-  //   SetLastError(filter->GetLastError());
-  //   // No output
-  //   return;
-  // }
+  filter->Update();
 
   // Write/Save results
-  typename ImageType::Pointer output = filter->GetOutput();
-  this->template SetNextOutput<ImageType>(output); 
+  typedef uchar MaskImagePixelType;
+  typedef itk::Image<MaskImagePixelType, 3> OutputImageType;
+  typename OutputImageType::Pointer output = filter->GetOutput();
+  this->template SetNextOutput<OutputImageType>(output); 
 }
 //--------------------------------------------------------------------