Oximeter min,max and avg cleanup

This commit is contained in:
Mark Watkins 2011-06-06 14:31:11 +10:00
parent 6970b7890c
commit 336ac05302
6 changed files with 75 additions and 42 deletions

View File

@ -8201,7 +8201,7 @@
"wx/treebase.h"
"wx/hashmap.h"
1307245704 source:/home/mark/projects/git/sleepyhead/src/GUIFrame.cpp
1307332633 source:/home/mark/projects/git/sleepyhead/src/GUIFrame.cpp
"wx/wxprec.h"
<wx/wx.h>
"GUIFrame.h"
@ -8312,7 +8312,7 @@
"preferences.h"
"tinyxml/tinyxml.h"
1307331240 source:/home/mark/projects/git/sleepyhead/src/SleepyHeadMain.cpp
1307333457 source:/home/mark/projects/git/sleepyhead/src/SleepyHeadMain.cpp
"wx_pch.h"
"version.h"
<wx/app.h>
@ -8331,7 +8331,7 @@
"sleeplib/profiles.h"
"sleeplib/machine_loader.h"
1307331318 source:/home/mark/projects/git/sleepyhead/src/graphs/graph.cpp
1307332921 source:/home/mark/projects/git/sleepyhead/src/graphs/graph.cpp
<wx/settings.h>
<wx/dcbuffer.h>
<wx/log.h>
@ -8412,7 +8412,7 @@
1307287644 /home/mark/projects/git/sleepyhead/src/libs/sleeplib/loader_plugins/cms50_loader.h
"sleeplib/machine_loader.h"
1307289931 source:/home/mark/projects/git/sleepyhead/src/libs/sleeplib/loader_plugins/cms50_loader.cpp
1307334532 source:/home/mark/projects/git/sleepyhead/src/libs/sleeplib/loader_plugins/cms50_loader.cpp
<wx/log.h>
<wx/progdlg.h>
"cms50_loader.h"

View File

