X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=segmentation%2FclitkRelativePositionList.txx;h=8d89e9fd364320d058ec1ba6ad88950ea9e12e58;hb=d7f456d86ca398a89ccf9de43ab68a2b50b8ca1f;hp=3ce555993b3d8d9131982517f68f87c01b478d8e;hpb=5b568893e14e5d955fa14f653bd176b54c6aee0c;p=clitk.git diff --git a/segmentation/clitkRelativePositionList.txx b/segmentation/clitkRelativePositionList.txx index 3ce5559..8d89e9f 100644 --- a/segmentation/clitkRelativePositionList.txx +++ b/segmentation/clitkRelativePositionList.txx @@ -16,11 +16,28 @@ - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html ======================================================================-====*/ +#include "clitkLabelImageOverlapMeasureFilter.h" //-------------------------------------------------------------------- template clitk::RelativePositionList:: -RelativePositionList() { +RelativePositionList(): + clitk::FilterBase(), + clitk::FilterWithAnatomicalFeatureDatabaseManagement(), + itk::ImageToImageFilter() +{ + ComputeOverlapFlagOff(); +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +template +void +clitk::RelativePositionList:: +SetReferenceImageForOverlapMeasure(ImagePointer ref) { + m_reference = ref; + ComputeOverlapFlagOn(); } //-------------------------------------------------------------------- @@ -77,7 +94,6 @@ Read(std::string filename) { if (!is) stop = true; else { std::getline(is, s); - // DD(s); if (s.find("object") != std::string::npos) stop=true; else ss << s << std::endl; if (!is) stop = true; @@ -88,6 +104,8 @@ Read(std::string filename) { std::ofstream os; openFileForWriting(os, tmpfilename); os << text; + os << "input = nothing" << std::endl; + os << "output = nothing" << std::endl; os.close(); // Create a struct to store options. I use two step to allow to @@ -96,15 +114,13 @@ Read(std::string filename) { ArgsInfoType args_info; std::vector writable(tmpfilename.size() + 1); std::copy(tmpfilename.begin(), tmpfilename.end(), writable.begin()); - char ** argv; - cmdline_parser_clitkRelativePosition2(0, argv, &args_info, 1, 1, 0); - args_info.input_given = 1; - args_info.input_arg = new char[1]; - args_info.output_given = 1; - args_info.output_arg = new char[1]; - cmdline_parser_clitkRelativePosition_configfile(&writable[0], &args_info, 0, 0, 1); - - // Store the args + char ** argv = new char*[1]; + argv[0] = new char[1]; + struct cmdline_parser_clitkRelativePosition_params params; + params.override = 0; + params.initialize = 1; + params.check_required = 0; + cmdline_parser_clitkRelativePosition_configfile(&writable[0], &args_info, 1, 1, 1); mArgsInfoList.push_back(args_info); // Delete the temporary file @@ -142,20 +158,37 @@ GenerateOutputInformation() { // Get input m_working_input = dynamic_cast(itk::ProcessObject::GetInput(0)); + std::string s = GetInputName(); + + // Debug + if (GetDisplayUsedStructuresOnlyFlag()) { + for(uint i=0; i(sname, "_S", " "); + std::string text = "["+sname+"] "; + if (mArgsInfoList[i].orientation_given) text += std::string(mArgsInfoList[i].orientation_arg[0])+" "; + else text = text+"("+toString(mArgsInfoList[i].angle1_arg)+" "+ + toString(mArgsInfoList[i].angle2_arg)+" "+ + (mArgsInfoList[i].inverse_flag?"true":"false")+") "; + text = text+mArgsInfoList[i].object_arg+" "+toString(mArgsInfoList[i].threshold_arg); if (mArgsInfoList[i].sliceBySlice_flag) { - text += " slice by slice"; + text += " SbS"; } else text += " 3D"; + text += " sp=" + toString(mArgsInfoList[i].spacing_arg)+" "; - StartNewStep(text); + StartNewStep(text, false); // no endl typename RelPosFilterType::Pointer relPosFilter; // Is it slice by slice or 3D ? @@ -168,6 +201,7 @@ GenerateOutputInformation() { f->SetUniqueConnectedComponentBySliceFlag(mArgsInfoList[i].uniqueCCL_flag); f->SetObjectCCLSelectionFlag(mArgsInfoList[i].uniqueObjectCCL_flag); f->IgnoreEmptySliceObjectFlagOn(); + f->SetVerboseSlicesFlag(mArgsInfoList[i].verboseSlices_flag); //f->SetObjectCCLSelectionDimension(0); //f->SetObjectCCLSelectionDirection(-1); //f->SetAutoCropFlag(false); @@ -188,6 +222,16 @@ GenerateOutputInformation() { relPosFilter->Update(); m_working_input = relPosFilter->GetOutput(); StopCurrentStep(m_working_input); + + // Compute overlap with reference if needed + if (GetComputeOverlapFlag()) { + typedef clitk::LabelImageOverlapMeasureFilter FilterType; + typename FilterType::Pointer filter = FilterType::New(); + filter->SetInput(0, m_working_input); + filter->SetInput(1, m_reference); + filter->Update(); + } + std::cout << std::endl; } } //-------------------------------------------------------------------- @@ -211,19 +255,36 @@ void clitk::RelativePositionList:: SetFilterOptions(typename RelPosFilterType::Pointer filter, ArgsInfoType & options) { - if (options.orientation_given != 1) { - DD("ERRROR DEBUG TODO no more than 1 orientation yet"); - exit(0); + if (options.orientation_given > 1) { + clitkExceptionMacro("Error in the RelPos options. I need a single --orientation (for the moment)." + << " Current options are for obj = '" << options.object_arg + << "', threshold = " << options.threshold_arg << std::endl); } ImagePointer object = GetAFDB()->template GetImage(options.object_arg); filter->SetInputObject(object); filter->WriteStepFlagOff(); + filter->SetRadius(options.radius_arg); + if (options.writeStep_flag) filter->WriteStepFlagOn(); filter->SetVerboseImageSizeFlag(GetVerboseImageSizeFlag()); filter->SetFuzzyThreshold(options.threshold_arg); filter->SetInverseOrientationFlag(options.inverse_flag); // MUST BE BEFORE AddOrientationTypeString - for(uint i=0; iAddOrientationTypeString(options.orientation_arg[i]); + filter->SetFastFlag(options.fastFlag_flag); + + if (options.orientation_given == 1) { + for(uint i=0; iAddOrientationTypeString(options.orientation_arg[i]); + } + else { + if (options.angle1_given && options.angle2_given) { + filter->AddAnglesInDeg(options.angle1_arg, options.angle2_arg); + } + else { + clitkExceptionMacro("Error in the RelPos options. I need --orientation or (--angle1 and --angle2)." + << " Current options are for obj = '" << options.object_arg + << "', threshold = " << options.threshold_arg << std::endl); + } + } filter->SetIntermediateSpacing(options.spacing_arg); if (options.spacing_arg == -1) filter->IntermediateSpacingFlagOff(); else filter->IntermediateSpacingFlagOn(); @@ -231,3 +292,5 @@ SetFilterOptions(typename RelPosFilterType::Pointer filter, ArgsInfoType & optio filter->SetAutoCropFlag(!options.noAutoCrop_flag); } //-------------------------------------------------------------------- + +