element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Legacy Personal Blogs hrmshield filtering and graphing
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: fustini
  • Date Created: 3 May 2012 7:12 AM Date Created
  • Views 586 views
  • Likes 1 like
  • Comments 2 comments
  • hrmshield
  • diy
  • biosensing
  • Health
  • arduino
Related
Recommended

hrmshield filtering and graphing

fustini
fustini
3 May 2012

I wrote a quick overview of how the hrmshield sketch works in my last post, so in this post I'd like explain what I do with the data it produces.  All the code along with sample data are in the hrmshield github repo.

 

Parse

After doing a test run with the hrmshield recording, the SD card contains a text file with timestamped BPM readings.  I have one script, parse.pl, which reads the text file (HRM23.CSV for example) and reformats it so that there is one BPM reading per line along with timestamp.  This makes the data easier to then filter and graph.

 

Filter

Filtering is needed to toss out invalid BPM readings.  Eric Boyd uses Asymptote to filter and graph HeartSpark data (see his Heart Plot repo).  However, the Asymptote script expects data to come in a different format than my hrmshield.  The HeartSpark logs data to EEPROM and then depends on a Processing sketch to download the data from it via the serial port. 

 

I initially tried to adapt the Asymptote script but ran into difficulty.  I decided to just go with my old standby Perl and copy the filtering logic from Eric's Asymptote script.  This is resulted in filter.pl in the hrmshield repo.  It is run with the output of parse.pl. 

 

Graph

The output of parse.pl and filter.pl are both joined into one file so that raw versus filtered BPM data can be graphed.  This is done by graph.sh which runs end-to-end needing only the raw CSV filename as a parameter to produce an image of the graph.  For example, running ./graph.sh data/HRM23.CSV creates ./graph/hrm.png.

 

I use gnuplot for graphing with two different configuration files: hrmshield-png.plot & hrmshield.plot.  The first is utilized by graph.sh, as describe above, to generate a PNG of the graph:

image

The second is opened in a GUI frontend to gnuplot called qgfe.  qgfe is very useful for exploring data as I can freely zoom in on any area of the graph:

image

So that is a brief run through of how I filter and graph the data from the hrmshield.  Looking forward, I want to further explore how I can improve the filter script to better normalize the BPM data so that the graph doesn't fluctuate as much.

 

 

Cheers,

Drew

  • Sign in to reply

Top Comments

  • YT2095
    YT2095 over 13 years ago +1
    I can think of a couple of simple ways that May help, One would be read each data point and If it goes above or below 10 units of the last data point, then it equals new data point + or - only 10. that…
  • fustini
    fustini over 13 years ago in reply to YT2095

    Thanks for the advice.  I will attempt to incorporate that logic into the filter and see how the graph differs.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • YT2095
    YT2095 over 13 years ago

    I can think of a couple of simple ways that May help, One would be read each data point and If it goes above or below 10 units of the last data point, then it equals new data point + or - only 10.

    that would clip the spikes.

    another way would be sampling a whole array of data points, where each point has a number in a row, and where it deviates wildly, those points between Valid ones are ignored and filled in with either flat line between the last 2 valid data points, or left blank and not graphed at all.

    so if we have points: 1,3,5,25,50,11,13...

    it would "see" that all was well as valid jumps between numbers up until we get to 25 and 50, so those get withheld, and you have 1,3,5,blank,blank,11,13.

    this could either be printed as is, or a line ploted between the 2 points 5 and 11.

    that line would cross the logical 7 and 9 that were missing because of the spike.

     

    Just an idea image

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube