Medical Imaging Interaction Toolkit  2018.4.99-b20efe7f
Medical Imaging Interaction Toolkit
mitkCurveParameterFunctor.cpp
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 
14 
17 const
18 {
19  if (this->m_Grid.GetSize() == 0)
20  {
21  itkExceptionMacro("Error. Cannot compute Curve Description Parameters. No Curve Grid set!");
22  }
23 
24  if (this->m_DescriptorMap.size() == 0)
25  {
26  itkGenericExceptionMacro( <<
27  "Error. Cannot compute Curve Description Parameters. No Parameters registered!");
28  }
29 
30  CurveDescriptionParameterBase::CurveType sample(value.size());
31 
32  for (CurveDescriptionParameterBase::CurveType::SizeValueType i = 0; i < sample.Size(); ++i)
33  {
34  sample[i] = value [i];
35  }
36 
38  result.reserve(m_DescriptorMap.size()); //we will have at least this number of values
39 
40  unsigned int i = 0;
41 
42  for (DescriptionParameterMapType::const_iterator pos = m_DescriptorMap.begin();
43  pos != m_DescriptorMap.end(); ++pos, ++i)
44  {
46  (pos->second.GetPointer());
47 
49  paramFct->GetCurveDescriptionParameter(sample, this->m_Grid);
50  result.insert(result.end(), fctResults.begin(), fctResults.end());
51  }
52 
53  if (this->GetDescriptionParameterNames().size() != result.size())
54  {
55  itkGenericExceptionMacro( <<
56  "Error. Curve parameter functor has an invalid state. Number of parameter names and number of computed values does not match. Names count: "
57  << this->GetDescriptionParameterNames().size() << "; value count: " << result.size());
58  }
59 
60  return result;
61 };
62 
63 unsigned int
65 {
66  return GetDescriptionParameterNames().size();
67 };
68 
71 {
72  return m_Grid;
73 };
74 
75 void
77 {
78  m_DescriptorMap.clear();
79 };
80 
81 void
83  CurveDescriptionParameterBase* parameterFunction)
84 {
85  CurveDescriptionParameterBase::Pointer paramFunctPtr = parameterFunction;
86 
87  m_DescriptorMap.insert(std::make_pair(parameterName, paramFunctPtr));
88 };
89 
92 {
93  ParameterNamesType result;
94 
95  for (auto descriptor : m_DescriptorMap)
96  {
98  descriptor.second->GetDescriptionParameterName();
99 
100  if (fctResults.size() > 1)
101  {
102  for (auto fctName : fctResults)
103  {
104  result.push_back(descriptor.first + "_" + fctName);
105  }
106  }
107  else
108  { //if the descriptor has only one parameter just use the registered descriptor name.
109  result.push_back(descriptor.first);
110  }
111  }
112 
113  return result;
114 };
115 
118 {
119  const CurveDescriptionParameterBase* result = nullptr;
120 
121  DescriptionParameterMapType::const_iterator pos = m_DescriptorMap.find(parameterName);
122 
123  if (pos != m_DescriptorMap.end())
124  {
125  result = (pos->second).GetPointer();
126  }
127 
128  return result;
129 };
130 
133 {};
134 
137 
SimpleFunctorBase::OutputPixelVectorType Compute(const InputPixelVectorType &value) const override
void RegisterDescriptionParameter(const ParameterNameType &parameterName, CurveDescriptionParameterBase *parameterFunction)
ParameterNamesType GetDescriptionParameterNames() const
unsigned int GetNumberOfOutputs() const override
GridArrayType GetGrid() const override
std::vector< CurveDescriptionParameterResultType > DescriptionParameterResultsType
std::vector< InputImagePixelType > InputPixelVectorType
std::vector< CurveDescriptionParameterNameType > DescriptionParameterNamesType
CurveDescriptionParameterBase::DescriptionParameterNamesType ParameterNamesType
std::vector< InputImagePixelType > OutputPixelVectorType
DescriptionParameterResultsType GetCurveDescriptionParameter(const CurveType &curve, const CurveGridType &grid) const
SimpleFunctorBase::GridArrayType GridArrayType
const CurveDescriptionParameterBase * GetDescriptionParameterFunction(const ParameterNameType &parameterName) const