LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to select a set of points in a xy graph contained in an area draw with the cursor ?

Solved!
Go to solution

I'm using tIhe XY graph to plot a Pointcare representation of RR intervals (heart beat). I would like to use the mouse to draw a polygone surrounding the points of interest and get their indexes from the original array. Thank you to oriented me to some strategy!

 

Olivier 

0 Kudos
Message 1 of 19
(14,259 Views)

OK your question might be "just a little bit vague" for the average forum member!

 

I realize that you have a time record of a EEG and are looking at Atrial depolarizations.  Here is where you should provide some sample data sets and exactly what information you want to observe within that data set.  The rest is simply proposing algorythims for you to implement (we are pretty good at that). Mind reading s a skill that most of us are poorly equiped for (but Ben seems to occasionally manage it)


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 19
(14,255 Views)

OK, I wasn't clear enough but got your attention..Thanks. Let's say that I have a series of data {x1,x2...xi...xn} that represents the duration of time between two adjacent heart beats. The pointcare plot is the representation of the points [xi,x(i+1)] and that can be achieved to by the XYGraph function. Using this graphic, it is expected that adjacent intervals with almost similar values will form a cloud (circular, eliptic or with more complex shapes) centered around the average values of the xi. Now, unusual changes between adjacent xi values in the time series (lower or higher x(i+1)) will result in points outside of the primary cloud. This is an easy way to identify abrupt changes in a time series.

 

The step I'm blocked with is that, after I used the XY graph, I would like to use the mouse the visually draw the border of the primary cloud and extract the indexes of the point in or and points outside the border separately. Is that make more sens?

 

Again, I really appreciate your help for that.

 

Olivier   

0 Kudos
Message 3 of 19
(14,248 Views)

This can be done, but unfortunately is not trivial. Since this is the second request I have seen in the last week for this type of functionality, I would encourage you to post the idea to the LabVIEW Idea Exchange.

 

All graphs have a front, middle, and back image, which is set using a picture control data type.  You can use this to draw your cursor using an unfilled rectangle.  You can capture mouse events on the XY graph using the event structure, and update your enclosed rectangle (or ellipse, or whatever you would like to draw) when the mouse moves.  You can extract the enclosed data points from your original data set when a mouse up event occurs or when the user clicks inside the rectangle after drawing it.  You may also want to include ways to tweak the boundaries of the rectangle.

 

This is relatively straightforward if you have used the event structure before, but could be very confusing if not.  Let us know if you need more information or help.

0 Kudos
Message 4 of 19
(14,187 Views)

If you only really need to designate the "low" and "high" values on the X-axis and similar values on the Y-axis thus describing a rectangle that is aligned with the axes (no rotation), then using the graph cursors would be an easy way to do this. You can place two cursors on each axis and lock their vertical or horizontal axes and allow the user to drag them to the visual boundaries of the cloud. You can even select the cursor's appearance so that there are vertical/horizontal lines to help with the visualization. It is then easy to read the cursor positions programmatically to determine the rectangle's position (in the graph units).

 

You could something a little bit more complicated by using the graph cursors and not locking them at all, but allow the user to drag several of them around to describe a more complex shape enclosing the point cloud and then read the cursor positions to do some shape fitting.

0 Kudos
Message 5 of 19
(14,181 Views)

Thanks for your inputs. The option of max and min on each axis may not work in my case since the boundary to determine can have complex shapes. 

I put the post at the Labview Idea forume:

http://forums.ni.com/t5/LabVIEW-Idea-Exchange/How-to-use-the-mouse-in-a-xy-graph-to-draw-some-bounda...

 

I don't think it will be easy for me to use the structure event right now....I'll try to work on it in the following days but any VI as an example for the use of mouse in XY graph will be greatly appreciated.

 

Olivier

0 Kudos
Message 6 of 19
(14,173 Views)
Solution
Accepted by OD

It seems harder to describe in words than to just post a simple example.  Simply click on the graph to add cursors, drag around as desired and see the included points.  I use a 1-bit bitmap to detect interior points, and the draw multiple points VI for the polygon image.

 

I sort the points so that the polygon is fully filled, so sometimes you will see it switch shape suddenly.  Not a full-blown solution, but a good start.

 

PolygonGraphSelect.png

Message 7 of 19
(14,155 Views)

This is really impressive and almost exactly what I was looking for ! The writing is somewhat upon my skills in labview so I may be completely wrong in my following observation. By using the pixel system (which is a cool strategy) we loose the direct connection to the initial array (time amplitude). Therefore, it didn't seem strait full to me to get the indexes of the points that are in and out the polygon in reference to the array feeding the XY graph. 

 

Thanks for helping!

O  

0 Kudos
Message 8 of 19
(14,130 Views)
Sorry I am on my iPhone right now so no pictures or code. If you look at the For Loop which indexes over the points and draws the circles, you see the Select function. The Boolean which feeds that function tells you in or out, I chose to draw a circle, you can choose to Build arrays of indices, or a Boolean array which corresponds to each point.

 

When I cooked up the pixel system yesterday I knew it should work, but I was still surprised to see that it actually did. I will see if I can add a little to the example for you, or you may be able to find some simple examples of conditional autoindexing on the forum.
0 Kudos
Message 9 of 19
(14,126 Views)

Thanks, I got the indexes based on your info. This is really a great VI for people dealing with clusters. I really wish this function be added in the next update!

 

Thanks for your brain-time !

 

Olivier 

0 Kudos
Message 10 of 19
(14,108 Views)