Constrain ResMed EDF Flow waveform data to within physical min/max values

This commit is contained in:
Mark Watkins 2015-09-21 10:02:15 +10:00
parent 7a7873bab2
commit 204d77e7b0
3 changed files with 10 additions and 5 deletions

View File

@ -428,8 +428,6 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion &region)
w.roundY(miny, maxy);
//#define DEBUG_AUTOSCALER
#ifdef DEBUG_AUTOSCALER
QString a = QString().sprintf("%.2f - %.2f",miny, maxy);

View File

@ -169,7 +169,7 @@ void EventList::AddWaveform(qint64 start, qint16 *data, int recs, qint64 duratio
if (m_update_minmax) {
EventDataType min = m_min, max = m_max, val, gain = m_gain;
for (int i=0; i < recs; ++i ) {
for (int i=0; i < recs; ++i) {
m_data[r++] = raw = *sp++;
val = EventDataType(raw) * gain + m_offset;
if (min > val) { min = val; }

View File

@ -2647,8 +2647,15 @@ bool ResmedLoader::LoadBRP(Session *sess, const QString & path)
EventList *a = sess->AddEventList(code, EVL_Waveform, es.gain, es.offset, 0, 0, rate);
a->setDimension(es.physical_dimension);
a->AddWaveform(edf.startdate, es.data, recs, duration);
sess->setMin(code, a->Min());
sess->setMax(code, a->Max());
EventDataType min = a->Min();
EventDataType max = a->Max();
// Cap to physical dimensions, because there can be ram glitches/whatever that throw really big outliers.
if (min < es.physical_minimum) min = es.physical_minimum;
if (max > es.physical_maximum) max = es.physical_maximum;
sess->setMin(code, min);
sess->setMax(code, max);
sess->setPhysMin(code, es.physical_minimum);
sess->setPhysMax(code, es.physical_maximum);
}