X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=tools%2FclitkSUVPeakGenericFilter.txx;h=893750dd3961b0d888ad4327346d7abfc66cccbe;hb=ba7eb37f66c14a90fe67ac035ecf9d8bc70fef1a;hp=127a071ce250346f84aa401eaed3191058b8ea40;hpb=adcb66e6659f609eab388827c24f52280253db99;p=clitk.git diff --git a/tools/clitkSUVPeakGenericFilter.txx b/tools/clitkSUVPeakGenericFilter.txx index 127a071..893750d 100644 --- a/tools/clitkSUVPeakGenericFilter.txx +++ b/tools/clitkSUVPeakGenericFilter.txx @@ -19,6 +19,9 @@ #define CLITKSUVPEAKGENERICFILTER_TXX #include "clitkImageCommon.h" +#include "clitkCropLikeImageFilter.h" +#include "clitkResampleImageWithOptionsFilter.h" + #include namespace clitk @@ -75,6 +78,34 @@ void SUVPeakGenericFilter::UpdateWithInputImageType() typename MaskImageType::Pointer mask; if(mArgsInfo.mask_given) { mask = this->template GetInput(1); + // Check mask sampling/size + if (!HaveSameSizeAndSpacing(mask, input)) { + if (mArgsInfo.allow_resize_flag) { + if (mArgsInfo.verbose_flag) { + std::cout << "Resize mask image like input" << std::endl; + } + typedef clitk::ResampleImageWithOptionsFilter ResamplerType; + typename ResamplerType::Pointer resampler = ResamplerType::New(); + resampler->SetInput(mask); //By default the interpolation in NN, Ok for mask + resampler->SetOutputSpacing(input->GetSpacing()); + resampler->SetOutputOrigin(mask->GetOrigin()); + resampler->SetGaussianFilteringEnabled(false); + resampler->Update(); + mask = resampler->GetOutput(); + + typedef clitk::CropLikeImageFilter FilterType; + typename FilterType::Pointer crop = FilterType::New(); + crop->SetInput(mask); + crop->SetCropLikeImage(input); + crop->Update(); + mask = crop->GetOutput(); + + } + else { + std::cerr << "Mask image has a different size/spacing than input. Abort. (Use option --allow_resize)" << std::endl; + exit(-1); + } + } } else { mask = MaskImageType::New(); @@ -86,6 +117,8 @@ void SUVPeakGenericFilter::UpdateWithInputImageType() } double volume = 1000; //1 cc into mc + if (mArgsInfo.volume_given) + volume *= mArgsInfo.volume_arg; const double PI = 3.141592653589793238463; double radius = std::pow(3*volume/(4*PI),1./3); @@ -120,7 +153,7 @@ void SUVPeakGenericFilter::UpdateWithInputImageType() } typename ImageType::PointType p; output->TransformIndexToPhysicalPoint(index, p); - std::cout<<"SUV Peak found in "<< p << " with the value " << max << std::endl; + std::cout<<"SUV Peak found in "<< p << " mm with the value " << max << std::endl; } //--------------------------------------------------------------------