Contador de picos en ondas de electromiografía

Hola comunidad. Necesito ayuda estado intentando contar cada pico máximo de las ondas pero no he logrado conseguirlo la onda al llegar a un pico máximo se envían 230 bytes por lo cual coloque que por encima de 225 se cuente un pico, adjunto imágenes de la onda y de la programación para que por favor me ayuden se los agradecería.

Hello community. I need help, I have been trying to count each maximum peak of the waves but I have not been able to achieve it, the wave reaches a maximum peak, 230 bytes are sent, so place a peak above 225, I attach images of the wave and the scheduling so please help me I would appreciate it.


Hello Yesid

Like this?


Hola Chris

Gracias por tu aporte, es más o menos la idea el problema es que se supone que por cada pico se debe contar de uno en uno ejemplo 1 contracción 2 contracción 3 contracción ....., haciéndolo así como dices, cuenta a lo que este >= 227 de forma automática 1+1+1+1+1+1 entonces a lo que llega el pico sigue sumando de forma automática y en dos picos salen datos como 10 contracciones.


This may be an idea, maybe you can simplify the code.

borrar_pico.aia (4.1 KB)


The technique you need to solve this problem is known in math under several names:

  • signal analysis
  • Fast Fourier Transforms
  • signal detection

You have some Internet searching to do.

A lot of signal analysis is done by generating the Fourier Transform of your signal.
A Fourier transform takes your data list and generates a graph of the intensities of different frequency ranges in your data. In the case of your data, a Fourier transform graph would have a peak at 6 cycles per whatever unit of time you have in your x axis width. There would also be some smaller peaks at 12 cycles, for the little wiggles in your heart beats.

There are a bunch of Javascript FFT transforms available for free, but they require fitting into AI2 like is done in this FAQ:

(I collect them, but have not yet coded one.)

P.S. If you collect a sample interval's readings and post them here as a Comma Separated Values (CSV) row, that would make it possible for other board members to attempt and test solutions to your problem.

1 Like

Thanks Juan Antonio

To improve on Juan Antonio's solution of entering a fixed threshold, you could try keeping a running average, derived by dividing a running sum of readings by a running count of readings, and mark a new cycle whenever both (the prior reading is <= the running average) and (the current reading > the running average).

This approach avoids peak counting in favor of upward cycle counting.