how to collect peak values from a live input stream
I'm measuring abdominal movement from breath using a stretch sensor and want to capture:
1. the maximum stretch value caused by each breath
2. the time between each of these peaks.
Does anyone know how I can collect each of these maximum values from a live input stream?
I am comparing each peak and time value with previous values to trigger an audio response and taking an average of both value types to trigger an output at the end of each participant's session.
Here's a (late-night) patch to evaluate peaks in a number stream; I've added a [timer] object, but it's not implemented correctly - need sleep will check again in the morning
Brendan
Maybe some combination of peak and trough that get reset by some thresholds being crossed?
Brendan, that's looking good, thanks! The timer and max values seem spot on. I'm wondering though how to collect the max values, keeping them linked to the corresponding timer value so I can trigger audio that rates the depth and pace of breath and ultimately measure the average depth and pace. There will probably be around 25 of them (from approx 25 breaths over a 2 minute period). Thanks again.
Again, forgive the messy logic, but here's a patch that collects the relevant data in a coll:
Brendan
look here for a tidier version, courtesy of Zachary
beautiful work!! I just want to check, I'm wanting to calculate an average value over the first ten values (max and time) and then use this average value to work out the variance against other subsequent max and time values over the 2 minute period. Can I access the values stored int the report for these real time calculations? Thanks again.
yeah, you can poll the [coll]; there's a message you can send, requesting index# and element value, then just use one of the [zl] objects, [zl mean] i think, to work out averages
Brendan
ps
MIB has improved my patch, including a very tasty GUI:
Brendan
This is mega Brendan thanks! There's a lot for me to digest here - I'm learning about lots of new objects and stuff just trying to keep up with your suggestions. Anyway, off to bed now I'll get back to your patch tomorrow.