- CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
======================================================================-====*/
+#include "clitkLabelImageOverlapMeasureFilter.h"
//--------------------------------------------------------------------
template <class TImageType>
clitk::RelativePositionList<TImageType>::
-RelativePositionList() {
+RelativePositionList():
+ clitk::FilterBase(),
+ clitk::FilterWithAnatomicalFeatureDatabaseManagement(),
+ itk::ImageToImageFilter<TImageType, TImageType>()
+{
+ ComputeOverlapFlagOff();
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template <class TImageType>
+void
+clitk::RelativePositionList<TImageType>::
+SetReferenceImageForOverlapMeasure(ImagePointer ref) {
+ m_reference = ref;
+ ComputeOverlapFlagOn();
}
//--------------------------------------------------------------------
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
std::copy(tmpfilename.begin(), tmpfilename.end(), writable.begin());
char ** argv = new char*[1];
argv[0] = new char[1];
- cmdline_parser_clitkRelativePosition2(1, 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
+ 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
// Get input
m_working_input = dynamic_cast<ImageType*>(itk::ProcessObject::GetInput(0));
+ std::string s = GetInputName();
+
+ // Debug
+ if (GetDisplayUsedStructuresOnlyFlag()) {
+ for(uint i=0; i<mArgsInfoList.size(); i++) {
+ // Check if we only want to display structure name
+ AddUsedStructures(s, mArgsInfoList[i].object_arg);
+ }
+ return;
+ }
// Loop on RelativePositionList of operations
- std::string s = GetInputName();
for(uint i=0; i<mArgsInfoList.size(); i++) {
- std::string text = "["+s+"] limits "+
- mArgsInfoList[i].orientation_arg[0]+" "+
- mArgsInfoList[i].object_arg+" "+
- toString(mArgsInfoList[i].threshold_arg);
+
+ // clitk::PrintMemory(true, "Start");
+ // remove _S in station name
+ std::string sname = s;
+ clitk::findAndReplace<std::string>(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 ?
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);
relPosFilter->Update();
m_working_input = relPosFilter->GetOutput();
StopCurrentStep<ImageType>(m_working_input);
+
+ // Compute overlap with reference if needed
+ if (GetComputeOverlapFlag()) {
+ typedef clitk::LabelImageOverlapMeasureFilter<ImageType> FilterType;
+ typename FilterType::Pointer filter = FilterType::New();
+ filter->SetInput(0, m_working_input);
+ filter->SetInput(1, m_reference);
+ filter->Update();
+ }
+ std::cout << std::endl;
}
}
//--------------------------------------------------------------------
clitk::RelativePositionList<TImageType>::
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<ImageType>(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; i<options.orientation_given; i++)
- filter->AddOrientationTypeString(options.orientation_arg[i]);
+ filter->SetFastFlag(options.fastFlag_flag);
+
+ if (options.orientation_given == 1) {
+ for(uint i=0; i<options.orientation_given; i++)
+ filter->AddOrientationTypeString(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();
filter->SetAutoCropFlag(!options.noAutoCrop_flag);
}
//--------------------------------------------------------------------
+
+