From: David Sarrut Date: Thu, 27 Oct 2011 13:57:03 +0000 (+0200) Subject: Second version of clitkRelativePositionAnalyzer X-Git-Tag: v1.3.0~174^2~15 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=58022431bbadc0a2eaeab74cb2f282caa7ec5e54;p=clitk.git Second version of clitkRelativePositionAnalyzer --- diff --git a/tools/clitkRelativePositionAnalyzer.cxx b/tools/clitkRelativePositionAnalyzer.cxx index 9b16e51..1e9541e 100644 --- a/tools/clitkRelativePositionAnalyzer.cxx +++ b/tools/clitkRelativePositionAnalyzer.cxx @@ -30,9 +30,33 @@ int main(int argc, char * argv[]) { // Filter typedef clitk::RelativePositionAnalyzerGenericFilter 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) { diff --git a/tools/clitkRelativePositionAnalyzer.ggo b/tools/clitkRelativePositionAnalyzer.ggo index c2f4d6f..202514d 100644 --- a/tools/clitkRelativePositionAnalyzer.ggo +++ b/tools/clitkRelativePositionAnalyzer.ggo @@ -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 diff --git a/tools/clitkRelativePositionAnalyzerGenericFilter.h b/tools/clitkRelativePositionAnalyzerGenericFilter.h index b1c3a1c..fc5f67e 100644 --- a/tools/clitkRelativePositionAnalyzerGenericFilter.h +++ b/tools/clitkRelativePositionAnalyzerGenericFilter.h @@ -36,6 +36,7 @@ namespace clitk public: //-------------------------------------------------------------------- RelativePositionAnalyzerGenericFilter(); + ~RelativePositionAnalyzerGenericFilter() {} //-------------------------------------------------------------------- typedef ImageToImageGenericFilter > Superclass; diff --git a/tools/clitkRelativePositionAnalyzerGenericFilter.txx b/tools/clitkRelativePositionAnalyzerGenericFilter.txx index df52194..a930062 100644 --- a/tools/clitkRelativePositionAnalyzerGenericFilter.txx +++ b/tools/clitkRelativePositionAnalyzerGenericFilter.txx @@ -64,7 +64,10 @@ template void clitk::RelativePositionAnalyzerGenericFilter:: 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 void clitk::RelativePositionAnalyzerGenericFilter:: UpdateWithInputImageType() { - // Reading input - typename ImageType::Pointer support = this->template GetInput(0); - typename ImageType::Pointer object = this->template GetInput(1); - typename ImageType::Pointer target = this->template GetInput(2); - // Create filter typedef clitk::RelativePositionAnalyzerFilter FilterType; typename FilterType::Pointer filter = FilterType::New(); - // Set global Options + // Reading input + typename ImageType::Pointer support = this->template GetInput(0); + typename ImageType::Pointer object = this->template GetInput(1); + typename ImageType::Pointer target = this->template GetInput(2); filter->SetInputSupport(support); filter->SetInputObject(object); filter->SetInputTarget(target); + + // Set global Options SetOptionsFromArgsInfoToFilter(filter); // Go ! filter->Update(); - - // Write/Save results - // typename ImageType::Pointer output = filter->GetOutput(); - //this->template SetNextOutput(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); } //--------------------------------------------------------------------