Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
QmitkPartialVolumeAnalysisWidget.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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
18 
19 #include <QPen>
20 #include <QFrame>
21 
23  : QmitkPlotWidget(parent)
24 {
25 // this->SetAxisTitle( QwtPlot::xBottom, "Grayvalue" );
26  // this->SetAxisTitle( QwtPlot::yLeft, "Probability" );
27 // this->Replot();
28  QFrame* canvas = qobject_cast<QFrame*>(m_Plot->canvas());
29  if (canvas)
30  {
31  canvas->setLineWidth(0);
32  canvas->setContentsMargins(0,0,0,0);
33  }
34 }
35 
36 
37 
39 {
40 }
41 
42 
44 {
45 
46 }
47 
48 
50 {
51 
52 }
53 
55 {
56  this->Clear();
57 
58  if(params != nullptr && results != nullptr)
59  {
60  for(unsigned int i=0; i<m_Vals.size(); i++)
61  {
62  delete m_Vals[i];
63  }
64 
65  m_Vals.clear();
66  m_Vals.push_back(hist->GetXVals());
67  m_Vals.push_back(hist->GetHVals());
68 
69 
70  std::vector<double> *xVals = hist->GetXVals();
71  std::vector<double> *fiberVals = new std::vector<double>(results->GetFiberVals());
72  std::vector<double> *nonFiberVals = new std::vector<double>(results->GetNonFiberVals());
73  std::vector<double> *mixedVals = new std::vector<double>(results->GetMixedVals());
74  std::vector<double> *combiVals = new std::vector<double>(results->GetCombiVals());
75 
76 
77  double fiberFA = 0.0;
78  double weights = 0.0;
79 
80  for(unsigned int i=0; i<xVals->size(); ++i)
81  {
82 
83  fiberFA += xVals->at(i) * fiberVals->at(i);
84  weights += fiberVals->at(i);
85  }
86 
87  fiberFA = fiberFA / weights;
88 
89  QPen pen( Qt::SolidLine );
90  pen.setWidth(1);
91 
92  QwtText plot_title("Compartment Histograms " );
93  plot_title.setFont( QFont("Helvetica", 10, QFont::Bold) );
94  this->SetPlotTitle( plot_title );
95 
96  pen.setColor(Qt::black);
97  int curveId = this->InsertCurve( "Histogram" );
98  this->SetCurveData( curveId, (*m_Vals[0]), (*m_Vals[1]) );
99  this->SetCurvePen( curveId, pen );
100  this->SetCurveAntialiasingOn( curveId );
101  // this->SetCurveTitle( curveId, "Image Histogram" );
102 
103  pen.setColor(Qt::blue);
104  pen.setWidth(2);
105  curveId = this->InsertCurve( "Combined" );
106  this->SetCurveData( curveId, (*hist->GetXVals()), (*combiVals) );
107  this->SetCurvePen( curveId, pen );
108  m_Vals.push_back(combiVals);
109  this->SetCurveAntialiasingOn( curveId );
110 
111 
112  curveId = this->InsertCurve( "Tissue class" );
113  this->SetCurveData(curveId, (*hist->GetXVals()), (*fiberVals));
114  this->SetCurvePen( curveId, QPen( Qt::NoPen ) );
115  this->SetCurveBrush(curveId, QBrush(QColor::fromRgbF(1,0,0,.5), Qt::SolidPattern));
116  m_Vals.push_back(fiberVals);
117 
118 
119  curveId = this->InsertCurve( "Non-tissue class" );
120  this->SetCurveData( curveId, (*hist->GetXVals()), (*nonFiberVals) );
121  this->SetCurvePen( curveId, QPen( Qt::NoPen ) );
122  this->SetCurveBrush(curveId, QBrush(QColor::fromRgbF(0,1,0,.5), Qt::SolidPattern));
123  m_Vals.push_back(nonFiberVals);
124 
125 
126  curveId = this->InsertCurve( "Mixed (PV) class" );
127  this->SetCurveData( curveId, (*hist->GetXVals()), (*mixedVals) );
128  this->SetCurvePen( curveId, QPen( Qt::NoPen ) );
129  this->SetCurveBrush(curveId, QBrush(QColor::fromRgbF(.7,.7,.7,.5), Qt::SolidPattern));
130  m_Vals.push_back(mixedVals);
131 
132  auto legend = new QwtLegend();
133  m_Plot->insertLegend( legend, QwtPlot::TopLegend );
134 
135  this->Replot();
136 
137 
138 
139  }
140 
141  this->Replot();
142 
143 }
144 
void SetPlotTitle(const QwtText &qwt_title)
std::vector< std::vector< double > * > m_Vals
void SetCurveAntialiasingOn(unsigned int curveId)
void SetCurvePen(unsigned int curveId, const QPen &pen)
unsigned int InsertCurve(const char *title, QColor color=QColor(Qt::black))
bool SetCurveData(unsigned int curveId, const DataVector &xValues, const DataVector &yValues)
void SetParameters(ParamsType *params, ResultsType *results, HistType *hist)
Set histogram to be displayed directly.
void SetCurveBrush(unsigned int curveId, const QBrush &brush)