// 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) {
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
public:
//--------------------------------------------------------------------
RelativePositionAnalyzerGenericFilter();
+ ~RelativePositionAnalyzerGenericFilter() {}
//--------------------------------------------------------------------
typedef ImageToImageGenericFilter<RelativePositionAnalyzerGenericFilter<ArgsInfoType> > Superclass;
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);
}
//--------------------------------------------------------------------
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);
}
//--------------------------------------------------------------------