如何在Java中的另一个信号之上绘制峰阵列?

时间:2019-05-11 10:17:33

标签: java android graph

我有一个ECG信号,该信号的R峰存储在Java应用程序的数组中。给出峰值作为心电信号的样本索引。

我想绘制带有其他颜色标记的峰的ECG。我当前的代码仅显示了ECG曲线,但看不到峰值。它没有给出任何错误,但一定有问题

 public void ConfigureGraph() {
   final GraphView graph = findViewById(R.id.graphview);
   graph.getViewport().setScalable(true);

    LineGraphSeries<DataPoint> series1 = new LineGraphSeries<>();
    LineGraphSeries<DataPoint> series2 = new LineGraphSeries<>();

   series1.setDrawDataPoints(true);
   series2.setDrawDataPoints(true);
   series2.setDataPointsRadius(10);
   series2.setThickness(8);

   ArrayList<Double> myDatan=readFileNorm(); //This is my ECG
   LinkedList<Integer> myPeaks= PanTompkins.findPeaks(myDatan); //Those are my peaks

   int numberofdatapoints = 20000;
   double x=0;
   double y;

   for(int i=0; i<numberofdatapoints; i++){ //Plot the ECG
       x = x + 0.004;
       y = myDatan.get(i);
       series1.appendData(new DataPoint(x,y),true,20000);

       for(int p=0; p<myPeaks.size(); p++) { //Add the peaks to plot
           if(y == myPeaks.get(p)){
               series2.appendData(new DataPoint(x,y),true,20000);
           }
       }
   }

   graph.addSeries(series1);
   graph.addSeries(series2);
}

在这里可以看到ECG,我已经查看了一系列峰,并且看起来应该可以工作。第一个峰指数为54,与54 * 0.004 = 0.216的峰相符;下一个是193 * 0.004 = 0.772。

result

0 个答案:

没有答案