我有一个 ECG 信号,该信号的 R 峰存储在我的 Java 应用程序的一个数组中。峰值作为 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);
}
在这里可以看到心电图,我查看了一系列峰值,看起来应该可以工作。第一个峰值指数为54,与峰值54*0.004 = 0.216吻合;下一个是 193*0.004=0.772。
