void SegmentDescription::BuildSignal(Signal & signal) const { signal.Reset(); for (size_t i = 0; i < cores.size(); ++i) { cores[i].AddToArray(signal.GetData(), signal.GetDesc().N); } }
void Polynom::AddToSignal(Signal & signal) const { const SignalDescription & d = signal.GetDesc(); double * data = signal.GetData(); for (int i = 0; i < d.N; ++i) { data[i] += (*this)(d.startTime + i * d.dt); } }
void MainWindow::onLoad() { QString fileName = QFileDialog::getOpenFileName(this, tr("Open Physionet ECG File"), "", tr("Physionet ECG File (*.dat)")); if(fileName.isEmpty()) return; Signal signal; if(signal.ReadFile(fileName.toStdWString().c_str())) { int dataSize = signal.GetLength(); double* data = signal.GetData(); double sr = signal.GetSR(); float msec = float((double)dataSize / sr); QVector<double> x(dataSize), y(dataSize); for (int i=0; i<dataSize; ++i) { x[i] = i * msec / dataSize; y[i] = data[i]; } EcgAnnotation ann; int** qrsAnn = ann.GetQRS(data, dataSize, sr, L"filters"); if (qrsAnn) { int** ANN = ann.GetPTU(data, dataSize, sr, L"filters", qrsAnn, ann.GetQrsNumber()); if (ANN) { fillArrhytmiaPlot(ANN, ui->plot, ann, x, y, signal.GetSR()); fillMyocardialPlot(ANN, ui->mPlot, ann, x, y, signal.GetSR()); fillPericarditisPlot(ANN, ui->pPlot, ann, x, y, signal.GetSR()); } else { QMessageBox::warning(this, "Warning", "Unknown error"); } } else { QMessageBox::warning(this, "Warning", "Could not get QRS complexes"); } ui->plot->replot(); } else { QMessageBox::warning(this, "Warning", "Failed to load file " + fileName); } }
bool MainWindow::getRDistances(Signal& signal, std::vector<float>& distances) { int dataSize = signal.GetLength(); double* data = signal.GetData(); double sr = signal.GetSR(); float msec = float((double)dataSize / sr); EcgAnnotation ann; int** qrsAnn = ann.GetQRS(data, dataSize, sr, L"filters"); distances.clear(); float lastRTime = -1; if (qrsAnn) { int** ANN = ann.GetPTU(data, dataSize, sr, L"filters", qrsAnn, ann.GetQrsNumber()); if (ANN) { int annNum = ann.GetEcgAnnotationSize(); for (int i = 0; i < annNum; i++) { int smpl = ANN[i][0]; int type = ANN[i][1]; msec = float(((double)smpl / sr)); if(anncodes[type][0] == L'R') { if(lastRTime >= 0) { distances.push_back(msec - lastRTime); } lastRTime = msec; } } } else { QMessageBox::warning(this, "Warning", "Unknown error"); return false; } } else { QMessageBox::warning(this, "Warning", "Could not get QRS complexes"); return false; } return true; }