Medical Imaging Interaction Toolkit  2024.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 
39  {
41  std::string name;
43  std::string featureClass;
45  std::string settingID;
47  std::string legacyName;
49  std::string version = "1";
50 
51  using ParametersType = std::map<std::string, us::Any>;
53 
54  bool operator < (const FeatureID& rh) const;
55  bool operator ==(const FeatureID& rh) const;
56  };
57 
61  MITKCLCORE_EXPORT FeatureID CreateFeatureID(FeatureID templateID, std::string name);
62 
152 {
153 public:
155 
156  typedef std::vector< std::pair<FeatureID, double> > FeatureListType;
158 
162  FeatureListType CalculateFeatures(const Image* image, const Image* mask);
163  virtual FeatureListType CalculateFeatures(const Image* image, const Image* mask, const Image* maskNoNAN) = 0;
164 
168  FeatureListType CalculateFeaturesSlicewise(const Image::Pointer & image, const Image::Pointer &mask, int sliceID);
169 
173  virtual void CalculateAndAppendFeaturesSliceWise(const Image::Pointer & image, const Image::Pointer &mask, int sliceID, FeatureListType &featureList, bool checkParameterActivation = true);
174 
184  void CalculateAndAppendFeatures(const Image* image, const Image* mask, const Image* maskNoNaN, FeatureListType &featureList, bool checkParameterActivation = true);
185 
186  itkSetMacro(Prefix, std::string);
187  itkSetMacro(ShortName, std::string);
188  itkSetMacro(LongName, std::string);
189  itkSetMacro(FeatureClassName, std::string);
190  itkSetMacro(Direction, int);
191 
193  {
194  m_Parameters = param;
195  this->ConfigureQuantifierSettingsByParameters();
196  this->ConfigureSettingsByParameters(param);
197  this->Modified();
198  };
199 
200  itkGetConstMacro(Prefix, std::string);
201  itkGetConstMacro(ShortName, std::string);
202  itkGetConstMacro(LongName, std::string);
203  itkGetConstMacro(FeatureClassName, std::string);
204  itkGetConstMacro(Parameters, ParametersType);
205 
206  itkGetMacro(Quantifier, IntensityQuantifier::Pointer);
207 
208  itkGetConstMacro(Direction, int);
209 
210  itkSetMacro(MinimumIntensity, double);
211  itkSetMacro(UseMinimumIntensity, bool);
212  itkSetMacro(MaximumIntensity, double);
213  itkSetMacro(UseMaximumIntensity, bool);
214  itkGetConstMacro(MinimumIntensity, double);
215  itkGetConstMacro(UseMinimumIntensity, bool);
216  itkGetConstMacro(MaximumIntensity, double);
217  itkGetConstMacro(UseMaximumIntensity, bool);
218 
219 
220  itkSetMacro(Binsize, double);
221  itkSetMacro(UseBinsize, bool);
222  itkGetConstMacro(Binsize, double);
223  itkGetConstMacro(UseBinsize, bool);
224 
225  itkSetMacro(MorphMask, mitk::Image::Pointer);
226  itkGetConstMacro(MorphMask, mitk::Image::Pointer);
227 
228  itkSetMacro(Bins, int);
229  itkSetMacro(UseBins, bool);
230  itkGetConstMacro(UseBins, bool);
231  itkGetConstMacro(Bins, int);
232 
233  itkSetMacro(IgnoreMask, bool);
234  itkGetConstMacro(IgnoreMask, bool);
235 
236  itkSetMacro(EncodeParametersInFeaturePrefix, bool);
237  itkGetConstMacro(EncodeParametersInFeaturePrefix, bool);
238  itkBooleanMacro(EncodeParametersInFeaturePrefix);
239 
240  std::string GetOptionPrefix() const
241  {
242  if (!m_Prefix.empty())
243  return m_Prefix + "::" + m_ShortName;
244  return m_ShortName;
245  }
246 
250  virtual void AddArguments(mitkCommandLineParser &parser) const = 0;
251 
254  static std::string GenerateLegacyFeatureNameWOEncoding(const FeatureID& id);
255 
256 protected:
257  std::vector<double> SplitDouble(std::string str, char delimiter);
258 
259  virtual FeatureListType DoCalculateFeatures(const Image* image, const Image* mask) = 0;
260 
261  void AddQuantifierArguments(mitkCommandLineParser& parser) const;
262 
264  void ConfigureQuantifierSettingsByParameters();
265 
268  virtual void ConfigureSettingsByParameters(const ParametersType& parameters);
269 
271  void InitializeQuantifier(const Image* image, const Image* mask, unsigned int defaultBins = 256);
272 
274  std::string QuantifierParameterString() const;
275 
276  /* Creates a template feature id.
277  * it will set the featureClass, the settingID (assuming that it is the featureClass with the passed suffix
278  * and all parameters that are global or have the option prefix of the instance.*/
279  FeatureID CreateTemplateFeatureID(std::string settingsSuffix = "", FeatureID::ParametersType additionalParams = {});
280 
286  virtual std::string GenerateLegacyFeatureName(const FeatureID& id) const;
287  virtual std::string GenerateLegacyFeatureNamePart(const FeatureID& id) const;
288  virtual std::string GenerateLegacyFeatureEncoding(const FeatureID& id) const;
289 
290 public:
291 
292 //#ifndef DOXYGEN_SKIP
293 
295  bool RequestedRegionIsOutsideOfTheBufferedRegion() override { return true; };
296  bool VerifyRequestedRegion() override { return false; };
297  void SetRequestedRegion (const itk::DataObject * /*data*/) override {};
298 
299  // Override
300  bool IsEmpty() const override
301  {
302  if(IsInitialized() == false)
303  return true;
304  const TimeGeometry* timeGeometry = const_cast<AbstractGlobalImageFeature*>(this)->GetUpdatedTimeGeometry();
305  if(timeGeometry == nullptr)
306  return true;
307  return false;
308  }
309 
310 
311 private:
312  std::string m_Prefix; // Prefix before all input parameters
313  std::string m_ShortName; // Name of all variables
314  std::string m_LongName; // Long version of the name (For turning on)
315  std::string m_FeatureClassName;
316  ParametersType m_Parameters; // Parameter setting
317 
318  mitk::Image::Pointer m_MorphMask = nullptr;
319 
320 
321  IntensityQuantifier::Pointer m_Quantifier;
322  //Quantifier relevant variables
323  double m_MinimumIntensity = 0;
324  bool m_UseMinimumIntensity = false;
325  double m_MaximumIntensity = 100;
326  bool m_UseMaximumIntensity = false;
327  bool m_EncodeParametersInFeaturePrefix = false;
328 
329  double m_Binsize = 1;
330  bool m_UseBinsize = false;
331 
332  int m_Bins = 256;
333  bool m_UseBins = true;
334  int m_Direction = 0;
335 
336  bool m_IgnoreMask = false;
337 //#endif // Skip Doxygen
338 
339 };
340 }
341 
342 #endif
mitk::TimeGeometry
Definition: mitkTimeGeometry.h:45
mitk::AbstractGlobalImageFeature::RequestedRegionIsOutsideOfTheBufferedRegion
bool RequestedRegionIsOutsideOfTheBufferedRegion() override
Determine whether the RequestedRegion is outside of the BufferedRegion.
Definition: mitkAbstractGlobalImageFeature.h:295
mitk::FeatureID::settingID
std::string settingID
Definition: mitkAbstractGlobalImageFeature.h:45
mitkImage.h
mitk::AbstractGlobalImageFeature::SetRequestedRegion
void SetRequestedRegion(const itk::DataObject *) override
Set the requested region from this data object to match the requested region of the data object passe...
Definition: mitkAbstractGlobalImageFeature.h:297
mitk::FeatureID::featureClass
std::string featureClass
Definition: mitkAbstractGlobalImageFeature.h:43
mitk::FeatureID::legacyName
std::string legacyName
Definition: mitkAbstractGlobalImageFeature.h:47
mitk::modelFit::operator<
bool operator<(const StaticParameterMap::ValueType &a, const StaticParameterMap::ValueType &b)
Compares two var lists and returns true if the first list's first item is lower than the second one's...
Definition: mitkModelFitStaticParameterMap.h:139
mitk::FeatureID
Definition: mitkAbstractGlobalImageFeature.h:38
mitk::Image
Image class for storing images.
Definition: mitkImage.h:69
itk::SmartPointer< Self >
MITKCLCORE_EXPORT
#define MITKCLCORE_EXPORT
Definition: MitkCLCoreExports.h:15
mitk::AbstractGlobalImageFeature::IsEmpty
bool IsEmpty() const override
Check whether object contains data (at least at one point in time), e.g., a set of points may be empt...
Definition: mitkAbstractGlobalImageFeature.h:300
mitkCommandLineParser.h
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::CreateFeatureID
MITKCLCORE_EXPORT FeatureID CreateFeatureID(FeatureID templateID, std::string name)
mitk::FeatureID::parameters
ParametersType parameters
Definition: mitkAbstractGlobalImageFeature.h:52
mitk::operator==
MITKCORE_EXPORT bool operator==(const InteractionEvent &a, const InteractionEvent &b)
mitk::AbstractGlobalImageFeature
Definition: mitkAbstractGlobalImageFeature.h:151
mitk::AbstractGlobalImageFeature::VerifyRequestedRegion
bool VerifyRequestedRegion() override
Verify that the RequestedRegion is within the LargestPossibleRegion.
Definition: mitkAbstractGlobalImageFeature.h:296
mitk::BaseData
Base of all data objects.
Definition: mitkBaseData.h:42
mitkConfigurationHolder.h
mitk::AbstractGlobalImageFeature::SetParameters
void SetParameters(ParametersType param)
Definition: mitkAbstractGlobalImageFeature.h:192
MitkCLCoreExports.h
mitk::AbstractGlobalImageFeature::SetRequestedRegionToLargestPossibleRegion
void SetRequestedRegionToLargestPossibleRegion() override
Set the RequestedRegion to the LargestPossibleRegion.
Definition: mitkAbstractGlobalImageFeature.h:294
mitk::AbstractGlobalImageFeature::GetOptionPrefix
std::string GetOptionPrefix() const
Definition: mitkAbstractGlobalImageFeature.h:240
mitk::FeatureID::name
std::string name
Definition: mitkAbstractGlobalImageFeature.h:41
mitkCommandLineParser
Definition: mitkCommandLineParser.h:50
mitkBaseData.h
mitkClassMacro
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
mitk::AbstractGlobalImageFeature::FeatureListType
std::vector< std::pair< FeatureID, double > > FeatureListType
Definition: mitkAbstractGlobalImageFeature.h:156
mitkIntensityQuantifier.h
mitk::AbstractGlobalImageFeature::ParametersType
FeatureID::ParametersType ParametersType
Definition: mitkAbstractGlobalImageFeature.h:157
mitk::FeatureID::ParametersType
std::map< std::string, us::Any > ParametersType
Definition: mitkAbstractGlobalImageFeature.h:51