FORUMS: list search recent posts

Using the Numbers effect to translate Heart Rate data into a readout??

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Saxon Rix
Using the Numbers effect to translate Heart Rate data into a readout??
on Jan 27, 2015 at 12:01:44 am

Hi guys I was recommended to come over to the expressions side of the AE forums as the problem I have may be able to be fixed by an expression.

I am doing a project where I'm making use of a heart rate monitor. I am able to extract the heart rate data (which is recorded once every second such as: 99, 101, 100, 100, 100, 101, 102, 102, 107, 113 etc). The data was recorded for around 31 minutes, which gave me 1910 of those numbers.

I am wanting to use this data to make a number readout in After Effects, but I'm not sure how to add or use the data I have in order to make it accurately follow the data.

So it has to read from the list of 1910 numbers, and display each number for 1 second each.

Any ideas if this is possible guys?

Thanks!


Return to posts index

Dan Ebberts
Re: Using the Numbers effect to translate Heart Rate data into a readout??
on Jan 27, 2015 at 12:29:32 am

What does the data look like?



Return to posts index

Saxon Rix
Re: Using the Numbers effect to translate Heart Rate data into a readout??
on Jan 27, 2015 at 12:34:40 am

It is literally just a list of numbers with commas separating them like such:

171,171,171,171,170,170,170,170,170,170,170,170,170,170,170,170,170,171,171,171,171,171,171,171,171,170,170,170,170,159,159,159,159,159,159,159,159,148,148,148,148,148,148,148,0,0,175,174,173,173,173,173,173,174,174,174,174,174,174,174,174,174,174,174,174,174,174,174,175,175,175,175,175,176,176,176,176,176,176,177,177,177,177,177,177,177,177,177,178,178,177,177,177,177,176,176,175,174,172,171,170,170,170,170,170,171,171,171,172,172,172,172,172,172,172,172,173,173,173,173,173, etc.


Return to posts index


Dan Ebberts
Re: Using the Numbers effect to translate Heart Rate data into a readout??
on Jan 27, 2015 at 12:50:17 am

If you can edit your text file so that the line starts like this:

myArray = [171,171,171,171,170,170,

and ends like this:

172,173,173,173,173,173];

Then an expression like this should work:

myPath = "c:/test/test.txt";
$.evalFile(myPath);
idx = Math.min(Math.max(Math.floor(time - inPoint),0),myArray.length-1);
myArray[idx]

You'll need to edit myPath to point to your text file.

Dan



Return to posts index

Saxon Rix
Re: Using the Numbers effect to translate Heart Rate data into a readout??
on Jan 27, 2015 at 12:59:53 am

Thanks Dan I am just about to try this out. Do I apply this expression to the numbers effect 'value' setting?


Return to posts index

Dan Ebberts
Re: Using the Numbers effect to translate Heart Rate data into a readout??
on Jan 27, 2015 at 1:05:27 am

That should work. I tested it by applying it to the Source Text property of a text layer.

Dan



Return to posts index


Saxon Rix
Re: Using the Numbers effect to translate Heart Rate data into a readout??
on Jan 27, 2015 at 1:13:15 am

It worked! Thank you so much :). Sooo glad I don't have to do it all manually lol.

Thanks again Dan, you're awesome!


Return to posts index

Saxon Rix
Re: Using the Numbers effect to translate Heart Rate data into a readout??
on Jan 27, 2015 at 1:20:16 am

Sorry to bother you with another question Dan, but is there a way to make the numbers change color once they get to a certain number threshold?

Like this
90 - 120 = green
121 - 150 = orange
151 - 180 = red


Return to posts index

Dan Ebberts
Re: Using the Numbers effect to translate Heart Rate data into a readout??
on Jan 27, 2015 at 1:29:17 am

With the numbers effect? Something like this for Fill Color should work:

val = effect("Numbers")("Value/Offset/Random Max");
if (val < 121)
[0,1,0,1]
else if (val < 151)
[1,.5,0,1]
else
[1,0,0,1]


Dan



Return to posts index


Saxon Rix
Re: Using the Numbers effect to translate Heart Rate data into a readout??
on Jan 27, 2015 at 1:36:44 am

That does work great! Is there a way to link it to 'hue/saturation' effect so that the color gradually changes from green to yellow to orange to red as the number gets higher, and then more towards green as it gets lower?

(PS: sorry for my stupidity, these expressions baffle me!)


Return to posts index

Dan Ebberts
Re: Using the Numbers effect to translate Heart Rate data into a readout??
on Jan 27, 2015 at 2:18:32 am

The hue effect doesn't take expressions, but you should be able to simulate it if you set the Fill color to red and replace the previous expression with this one:

val = effect("Numbers")("Value/Offset/Random Max");
hsl1 = rgbToHsl([0,1,0,1]);
hsl2 = rgbToHsl([1,.5,0,1]);
hsl3 = rgbToHsl([1,0,0,1]);
if (val < 121)
h = linear (val,90,121,hsl1[0],hsl2[0])
else if (val < 151)
h = linear(val,121,151,hsl2[0],hsl3[0])
else
h = hsl3[0];
hslToRgb([h,hsl1[1],hsl1[2],1])


Dan



Return to posts index

Saxon Rix
Re: Using the Numbers effect to translate Heart Rate data into a readout??
on Jan 27, 2015 at 10:23:32 am

yep, that did great! Thank you very much Dan!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]