19 #include <qwt_scale_engine.h>
20 #include <qwt_legend.h>
25 QFrame* canvas = qobject_cast< QFrame* >(
m_Plot->canvas() );
28 canvas->setLineWidth(0);
29 canvas->setContentsMargins(0, 0, 0, 0);
49 auto logScale =
new QwtLogScaleEngine();
50 m_Plot->setAxisScaleEngine(0, logScale );
51 m_Plot->setAxisScale(0, 0.1, max_y_val );
53 QString s(
"D=%1, K=%2");
54 s = s.arg( snap.
m_D, 4); s = s.arg( snap.
m_K, 4);
57 int curveId = this->
InsertCurve( s.toLatin1(), QColor( Qt::black ) );
61 pen.setColor( QColor( Qt::red ));
63 pen.setStyle( Qt::PenStyle::DashLine );
66 const double max_bvalue = snap.
bvalues.max_value();
72 double y_bzero = measured_values[0];
82 std::vector<double> single_bzero;
83 single_bzero.push_back(0);
85 std::vector<double> fitted_bzero;
88 auto c_measurements_bzero = this->
InsertCurve(
"Fitted b=0" );
89 this->
SetCurveData( c_measurements_bzero, single_bzero, fitted_bzero );
90 this->
SetCurvePen( c_measurements_bzero, QPen(Qt::NoPen) );
91 QwtSymbol* blackDiamond =
new QwtSymbol(QwtSymbol::Diamond, QColor(Qt::black), QColor(Qt::black), QSize(8,8));
100 auto measurements_curve = this->
InsertCurve(
"Measured values" );
102 this->
SetCurvePen( measurements_curve, QPen(Qt::NoPen) );
103 QwtSymbol* redDiamond =
new QwtSymbol(QwtSymbol::Diamond, QColor(Qt::red), QColor(Qt::red), QSize(8,8));
109 pen.setColor( QColor( Qt::black ));
110 pen.setStyle( Qt::SolidLine );
111 const unsigned int num_samples = 50;
113 vnl_vector<double> x_K_model(num_samples);
114 vnl_vector<double> y_K_model(num_samples);
116 vnl_vector<double> y_D_model(num_samples);
118 const double x_tics_offset = max_bvalue /
static_cast<double>( num_samples );
120 for(
unsigned int i=0; i<num_samples; ++i)
122 x_K_model[i] = i * x_tics_offset;
124 double bval = x_K_model[i];
125 y_K_model[i] = y_bzero * exp( -bval * snap.
m_D + bval*bval * snap.
m_D * snap.
m_D * snap.
m_K / 6.0 );
126 y_D_model[i] = y_bzero * exp( -bval * snap.
m_D );
129 auto kurtosis_curve = this->
InsertCurve(
"Resulting fit of the model" );
130 this->
SetCurveData( kurtosis_curve, toStdVec( x_K_model ), toStdVec( y_K_model ) );
134 auto d_curve = this->
InsertCurve(
"D-part of the fitted model" );
135 this->
SetCurveData( d_curve, toStdVec( x_K_model ), toStdVec( y_D_model ) );
137 pen.setColor( QColor( Qt::red));
138 pen.setStyle( Qt::PenStyle::DashLine );
145 auto legend =
new QwtLegend();
146 legend->setMaxColumns(3);
147 m_Plot->insertLegend( legend, QwtPlot::BottomLegend );
152 std::vector<double> QmitkKurtosisWidget::toStdVec(
const vnl_vector<double>& vector)
154 std::vector<double> retval(vector.size());
155 for(
unsigned int i=0; i<vector.size(); i++)
157 retval.at(i) = vector[i];
vnl_vector< double > measurements
Struct describing a result (and the data) of a Kurtosis model fit.
vnl_vector< double > bvalues