mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-05 10:40:42 +00:00
Added second User Event Flag detection and preferences
This commit is contained in:
parent
7c54c8d13b
commit
4cf6c41f9a
@ -35,6 +35,12 @@ bool SearchApnea(Session *session, qint64 time, qint64 dist)
|
||||
if (session->SearchEvent(CPAP_Hypopnea, time, dist))
|
||||
return true;
|
||||
|
||||
if (session->SearchEvent(CPAP_UserFlag1, time, dist))
|
||||
return true;
|
||||
|
||||
if (session->SearchEvent(CPAP_UserFlag2, time, dist))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -614,29 +620,21 @@ void FlowParser::calc(bool calcResp, bool calcTv, bool calcTi, bool calcTe, bool
|
||||
}
|
||||
}
|
||||
|
||||
void FlowParser::flagEvents()
|
||||
void FlowParser::flagUserEvents(ChannelID code, EventDataType restriction, EventDataType duration)
|
||||
{
|
||||
if (!p_profile->cpap->userEventFlagging()) { return; }
|
||||
|
||||
int numbreaths = breaths.size();
|
||||
|
||||
if (numbreaths < 5) { return; }
|
||||
|
||||
EventDataType val, mx, mn;
|
||||
QVector<EventDataType> br;
|
||||
|
||||
QVector<qint32> bstart;
|
||||
QVector<qint32> bend;
|
||||
//QVector<EventDataType> bvalue;
|
||||
|
||||
bstart.reserve(numbreaths * 2);
|
||||
bend.reserve(numbreaths * 2);
|
||||
//bvalue.reserve(numbreaths*2);
|
||||
br.reserve(numbreaths * 2);
|
||||
|
||||
double start = m_flow->first();
|
||||
// double sps=1000.0/m_rate;
|
||||
double st, et, dur; //mt
|
||||
double st, et, dur;
|
||||
qint64 len;
|
||||
|
||||
bool allowDuplicates = p_profile->cpap->userEventDuplicates();
|
||||
@ -649,23 +647,13 @@ void FlowParser::flagEvents()
|
||||
br.push_back(qAbs(p->min));
|
||||
}
|
||||
|
||||
// for (int i = 0; i < numbreaths; i++) {
|
||||
// mx = breaths[i].max;
|
||||
// mn = breaths[i].min;
|
||||
// br.push_back(qAbs(mx));
|
||||
// br.push_back(qAbs(mn));
|
||||
// }
|
||||
|
||||
//EventList * uf2=m_session->AddEventList(CPAP_UserFlag2,EVL_Event);
|
||||
//EventList * uf3=m_session->AddEventList(CPAP_UserFlag3,EVL_Event);
|
||||
|
||||
const EventDataType perc = 0.6F;
|
||||
int idx = float(br.size()) * perc;
|
||||
nth_element(br.begin(), br.begin() + idx, br.end() - 1);
|
||||
|
||||
EventDataType peak = br[idx]; //*(br.begin()+idx);
|
||||
EventDataType peak = br[idx]; ;
|
||||
|
||||
EventDataType cutoffval = peak * (p_profile->cpap->userFlowRestriction() / 100.0F);
|
||||
EventDataType cutoffval = peak * (restriction / 100.0F);
|
||||
|
||||
int bs, bm, be, bs1, bm1, be1;
|
||||
|
||||
@ -675,16 +663,8 @@ void FlowParser::flagEvents()
|
||||
be = p->end;
|
||||
mx = p->max;
|
||||
mn = p->min;
|
||||
// for (int i = 0; i < numbreaths; i++) {
|
||||
// bs = breaths[i].start;
|
||||
// bm = breaths[i].middle;
|
||||
// be = breaths[i].end;
|
||||
|
||||
// mx = breaths[i].max;
|
||||
// mn = breaths[i].min;
|
||||
val = mx - mn;
|
||||
|
||||
// if (qAbs(mx) > cutoffval) {
|
||||
bs1 = bs;
|
||||
|
||||
for (; bs1 < be; bs1++) {
|
||||
@ -706,8 +686,6 @@ void FlowParser::flagEvents()
|
||||
bend.push_back(bm1);
|
||||
}
|
||||
|
||||
// }
|
||||
// if (qAbs(mn) > cutoffval) {
|
||||
bm1 = bm;
|
||||
|
||||
for (; bm1 < be; bm1++) {
|
||||
@ -729,20 +707,12 @@ void FlowParser::flagEvents()
|
||||
bend.push_back(be1);
|
||||
}
|
||||
|
||||
// }
|
||||
st = start + bs1 * m_rate;
|
||||
et = start + be1 * m_rate;
|
||||
// uf2->AddEvent(st,0);
|
||||
// uf3->AddEvent(et,0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
EventDataType duration = p_profile->cpap->userEventDuration();
|
||||
//double lastst=start, lastet=start;
|
||||
//EventDataType v;
|
||||
int bsize = bstart.size();
|
||||
EventList *uf1 = nullptr;
|
||||
EventList *uf = nullptr;
|
||||
|
||||
for (int i = 0; i < bsize - 1; i++) {
|
||||
bs = bend[i];
|
||||
@ -755,16 +725,28 @@ void FlowParser::flagEvents()
|
||||
|
||||
if (dur >= duration) {
|
||||
if (allowDuplicates || !SearchApnea(m_session, et - len / 2, 15000)) {
|
||||
if (!uf1) {
|
||||
uf1 = m_session->AddEventList(CPAP_UserFlag1, EVL_Event);
|
||||
if (!uf) {
|
||||
uf = m_session->AddEventList(code, EVL_Event);
|
||||
}
|
||||
|
||||
uf1->AddEvent(et, dur);
|
||||
uf->AddEvent(et, dur);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FlowParser::flagEvents()
|
||||
{
|
||||
if (!p_profile->cpap->userEventFlagging()) { return; }
|
||||
|
||||
int numbreaths = breaths.size();
|
||||
|
||||
if (numbreaths < 5) { return; }
|
||||
|
||||
flagUserEvents(CPAP_UserFlag1, p_profile->cpap->userFlowRestriction(), p_profile->cpap->userEventDuration());
|
||||
flagUserEvents(CPAP_UserFlag2, p_profile->cpap->userFlowRestriction2(), p_profile->cpap->userEventDuration2());
|
||||
}
|
||||
|
||||
void calcRespRate(Session *session, FlowParser *flowparser)
|
||||
{
|
||||
if (session->machine()->GetType() != MT_CPAP) { return; }
|
||||
|
@ -115,6 +115,7 @@ class FlowParser
|
||||
// Minute vent needs Resp & TV calcs made here..
|
||||
void calc(bool calcResp, bool calcTv, bool calcTi, bool calcTe, bool calcMv);
|
||||
void flagEvents();
|
||||
void flagUserEvents(ChannelID code, EventDataType restriction, EventDataType duration);
|
||||
|
||||
/*void calcTidalVolume();
|
||||
void calcRespRate();
|
||||
|
@ -273,6 +273,8 @@ const QString STR_CS_DateDiagnosed = "DateDiagnosed";
|
||||
const QString STR_CS_UserEventFlagging = "UserEventFlagging";
|
||||
const QString STR_CS_UserFlowRestriction = "UserFlowRestriction";
|
||||
const QString STR_CS_UserEventDuration = "UserEventDuration";
|
||||
const QString STR_CS_UserFlowRestriction2 = "UserFlowRestriction2";
|
||||
const QString STR_CS_UserEventDuration2 = "UserEventDuration2";
|
||||
const QString STR_CS_UserEventDuplicates = "UserEventDuplicates";
|
||||
const QString STR_CS_AHIWindow = "AHIWindow";
|
||||
const QString STR_CS_AHIReset = "AHIReset";
|
||||
@ -514,7 +516,9 @@ class CPAPSettings : public ProfileSettings
|
||||
initPref(STR_CS_Notes, QString());
|
||||
initPref(STR_CS_DateDiagnosed, QDate());
|
||||
initPref(STR_CS_UserFlowRestriction, 20.0);
|
||||
initPref(STR_CS_UserEventDuration, 10.0);
|
||||
initPref(STR_CS_UserEventDuration, 8.0);
|
||||
initPref(STR_CS_UserFlowRestriction2, 50.0);
|
||||
initPref(STR_CS_UserEventDuration2, 8.0);
|
||||
initPref(STR_CS_UserEventDuplicates, false);
|
||||
initPref(STR_CS_UserEventFlagging, false);
|
||||
initPref(STR_CS_AHIWindow, 60.0);
|
||||
@ -541,6 +545,8 @@ class CPAPSettings : public ProfileSettings
|
||||
QDate dateDiagnosed() const { return getPref(STR_CS_DateDiagnosed).toDate(); }
|
||||
double userFlowRestriction() const { return getPref(STR_CS_UserFlowRestriction).toDouble(); }
|
||||
double userEventDuration() const { return getPref(STR_CS_UserEventDuration).toDouble(); }
|
||||
double userFlowRestriction2() const { return getPref(STR_CS_UserFlowRestriction2).toDouble(); }
|
||||
double userEventDuration2() const { return getPref(STR_CS_UserEventDuration2).toDouble(); }
|
||||
bool userEventDuplicates() const { return getPref(STR_CS_UserEventDuplicates).toBool(); }
|
||||
double AHIWindow() const { return getPref(STR_CS_AHIWindow).toDouble(); }
|
||||
bool AHIReset() const { return getPref(STR_CS_AHIReset).toBool(); }
|
||||
@ -563,6 +569,8 @@ class CPAPSettings : public ProfileSettings
|
||||
void setMaskType(MaskType masktype) { setPref(STR_CS_MaskType, (int)masktype); }
|
||||
void setUserFlowRestriction(double flow) { setPref(STR_CS_UserFlowRestriction, flow); }
|
||||
void setUserEventDuration(double duration) { setPref(STR_CS_UserEventDuration, duration); }
|
||||
void setUserFlowRestriction2(double flow) { setPref(STR_CS_UserFlowRestriction2, flow); }
|
||||
void setUserEventDuration2(double duration) { setPref(STR_CS_UserEventDuration2, duration); }
|
||||
void setAHIWindow(double window) { setPref(STR_CS_AHIWindow, window); }
|
||||
void setAHIReset(bool reset) { setPref(STR_CS_AHIReset, reset); }
|
||||
void setUserEventFlagging(bool flagging) { setPref(STR_CS_UserEventFlagging, flagging); }
|
||||
|
@ -242,6 +242,8 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Profile *_profile) :
|
||||
ui->customEventGroupbox->setChecked(profile->cpap->userEventFlagging());
|
||||
ui->apneaDuration->setValue(profile->cpap->userEventDuration());
|
||||
ui->apneaFlowRestriction->setValue(profile->cpap->userFlowRestriction());
|
||||
ui->apneaDuration2->setValue(profile->cpap->userEventDuration2());
|
||||
ui->apneaFlowRestriction2->setValue(profile->cpap->userFlowRestriction2());
|
||||
ui->userEventDuplicates->setChecked(profile->cpap->userEventDuplicates());
|
||||
ui->userEventDuplicates->setVisible(false);
|
||||
|
||||
@ -355,7 +357,9 @@ bool PreferencesDialog::Save()
|
||||
|
||||
if (profile->cpap->userEventFlagging() &&
|
||||
(profile->cpap->userEventDuration() != ui->apneaDuration->value() ||
|
||||
profile->cpap->userEventDuration2() != ui->apneaDuration2->value() ||
|
||||
profile->cpap->userEventDuplicates() != ui->userEventDuplicates->isChecked() ||
|
||||
profile->cpap->userFlowRestriction2() != ui->apneaFlowRestriction2->value() ||
|
||||
profile->cpap->userFlowRestriction() != ui->apneaFlowRestriction->value())) {
|
||||
recalc_events = true;
|
||||
}
|
||||
@ -478,6 +482,9 @@ bool PreferencesDialog::Save()
|
||||
|
||||
profile->cpap->setUserEventDuration(ui->apneaDuration->value());
|
||||
profile->cpap->setUserFlowRestriction(ui->apneaFlowRestriction->value());
|
||||
profile->cpap->setUserEventDuration2(ui->apneaDuration2->value());
|
||||
profile->cpap->setUserFlowRestriction2(ui->apneaFlowRestriction2->value());
|
||||
|
||||
profile->cpap->setUserEventDuplicates(ui->userEventDuplicates->isChecked());
|
||||
|
||||
PREF[STR_GEN_SkipLogin] = ui->skipLoginScreen->isChecked();
|
||||
|
@ -51,7 +51,7 @@
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="importTab">
|
||||
<attribute name="title">
|
||||
@ -878,19 +878,6 @@ This option must be enabled before import, otherwise a purge is required.</strin
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_35">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Flow Restriction</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="apneaFlowRestriction">
|
||||
<property name="sizePolicy">
|
||||
@ -924,6 +911,19 @@ A value of 20% works well for detecting apneas. </string>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_35">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Flow Restriction</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="5">
|
||||
<widget class="QLabel" name="label_34">
|
||||
<property name="sizePolicy">
|
||||
@ -975,7 +975,41 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="4">
|
||||
<item row="3" column="1">
|
||||
<widget class="QDoubleSpinBox" name="apneaFlowRestriction2">
|
||||
<property name="suffix">
|
||||
<string>%</string>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>10.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_50">
|
||||
<property name="text">
|
||||
<string>#2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QDoubleSpinBox" name="apneaDuration2">
|
||||
<property name="suffix">
|
||||
<string>s</string>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>10.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_49">
|
||||
<property name="text">
|
||||
<string>#1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="4">
|
||||
<widget class="QCheckBox" name="userEventDuplicates">
|
||||
<property name="text">
|
||||
<string>Allow duplicates near machine events.</string>
|
||||
|
Loading…
Reference in New Issue
Block a user