22 this->SetNumberOfIndexedInputs(2);
23 this->SetNumberOfIndexedOutputs(2);
39 void mitk::pa::SpectralUnmixingSO2::GenerateData()
47 CheckPreConditions(inputHbO2, inputHb);
49 unsigned int xDim = inputHbO2->GetDimensions()[0];
50 unsigned int yDim = inputHbO2->GetDimensions()[1];
51 unsigned int zDim = inputHbO2->GetDimensions()[2];
58 const float* inputDataArrayHbO2 = ((
const float*)readAccessHbO2.
GetData());
59 const float* inputDataArrayHb = ((
const float*)readAccessHb.
GetData());
65 float* writeBuffer = (
float *)writeOutput.
GetData();
68 float* writeBuffer1 = (
float *)writeOutput1.
GetData();
70 for (
unsigned int x = 0; x < xDim; x++)
72 for (
unsigned int y = 0; y < yDim; y++)
74 for (
unsigned int z = 0;z < zDim; z++)
76 unsigned int pixelNumber = (xDim*yDim * z) + x * yDim + y;
77 float pixelHb = inputDataArrayHb[pixelNumber];
78 float pixelHbO2 = inputDataArrayHbO2[pixelNumber];
79 float resultSO2 = CalculateSO2(pixelHb, pixelHbO2);
80 writeBuffer[(xDim*yDim * z) + x * yDim + y] = resultSO2;
81 float resultTHb = CalculateTHb(pixelHb, pixelHbO2);
82 writeBuffer1[(xDim*yDim * z) + x * yDim + y] = resultTHb;
91 unsigned int xDimHb = inputHb->GetDimensions()[0];
92 unsigned int yDimHb = inputHb->GetDimensions()[1];
93 unsigned int zDimHb = inputHb->GetDimensions()[2];
95 unsigned int xDimHbO2 = inputHbO2->GetDimensions()[0];
96 unsigned int yDimHbO2 = inputHbO2->GetDimensions()[1];
97 unsigned int zDimHbO2 = inputHbO2->GetDimensions()[2];
99 if (xDimHb != xDimHbO2 || yDimHb != yDimHbO2 || zDimHb != zDimHbO2)
102 if (inputHbO2->GetPixelType() != mitk::MakeScalarPixelType<float>())
103 mitkThrow() <<
"PIXELTYPE ERROR! FLOAT REQUIRED";
105 if (inputHb->GetPixelType() != mitk::MakeScalarPixelType<float>())
106 mitkThrow() <<
"PIXELTYPE ERROR! FLOAT REQUIRED";
111 void mitk::pa::SpectralUnmixingSO2::InitializeOutputs()
114 unsigned int numberOfOutputs = GetNumberOfIndexedOutputs();
117 const int NUMBER_OF_SPATIAL_DIMENSIONS = 3;
118 auto* dimensions =
new unsigned int[NUMBER_OF_SPATIAL_DIMENSIONS];
119 for(
unsigned int dimIdx=0; dimIdx<NUMBER_OF_SPATIAL_DIMENSIONS; dimIdx++)
124 for (
unsigned int outputIdx = 0; outputIdx < numberOfOutputs; outputIdx++)
126 GetOutput(outputIdx)->Initialize(pixelType, NUMBER_OF_SPATIAL_DIMENSIONS, dimensions);
130 float mitk::pa::SpectralUnmixingSO2::CalculateSO2(
float Hb,
float HbO2)
132 float result = HbO2 / (Hb + HbO2);
134 if (result != result)
141 if (SO2ValueNotSiginificant(Hb, HbO2, result))
149 float mitk::pa::SpectralUnmixingSO2::CalculateTHb(
float Hb,
float HbO2)
151 float result = (Hb + HbO2);
153 if (result != result)
169 bool mitk::pa::SpectralUnmixingSO2::SO2ValueNotSiginificant(
float Hb,
float HbO2,
float result)
171 std::vector<float> significant;
172 significant.push_back(HbO2);
173 significant.push_back(Hb);
174 significant.push_back(HbO2 + Hb);
175 significant.push_back(100*(result));
SpectralUnmixingSO2()
Constructor sets number of input images to two and number of output images to one, respectively.
unsigned int * GetDimensions() const
Get the sizes of all dimensions as an integer-array.
void * GetData()
Gives full data access.
virtual void AddSO2Settings(int value)
AddSO2Settings takes integers and writes them at the end of the m_SO2Settings vector.
std::vector< int > m_SO2Settings
~SpectralUnmixingSO2() override
InputImageType * GetInput(void)
OutputType * GetOutput()
Get the output data of this image source object.
ImageWriteAccessor class to get locked write-access for a particular image part.
ImageReadAccessor class to get locked read access for a particular image part.
const void * GetData() const
Gives const access to the data.
Class for defining the data type of pixels.
virtual void Verbose(bool verbose)
Verbose gives more information to the console. Default value is false.