18 #ifndef _MITK_PartialVolumeAnalysisClusteringCalculator_H
19 #define _MITK_PartialVolumeAnalysisClusteringCalculator_H
26 #include <itkObject.h>
27 #include <itkObjectFactory.h>
29 #include <itkRGBAPixel.h>
31 #include <vnl/vnl_vector.h>
53 this->xVals = p.
xVals;
54 this->hVals = p.
hVals;
65 this->xVals = p.
xVals;
66 this->hVals = p.
hVals;
73 xVals.set_size(histogram->GetSize()[0]);
74 hVals.set_size(histogram->GetSize()[0]);
75 double sum = histogram->GetTotalFrequency();
76 MitkHistType::ConstIterator endIt = histogram->End();
77 MitkHistType::ConstIterator it = histogram->Begin();
78 bool firstNonEmptyBinFound =
false;
83 if(it.GetFrequency() || firstNonEmptyBinFound)
85 firstNonEmptyBinFound =
true;
86 xVals(i) = it.GetMeasurementVector().GetElement(0);
87 hVals(i) = it.GetFrequency()/sum;
105 for(
int i=0; i<s; i++)
115 for(
int i=0; i<s; i++)
123 int s = xVals.size();
124 std::vector<double>* retval =
new std::vector<double>(s);
125 for(
int i=0; i<s; i++)
127 (*retval)[i] = xVals(i);
134 int s = hVals.size();
135 std::vector<double>* retval =
new std::vector<double>(s);
136 for(
int i=0; i<s; i++)
138 (*retval)[i] = hVals(i);
160 vals.push_back(VecType(sz));
161 vals.push_back(VecType(sz));
162 mixedVals.push_back(VecType(sz));
163 combiVals.set_size(sz);
204 this->mixedVals.clear();
206 int s = p->
vals.size();
207 for(
int i=0; i<s;i++)
209 VecType v = p->
vals[i];
210 this->vals.push_back(v);
214 for(
int i=0; i<s;i++)
217 this->mixedVals.push_back(v);
226 if(vals.size()==2 && vals[1].data_block())
228 int s = vals[1].size();
229 std::vector<double> retval(s);
230 for(
int i=0; i<s; i++)
232 retval[i] = vals[1](i);
238 MITK_ERROR <<
"GetFiberVals() struct not initialized!!";
239 return std::vector<double>(0);
245 if(vals.size()==2 && vals[0].data_block())
247 int s = vals[0].size();
248 std::vector<double> retval(s);
249 for(
int i=0; i<s; i++)
251 retval[i] = vals[0](i);
257 MITK_ERROR <<
"GetNonFiberVals() struct not initialized!!";
258 return std::vector<double>(0);
264 if(mixedVals.size()==1 && mixedVals[0].data_block())
266 int s = mixedVals[0].size();
267 std::vector<double> retval(s);
268 for(
int i=0; i<s; i++)
270 retval[i] = mixedVals[0](i);
276 MITK_ERROR <<
"GetMixedVals() struct not initialized!!";
277 return std::vector<double>(0);
283 if(combiVals.data_block())
285 int s = combiVals.size();
286 std::vector<double> retval(s);
287 for(
int i=0; i<s; i++)
289 retval[i] = combiVals(i);
295 MITK_ERROR <<
"GetCombiVals() struct not initialized!!";
296 return std::vector<double>(0);
346 means[0] = p->
means[0];
347 means[1] = p->
means[1];
399 rgbChannels(nullptr), params(nullptr), result(nullptr), hist(nullptr)
420 clusteredImage(nullptr), displayImage(nullptr),
421 params(nullptr), result(nullptr), hist(nullptr)
427 clusteredImage =
nullptr;
428 displayImage =
nullptr;
433 itkFactorylessNewMacro(Self)
436 ParamsType *InitialGuess(HistType h) const;
438 ParamsType *Cluster(const HistType h, ParamsType* initialGuess) const;
440 ClusterResultType CalculateCurves(ParamsType params, VecType xVals) const;
442 void Normalize(ParamsType params, ClusterResultType* curves) const;
444 HelperStructPerformClusteringRetval* PerformClustering(
mitk::
Image::
ConstPointer image, const MitkHistType *histogram,
int classIdent, HelperStructPerformClusteringRetval* precResult =
nullptr) const;
446 HelperStructPerformRGBClusteringRetval* PerformRGBClustering(
mitk::
Image::
ConstPointer image, const MitkHistType *histogram) const;
448 HelperStructPerformClusteringRetval* PerformQuantiles(
mitk::
Image::
ConstPointer image, const MitkHistType *histogram,
double p1,
double p2) const;
450 HelperStructPerformRGBClusteringRetval* PerformRGBQuantiles(
mitk::
Image::
ConstPointer image, const MitkHistType *histogram,
double p1,
double p2 ) const;
457 template <
unsigned int VImageDimension >
458 void InternalGenerateRGB( HelperStructRGBChannels *rgb,
mitk::
Image::
Pointer retval ) const;
460 template < typename TPixel,
unsigned int VImageDimension >
461 void InternalGenerateProbabilityImage(
462 const
itk::
Image< TPixel, VImageDimension > *image,
463 const HelperStructClusteringResults clusterResults,
466 template < typename TPixel,
unsigned int VImageDimension >
467 void InternalQuantify(
468 const
itk::
Image< TPixel, VImageDimension > *image,
471 template < typename TPixel,
unsigned int VImageDimension >
472 void InternalGenerateQuantileImage(
473 const
itk::
Image< TPixel, VImageDimension > *image,
478 {
return Cluster(h, InitialGuess(h));}
487 { m_StepsNumIntegration = n; }
490 {
return m_StepsNumIntegration; }
505 #endif // #define _MITK_PartialVolumeAnalysisClusteringCalculator_H
void InitByMitkHistogram(const MitkHistType *histogram)
unsigned int m_StepsNumIntegration
void Initialize(const ClusterResultType *p)
mitk::Image::HistogramType MitkHistType
unsigned int GetStepsNumIntegration()
std::vector< VecType > vals
MitkHistType * interestingHist
std::vector< double > GetNonFiberVals()
void SetHVals(std::vector< double > h)
DataCollection - Class to facilitate loading/accessing structured data.
std::vector< double > GetCombiVals()
std::vector< double > * GetHVals()
#define MITKDIFFUSIONCORE_EXPORT
void SetStepsNumIntegration(unsigned int n)
itk::Statistics::Histogram< double > HistogramType
HistType(const HistType &p)
std::vector< double > * GetXVals()
#define mitkClassMacroItkParent(className, SuperClassName)
std::vector< VecType > mixedVals
Image class for storing images.
std::vector< double > GetMixedVals()
~HelperStructRGBChannels()
void SetXVals(std::vector< double > x)
std::vector< double > GetFiberVals()
void SetMaxIt(unsigned int it)
void Normalize(itk::Image< TPixel, VImageDimension > *itkImage, mitk::Image::Pointer im2, mitk::Image::Pointer mask1, std::string output)
vnl_vector< double > VecType
ClusterResultType(int sz)
void Initialize(const ParamsType *p)