1

I'm developing a webpage where you can upload a text file with one column of data and then do some analysis on this data. The data is raw ECG sensor values and is converted to Voltage values. I would like to find the multiple peaks and their positions in this (1D array) in order to make some analysis about a patient's heart condition. Can not seem to find an answer for multiple peaks only one. Below is my barebones code.

The text file is structured like this:

  • 448
  • 448
  • 449
  • 451
  • 452
  • 454
  • 455
  • Note text file is not constant that's why I have the option to upload. But the structure will always be the same ( one column of data).

document.querySelector('#fileInput').addEventListener('change', (e) => {
  readFile(e.target.files[0]);
});

let windowWidth = 2;
let threshold = 2;

function readFile(file) {
  const reader = new FileReader();
  reader.readAsText(file);
  reader.onload = function() {
  const values = reader.result.split('\n').map(line => (+line.split(' ' [2])));
  console.log(values);
  
  var i=0;
  var j=0;
  var sum=0;
  var length= values.length;
  
  for (i=0; i<values.length; i++){
  
  sum += (((values[i]/(Math.pow(2,8)))-0.5)*3)/1000      

  }
  console.log(sum/length);
  
  };
}
<input id="fileInput" type="file" onchange="readFile(this.files[0])">
12bio23
  • 203
  • 1
  • 2
  • 6
  • I do a simple search and found this, [peak-signal-detection-in-realtime-timeseries-data, in stackoverflow](https://stackoverflow.com/questions/22583391/peak-signal-detection-in-realtime-timeseries-data). – ian00 Nov 20 '20 at 05:41

0 Answers0