Skip to content

Commit c6c6a80

Browse files
authored
Merge pull request #3 from dpscience/dpscience-local
preparing for release of version 3.01
2 parents 0b1c447 + 3056576 commit c6c6a80

17 files changed

Lines changed: 597 additions & 117 deletions

DLib/DPlot/plot2DXAxis.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ void plot2DXAxis::setAxisRange(double axisMin, double axisMax)
125125

126126
m_axisSpan = (m_axisMaxValue - m_axisMinValue);
127127

128-
if ( axisMax <= m_axisSpan )
129-
m_lastDisplayedValue = m_axisMaxValue;
128+
/*if ( axisMax <= m_axisSpan )
129+
m_lastDisplayedValue = m_axisMaxValue;*/
130130

131131
updateAxis();
132132

DLib/DPlot/plot2DXCanvas.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -218,16 +218,11 @@ void plot2DXCanvas::drawRect(const QPoint &pixel,
218218
void plot2DXCanvas::drawLine(const QList<QPoint> &pixelList,
219219
QPainter *painter)
220220
{
221-
QPainterPath path;
222-
223-
for ( int i = 0 ; i < pixelList.size() - 1 ; i ++ ){
224-
if ( i == 0 )
225-
path.moveTo(pixelList.at(i));
221+
QVector<QLineF> lineVec;
222+
for ( int i = 0 ; i < pixelList.size() - 1 ; i ++ )
223+
lineVec.append(QLineF(QPointF(pixelList.at(i)), QPointF(pixelList.at(i+1))));
226224

227-
path.lineTo(pixelList.at(i+1));
228-
}
229-
230-
painter->drawPath(path);
225+
painter->drawLines(lineVec);
231226
}
232227

233228
void plot2DXCanvas::drawCircle(const QPoint &pixel,

DLib/DPlot/plot2DXWidget.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ void plot2DXWidget::replot()
244244
const QPoint lastValue( xBottom()->ConvertToPixel(curve().at(index)->getLastValueBeforeReplot().x(),xBottom()->getAxisScaling()),
245245
yLeft()->ConvertToPixel(curve().at(index)->getLastValueBeforeReplot().y(),yLeft()->getAxisScaling()) );
246246

247-
cachePixelList.insert(0,lastValue);
247+
//cachePixelList.insert(0,lastValue);
248248
}
249249
break;
250250

@@ -254,7 +254,7 @@ void plot2DXWidget::replot()
254254
const QPoint lastValue( xTop()->ConvertToPixel(curve().at(index)->getLastValueBeforeReplot().x(),xTop()->getAxisScaling()),
255255
yLeft()->ConvertToPixel(curve().at(index)->getLastValueBeforeReplot().y(),yLeft()->getAxisScaling()) );
256256

257-
cachePixelList.insert(0,lastValue);
257+
//cachePixelList.insert(0,lastValue);
258258
}
259259
break;
260260

@@ -264,7 +264,7 @@ void plot2DXWidget::replot()
264264
const QPoint lastValue( xTop()->ConvertToPixel(curve().at(index)->getLastValueBeforeReplot().x(),xTop()->getAxisScaling()),
265265
yRight()->ConvertToPixel(curve().at(index)->getLastValueBeforeReplot().y(),yRight()->getAxisScaling()) );
266266

267-
cachePixelList.insert(0,lastValue);
267+
//cachePixelList.insert(0,lastValue);
268268
}
269269
break;
270270

@@ -274,7 +274,7 @@ void plot2DXWidget::replot()
274274
const QPoint lastValue( xBottom()->ConvertToPixel(curve().at(index)->getLastValueBeforeReplot().x(),xBottom()->getAxisScaling()),
275275
yRight()->ConvertToPixel(curve().at(index)->getLastValueBeforeReplot().y(),yRight()->getAxisScaling()) );
276276

277-
cachePixelList.insert(0,lastValue);
277+
//cachePixelList.insert(0,lastValue);
278278
}
279279
break;
280280

DLib/DXML/simplexml.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,10 @@ void DSimpleXMLNode::addChild(DSimpleXMLNode *childNode)
265265
m_childs.append(childNode);
266266
childNode->setParent(this);
267267
}
268-
269-
DERRORLOG("DSimpleXMLNode: !Child-Pointer is nullptr.");
268+
else
269+
{
270+
DERRORLOG("DSimpleXMLNode: !Child-Pointer is nullptr.");
271+
}
270272
}
271273

272274
QList<DSimpleXMLNode*> DSimpleXMLNode::getChilds() const

