mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-07 03:30:44 +00:00
Add support for PRS1 sessions with oximetry data split between files.
This commit is contained in:
parent
6261752022
commit
5f0960aa4d
@ -982,12 +982,9 @@ void PRS1Loader::ScanFiles(const QStringList & paths, int sessionid_base, Machin
|
|||||||
// All samples exhibiting this behavior are DreamStations.
|
// All samples exhibiting this behavior are DreamStations.
|
||||||
task->m_wavefiles.append(fi.canonicalFilePath());
|
task->m_wavefiles.append(fi.canonicalFilePath());
|
||||||
} else if (ext == 6) {
|
} else if (ext == 6) {
|
||||||
if (!task->oxifile.isEmpty()) {
|
// Oximetry data can also be split into multiple files, see waveform
|
||||||
qDebug() << sid << "already has oximetry file" << relativePath(task->oxifile)
|
// comment above.
|
||||||
<< "skipping" << relativePath(fi.canonicalFilePath());
|
task->m_oxifiles.append(fi.canonicalFilePath());
|
||||||
continue;
|
|
||||||
}
|
|
||||||
task->oxifile = fi.canonicalFilePath();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
@ -8413,7 +8410,7 @@ bool PRS1Import::ParseSession(void)
|
|||||||
|
|
||||||
// If are no mask-on slices, then there's not any meaningful event or waveform data for the session.
|
// If are no mask-on slices, then there's not any meaningful event or waveform data for the session.
|
||||||
// If there's no no event or waveform data, mark this session as a summary.
|
// If there's no no event or waveform data, mark this session as a summary.
|
||||||
if (session->m_slices.count() == 0 || (m_event_chunks.count() == 0 && m_wavefiles.isEmpty() && oxifile.isEmpty())) {
|
if (session->m_slices.count() == 0 || (m_event_chunks.count() == 0 && m_wavefiles.isEmpty() && m_oxifiles.isEmpty())) {
|
||||||
session->setSummaryOnly(true);
|
session->setSummaryOnly(true);
|
||||||
save = true;
|
save = true;
|
||||||
break; // and skip the occasional fragmentary event or waveform data
|
break; // and skip the occasional fragmentary event or waveform data
|
||||||
@ -8430,13 +8427,26 @@ bool PRS1Import::ParseSession(void)
|
|||||||
|
|
||||||
if (!m_wavefiles.isEmpty()) {
|
if (!m_wavefiles.isEmpty()) {
|
||||||
// Parse .005 Waveform files
|
// Parse .005 Waveform files
|
||||||
ImportWaveforms();
|
waveforms = ReadWaveformData(m_wavefiles, "Waveform");
|
||||||
|
|
||||||
|
if (session->eventlist.contains(CPAP_FlowRate)) {
|
||||||
|
if (waveforms.size() > 0) {
|
||||||
|
// Delete anything called "Flow rate" picked up in the events file if high-resolution data is present
|
||||||
|
// TODO: Is this still used anywhere?
|
||||||
|
qWarning() << session->session() << "Deleting flow rate events due to flow rate waveform data";
|
||||||
|
session->destroyEvent(CPAP_FlowRate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract raw data into channels.
|
||||||
|
ParseWaveforms();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!oxifile.isEmpty()) {
|
if (!m_oxifiles.isEmpty()) {
|
||||||
// Parse .006 Waveform file
|
// Parse .006 Waveform files
|
||||||
oximetry = loader->ParseFile(oxifile);
|
oximetry = ReadWaveformData(m_oxifiles, "Oximetry");
|
||||||
oximetry = CoalesceWaveformChunks(oximetry);
|
|
||||||
|
// Extract raw data into channels.
|
||||||
ParseOximetry();
|
ParseOximetry();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8447,16 +8457,17 @@ bool PRS1Import::ParseSession(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PRS1Import::ImportWaveforms()
|
QList<PRS1DataChunk *> PRS1Import::ReadWaveformData(QList<QString> & files, const char* label)
|
||||||
{
|
{
|
||||||
QMap<qint64,PRS1DataChunk *> waveform_chunks;
|
QMap<qint64,PRS1DataChunk *> waveform_chunks;
|
||||||
|
QList<PRS1DataChunk *> result;
|
||||||
|
|
||||||
if (m_wavefiles.count() > 1) {
|
if (files.count() > 1) {
|
||||||
qDebug() << session->session() << "Waveform data split across multiple files";
|
qDebug() << session->session() << label << "data split across multiple files";
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto & f : m_wavefiles) {
|
for (auto & f : files) {
|
||||||
// Parse a single .005 Waveform file
|
// Parse a single .005 or .006 waveform file
|
||||||
QList<PRS1DataChunk *> file_chunks = loader->ParseFile(f);
|
QList<PRS1DataChunk *> file_chunks = loader->ParseFile(f);
|
||||||
for (auto & chunk : file_chunks) {
|
for (auto & chunk : file_chunks) {
|
||||||
PRS1DataChunk* previous = waveform_chunks[chunk->timestamp];
|
PRS1DataChunk* previous = waveform_chunks[chunk->timestamp];
|
||||||
@ -8471,21 +8482,12 @@ void PRS1Import::ImportWaveforms()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the list of pointers sorted by timestamp.
|
// Get the list of pointers sorted by timestamp.
|
||||||
waveforms = waveform_chunks.values();
|
result = waveform_chunks.values();
|
||||||
|
|
||||||
// Coalesce contiguous waveform chunks into larger chunks.
|
// Coalesce contiguous waveform chunks into larger chunks.
|
||||||
waveforms = CoalesceWaveformChunks(waveforms);
|
result = CoalesceWaveformChunks(result);
|
||||||
|
|
||||||
if (session->eventlist.contains(CPAP_FlowRate)) {
|
return result;
|
||||||
if (waveforms.size() > 0) {
|
|
||||||
// Delete anything called "Flow rate" picked up in the events file if real data is present
|
|
||||||
qWarning() << session->session() << "Deleting flow rate events due to flow rate waveform data";
|
|
||||||
session->destroyEvent(CPAP_FlowRate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extract raw data into channels.
|
|
||||||
ParseWaveforms();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -295,7 +295,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
QList<QString> m_wavefiles;
|
QList<QString> m_wavefiles;
|
||||||
QString oxifile;
|
QList<QString> m_oxifiles;
|
||||||
|
|
||||||
//! \brief Imports .000 files for bricks.
|
//! \brief Imports .000 files for bricks.
|
||||||
bool ImportCompliance();
|
bool ImportCompliance();
|
||||||
@ -306,8 +306,8 @@ public:
|
|||||||
//! \brief Imports the .002 event file(s).
|
//! \brief Imports the .002 event file(s).
|
||||||
bool ImportEvents();
|
bool ImportEvents();
|
||||||
|
|
||||||
//! \brief Imports the .005 event file(s).
|
//! \brief Reads the .005 or .006 waveform file(s).
|
||||||
void ImportWaveforms();
|
QList<PRS1DataChunk *> ReadWaveformData(QList<QString> & files, const char* label);
|
||||||
|
|
||||||
//! \brief Coalesce contiguous .005 or .006 waveform chunks from the file into larger chunks for import.
|
//! \brief Coalesce contiguous .005 or .006 waveform chunks from the file into larger chunks for import.
|
||||||
QList<PRS1DataChunk *> CoalesceWaveformChunks(QList<PRS1DataChunk *> & allchunks);
|
QList<PRS1DataChunk *> CoalesceWaveformChunks(QList<PRS1DataChunk *> & allchunks);
|
||||||
|
Loading…
Reference in New Issue
Block a user