]> Creatis software - clitk.git/commitdiff
Second version of clitkRelativePositionAnalyzer
authorDavid Sarrut <david.sarrut@gmail.com>
Thu, 27 Oct 2011 13:57:03 +0000 (15:57 +0200)
committerDavid Sarrut <david.sarrut@gmail.com>
Thu, 27 Oct 2011 13:57:03 +0000 (15:57 +0200)
tools/clitkRelativePositionAnalyzer.cxx
tools/clitkRelativePositionAnalyzer.ggo
tools/clitkRelativePositionAnalyzerGenericFilter.h
tools/clitkRelativePositionAnalyzerGenericFilter.txx

index 9b16e51515f9f4dadaf68e77f945464c77d69911..1e9541e368269e457789708386f9729b9938f6c7 100644 (file)
@@ -30,9 +30,33 @@ int main(int argc, char * argv[]) {
   // Filter
   typedef clitk::RelativePositionAnalyzerGenericFilter<args_info_clitkRelativePositionAnalyzer> FilterType;
   FilterType::Pointer filter = FilterType::New();
-  
+
+  // Set filename from the AFDB if needed
+#define SetOptionFromAFDBMacro(ARGS, OPTIONNAME, OPTION)                \
+  if (ARGS.OPTIONNAME##_given) {                                        \
+    if (ARGS.OPTION##_given) {                                          \
+      std::cerr << "Warning --"#OPTION" is ignored" << std::endl;       \
+    }                                                                   \
+    std::string f = afdb->GetTagValue(ARGS.OPTIONNAME##_arg);           \
+    f = std::string(args_info.afdb_path_arg)+"/"+f;                     \
+    filter->AddInputFilename(f);                                        \
+  }                                                                     \
+  else if (!ARGS.OPTION##_given) {                                      \
+    std::cerr << "Error on the command line please provide --"#OPTION" or --"#OPTIONNAME"." << std::endl; \
+    return EXIT_FAILURE;                                                \
+  }
+
+  // Set options
   filter->SetArgsInfo(args_info);
   
+  NewAFDB(afdb, args_info.afdb_arg);
+  // The order is important. If --supportName and --support are
+  // given, the first is set before, so the second ignored
+  SetOptionFromAFDBMacro(args_info, supportName, support);
+  SetOptionFromAFDBMacro(args_info, objectName, object);
+  SetOptionFromAFDBMacro(args_info, targetName, target);
+
+  // Go !
   try {
     filter->Update();
   } catch(std::runtime_error e) {
index c2f4d6f1dcde5db762251b3389cce9ae0e7c25aa..202514daf45b0b836d8b25145230a7bd4a23bfb3 100644 (file)
@@ -9,11 +9,20 @@ option "verbose"      v       "Verbose"                         flag          off
 option "imagetypes"     -       "Display allowed image types"     flag          off
 
 section "Input/Output"
-option "support"       i       "Input mask support"      string        yes
-option "object"                j       "Input mask object"       string        yes
-option "target"                t       "Input mask target"       string        yes
-option "output"        o       "Output image "           string        yes
+option "support"       i       "Input mask support"      string        no
+option "object"                j       "Input mask object"       string        no
+option "target"                t       "Input mask target"       string        no
+option "afdb"           a       "Input Anatomical Feature DB"           string no
+option "afdb_path"      -       "Path to search image in afdb"          string no
+option "supportName"   -       "Input mask support name in afdb"       string no
+option "objectName"    -       "Input mask object name in afdb"        string no
+option "targetName"    -       "Input mask target name in afdb"        string no
+option "output"        o       "Output image "                         string yes
+
+section "Options for building the relative positions"
+option "bins"           b       "Number of histo bins for fuzzy map"      int default="100" no
+option "nb"             n       "Number of angles to test"                int default="4" no
+option "tol"            -       "Target area loss tolerance (|0-1])"      double default="0.01" no
 
 
-option "afdb" a "Input Anatomical Feature DB" string no
 
index b1c3a1c16fc9c4d24ae74b5e1f1bfa73a9c593a3..fc5f67e8f4bce34a54611fcb083b0bc5f917a414 100644 (file)
@@ -36,6 +36,7 @@ namespace clitk
   public:
     //--------------------------------------------------------------------
     RelativePositionAnalyzerGenericFilter();
+    ~RelativePositionAnalyzerGenericFilter() {}
   
     //--------------------------------------------------------------------
     typedef ImageToImageGenericFilter<RelativePositionAnalyzerGenericFilter<ArgsInfoType> > Superclass;
index df52194bd00343030b3fe6811956185f94972084..a9300627d24fb4eb8c49bdf56536821af60012b5 100644 (file)
@@ -64,7 +64,10 @@ template<class FilterType>
 void clitk::RelativePositionAnalyzerGenericFilter<ArgsInfoType>::
 SetOptionsFromArgsInfoToFilter(FilterType * f) 
 {
-  f->SetAFDBFilename(mArgsInfo.afdb_arg);  
+  f->SetAFDBFilename(mArgsInfo.afdb_arg);
+  f->SetNumberOfBins(mArgsInfo.bins_arg);
+  f->SetNumberOfAngles(mArgsInfo.nb_arg);
+  f->SetAreaLossTolerance(mArgsInfo.tol_arg);
 }
 
 //--------------------------------------------------------------------
@@ -75,28 +78,38 @@ template<class ImageType>
 void clitk::RelativePositionAnalyzerGenericFilter<ArgsInfoType>::
 UpdateWithInputImageType() 
 { 
-  // Reading input
-  typename ImageType::Pointer support = this->template GetInput<ImageType>(0);
-  typename ImageType::Pointer object = this->template GetInput<ImageType>(1);
-  typename ImageType::Pointer target = this->template GetInput<ImageType>(2);
-
   // Create filter
   typedef clitk::RelativePositionAnalyzerFilter<ImageType> FilterType;
   typename FilterType::Pointer filter = FilterType::New();
   
-  // Set global Options 
+  // Reading input
+  typename ImageType::Pointer support = this->template GetInput<ImageType>(0);
+  typename ImageType::Pointer object = this->template GetInput<ImageType>(1);
+  typename ImageType::Pointer target = this->template GetInput<ImageType>(2);
   filter->SetInputSupport(support);
   filter->SetInputObject(object);
   filter->SetInputTarget(target);
+
+  // Set global Options 
   SetOptionsFromArgsInfoToFilter<FilterType>(filter);
 
   // Go !
   filter->Update();
-  
-  // Write/Save results
-  //  typename ImageType::Pointer output = filter->GetOutput();
-  //this->template SetNextOutput<ImageType>(output); 
 
+  // Display output
+  std::string s;
+  if (mArgsInfo.afdb_given) {
+    NewAFDB(afdb, mArgsInfo.afdb_arg);
+    std::string patient = afdb->GetTagValue("PatientID");
+    std::string support;
+    std::string object;
+    if (mArgsInfo.objectName_given) object = mArgsInfo.objectName_arg;
+    else object = mArgsInfo.object_arg;
+    if (mArgsInfo.supportName_given) support = mArgsInfo.supportName_arg;
+    else support = mArgsInfo.support_arg;
+    s = patient+" "+support+" "+object+" ";
+  }
+  filter->Print(s, std::cout);
 }
 //--------------------------------------------------------------------