MCPcopy Create free account
hub / github.com/MITK/MITK / NormalizeTimeSteps

Method NormalizeTimeSteps

Modules/CEST/src/mitkCESTImageNormalizationFilter.cpp:65–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63
64template <typename TPixel, unsigned int VImageDimension>
65void mitk::CESTImageNormalizationFilter::NormalizeTimeSteps(const itk::Image<TPixel, VImageDimension>* image)
66{
67 typedef itk::Image<TPixel, VImageDimension> ImageType;
68 typedef itk::Image<double, VImageDimension> OutputImageType;
69
70 auto offsets = ExtractCESTOffset(this->GetInput());
71
72 // determine normalization images
73 std::vector<unsigned int> mZeroIndices;
74 std::stringstream offsetsWithoutM0;
75 offsetsWithoutM0.imbue(std::locale("C"));
76 m_NonM0Indices.clear();
77 for (unsigned int index = 0; index < offsets.size(); ++index)
78 {
79 if ((offsets.at(index) < -299) || (offsets.at(index) > 299))
80 {
81 mZeroIndices.push_back(index);
82 }
83 else
84 {
85 offsetsWithoutM0 << offsets.at(index) << " ";
86 m_NonM0Indices.push_back(index);
87 }
88 }
89
90 auto resultImage = OutputImageType::New();
91 typename ImageType::RegionType targetEntireRegion = image->GetLargestPossibleRegion();
92 targetEntireRegion.SetSize(3, m_NonM0Indices.size());
93 resultImage->SetRegions(targetEntireRegion);
94 resultImage->Allocate();
95 resultImage->FillBuffer(0);
96
97 unsigned int numberOfTimesteps = image->GetLargestPossibleRegion().GetSize(3);
98
99 typename ImageType::RegionType lowerMZeroRegion = image->GetLargestPossibleRegion();
100 lowerMZeroRegion.SetSize(3, 1);
101 typename ImageType::RegionType upperMZeroRegion = image->GetLargestPossibleRegion();
102 upperMZeroRegion.SetSize(3, 1);
103 typename ImageType::RegionType sourceRegion = image->GetLargestPossibleRegion();
104 sourceRegion.SetSize(3, 1);
105 typename OutputImageType::RegionType targetRegion = resultImage->GetLargestPossibleRegion();
106 targetRegion.SetSize(3, 1);
107 unsigned int targetTimestep = 0;
108 for (unsigned int sourceTimestep = 0; sourceTimestep < numberOfTimesteps; ++sourceTimestep)
109 {
110 unsigned int lowerMZeroIndex = mZeroIndices[0];
111 unsigned int upperMZeroIndex = mZeroIndices[0];
112 for (unsigned int loop = 0; loop < mZeroIndices.size(); ++loop)
113 {
114 if (mZeroIndices[loop] <= sourceTimestep)
115 {
116 lowerMZeroIndex = mZeroIndices[loop];
117 }
118 if (mZeroIndices[loop] > sourceTimestep)
119 {
120 upperMZeroIndex = mZeroIndices[loop];
121 break;
122 }

Callers

nothing calls this directly

Calls 13

atMethod · 0.80
SetIndexMethod · 0.80
GetPointerMethod · 0.80
NewFunction · 0.50
EqualFunction · 0.50
GetInputMethod · 0.45
clearMethod · 0.45
sizeMethod · 0.45
SetSizeMethod · 0.45
GetSizeMethod · 0.45
GetMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected