Fixed bug with FlagsLine Span, minor speed improvement in Day weighted percentile calculation.

This commit is contained in:
Mark Watkins 2012-01-05 22:12:42 +10:00
parent 96ff7471d9
commit 935850faa6
5 changed files with 51 additions and 32 deletions

View File

@ -156,13 +156,15 @@ void gFlagsLine::paint(gGraph & w,int left, int top, int width, int height)
int np=el.count();
for (idx=0; idx < np; idx++) {
X=start + *tptr++;
L=*dptr++ * 1000;
X=start + *tptr;
L=*dptr * 1000;
if (X >= minx)
break;
X2=X-L;
if (X2 >= minx)
break;
dptr++;
tptr++;
}
np-=idx;
@ -211,12 +213,13 @@ void gFlagsLine::paint(gGraph & w,int left, int top, int width, int height)
if (X > maxx)
break;
L=*dptr++ * 1000;
L=*dptr++ * 1000L;
X2=X-L;
x1=(X - minx) * xmult + left;
x2=(X2-minx)*xmult+left;
quads->unsafe_add(x2,bartop,x1,bartop, x1,bottom,x2,bottom);
x1=double(X - minx) * xmult + left;
x2=double(X2 - minx) * xmult + left;
quads->add(x2,bartop,x1,bartop, x1,bottom,x2,bottom);
//if (quads->full()) { verts_exceeded=true; break; }
}

View File

