Ejemplo n.º 1
0
bool MainWindow::loadLearningSignals(Signal& referenceSignal, Signal& distortedSignal)
{
    QString referenceFileName = QFileDialog::getOpenFileName(this, tr("Open Reference Physionet ECG File"),
                                                    "", tr("Physionet ECG File (*.dat)"));

    if(referenceFileName.isEmpty())
        return false;

    if(!referenceSignal.ReadFile(referenceFileName.toStdWString().c_str()))
    {
        QMessageBox::warning(this, "Warning", "Failed to load file " + referenceFileName);
        return false;
    }

    QString distortedFileName = QFileDialog::getOpenFileName(this, tr("Open Distorted Physionet ECG File"),
                                                    "", tr("Physionet ECG File (*.dat)"));

    if(distortedFileName.isEmpty())
        return false;

    if(!distortedSignal.ReadFile(distortedFileName.toStdWString().c_str()))
    {
        QMessageBox::warning(this, "Warning", "Failed to load file " + distortedFileName);
        return false;
    }

    return true;
}
Ejemplo n.º 2
0
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);
    }
}