@ -27,7 +27,7 @@ GUIFrame::GUIFrame( wxWindow* parent, wxWindowID id, const wxString& title, cons
menubar = new wxMenuBar( 0 );
FileMenu = new wxMenu();
wxMenuItem* FileMenuImportSD;
FileMenuImportSD = new wxMenuItem( FileMenu, wxID_ANY, wxString( _("&Import SD") ) + wxT('\t') + wxT("F9"), wxEmptyString, wxITEM_NORMAL );
FileMenuImportSD = new wxMenuItem( FileMenu, wxID_ANY, wxString( _("&Import Data") ) + wxT('\t') + wxT("F9"), wxEmptyString, wxITEM_NORMAL );
FileMenu->Append( FileMenuImportSD );
wxMenuItem* FileMenuPreferences;

View File

@ -577,16 +577,16 @@ Daily::Daily(wxWindow *win,Profile *p)
G_AHI->AddLayer(l);
AddOXIData(pulse=new SkipZeroData(OXI_Pulse,0,32768));
pulse->ForceMinY(40);
pulse->ForceMaxY(120);
//pulse->ForceMinY(40);
//pulse->ForceMaxY(120);
PULSE=new gGraphWindow(ScrolledWindow,-1,wxT("Pulse"),wxPoint(0,0), wxSize(600,130), wxNO_BORDER);
PULSE->AddLayer(new gLineChart(pulse,wxRED,32768,false,false,true));
PULSE->AddLayer(new gXAxis(wxBLACK));
AddOXIData(spo2=new SkipZeroData(OXI_SPO2,0,32768));
spo2->ForceMinY(60);
spo2->ForceMaxY(100);
//spo2->ForceMinY(60);
//spo2->ForceMaxY(100);
SPO2=new gGraphWindow(ScrolledWindow,-1,wxT("SpO2"),wxPoint(0,0), wxSize(600,130), wxNO_BORDER);
SPO2->AddLayer(new gLineChart(spo2,wxBLUE,32768,false,false,true));
SPO2->AddLayer(new gXAxis(wxBLACK));
@ -858,12 +858,12 @@ void Daily::RefreshData()
if (oxi) {
html=html+wxT("<tr><td colspan=2 align=center><i>")+_("Oximeter Information")+wxT("</i></td></tr>\n");
html=html+wxT("<tr><td><b>")+_("Pulse Avg")+wxT("</b></td><td>")+wxString::Format(wxT("%.1fcmH2O"),d->summary_avg(OXI_PulseAverage))+wxT("</td></tr>\n");
html=html+wxT("<tr><td><b>")+_("Pulse Min")+wxT("</b></td><td>")+wxString::Format(wxT("%.1fcmH2O"),d->summary_min(OXI_PulseMin))+wxT("</td></tr>\n");
html=html+wxT("<tr><td><b>")+_("Pulse Max")+wxT("</b></td><td>")+wxString::Format(wxT("%.1fcmH2O"),d->summary_max(OXI_PulseMax))+wxT("</td></tr>\n");
html=html+wxT("<tr><td><b>")+_("SpO2 Avg")+wxT("</b></td><td>")+wxString::Format(wxT("%.1fcmH2O"),d->summary_avg(OXI_SPO2Average))+wxT("</td></tr>\n");
html=html+wxT("<tr><td><b>")+_("SpO2 Min")+wxT("</b></td><td>")+wxString::Format(wxT("%.1fcmH2O"),d->summary_min(OXI_SPO2Min))+wxT("</td></tr>\n");
html=html+wxT("<tr><td><b>")+_("SpO2 Max")+wxT("</b></td><td>")+wxString::Format(wxT("%.1fcmH2O"),d->summary_max(OXI_SPO2Max))+wxT("</td></tr>\n");
html=html+wxT("<tr><td><b>")+_("Pulse Avg")+wxT("</b></td><td>")+wxString::Format(wxT("%.1fcmH2O"),oxi->summary_avg(OXI_PulseAverage))+wxT("</td></tr>\n");
html=html+wxT("<tr><td><b>")+_("Pulse Min")+wxT("</b></td><td>")+wxString::Format(wxT("%.1fcmH2O"),oxi->summary_min(OXI_PulseMin))+wxT("</td></tr>\n");
html=html+wxT("<tr><td><b>")+_("Pulse Max")+wxT("</b></td><td>")+wxString::Format(wxT("%.1fcmH2O"),oxi->summary_max(OXI_PulseMax))+wxT("</td></tr>\n");
html=html+wxT("<tr><td><b>")+_("SpO2 Avg")+wxT("</b></td><td>")+wxString::Format(wxT("%.1fcmH2O"),oxi->summary_avg(OXI_SPO2Average))+wxT("</td></tr>\n");
html=html+wxT("<tr><td><b>")+_("SpO2 Min")+wxT("</b></td><td>")+wxString::Format(wxT("%.1fcmH2O"),oxi->summary_min(OXI_SPO2Min))+wxT("</td></tr>\n");
html=html+wxT("<tr><td><b>")+_("SpO2 Max")+wxT("</b></td><td>")+wxString::Format(wxT("%.1fcmH2O"),oxi->summary_max(OXI_SPO2Max))+wxT("</td></tr>\n");
PULSE->Show(true);
SPO2->Show(true);
} else {

View File

@ -208,7 +208,7 @@
<property name="help"></property>
<property name="id">wxID_ANY</property>
<property name="kind">wxITEM_NORMAL</property>
<property name="label">&amp;Import SD</property>
<property name="label">&amp;Import Data</property>
<property name="name">FileMenuImportSD</property>
<property name="permission">none</property>
<property name="shortcut">F9</property>

View File

@ -1601,6 +1601,9 @@ void FlowData::Reload(Day *day)
m_ready=true;
//graph->Refresh(false);
}
// This can be merged back in with PressureData (and can be renamed while we are at it)
SkipZeroData::SkipZeroData(MachineCode _code,int _field,int _size)
:gPointData(_size),code(_code),field(_field)
{
@ -1622,7 +1625,7 @@ void SkipZeroData::Reload(Day *day)
min_y=max_y=0;
int tt=0;
bool first=true;
EventDataType lastp;
EventDataType lastp=0;
for (vector<Session *>::iterator s=day->begin();s!=day->end(); s++) {
if ((*s)->events.find(code)==(*s)->events.end()) continue;
if (vc>=(int)point.size()) {
@ -1630,7 +1633,7 @@ void SkipZeroData::Reload(Day *day)
}
int t=0;
EventDataType p; //,lastp=-1;
EventDataType p;
for (vector<Event *>::iterator ev=(*s)->events[code].begin(); ev!=(*s)->events[code].end(); ev++) {
p=(*(*ev))[field];
if (p!=0) {
@ -1639,6 +1642,7 @@ void SkipZeroData::Reload(Day *day)
assert(t<max_points);
if (first) {
max_y=min_y=r.y;
//lastp=p;
first=false;
} else {
if (r.y<min_y) min_y=r.y;
@ -1668,7 +1672,6 @@ void SkipZeroData::Reload(Day *day)
if (min_y>1) min_y-=1;
}
//}
if (force_min_y!=force_max_y) {
min_y=force_min_y;
max_y=force_max_y;

View File

@ -127,35 +127,62 @@ bool CMS50Loader::OpenSPORFile(wxString path,Machine *mach,Profile *profile)
if (br!=num_records) {
wxLogDebug(wxT("Short .spoR File: ")+path);
}
char last_pulse=buffer[0];
char last_spo2=buffer[1];
EventDataType data[2];
wxDateTime last_pulse_time=date;
wxDateTime last_spo2_time=date;
data[0]=last_pulse;
data[1]=last_spo2;
EventDataType last_pulse=buffer[0];
EventDataType last_spo2=buffer[1];
EventDataType cp,cs;
Session *sess=new Session(mach,sessid);
sess->set_first(date);
sess->AddEvent(new Event(date,OXI_Pulse,data,1));
sess->AddEvent(new Event(date,OXI_SPO2,&data[1],1));
sess->AddEvent(new Event(date,OXI_Pulse,&last_pulse,1));
sess->AddEvent(new Event(date,OXI_SPO2,&last_spo2,1));
EventDataType PMin,PMax=0,SMin,SMax=0,PAvg=0,SAvg=0;
int PCnt=0,SCnt=0;
//wxDateTime
wxDateTime tt=date;
bool first_p=true,first_s=true;
for (int i=2;i<num_records;i+=2) {
if (last_pulse!=buffer[i]) {
data[0]=buffer[i];
sess->AddEvent(new Event(tt,OXI_Pulse,data,1));
cp=buffer[i];
cs=buffer[i+1];
if (last_pulse!=cp) {
sess->AddEvent(new Event(tt,OXI_Pulse,&cp,1));
if (cp>0) {
if (first_p) {
PMin=cp;
first_p=false;
} else {
if (PMin>cp) PMin=cp;
}
PAvg+=cp;
PCnt++;
}
}
if (last_spo2!=buffer[i+1]) {
data[1]=buffer[i+1];
sess->AddEvent(new Event(tt,OXI_SPO2,&data[1],1));
if (last_spo2!=cs) {
sess->AddEvent(new Event(tt,OXI_SPO2,&cs,1));
if (cs>0) {
if (first_s) {
SMin=cs;
first_s=false;
} else {
if (SMin>cs) SMin=cs;
}
SAvg+=cs;
SCnt++;
}
}
last_pulse=buffer[i];
last_spo2=buffer[i+1];
last_pulse=cp;
last_spo2=cs;
if (PMax<cp) PMax=cp;
if (SMax<cs) SMax=cs;
tt+=wxTimeSpan::Seconds(1);
}
sess->AddEvent(new Event(tt,OXI_Pulse,data,1));
sess->AddEvent(new Event(tt,OXI_SPO2,&data[1],1));
sess->AddEvent(new Event(tt,OXI_Pulse,&cp,1));
sess->AddEvent(new Event(tt,OXI_SPO2,&cs,1));
sess->set_last(tt);
wxTimeSpan t=sess->last()-sess->first();
@ -163,12 +190,15 @@ bool CMS50Loader::OpenSPORFile(wxString path,Machine *mach,Profile *profile)
double hours=(t.GetSeconds().GetLo()/3600.0);
sess->set_hours(hours);
sess->summary[OXI_PulseAverage]=sess->weighted_avg_event_field(OXI_Pulse,0);
sess->summary[OXI_PulseMin]=sess->min_event_field(OXI_Pulse,0);
sess->summary[OXI_PulseMax]=sess->max_event_field(OXI_Pulse,0);
sess->summary[OXI_SPO2Average]=sess->weighted_avg_event_field(OXI_SPO2,0);
sess->summary[OXI_SPO2Min]=sess->min_event_field(OXI_SPO2,0);
sess->summary[OXI_SPO2Max]=sess->max_event_field(OXI_SPO2,0);
EventDataType pa=0,sa=0;
if (PCnt>0) pa=PAvg/double(PCnt);
if (SCnt>0) sa=SAvg/double(SCnt);
sess->summary[OXI_PulseAverage]=pa;
sess->summary[OXI_PulseMin]=PMin;
sess->summary[OXI_PulseMax]=PMax;
sess->summary[OXI_SPO2Average]=sa;
sess->summary[OXI_SPO2Min]=SMin;
sess->summary[OXI_SPO2Max]=SMax;
mach->AddSession(sess,profile);
sess->SetChanged(true);