15 #include "itkExceptionObject.h" 19 const auto beginPos = timeGrid.begin();
20 const auto endPos = timeGrid.end();
21 for(mitk::ModelBase::TimeGridType::const_iterator posTime = beginPos; posTime != endPos; ++posTime)
23 if (posTime != beginPos && *(posTime-1)<*posTime)
return false;
32 if (! inputSignal.GetSize())
37 if (inputSignal.GetSize() != inputGrid.GetSize())
39 itkGenericExceptionMacro(
"Input signal and input time grid have not the same size.");
45 mitk::ModelBase::TimeGridType::const_iterator posITime = inputGrid.begin();
46 mitk::ModelBase::ModelResultType::const_iterator posValue = inputSignal.begin();
47 mitk::ModelBase::ModelResultType::iterator posResult = result.begin();
49 for(mitk::ModelBase::TimeGridType::const_iterator posOTime = outputGrid.begin(); posOTime != outputGrid.end(); ++posResult, ++posOTime)
51 while(posITime!=inputGrid.end() && *posOTime > *posITime)
54 lastValue = *posValue;
60 double weightLast = 1 - (*posOTime - lastTime)/(*posITime - lastTime);
61 double weightNext = 1 - (*posITime - *posOTime)/(*posITime - lastTime);
63 *posResult = weightLast * lastValue + weightNext * (*posValue);
72 unsigned int origGridSize = grid.size();
76 for (
unsigned int t = 0; t < origGridSize - 1; ++t)
78 double delta = (grid[t + 1] - grid[t]) / samplingRate;
80 for (
unsigned int i = 0; i < samplingRate; ++i)
82 interpolatedTimeGrid[(t * samplingRate) + i] = grid[t] + i * delta;
86 interpolatedTimeGrid[interpolatedTimeGrid.size() - 1] = grid[grid.size() - 1];
88 return interpolatedTimeGrid;
MITKMODELFIT_EXPORT bool TimeGridIsMonotonIncreasing(const ModelBase::TimeGridType timeGrid)
itk::Array< double > TimeGridType
ValueType
Type of the value held by a Value object.
ModelTraitsInterface::ModelResultType ModelResultType
MITKMODELFIT_EXPORT ModelBase::ModelResultType InterpolateSignalToNewTimeGrid(const ModelBase::ModelResultType &inputSignal, const ModelBase::TimeGridType &inputGrid, const ModelBase::TimeGridType &outputGrid)
MITKMODELFIT_EXPORT ModelBase::TimeGridType GenerateSupersampledTimeGrid(const mitk::ModelBase::TimeGridType &grid, const unsigned int samplingRate)