mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-05 10:40:42 +00:00
Flip the sleep stage data to negative so that the chart is drawn in the right orientation.
Ideally graphs would be able to invert their Y axis without this hack, but it works for now. It would also be good to support non-numeric labels in the graph legend.
This commit is contained in:
parent
62880d1a00
commit
ab9d5e87c5
@ -663,7 +663,8 @@ void gGraph::roundY(EventDataType &miny, EventDataType &maxy)
|
||||
}
|
||||
}
|
||||
|
||||
if (miny < 0) {
|
||||
// Make the range symmetrical if there are both positive and negative values.
|
||||
if (miny < 0 && maxy > 0) {
|
||||
EventDataType tmp = qMax(qAbs(miny), qAbs(maxy));
|
||||
maxy = tmp;
|
||||
miny = -tmp;
|
||||
|
@ -120,7 +120,7 @@ Session* DreemLoader::readNextSession()
|
||||
QDateTime start_time, stop_time;
|
||||
int sleep_onset, sleep_duration;
|
||||
int light_sleep_duration, deep_sleep_duration, rem_duration, awakened_duration;
|
||||
int awakenings, position_changes, average_hr, average_rr;
|
||||
int awakenings, position_changes; // average_hr, average_rr;
|
||||
float sleep_efficiency;
|
||||
QStringList hypnogram;
|
||||
|
||||
@ -147,12 +147,13 @@ Session* DreemLoader::readNextSession()
|
||||
awakened_duration = readDuration(row["Wake After Sleep Onset Duration"]);
|
||||
awakenings = readInt(row["Number of awakenings"]);
|
||||
position_changes = readInt(row["Position Changes"]);
|
||||
average_hr = readInt(row["Mean Heart Rate"]);
|
||||
average_rr = readInt(row["Mean Respiration CPM"]);
|
||||
//average_hr = readInt(row["Mean Heart Rate"]); // TODO: sometimes "None"
|
||||
//average_rr = readInt(row["Mean Respiration CPM"]);
|
||||
// "Number of Stimulations" is 0 for US models
|
||||
sleep_efficiency = readInt(row["Sleep efficiency"]) / 100.0;
|
||||
|
||||
if (invalid_fields) {
|
||||
qWarning() << "invalid Dreem row, skipping" << start_time;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -177,8 +178,8 @@ Session* DreemLoader::readNextSession()
|
||||
sess->settings[ZEO_TimeInREM] = rem_duration / 60;
|
||||
sess->settings[ZEO_TimeInLight] = light_sleep_duration / 60;
|
||||
sess->settings[ZEO_TimeInDeep] = deep_sleep_duration / 60;
|
||||
sess->settings[OXI_Pulse] = average_hr;
|
||||
sess->settings[CPAP_RespRate] = average_rr;
|
||||
//sess->settings[OXI_Pulse] = average_hr;
|
||||
//sess->settings[CPAP_RespRate] = average_rr;
|
||||
// Dreem also provides:
|
||||
// total sleep duration
|
||||
// # position changes
|
||||
@ -194,7 +195,7 @@ Session* DreemLoader::readNextSession()
|
||||
qint64 tt = st;
|
||||
qint64 second_sample_tt = ((tt + step - 1L) / step) * step;
|
||||
|
||||
EventList *sleepstage = sess->AddEventList(ZEO_SleepStage, EVL_Event, 1, 0, 0, 4);
|
||||
EventList *sleepstage = sess->AddEventList(ZEO_SleepStage, EVL_Event, 1, 0, -4, 0);
|
||||
|
||||
for (int i = 0; i < hypnogram.size(); i++) {
|
||||
auto & label = hypnogram.at(i);
|
||||
@ -209,7 +210,8 @@ Session* DreemLoader::readNextSession()
|
||||
tt = last;
|
||||
}
|
||||
|
||||
sleepstage->AddEvent(tt, stage);
|
||||
if (stage == 0) qDebug() << start_time << "0 Dreem sleep stage?";
|
||||
sleepstage->AddEvent(tt, -stage); // use negative values so that the chart is oriented the right way
|
||||
}
|
||||
if (i == 0) {
|
||||
tt = second_sample_tt;
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "SleepLib/machine_loader.h"
|
||||
|
||||
const QString dreem_class_name = "Dreem";
|
||||
const int dreem_data_version = 1;
|
||||
const int dreem_data_version = 2;
|
||||
|
||||
|
||||
/*! \class DreemLoader
|
||||
|
@ -227,12 +227,15 @@ Session* ZEOLoader::readNextSession()
|
||||
st = qint64(start_of_night.toTime_t()) * 1000L;
|
||||
sess->really_set_first(st);
|
||||
tt = st;
|
||||
EventList *sleepstage = sess->AddEventList(ZEO_SleepStage, EVL_Event, 1, 0, 0, 4);
|
||||
EventList *sleepstage = sess->AddEventList(ZEO_SleepStage, EVL_Event, 1, 0, -4, 0);
|
||||
|
||||
for (int i = 0; i < DSG.size(); i++) {
|
||||
bool ok;
|
||||
stage = DSG[i].toInt(&ok);
|
||||
if (ok) {
|
||||
sleepstage->AddEvent(tt, stage);
|
||||
// 1 = Awake, 2 = REM, 3 = Light Sleep, 4 = Deep Sleep
|
||||
// TODO: What is 0? What is 6?
|
||||
sleepstage->AddEvent(tt, -stage); // use negative values so that the chart is oriented the right way
|
||||
}
|
||||
tt += WindowSize;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "SleepLib/machine_loader.h"
|
||||
|
||||
const QString zeo_class_name = "ZEO";
|
||||
const int zeo_data_version = 1;
|
||||
const int zeo_data_version = 2;
|
||||
|
||||
|
||||
/*! \class ZEOLoader
|
||||
|
Loading…
Reference in New Issue
Block a user