mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-05 18:50:44 +00:00
Improved SpO2 Drop Detection algorithm
This commit is contained in:
parent
f8a134c26f
commit
64a0803806
@ -508,31 +508,43 @@ int calcSPO2Drop(Session *session)
|
|||||||
EventDataType lv=0;
|
EventDataType lv=0;
|
||||||
int li=0;
|
int li=0;
|
||||||
|
|
||||||
|
// Fix me.. Time scale varies.
|
||||||
const unsigned ringsize=10;
|
const unsigned ringsize=10;
|
||||||
EventDataType ring[ringsize];
|
EventDataType ring[ringsize]={0};
|
||||||
|
qint64 rtime[ringsize]={0};
|
||||||
int rp=0;
|
int rp=0;
|
||||||
int min;
|
int min;
|
||||||
|
int cnt=0;
|
||||||
for (int e=0;e<it.value().size();e++) {
|
for (int e=0;e<it.value().size();e++) {
|
||||||
EventList & el=*(it.value()[e]);
|
EventList & el=*(it.value()[e]);
|
||||||
for (unsigned i=0;i<el.count();i++) {
|
for (unsigned i=0;i<el.count();i++) {
|
||||||
val=el.data(i);
|
val=el.data(i);
|
||||||
if (!val) continue;
|
if (!val) continue;
|
||||||
ring[rp]=val;
|
ring[rp]=val;
|
||||||
|
time=el.time(i);
|
||||||
|
rtime[rp]=time;
|
||||||
rp++;
|
rp++;
|
||||||
rp=rp % ringsize;
|
rp=rp % ringsize;
|
||||||
if (i<ringsize) {
|
if (i<ringsize) {
|
||||||
for (unsigned j=i;j<ringsize;j++) {
|
for (unsigned j=i;j<ringsize;j++) {
|
||||||
ring[j]=val;
|
ring[j]=val;
|
||||||
|
rtime[j]=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tmp=0;
|
tmp=0;
|
||||||
|
cnt=0;
|
||||||
for (unsigned j=0;j<ringsize;j++) {
|
for (unsigned j=0;j<ringsize;j++) {
|
||||||
tmp+=ring[j];
|
if (rtime[j] > time-window) {
|
||||||
|
tmp+=ring[j];
|
||||||
|
cnt++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
tmp/=EventDataType(ringsize);
|
if (!cnt) {
|
||||||
|
unsigned j=abs((rp-1) % ringsize);
|
||||||
|
tmp=ring[j];
|
||||||
|
} else tmp/=EventDataType(cnt);
|
||||||
|
|
||||||
val=tmp;
|
val=tmp;
|
||||||
time=el.time(i);
|
|
||||||
lastt=0;
|
lastt=0;
|
||||||
lv=val;
|
lv=val;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user