@ -165,10 +165,11 @@ EventDataType Day::percentile(ChannelID code,EventDataType percentile)
QVector<Session *>::iterator s;
QMap<EventDataType, int> wmap;
QHash<EventStoreType, int> wmap;
int SN=0;
EventDataType lastgain=0, gain=0;
// First Calculate count of all events
for (s=sessions.begin();s!=sessions.end();s++) {
if (!(*s)->enabled()) continue;
@ -177,27 +178,42 @@ EventDataType Day::percentile(ChannelID code,EventDataType percentile)
QHash<ChannelID,QHash<EventStoreType, EventStoreType> > ::iterator ei=sess.m_valuesummary.find(code);
if (ei==sess.m_valuesummary.end()) continue;
EventDataType gain=sess.m_gain[code];
EventDataType weight,value;
gain=sess.m_gain[code];
// Here's assuming gains don't change accross a days sessions
// Can't assume this in any multi day calculations..
if (lastgain>0) {
if (gain!=lastgain) {
qDebug() << "Gains differ across sessions :(";
}
}
lastgain=gain;
int weight,value;
QHash<EventStoreType,int>::iterator wit;
for (QHash<EventStoreType, EventStoreType>::iterator i=ei.value().begin();i!=ei.value().end();i++) {
weight=i.value();
value=EventDataType(i.key())*gain;
value=i.key();
SN+=weight;
if (wmap.contains(value)) {
// Cheating here.. On first access, it initializes to zero
wmap[value]+=weight;
} else {
wmap[value]=weight;
}
// wit=wmap.find(value);
// if (wit==wmap.end()) {
// wmap[value]=weight;
// } else {
// wit.value()+=weight;
// }
}
}
QVector<ValueCount> valcnt;
// Build sorted list of value/counts
for (QMap<EventDataType, int>::iterator n=wmap.begin();n!=wmap.end();n++) {
for (QHash<EventStoreType, int>::iterator n=wmap.begin();n!=wmap.end();n++) {
ValueCount vc;
vc.value=n.key();
vc.value=EventDataType(n.key()) * gain;
vc.count=n.value();
vc.p=0;
valcnt.push_back(vc);
@ -213,7 +229,7 @@ EventDataType Day::percentile(ChannelID code,EventDataType percentile)
int sum1=0,sum2=0;
int w1,w2=0;
EventDataType v1,v2;
EventDataType v1=0,v2;
int N=valcnt.size();
int k=0;
@ -249,11 +265,9 @@ EventDataType Day::percentile(ChannelID code,EventDataType percentile)
return v;
// p1.....p.............p2
// 37 55 70
}
EventDataType Day::p90(ChannelID code)

View File

@ -710,8 +710,8 @@ EventDataType Profile::calcPercentile(ChannelID code, EventDataType percent, Mac
QMap<EventDataType, int> wmap;
QHash<ChannelID,QHash<EventStoreType, EventStoreType> >::iterator vsi;
EventDataType val,gain;
bool setgain=false;
EventDataType gain;
//bool setgain=false;
EventDataType weight,value;
int SN=0;
@ -768,7 +768,7 @@ EventDataType Profile::calcPercentile(ChannelID code, EventDataType percent, Mac
int sum1=0,sum2=0;
int w1,w2=0;
EventDataType v1,v2;
EventDataType v1=0,v2=0;
int N=valcnt.size();
int k=0;

View File

@ -724,7 +724,7 @@ void Daily::Load(QDate date)
//ui->graphVisibilityToggleArea->setVisible(true);
updateGraphCombo();
int graphsAvailable=GraphView->visibleGraphs();
//int graphsAvailable=GraphView->visibleGraphs();
// if (graphsAvailable>0) {
// GraphView->setCubeImage(images["sheep"]);
// GraphView->setEmptyText(tr("Graphs Switched Off"));
@ -1537,7 +1537,7 @@ void Daily::on_bookmarkTable_itemClicked(QTableWidgetItem *item)
bool ok;
st=it->data(Qt::UserRole).toLongLong(&ok);
et=it->data(Qt::UserRole+1).toLongLong(&ok);
qint64 st2,et2,st3,et3;
qint64 st2=0,et2=0,st3,et3;
Day * day=PROFILE.GetGoodDay(previous_date,MT_CPAP);
if (day) {
st2=day->first();

View File

@ -272,10 +272,10 @@ void SerialOximeter::compactToEvent(EventList *el)
{
if (el->count()<2) return;
EventList nel(EVL_Waveform);
EventDataType t,lastt=0; //el->data(0);
qint64 ti;//=el->time(0);
EventDataType t=0,lastt=0; //el->data(0);
qint64 ti=0;//=el->time(0);
//nel.AddEvent(ti,lastt);
bool f;
bool f=false;
qint64 lasttime=0;
EventDataType min=999,max=0;
for (quint32 i=0;i<el->count();i++) {
@ -1373,7 +1373,7 @@ bool Oximetry::openSPOFile(QString filename)
secondSPO2Update=true;
unsigned char o2,pr;
quint16 pl;
//quint16 pl;
qint64 tt=qint64(date.toTime_t())*1000L;
for (int i=pos;i<size-5;) {
@ -1382,7 +1382,9 @@ bool Oximetry::openSPOFile(QString filename)
//oximeter->setLastTime(tt);
oximeter->addPulse(tt,pr);
oximeter->addSpO2(tt,o2);
pl=(unsigned char)(data.at(i+1));
//pl=(unsigned char)(data.at(i+1));
//oximeter->addPlethy(tt,pl);
//pl=(unsigned char)(data.at(i+1));
//oximeter->addPlethy(tt,pl);
@ -1453,7 +1455,7 @@ bool Oximetry::openSPORFile(QString filename)
secondSPO2Update=true;
unsigned char o2,pr;
quint16 pl;
//quint16 pl;
qint64 tt=qint64(date.toTime_t())*1000L;
for (int i=pos;i<size-2;) {
@ -1461,7 +1463,7 @@ bool Oximetry::openSPORFile(QString filename)
pr=(unsigned char)(data.at(i+0));
oximeter->addPulse(tt,pr);
oximeter->addSpO2(tt,o2);
pl=(unsigned char)(data.at(i+1));
//pl=(unsigned char)(data.at(i+1));
i+=2;
tt+=1000;
}