Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkAbstractGlobalImageFeature.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 
14 #ifndef mitkAbstractGlobalImageFeature_h
15 #define mitkAbstractGlobalImageFeature_h
16 
17 #include <MitkCLCoreExports.h>
18 
19 #include <mitkBaseData.h>
20 #include <mitkImage.h>
21 
22 #include <mitkCommandLineParser.h>
23 
25 
26 // STD Includes
27 
28 // Eigen
29 #include <itkeigen/Eigen/Dense>
30 
31 // MITK includes
33 
34 namespace mitk
35 {
36 
47  {
48  std::string name;
49  std::string featureClass;
50  std::string settingID;
51  std::string legacyName;
52  std::string version = "1";
53 
54  using ParametersType = std::map<std::string, us::Any>;
56 
62  bool operator < (const FeatureID& rh) const;
63 
69  bool operator ==(const FeatureID& rh) const;
70  };
71 
79  MITKCLCORE_EXPORT FeatureID CreateFeatureID(FeatureID templateID, std::string name);
80 
170 {
171 public:
173 
174  typedef std::vector< std::pair<FeatureID, double> > FeatureListType;
176 
180  FeatureListType CalculateFeatures(const Image* image, const Image* mask);
181  virtual FeatureListType CalculateFeatures(const Image* image, const Image* mask, const Image* maskNoNAN) = 0;
182 
186  FeatureListType CalculateFeaturesSlicewise(const Image::Pointer & image, const Image::Pointer &mask, int sliceID);
187 
191  virtual void CalculateAndAppendFeaturesSliceWise(const Image::Pointer & image, const Image::Pointer &mask, int sliceID, FeatureListType &featureList, bool checkParameterActivation = true);
192 
202  void CalculateAndAppendFeatures(const Image* image, const Image* mask, const Image* maskNoNaN, FeatureListType &featureList, bool checkParameterActivation = true);
203 
205  itkSetMacro(Prefix, std::string);
207  itkSetMacro(ShortName, std::string);
209  itkSetMacro(LongName, std::string);
211  itkSetMacro(FeatureClassName, std::string);
213  itkSetMacro(Direction, int);
214 
224  {
225  m_Parameters = param;
226  this->ConfigureQuantifierSettingsByParameters();
227  this->ConfigureSettingsByParameters(param);
228  this->Modified();
229  };
230 
232  itkGetConstMacro(Prefix, std::string);
234  itkGetConstMacro(ShortName, std::string);
236  itkGetConstMacro(LongName, std::string);
238  itkGetConstMacro(FeatureClassName, std::string);
240  itkGetConstMacro(Parameters, ParametersType);
241 
243  itkGetMacro(Quantifier, IntensityQuantifier::Pointer);
244 
246  itkGetConstMacro(Direction, int);
247 
249  itkSetMacro(MinimumIntensity, double);
251  itkSetMacro(UseMinimumIntensity, bool);
253  itkSetMacro(MaximumIntensity, double);
255  itkSetMacro(UseMaximumIntensity, bool);
257  itkGetConstMacro(MinimumIntensity, double);
259  itkGetConstMacro(UseMinimumIntensity, bool);
261  itkGetConstMacro(MaximumIntensity, double);
263  itkGetConstMacro(UseMaximumIntensity, bool);
264 
266  itkSetMacro(Binsize, double);
268  itkSetMacro(UseBinsize, bool);
270  itkGetConstMacro(Binsize, double);
272  itkGetConstMacro(UseBinsize, bool);
273 
275  itkSetMacro(MorphMask, mitk::Image::Pointer);
277  itkGetConstMacro(MorphMask, mitk::Image::Pointer);
278 
280  itkSetMacro(Bins, int);
282  itkSetMacro(UseBins, bool);
284  itkGetConstMacro(UseBins, bool);
286  itkGetConstMacro(Bins, int);
287 
289  itkSetMacro(IgnoreMask, bool);
291  itkGetConstMacro(IgnoreMask, bool);
292 
294  itkSetMacro(EncodeParametersInFeaturePrefix, bool);
296  itkGetConstMacro(EncodeParametersInFeaturePrefix, bool);
298  itkBooleanMacro(EncodeParametersInFeaturePrefix);
299 
307  std::string GetOptionPrefix() const
308  {
309  if (!m_Prefix.empty())
310  return m_Prefix + "::" + m_ShortName;
311  return m_ShortName;
312  }
313 
317  virtual void AddArguments(mitkCommandLineParser &parser) const = 0;
318 
321  static std::string GenerateLegacyFeatureNameWOEncoding(const FeatureID& id);
322 
323 protected:
324  std::vector<double> SplitDouble(std::string str, char delimiter);
325 
326  virtual FeatureListType DoCalculateFeatures(const Image* image, const Image* mask) = 0;
327 
329 
332 
335  virtual void ConfigureSettingsByParameters(const ParametersType& parameters);
336 
338  void InitializeQuantifier(const Image* image, const Image* mask, unsigned int defaultBins = 256);
339 
341  std::string QuantifierParameterString() const;
342 
343  /* Creates a template feature id.
344  * it will set the featureClass, the settingID (assuming that it is the featureClass with the passed suffix
345  * and all parameters that are global or have the option prefix of the instance.*/
346  FeatureID CreateTemplateFeatureID(std::string settingsSuffix = "", FeatureID::ParametersType additionalParams = {});
347 
353  virtual std::string GenerateLegacyFeatureName(const FeatureID& id) const;
354  virtual std::string GenerateLegacyFeatureNamePart(const FeatureID& id) const;
355  virtual std::string GenerateLegacyFeatureEncoding(const FeatureID& id) const;
356 
357 public:
358 
359 //#ifndef DOXYGEN_SKIP
360 
362  bool RequestedRegionIsOutsideOfTheBufferedRegion() override { return true; };
363  bool VerifyRequestedRegion() override { return false; };
364  void SetRequestedRegion (const itk::DataObject * /*data*/) override {};
365 
366  // Override
367  bool IsEmpty() const override
368  {
369  if(IsInitialized() == false)
370  return true;
371  const TimeGeometry* timeGeometry = const_cast<AbstractGlobalImageFeature*>(this)->GetUpdatedTimeGeometry();
372  if(timeGeometry == nullptr)
373  return true;
374  return false;
375  }
376 
377 
378 private:
379  std::string m_Prefix; // Prefix before all input parameters
380  std::string m_ShortName; // Name of all variables
381  std::string m_LongName; // Long version of the name (For turning on)
382  std::string m_FeatureClassName;
383  ParametersType m_Parameters; // Parameter setting
384 
385  mitk::Image::Pointer m_MorphMask = nullptr;
386 
387 
388  IntensityQuantifier::Pointer m_Quantifier;
389  //Quantifier relevant variables
390  double m_MinimumIntensity = 0;
391  bool m_UseMinimumIntensity = false;
392  double m_MaximumIntensity = 100;
393  bool m_UseMaximumIntensity = false;
394  bool m_EncodeParametersInFeaturePrefix = false;
395 
396  double m_Binsize = 1;
397  bool m_UseBinsize = false;
398 
399  int m_Bins = 256;
400  bool m_UseBins = true;
401  int m_Direction = 0;
402 
403  bool m_IgnoreMask = false;
404 //#endif // Skip Doxygen
405 
406 };
407 }
408 
409 #endif
#define MITKCLCORE_EXPORT
Command line argument parser for MITK applications, based on the CTK command line parser.
std::string GetOptionPrefix() const
Build the full option prefix string for command line parameters.
virtual void CalculateAndAppendFeaturesSliceWise(const Image::Pointer &image, const Image::Pointer &mask, int sliceID, FeatureListType &featureList, bool checkParameterActivation=true)
Calculates the feature of this abstract interface. Does not necessarily considers the parameter setti...
void SetRequestedRegion(const itk::DataObject *) override
Set the requested region from this data object to match the requested region of the data object passe...
static std::string GenerateLegacyFeatureNameWOEncoding(const FeatureID &id)
bool RequestedRegionIsOutsideOfTheBufferedRegion() override
Determine whether the RequestedRegion is outside of the BufferedRegion.
void SetRequestedRegionToLargestPossibleRegion() override
Set the RequestedRegion to the LargestPossibleRegion.
std::vector< double > SplitDouble(std::string str, char delimiter)
void InitializeQuantifier(const Image *image, const Image *mask, unsigned int defaultBins=256)
virtual std::string GenerateLegacyFeatureEncoding(const FeatureID &id) const
FeatureListType CalculateFeaturesSlicewise(const Image::Pointer &image, const Image::Pointer &mask, int sliceID)
Calculates the given feature Slice-wise. Might not be available for an individual filter!
void SetParameters(ParametersType param)
Set the parameter map and reconfigure the instance accordingly.
FeatureID CreateTemplateFeatureID(std::string settingsSuffix="", FeatureID::ParametersType additionalParams={})
bool IsEmpty() const override
Check whether the object contains data at any time step.
std::string QuantifierParameterString() const
void CalculateAndAppendFeatures(const Image *image, const Image *mask, const Image *maskNoNaN, FeatureListType &featureList, bool checkParameterActivation=true)
Calculates the feature of this abstract interface. Does not necessarily considers the parameter setti...
virtual void AddArguments(mitkCommandLineParser &parser) const =0
virtual FeatureListType DoCalculateFeatures(const Image *image, const Image *mask)=0
FeatureListType CalculateFeatures(const Image *image, const Image *mask)
Calculates the feature of this abstract interface. Does not necessarily considers the parameter setti...
mitkClassMacro(AbstractGlobalImageFeature, BaseData)
virtual void ConfigureSettingsByParameters(const ParametersType &parameters)
virtual std::string GenerateLegacyFeatureNamePart(const FeatureID &id) const
void AddQuantifierArguments(mitkCommandLineParser &parser) const
virtual std::string GenerateLegacyFeatureName(const FeatureID &id) const
std::vector< std::pair< FeatureID, double > > FeatureListType
bool VerifyRequestedRegion() override
Verify that the RequestedRegion is within the LargestPossibleRegion.
virtual FeatureListType CalculateFeatures(const Image *image, const Image *mask, const Image *maskNoNAN)=0
Base class of all data objects.
Definition: mitkBaseData.h:60
Image class for storing multi-dimensional medical image data.
Definition: mitkImage.h:76
bool operator<(const StaticParameterMap::ValueType &a, const StaticParameterMap::ValueType &b)
Compares two value lists by their first element.
Find image slices visible on a given plane.
MITKCLCORE_EXPORT FeatureID CreateFeatureID(FeatureID templateID, std::string name)
Create a FeatureID by cloning a template and setting its name.
MITKCORE_EXPORT bool operator==(const InteractionEvent &a, const InteractionEvent &b)
Unique identifier for a computed image feature.
std::string featureClass
Name of the feature class that computed this feature.
ParametersType parameters
Map of parameter name-value pairs used for computation.
std::string legacyName
Legacy feature name that encodes parameter settings directly in the string.
std::string settingID
Identifier encoding the parameter configuration; must be unique per parameter set.
std::string name
Name of the individual feature.
std::map< std::string, us::Any > ParametersType