phyphox Forums

Full Version: How can count amount peak of graph ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi Big Grin .This is the first time I have used Phyphox and I have some problems. Now I'm making a simple sensor that measures heart beat rate by acceleration without g(Y-Axis), the graph shows a peak of a graph like an electrocardiogram and we can count a peak of the graph and calculate to BPM 
Ex.measure in 20s BPM = amount of peak x 3

And this is my question
1. how can count the amount of peak in the graph?. this is the first time and I don't know what blog or function can work. I'm guessing it is a threshold blog but I'm not sure it gonna work 

[attachment=707] [attachment=708]

2. Why does the graph not look the same in the app? It looks like it's not stable. I think I missed some setting or something.
=> After Trial and error just have 0hz no average

[attachment=707] [attachment=709] [attachment=710][attachment=711]
You could have a look at the “Motion Stopwatch” that has likely most of the functionality implemented (particularly, check the “many” tab). Personally, I would start with it and kick anything out that looks unneeded – and learn a lot doing that because Sebastian has included some magic… Wink

Have you tried a rate of 100 Hz like in the original graph? It could be that you just miss the full height with a lower rate.
After I tried dissecting the code, it seemed complex and quite error-prone. So now, I'm attempting to do it in my way. Could you review my code and help me why it's not working? The issue seems to be with the if function count = count+1, and I'm wondering how to write it correctly in this style or simiar logic.
acc = input y, acct = input time and idk just need to use append or not

simple logic 
count = 0
if y value > threshold(approximately 0.2) => count = count+1
BPM = count*3(measure in 20s)
[attachment=712]
It would be much easier if you could simply copy the code into a text file and share it as an attachment. On append: it makes sense to rewatch the part on containers, “keep”, and “append” of the introductory video. The phyphox containers behave quite different to regular variables.

For debugging purposes, it makes sense to export the containers that you are working with and verify the data that you would expect is actually in there.

HTH a bit.
this is my code without an if blog because it can't generate so I know that bug here now i didn't  ✓ anything
you can see a if blog in previous pic


<phyphox xmlns="https://phyphox.org/xml" version="1.18">
  <title>New Experiment</title>
  <category>No Category</category>
  <data-containers>
    <container size="0">acc</container>
    <container size="0">acct</container>
    <container size="0">accCopy</container>
    <container size="0">acctCopy</container>
    <container size="0">max</container>
    <container size="0">t</container>
    <container size="0">count</container>
    <container size="0">BPM</container>
  </data-containers>
  <input>
    <sensor type="linear_acceleration">
      <output component="y">acc</output>
      <output component="t">acct</output>
    </sensor>
  </input>
  <analysis>
    <append>
      <input>acc</input>
      <output>accCopy</output>
    </append>
    <append>
      <input>acct</input>
      <output>acctCopy</output>
    </append>
    <max>
      <input as="x">acctCopy</input>
      <input as="y">accCopy</input>
      <output as="max">max</output>
      <output as="position">t</output>
    </max>
    <multiply>
      <input>count</input>
      <input type="value">3</input>
      <output>BPM</output>
    </multiply>
  </analysis>
  <views>
    <view label="New View">
      <graph label="New Graph">
        <input axis="x">acct</input>
        <input axis="y">acc</input>
      </graph>
      <value unit="BPM" label="your heart beat rate is">
        <input>BPM</input>
      </value>
    </view>
  </views>
</phyphox>
time zone gonna kill me, Up until now, I still don't know how to write. I still don't know the purpose of some blogs If anything is wrong, you know I'm just guessing.

[attachment=713]
It's not so much the time difference but rather the federal holiday here today… Wink
Your project is rather ambitious for first steps with the editor. Perhaps it is a good idea to have an eye on the (technical) documentation of the file format in our wiki: https://phyphox.org/wiki/index.php/Phyphox_file_format
This sounds a biyt like the morse translator experiment that Sebastian wrote for me....

https://phyphox.org/forums/showthread.ph...ight=morse