22 #include <itkImageRegionIteratorWithIndex.h> 23 #include <itkNeighborhoodIterator.h> 29 struct GIFIntensityVolumeHistogramFeaturesParameters
35 template<
typename TPixel,
unsigned int VImageDimension>
38 typedef itk::Image<TPixel, VImageDimension>
ImageType;
39 typedef itk::Image<unsigned short, VImageDimension> MaskType;
41 typename MaskType::Pointer itkMask = MaskType::New();
45 std::string prefix = params.prefix;
47 itk::ImageRegionConstIterator<ImageType> iter(itkImage, itkImage->GetLargestPossibleRegion());
48 itk::ImageRegionConstIterator<MaskType> iterMask(itkMask, itkMask->GetLargestPossibleRegion());
50 MITK_INFO <<
"Quantification: " << quantifier->GetMinimum() <<
" to " << quantifier->GetMaximum() <<
" with " << quantifier->GetBins() <<
" bins";
54 std::vector<double> hist;
55 hist.resize(quantifier->GetBins(), 0);
58 while (!iter.IsAtEnd())
60 if (iterMask.Get() > 0)
62 double value = iter.Get();
64 std::size_t index = quantifier->IntensityToIndex(value);
72 bool notFoundIntenstiy010 =
true;
73 bool notFoundIntenstiy090 =
true;
75 double intensity010 = -1;
76 double intensity090 = -1;
79 bool firstRound =
true;
80 for (
int i = quantifier->GetBins() - 1; i >= 0; --i)
87 auc += 0.5 * (hist[i] + hist[i + 1]) / (quantifier->GetBins() - 1);
91 if (notFoundIntenstiy010 && fraction > 0.1)
93 intensity010 = quantifier->IndexToMeanIntensity(i + 1);
94 notFoundIntenstiy010 =
false;
96 if (notFoundIntenstiy090 && fraction > 0.9)
98 intensity090 = quantifier->IndexToMeanIntensity(i + 1);
99 notFoundIntenstiy090 =
false;
103 unsigned int index010 = std::ceil(quantifier->GetBins() * 0.1);
104 unsigned int index090 = std::floor(quantifier->GetBins() * 0.9);
106 featureList.push_back(std::make_pair(prefix +
"Volume fraction at 0.10 intensity", hist[index010]));
107 featureList.push_back(std::make_pair(prefix +
"Volume fraction at 0.90 intensity", hist[index090]));
108 featureList.push_back(std::make_pair(prefix +
"Intensity at 0.10 volume", intensity010));
109 featureList.push_back(std::make_pair(prefix +
"Intensity at 0.90 volume", intensity090));
110 featureList.push_back(std::make_pair(prefix +
"Difference volume fraction at 0.10 and 0.90 intensity", std::abs<double>(hist[index010] - hist[index090])));
111 featureList.push_back(std::make_pair(prefix +
"Difference intensity at 0.10 and 0.90 volume", std::abs<double>(intensity090 - intensity010)));
112 featureList.push_back(std::make_pair(prefix +
"Area under IVH curve", auc));
119 SetLongName(
"intensity-volume-histogram");
120 SetShortName(
"ivoh");
121 SetFeatureClassName(
"Intensity Volume Histogram");
126 InitializeQuantifier(image, mask, 1000);
128 GIFIntensityVolumeHistogramFeaturesParameters params;
129 params.quantifier = GetQuantifier();
130 params.prefix = FeatureDescriptionPrefix();
144 std::string name = GetOptionPrefix();
147 AddQuantifierArguments(parser);
153 InitializeQuantifierFromParameters(feature, mask, 1000);
155 auto parsedArgs = GetParameter();
156 if (parsedArgs.count(GetLongName()))
158 MITK_INFO <<
"Start calculating local intensity features ....";
160 featureList.insert(featureList.end(), localResults.begin(), localResults.end());
161 MITK_INFO <<
"Finished calculating local intensity features....";
167 return QuantifierParameterString();
#define AccessByItk_3(mitkImage, itkImageTypeFunction, arg1, arg2, arg3)
std::vector< std::string > FeatureNameListType
void CalculateFeaturesUsingParameters(const Image::Pointer &feature, const Image::Pointer &mask, const Image::Pointer &maskNoNAN, FeatureListType &featureList) override
Calculates the feature of this abstact interface. Does not necessarily considers the parameter settin...
itk::Image< unsigned char, 3 > ImageType
std::string GetCurrentFeatureEncoding() override
Adds an additional Separator to the name of the feature, which encodes the used parameters.
static void CalculateIntensityPeak(itk::Image< TPixel, VImageDimension > *itkImage, mitk::Image::Pointer mask, mitk::GIFLocalIntensity::FeatureListType &featureList, GIFLocalIntensityParameter params)
void addArgument(const std::string &longarg, const std::string &shortarg, Type type, const std::string &argLabel, const std::string &argHelp=std::string(), const us::Any &defaultValue=us::Any(), bool optional=true, bool ignoreRest=false, bool deprecated=false, mitkCommandLineParser::Channel channel=mitkCommandLineParser::Channel::None)
std::vector< std::pair< std::string, double > > FeatureListType
FeatureNameListType GetFeatureNames() override
Returns a list of the names of all features that are calculated from this class.
mitk::Image::Pointer image
void AddArguments(mitkCommandLineParser &parser) override
void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Cast an mitk::Image to an itk::Image with a specific type.
FeatureListType CalculateFeatures(const Image::Pointer &image, const Image::Pointer &mask) override
Calculates the Cooccurence-Matrix based features for this class.
mitk::Image::Pointer mask
void CalculateFeatures(mitk::CoocurenceMatrixHolder &holder, mitk::CoocurenceMatrixFeatures &results)
GIFIntensityVolumeHistogramFeatures()