Transformation d'ECG en image ou son

Est-il possible de créer une images / animation , a parti de données d’ECG (electrocardioramme) grâce au code ? (j’ai un projet artistique dessus je ne sais pas faire de code j’ai besoin d’aide )

Something like this?

This was created from made up data points and plotted as a drawing and then saved as an image. Or you can plot real ecg data if you have the hardware to capture it:

If you want a simulated ecg something like this should get you started:

// Fake ECG
int[] ecg = {40, 38, 42, 43, 44, 45, 44, 43, 42, 41,
  40, 40, 40, 40, 40, 39, 42, 43, 60, 80,
  100, 120, 80, 50, 5, 10, 20, 30, 40, 50,
  35, 40, 41, 42, 43, 44, 45, 46, 47, 48,
  49, 50, 51, 51, 50, 49, 48, 45, 42, 40, 40}; // n = 51

int x = 0;
int baseline = 100;

void setup() {
  size (600, 400);
  surface.setTitle("Simulated ECG");
  frameRate(4);
  background(255);
  strokeWeight(3.0);
}

// Draw from bottom of window
void draw() {
  for (int i = 0; i < ecg.length-1; i++) {
    line(x, height - baseline - ecg[i] , x, height - baseline - ecg[i+1]);
    x++;
  }
  if (x >= width) {
    x = 0; // at edge of screen -> back to beginning
    background(255);
  } 
}

Output:

2 Likes

Bonjour @Clem,

You certainly can create some cool art, images and animation with data.

Some minimal and incomplete code to generate simulated data and plot it over time:

int counter = 0;

void setup () 
  {
  size(400, 400, P3D);   
  frameRate(60); // Default
  }

void draw () {
  //GLV Testing without serial
  float angle = TWO_PI/360; // this is 1 degree in radians
  
  float xi = counter; // x increments
  counter++;          // increment for next draw cycle
 
  // Simulated ECG data
  float sc = 100;                                  // scale
  float xa = xi*angle;                             // x angle
  float yp = sc*(sin(3*xa - TAU/2) * cos(xa)) + height/2;  // y plot value
  
  // Plots data points:
  strokeWeight(5);  
  stroke(0, 0, yp%255);
  point(xi, yp);
    
  //stroke(?);
  //line(?, ?, ?, ?);
  
  //fill(?);
  //circle(200, 200, ?);
  
  // polar plot
  //float xr = ?*cos(?);
  //float yr = ?*sin(?);
  //stroke(?);
  //point(?, ?);
  }

This is a screen grab of my complete code that is animated and has some artistic flair:

The data you are using can be read from a file, a static array, serial port, network, etc.).

Everything you need to start your art project is here in the tutorials, examples and references:

You will have to add your personal creativity to this.

References:

Amusez-vous bien !

:)

Thank you for your response. Actually, I am not supposed to represent an ECG in a figurative way, but rather create an abstract image or abstract animation based on its data. Thank you very much for the reference you sent me.