mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-05 10:40:42 +00:00
Make PRS1 User flags search for nearby events to avoid double ups
This commit is contained in:
parent
e8d11f3337
commit
8813529f67
@ -7,10 +7,60 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include "calcs.h"
|
#include "calcs.h"
|
||||||
#include "profiles.h"
|
#include "profiles.h"
|
||||||
|
bool SearchApnea(Session *session, qint64 time, qint64 dist=15000)
|
||||||
|
{
|
||||||
|
qint64 t;
|
||||||
|
QHash<ChannelID,QVector<EventList *> >::iterator it;
|
||||||
|
it=session->eventlist.find(CPAP_Obstructive);
|
||||||
|
if (it!=session->eventlist.end()) {
|
||||||
|
for (int i=0;i<it.value().size();i++) {
|
||||||
|
EventList *el=it.value()[i];
|
||||||
|
for (unsigned j=0;j<el->count();j++) {
|
||||||
|
t=el->time(j);
|
||||||
|
if (qAbs(time-t)<dist)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
it=session->eventlist.find(CPAP_Apnea);
|
||||||
|
if (it!=session->eventlist.end()) {
|
||||||
|
for (int i=0;i<it.value().size();i++) {
|
||||||
|
EventList *el=it.value()[i];
|
||||||
|
for (unsigned j=0;j<el->count();j++) {
|
||||||
|
t=el->time(j);
|
||||||
|
if (qAbs(time-t)<dist)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
it=session->eventlist.find(CPAP_ClearAirway);
|
||||||
|
if (it!=session->eventlist.end()) {
|
||||||
|
for (int i=0;i<it.value().size();i++) {
|
||||||
|
EventList *el=it.value()[i];
|
||||||
|
for (unsigned j=0;j<el->count();j++) {
|
||||||
|
t=el->time(j);
|
||||||
|
if (qAbs(time-t)<dist)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
it=session->eventlist.find(CPAP_Hypopnea);
|
||||||
|
if (it!=session->eventlist.end()) {
|
||||||
|
for (int i=0;i<it.value().size();i++) {
|
||||||
|
EventList *el=it.value()[i];
|
||||||
|
for (unsigned j=0;j<el->count();j++) {
|
||||||
|
t=el->time(j);
|
||||||
|
if (qAbs(time-t)<dist)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Support function for calcRespRate()
|
// Support function for calcRespRate()
|
||||||
int filterFlow(EventList *in, EventList *out, EventList *tv, EventList *mv, double rate, EventList *uf1, EventList *uf2)
|
int filterFlow(Session *session, EventList *in, EventList *out, EventList *tv, EventList *mv, double rate)
|
||||||
{
|
{
|
||||||
|
|
||||||
int size=in->count();
|
int size=in->count();
|
||||||
@ -155,30 +205,6 @@ int filterFlow(EventList *in, EventList *out, EventList *tv, EventList *mv, doub
|
|||||||
breaths_max.push_back(max);
|
breaths_max.push_back(max);
|
||||||
min=0;
|
min=0;
|
||||||
|
|
||||||
// ringmax[rpos]=max;
|
|
||||||
// ringtime[rpos]=peakmax;
|
|
||||||
|
|
||||||
// int zz=ringsize;
|
|
||||||
// if (i<ringsize) {
|
|
||||||
// zz=i;
|
|
||||||
// }
|
|
||||||
// int j;
|
|
||||||
// if (max<=4)
|
|
||||||
// for (j=1;j<zz;j++) {
|
|
||||||
// int q=(rpos-j) & 0xff;
|
|
||||||
// if (ringmax[q]>4) {
|
|
||||||
// q--;
|
|
||||||
// q&=0xff;
|
|
||||||
// if ((peakmax-ringtime[q])>8000) {
|
|
||||||
// uf1->AddEvent(peakmax,(double(ringtime[q])/1000.0),max);
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// rpos++;
|
|
||||||
// rpos &= 0xff;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (c<=min) {
|
if (c<=min) {
|
||||||
@ -206,7 +232,6 @@ int filterFlow(EventList *in, EventList *out, EventList *tv, EventList *mv, doub
|
|||||||
for (int i=0;i<breaths_min.size();i++) {
|
for (int i=0;i<breaths_min.size();i++) {
|
||||||
min=breaths_min[i];
|
min=breaths_min[i];
|
||||||
avgmin+=min;
|
avgmin+=min;
|
||||||
//uf2->AddEvent(breaths_min_peak[i],0,min);
|
|
||||||
}
|
}
|
||||||
avgmin/=EventDataType(breaths_min.size());
|
avgmin/=EventDataType(breaths_min.size());
|
||||||
|
|
||||||
@ -226,12 +251,20 @@ int filterFlow(EventList *in, EventList *out, EventList *tv, EventList *mv, doub
|
|||||||
goodb.push_back(time);
|
goodb.push_back(time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
EventList *uf=NULL;
|
||||||
|
|
||||||
qSort(goodb);
|
qSort(goodb);
|
||||||
for (int i=1;i<goodb.size();i++) {
|
for (int i=1;i<goodb.size();i++) {
|
||||||
qint64 len=qAbs(goodb[i]-goodb[i-1]);
|
qint64 len=qAbs(goodb[i]-goodb[i-1]);
|
||||||
if (len>=10000) {
|
if (len>=10000) {
|
||||||
time=goodb[i-1]+len/2;
|
time=goodb[i-1]+len/2;
|
||||||
uf1->AddEvent(time,0,1);
|
if (!SearchApnea(session,time)) {
|
||||||
|
if (!uf) {
|
||||||
|
uf=new EventList(EVL_Event,1,0,0,0,0,true);
|
||||||
|
session->eventlist["UserFlag1"].push_back(uf);
|
||||||
|
}
|
||||||
|
uf->AddEvent(time,0,1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,7 +380,7 @@ int calcRespRate(Session *session)
|
|||||||
if (session->eventlist.contains(CPAP_RespRate))
|
if (session->eventlist.contains(CPAP_RespRate))
|
||||||
return 0; // already exists?
|
return 0; // already exists?
|
||||||
|
|
||||||
EventList *flow, *rr=NULL, *tv=NULL, *mv=NULL, *uf=NULL, *uf2=NULL;
|
EventList *flow, *rr=NULL, *tv=NULL, *mv=NULL;
|
||||||
|
|
||||||
if (!session->eventlist.contains(CPAP_TidalVolume)) {
|
if (!session->eventlist.contains(CPAP_TidalVolume)) {
|
||||||
tv=new EventList(EVL_Event);
|
tv=new EventList(EVL_Event);
|
||||||
@ -363,8 +396,6 @@ int calcRespRate(Session *session)
|
|||||||
if (rr) session->eventlist[CPAP_RespRate].push_back(rr);
|
if (rr) session->eventlist[CPAP_RespRate].push_back(rr);
|
||||||
if (tv) session->eventlist[CPAP_TidalVolume].push_back(tv);
|
if (tv) session->eventlist[CPAP_TidalVolume].push_back(tv);
|
||||||
if (mv) session->eventlist[CPAP_MinuteVent].push_back(mv);
|
if (mv) session->eventlist[CPAP_MinuteVent].push_back(mv);
|
||||||
uf=new EventList(EVL_Event,1,0,0,0,0,true);
|
|
||||||
session->eventlist["UserFlag1"].push_back(uf);
|
|
||||||
|
|
||||||
//uf2=new EventList(EVL_Event,1,0,0,0,0,true);
|
//uf2=new EventList(EVL_Event,1,0,0,0,0,true);
|
||||||
//session->eventlist["UserFlag2"].push_back(uf2);
|
//session->eventlist["UserFlag2"].push_back(uf2);
|
||||||
@ -373,16 +404,7 @@ int calcRespRate(Session *session)
|
|||||||
for (int ws=0; ws < session->eventlist[CPAP_FlowRate].size(); ws++) {
|
for (int ws=0; ws < session->eventlist[CPAP_FlowRate].size(); ws++) {
|
||||||
flow=session->eventlist[CPAP_FlowRate][ws];
|
flow=session->eventlist[CPAP_FlowRate][ws];
|
||||||
if (flow->count() > 5) {
|
if (flow->count() > 5) {
|
||||||
|
cnt+=filterFlow(session, flow,rr,tv,mv,flow->rate());
|
||||||
|
|
||||||
if (flow->count()==103200) {
|
|
||||||
int i=5;
|
|
||||||
}
|
|
||||||
cnt+=filterFlow(flow,rr,tv,mv,flow->rate(),uf,uf2);
|
|
||||||
|
|
||||||
if (tv->count()==0) {
|
|
||||||
int i=5;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return cnt;
|
return cnt;
|
||||||
|
@ -417,6 +417,7 @@ void Daily::UpdateEventsTree(QTreeWidget *tree,Day *day)
|
|||||||
&& (code!=CPAP_ClearAirway)
|
&& (code!=CPAP_ClearAirway)
|
||||||
&& (code!=CPAP_CSR)
|
&& (code!=CPAP_CSR)
|
||||||
&& (code!=CPAP_RERA)
|
&& (code!=CPAP_RERA)
|
||||||
|
&& (code!="UserFlag1")
|
||||||
&& (code!=CPAP_NRI)
|
&& (code!=CPAP_NRI)
|
||||||
&& (code!=CPAP_LeakFlag)
|
&& (code!=CPAP_LeakFlag)
|
||||||
&& (code!=CPAP_ExP)
|
&& (code!=CPAP_ExP)
|
||||||
|
@ -21,6 +21,7 @@ One id code per item
|
|||||||
<channel id="0x100a" class="data" name="LeakFlag" details="Leak Event" label="L" unit="events/hour" color="dark blue"/>
|
<channel id="0x100a" class="data" name="LeakFlag" details="Leak Event" label="L" unit="events/hour" color="dark blue"/>
|
||||||
<channel id="0x100b" class="data" name="NRI" details="Non-Responding Event" label="NRI" unit="events/hour" color="orange"/>
|
<channel id="0x100b" class="data" name="NRI" details="Non-Responding Event" label="NRI" unit="events/hour" color="orange"/>
|
||||||
<channel id="0x100c" class="data" name="EP" details="Exhale Puff" label="EP" unit="events/hour" color="dark magenta"/>
|
<channel id="0x100c" class="data" name="EP" details="Exhale Puff" label="EP" unit="events/hour" color="dark magenta"/>
|
||||||
|
<channel id="0x101f" class="data" name="UserFlag1" details="User Flag 1" label="UF1" unit="events/hour" color="dark cyan"/>
|
||||||
|
|
||||||
<channel id="0x1020" class="data" name="PressureMin" details="Min Therapy Pressure" label="PMin" color="black"/>
|
<channel id="0x1020" class="data" name="PressureMin" details="Min Therapy Pressure" label="PMin" color="black"/>
|
||||||
<channel id="0x1021" class="data" name="PressureMax" details="Max Therapy Pressure" label="PMax" color="black"/>
|
<channel id="0x1021" class="data" name="PressureMax" details="Max Therapy Pressure" label="PMax" color="black"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user