DQuickLTFit.pro.user

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE QtCreatorProject>
3-
<!-- Written by QtCreator 3.5.1, 2018-03-17T12:32:15. -->
3+
<!-- Written by QtCreator 3.5.1, 2018-03-27T09:12:50. -->
44
<qtcreator>
55
<data>
66
<variable>EnvironmentId</variable>

Fit/lifetimedecayfit.cpp

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,10 @@ void LifeTimeDecayFitEngine::updateDataStructureFromResult(PALSDataStructure *da
843843
QList<QPointF> residuals;
844844

845845
const double bkgrdVal = params[bkgrdIndex];
846+
double intergralCountsWithoutBkgrd = ((double)v->integralCountsInROI)-(v->stopChannel-v->startChannel)*bkgrdVal;
847+
double tZeroChannel = 0;
848+
int tZeroIndex = 0;
849+
double maxf = -1;
846850

847851
for ( int i = 0 ; i < v->dataCnt-1 ; ++ i )
848852
{
@@ -870,9 +874,15 @@ void LifeTimeDecayFitEngine::updateDataStructureFromResult(PALSDataStructure *da
870874

871875
x += v->startChannel;
872876

873-
f *= ((double)v->integralCountsInROI)-(v->stopChannel-v->startChannel)*bkgrdVal;
877+
f *= intergralCountsWithoutBkgrd;
874878
f += bkgrdVal;
875879

880+
if (f > maxf) {
881+
maxf = f;
882+
tZeroChannel = x;
883+
tZeroIndex = i;
884+
}
885+
876886
if ( !qFuzzyCompare(v->y[i], 0.0) )
877887
chiSquare += (f-v->y[i])*(f-v->y[i])/v->y[i];
878888

@@ -882,10 +892,26 @@ void LifeTimeDecayFitEngine::updateDataStructureFromResult(PALSDataStructure *da
882892
residuals.append(QPointF(x, res));
883893
}
884894

895+
//center of mass (spectral centroid):
896+
double tCenter = 0;
897+
double sumOfCounts = 0;
898+
for ( int i = tZeroIndex ; i < m_fitPlotSet.size()-1 ; ++ i ) {
899+
const double time = ((m_fitPlotSet.at(i).x()-tZeroChannel) + 0.5)*channelResolution;
900+
const double counts = 0.5*(m_fitPlotSet.at(i).y()+m_fitPlotSet.at(i+1).y());
901+
902+
tCenter += time*counts;
903+
sumOfCounts += counts;
904+
}
905+
906+
tCenter /= sumOfCounts;
907+
885908
chiSquare /= (double)v->dataCnt;
886909

887910
dataStructure->getFitSetPtr()->setChiSquareAfterFit(chiSquare);
888911

912+
dataStructure->getFitSetPtr()->setTZeroSpectralCentroid((tZeroChannel-v->startChannel)*channelResolution);
913+
dataStructure->getFitSetPtr()->setSpectralCentroid(tCenter);
914+
889915
dataStructure->getDataSetPtr()->setResiduals(residuals);
890916
dataStructure->getDataSetPtr()->setFitData(m_fitPlotSet);
891917

@@ -943,6 +969,10 @@ void LifeTimeDecayFitEngine::createResultString(PALSDataStructure *dataStructure
943969
const QString chiSquare("<nobr><b>&#935;<sup>2</sup>:</b></nobr>");
944970
const QString chiSquareVal("<nobr><b>" % QString::number(fitSet->getChiSquareAfterFit(), 'g', 4) % "</b> (" % QString::number(fitSet->getChiSquareOnStart(), 'g', 4) % " @ start)" % "</nobr>");
945971

972+
const QString fitWeighting("<nobr><b>Fit-Weighting:</b></nobr>");
973+
const QString fitWeightingVal("<nobr><b>" % QString((!fitSet->getUsingYVariance()?QString("no weighting"):QString("variance"))) % "</b></nobr>");
974+
975+
946976
const QString iterations("<nobr><b>Iterations:</b></nobr>");
947977
QString iterationsVal = "";
948978

@@ -961,14 +991,18 @@ void LifeTimeDecayFitEngine::createResultString(PALSDataStructure *dataStructure
961991
const QString channelResolutionVal("<nobr><b>" % QVariant(fitSet->getChannelResolution()).toString() % " </b>ps</nobr>");
962992

963993
const QString backgroundCounts("<nobr>Background:</nobr>");
964-
const QString backgroundCountsVal("<nobr><b>" % QVariant(fitSet->getBackgroundParamPtr()->getParameter()->getStartValue()).toString() % "</b></nobr>");
994+
const QString backgroundCountsVal("<nobr><b>" % QString::number(fitSet->getBackgroundParamPtr()->getParameter()->getStartValue(), 'f', 4) % "</b></nobr>");
965995

966996
const QString countsInRange("<nobr>Integral Counts in ROI:</nobr>");
967997
const QString countsInRangeVal("<nobr><b>" % QVariant(fitSet->getCountsInRange()).toString() % "</b></nobr>");
968998

969999
const QString peakToBackgroundRatio("<nobr>Peak-to-Background Ratio:</nobr>");
9701000
const QString peakToBackgroundRatioVal("<nobr><b>" % QString::number(fitSet->getPeakToBackgroundRation(), 'f', 3) % "</b></nobr>");
9711001

1002+
const QString centerOfMass("<nobr>Center of Mass:</nobr>");
1003+
const QString centerOfMassVal("<nobr><b>" % QString::number(fitSet->getSpectralCentroid(), 'f', 4) % " </b>ps (estimated t<sub>0</sub>: <b>" % QString::number(fitSet->getT0SpectralCentroid(), 'f', 4) % "</b> ps) - ROI: [" % QVariant(fitSet->getStartChannel()).toString() % ":" % QVariant(fitSet->getStopChannel()).toString() % "]</nobr>");
1004+
1005+
9721006
const QString fitParamCount("<nobr>Fit-Parameter Count:</nobr>");
9731007
const QString fitParamCountVal("<nobr><b>" % QVariant(fitSet->getComponentsCount()+fitSet->getDeviceResolutionParamPtr()->getSize()).toString() % "</b></nobr>");
9741008

@@ -995,6 +1029,7 @@ void LifeTimeDecayFitEngine::createResultString(PALSDataStructure *dataStructure
9951029
/*finish code and time/date:*/resultString = resultString % startRow % startContent % fitFinishCode % finishContent % startContent % fitFinishCodeVal % finishContent % finishRow % lineBreak;
9961030

9971031
/*chi-square:*/resultString = resultString % startRow % startContent % chiSquare % finishContent % startContent % chiSquareVal % finishContent % finishRow % lineBreak;
1032+
/*fit-weighting:*/resultString = resultString % startRow % startContent % fitWeighting % finishContent % startContent % fitWeightingVal % finishContent % finishRow % lineBreak;
9981033

9991034
/*iterations:*/resultString = resultString % startRow % startContent % iterations % finishContent % startContent % iterationsVal % finishContent % finishRow % lineBreak;
10001035

@@ -1007,6 +1042,8 @@ void LifeTimeDecayFitEngine::createResultString(PALSDataStructure *dataStructure
10071042
/*Counts in Range:*/resultString = resultString % startRow % startContent % countsInRange % finishContent % startContent % countsInRangeVal % finishContent % finishRow;
10081043
/*Peak-to-Background Ratio:*/resultString = resultString % startRow % startContent % peakToBackgroundRatio % finishContent % startContent % peakToBackgroundRatioVal % finishContent % finishRow % lineBreak;
10091044

1045+
/*Center-of-Mass:*/resultString = resultString % startRow % startContent % centerOfMass % finishContent % startContent % centerOfMassVal % finishContent % finishRow % lineBreak;
1046+
10101047
/*Fit-Parameter-Count:*/resultString = resultString % startRow % startContent % fitParamCount % finishContent % startContent % fitParamCountVal % finishContent % finishRow % lineBreak;
10111048

10121049

Settings/settings.cpp

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,16 @@ void PALSFitSet::setResidualPlotImage(const QImage &image)
384384
m_residualPlotImageNode->setValue("");
385385
}
386386

387+
void PALSFitSet::setSpectralCentroid(double center)
388+
{
389+
m_spectralCentroidNode->setValue(center);
390+
}
391+
392+
void PALSFitSet::setTZeroSpectralCentroid(double center)
393+
{
394+
m_t0spectralCentroidNode->setValue(center);
395+
}
396+
387397
double PALSFitSet::getChannelResolution() const
388398
{
389399
return m_channelResolutionNode->getValue().toDouble();
@@ -453,6 +463,26 @@ QImage PALSFitSet::getResidualPlotImage() const
453463
return QImage::fromData(img, "PNG");
454464
}
455465

466+
double PALSFitSet::getSpectralCentroid() const
467+
{
468+
bool ok = false;
469+
double center = m_spectralCentroidNode->getValue().toDouble(&ok);
470+
if (!ok)
471+
center = 0;
472+
473+
return center;
474+
}
475+
476+
double PALSFitSet::getT0SpectralCentroid() const
477+
{
478+
bool ok = false;
479+
double center = m_t0spectralCentroidNode->getValue().toDouble(&ok);
480+
if (!ok)
481+
center = 0;
482+
483+
return center;
484+
}
485+
456486
PALSDataSet *PALSDataStructure::getDataSetPtr() const
457487
{
458488
return m_dataSet;
@@ -513,6 +543,7 @@ PALSDataSet::PALSDataSet(PALSDataStructure *parent, const DSimpleXMLTag &tag)
513543

514544
safeTag = tag.getTag("data").getTag("bin-factor", &ok);
515545
if ( ok ) m_xyDataBinFac->setValue(safeTag.getValue());
546+
else m_xyDataBinFac->setValue(1);
516547

517548
safeTag = tag.getTag("data").getTag("lt-fit-data", &ok);
518549
if ( ok ) m_fitDataNode->setValue(safeTag.getValue());
@@ -749,6 +780,8 @@ PALSFitSet::PALSFitSet(PALSDataStructure *parent)
749780
m_sumOfIntensitiesNode = new DSimpleXMLNode("sum-of-intensities");
750781
m_dataPlotImageNode = new DSimpleXMLNode("data-plot-raw-image");
751782
m_residualPlotImageNode = new DSimpleXMLNode("residual-plot-raw-image");
783+
m_spectralCentroidNode = new DSimpleXMLNode("spectral-centroid");
784+
m_t0spectralCentroidNode = new DSimpleXMLNode("t0-spectral-centroid");
752785

753786
m_sourceParams = new PALSSourceParameter(this);
754787
m_deviceResolutionParams = new PALSDeviceResolutionParameter(this);
@@ -774,9 +807,11 @@ PALSFitSet::PALSFitSet(PALSDataStructure *parent)
774807
m_sumOfIntensitiesNode->setValue(0.0f);
775808
m_dataPlotImageNode->setValue("");
776809
m_residualPlotImageNode->setValue("");
810+
m_spectralCentroidNode->setValue(0.0f);
811+
m_t0spectralCentroidNode->setValue(0.0f);
777812

778813

779-
*m_parentNode << m_maxIterationsNode << m_neededIterationsNode << m_usingYVarianceNode << m_chiSquareOnStart << m_chiSquareAfterFit << m_channelResolutionNode << m_startChannelNode << m_stopChannelNode << m_averageLifeTimeNode << m_averageLifeTimeErrorNode << m_countsInRangeNode << m_dateTimeOfLastFitResultsNode << m_fitFinishCodeNode << m_fitFinishCodeValueNode << m_peakToBackgroundRatioNode << m_sumOfIntensitiesNode << m_dataPlotImageNode << m_residualPlotImageNode;
814+
*m_parentNode << m_maxIterationsNode << m_neededIterationsNode << m_usingYVarianceNode << m_t0spectralCentroidNode << m_spectralCentroidNode << m_chiSquareOnStart << m_chiSquareAfterFit << m_channelResolutionNode << m_startChannelNode << m_stopChannelNode << m_averageLifeTimeNode << m_averageLifeTimeErrorNode << m_countsInRangeNode << m_dateTimeOfLastFitResultsNode << m_fitFinishCodeNode << m_fitFinishCodeValueNode << m_peakToBackgroundRatioNode << m_sumOfIntensitiesNode << m_dataPlotImageNode << m_residualPlotImageNode;
780815
*(parent->getParent()) << m_parentNode;
781816
}
782817

@@ -802,6 +837,8 @@ PALSFitSet::PALSFitSet(PALSDataStructure *parent, const DSimpleXMLTag &tag)
802837
m_sumOfIntensitiesNode = new DSimpleXMLNode("sum-of-intensities");
803838
m_dataPlotImageNode = new DSimpleXMLNode("data-plot-raw-image");
804839
m_residualPlotImageNode = new DSimpleXMLNode("residual-plot-raw-image");
840+
m_spectralCentroidNode = new DSimpleXMLNode("spectral-centroid");
841+
m_t0spectralCentroidNode = new DSimpleXMLNode("t0-spectral-centroid");
805842

806843
m_sourceParams = new PALSSourceParameter(this, tag.getTag("fit"));
807844
m_deviceResolutionParams = new PALSDeviceResolutionParameter(this, tag.getTag("fit"));
@@ -826,6 +863,16 @@ PALSFitSet::PALSFitSet(PALSDataStructure *parent, const DSimpleXMLTag &tag)
826863
if ( ok ) m_usingYVarianceNode->setValue(safeTag.getValue());
827864
else m_usingYVarianceNode->setValue(false);
828865

866+
safeTag = tag.getTag("fit").getTag("spectral-centroid", &ok);
867+
868+
if ( ok ) m_spectralCentroidNode->setValue(safeTag.getValue());
869+
else m_spectralCentroidNode->setValue(0.0f);
870+
871+
safeTag = tag.getTag("fit").getTag("t0-spectral-centroid", &ok);
872+
873+
if ( ok ) m_t0spectralCentroidNode->setValue(safeTag.getValue());
874+
else m_t0spectralCentroidNode->setValue(0.0f);
875+
829876
safeTag = tag.getTag("fit").getTag("chi-square-start", &ok);
830877

831878
if ( ok ) m_chiSquareOnStart->setValue(safeTag.getValue());
@@ -902,7 +949,7 @@ PALSFitSet::PALSFitSet(PALSDataStructure *parent, const DSimpleXMLTag &tag)
902949
else m_residualPlotImageNode->setValue("");
903950

904951

905-
*m_parentNode << m_maxIterationsNode << m_neededIterationsNode << m_usingYVarianceNode << m_chiSquareOnStart << m_chiSquareAfterFit << m_channelResolutionNode << m_startChannelNode << m_stopChannelNode << m_averageLifeTimeNode << m_averageLifeTimeErrorNode << m_countsInRangeNode << m_dateTimeOfLastFitResultsNode << m_fitFinishCodeNode << m_fitFinishCodeValueNode << m_peakToBackgroundRatioNode << m_sumOfIntensitiesNode << m_dataPlotImageNode << m_residualPlotImageNode;
952+
*m_parentNode << m_maxIterationsNode << m_neededIterationsNode << m_usingYVarianceNode << m_t0spectralCentroidNode << m_spectralCentroidNode << m_chiSquareOnStart << m_chiSquareAfterFit << m_channelResolutionNode << m_startChannelNode << m_stopChannelNode << m_averageLifeTimeNode << m_averageLifeTimeErrorNode << m_countsInRangeNode << m_dateTimeOfLastFitResultsNode << m_fitFinishCodeNode << m_fitFinishCodeValueNode << m_peakToBackgroundRatioNode << m_sumOfIntensitiesNode << m_dataPlotImageNode << m_residualPlotImageNode;
906953
*(parent->getParent()) << m_parentNode;
907954
}
908955

@@ -916,6 +963,8 @@ PALSFitSet::~PALSFitSet()
916963
DDELETE_SAFETY(m_maxIterationsNode);
917964
DDELETE_SAFETY(m_neededIterationsNode);
918965
DDELETE_SAFETY(m_usingYVarianceNode);
966+
DDELETE_SAFETY(m_t0spectralCentroidNode);
967+
DDELETE_SAFETY(m_spectralCentroidNode);
919968
DDELETE_SAFETY(m_chiSquareOnStart);
920969
DDELETE_SAFETY(m_chiSquareAfterFit);
921970
DDELETE_SAFETY(m_channelResolutionNode);

Settings/settings.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ class PALSFitSet
207207
DSimpleXMLNode *m_dataPlotImageNode;
208208
DSimpleXMLNode *m_residualPlotImageNode;
209209

210+
DSimpleXMLNode *m_spectralCentroidNode;
211+
DSimpleXMLNode *m_t0spectralCentroidNode;
212+
210213

211214
PALSSourceParameter *m_sourceParams;
212215
PALSDeviceResolutionParameter *m_deviceResolutionParams;
@@ -251,6 +254,8 @@ SETTINGS_WRITE
251254
void setSumOfIntensities(double sum);
252255
void setDataPlotImage(const QImage& image);
253256
void setResidualPlotImage(const QImage& image);
257+
void setSpectralCentroid(double center);
258+
void setTZeroSpectralCentroid(double center);
254259

255260
SETTINGS_READ
256261
unsigned int getMaximumIterations() const;
@@ -272,6 +277,8 @@ SETTINGS_READ
272277
double getSumOfIntensities() const;
273278
QImage getDataPlotImage() const;
274279
QImage getResidualPlotImage() const;
280+
double getSpectralCentroid() const;
281+
double getT0SpectralCentroid() const;
275282
};
276283

277284
class PALSResultHistorie

TestData/TestData.dquicklt

Lines changed: 40 additions & 38 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)