LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Area between two curves/ lines

Solved!
Go to solution

Hi everyone,

 

I have an accelerometer I am using to measure position of a thumb movement - this gets processed and spat out as a curve/line representing where the thumb moved in XY coordinates.

 

I want to then compare this to a 'target movement' vector, to see how far off achieving this target position users were when moving their thumb.

 

I have attached some examples of the actual movement (red) and desired movement (white dotted) lines. In the second pic of each example I shaded in white lines the area I want to estimate

 

Does anyone have any ideas of how they would implement this in LabVIEW?? I had thought about using integration and getting area under curves and subtracting one from the other, or turning the lines into a triangle and getting the area of the triangle (sometimes the lines are a bit curvey, but I don't mind losing some precision by making them into lines - rough estimation is good enough).

 

 

Thanks so much for any ideas in advance! I am new to labview and have crafted my life to avoid doing math generally, which now bites me in the butt

Download All
0 Kudos
Message 1 of 10
(3,269 Views)

I'm going to question whether "area between curves" is what you really want to do here. 

 

I would think you would want to plot/quantify "error versus time".  If you set up your target trajectory to be "sampled" at the same rate as the actual, you could use the absolute value of the point-to-point distance at each time to show the error.  The area under THAT curve might be what you're after.

 

Your data so far suggest linear movement and linear target.  Could you quantify the error as angle and (final) distance error?  That, of course, assumes all future tests will be linear.

0 Kudos
Message 2 of 10
(3,257 Views)

Hey there! thanks for replying

 

So are you suggesting that I take the data in a more raw form (i.e., I have it as acceleration in g's over samples - which I then later integrate once to get to velocity, then again to get to position). I use this data to get a root mean square value or something for the two different axes (X axis change, Y axis change), and then compare this with the target values for the same thing? That might work... though I would prefer to use the position data - as this is the feedback the users will actually *see*

 

Angles could work if I get nothing else to work, but I think it would miss some of the information out i.e., if there is a slight curve in the line, or its shorter than the target line etc. To get the angle I would use the dot product of 2 vectors to and cosine of the angle between these vectors I guess

 

If anyone thinks of anything that would be like root mean square but between these two lines that is also easy to implement in LV that would be brilliant 🙂

0 Kudos
Message 3 of 10
(3,250 Views)

This is what the raw acceleration (g) data looks like

0 Kudos
Message 4 of 10
(3,249 Views)

I think you might be asking the wrong question (or at least getting the math a little confused).  In any behavior experiment, you need to ask "What is the goal?" (or what do you want the subject to do?).  If the answer is "follow this target as closely as you can", one measure of "how good am I doing" could be "how close am I to the target".  In the figures that you showed, what was curious is that the red line was in a different direction from the white line, so as time goes on ...  Oops, my mistake (see next paragraph) ...

 

I just realized you are tracking a target in 2 dimension (X, Y), and there's an implicit third dimension of time.  Disregard the emphasized word "direction" in the previous paragraph -- that was looking at the trace as an XY plot, when it is probably an X-t (or something else) plot.  I'd be interested in seeing "closeness" vs t, as well as both delta-x (difference in X between target and subject) and delta-y vs t (to check for bias or spatial dependence).

 

Something that worries me a bit is using an accelerometer to measure the position of an object.  You need to integrate the signal twice, and even an accelerometer at rest when integrated twice will show drift.  [Probably a good thing I'm not reviewing this Project ...].

 

Bob Schor

0 Kudos
Message 5 of 10
(3,243 Views)
Solution
Accepted by topic author hdempseyjones

I agree with Bob  -- an accelerometer is probably the wrong tool to measure position.   Be that as it may, even if you had perfect position data you still face the problem of quantifying the error relative to the ideal trajectory.

 

In my post I was suggesting comparing the position data at discrete points in time to get the 2D distance between them, not operating on the acceleration.

 

error_quant.png    error_quant2.png

0 Kudos
Message 6 of 10
(3,231 Views)

@Bob_Schor wrote:

Something that worries me a bit is using an accelerometer to measure the position of an object.  You need to integrate the signal twice, and even an accelerometer at rest when integrated twice will show drift.  [Probably a good thing I'm not reviewing this Project ...].


A lot of navigation systems actually do this.  So it is not an uncommon thing.  Granted, the good navigation systems also use GPS to retune the accelerometer and gyroscope tracking.  GPS is slow, so not so good for many systems to rely on entirely.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 10
(3,224 Views)

If memory serves me there was also a complication of a phase shift when integrating twice. Don't ask me to justify that math-wise. It is just something that I think I saw many years ago...

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 8 of 10
(3,221 Views)

@Zwired1 wrote:

error_quant.png    error_quant2.png


Before Christian gets in on this action...

You might want to try messing around with Complex numbers since it does make the math a little easier.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 9 of 10
(3,220 Views)

Thanks everyone for your suggestions, I ended up trying something that I think was a bit of a combination of your suggestions. I worked out the middle point (X,Y coords) and end point ('') of both lines, and then subtracted the absolute values to give a distance measure. The larger the distance the further away... not sure what people think of this approach...

0 Kudos
Message 10 of 10
(3,127 Views)