LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Selecting unusual-shaped regions of a graph

In my research, I collect data that I display in either an intensity graph or an XY graph. I'm looking for an easy way to select a subset of pixels (for the intensity graph) or a subset of points (for the XY graph). My instrument would then return to all those locations and take more data. The ideal way would be to "highlight" the areas I want in the graph by dragging my mouse around. I've done some google searching for VIs or front panel tricks that would be useful, but I haven't found anything yet. Can anyone give some suggestions or point to some relevant resources?

 

So far, I've settled for a rudimentary solution. I enter an (x,y) point and a distance d, and all the points in the XY plot that are within d of (x,y) are selected. I could also add two cursors to the graph and choose the rectangular area between them. But I'm dreaming of highlighting unusually shaped regions so I can get all the points I want in one go.

 

This is the closest thing I've found so far: https://lavag.org/topic/19824-select-a-set-of-points-in-a-xy-graph/

0 Kudos
Message 1 of 9
(1,206 Views)

You can use the "plot images" tools and mouse events to draw anything using picture commands. Start with this simple example. There are plenty more, I'll add a few more links later.

0 Kudos
Message 2 of 9
(1,165 Views)

In the above you saw how to use plot images.

 

Here is a simple example to draw/resize/move a circular area using two handles. Should work equally well on an intensity graph instead of a picture. Simply make sure you transform the coordinates correctly.

 

CircularImageAverage.png

 

0 Kudos
Message 3 of 9
(1,155 Views)

@alexderjuengere wrote:
that reminds me of this https://forums.ni.com/t5/LabVIEW/How-can-I-rotate-a-box/m-p/3972975#M1132528

Ah, forgot about that an it was only a few of years ago. I guess my memory is no longer what it never was. 😄

 

(Of course the inability to efficiently search the forum is a problem too. Maybe we should create a "plot images" tag or similar.)

0 Kudos
Message 5 of 9
(1,116 Views)

😄

0 Kudos
Message 6 of 9
(1,084 Views)

I made a VI that should work for my purposes. The way I draw a circle with PlotImages will misbehave if the x and y axes are scaled differently, but I'm okay with that for now. Also, this VI made me realize that if you use "Array Max & Min" on an empty array, you'll get a min of 0. Seems to me like it should give min = NaN or -inf.

 

Thanks for the examples, altenbach. The tricks of PlotImages, using event structures for mouse movement, and representing (x,y) points as complex numbers were all useful. Another missing piece was to use "Invoke Node>>Map Coordinates to XY" for the XY graph.

0 Kudos
Message 7 of 9
(1,065 Views)

Here's a very quick and dirty example that doesn't use picture controls. Instead, it just draws a new plot on the plot to make a box. I'd assume something like this would work similarly for intensity plots but I'm not sure.

 

Select region.png

 

You'll definitely want to clean it up and encapsulate a lot of this in subVI's, but it's all in one VI just to clearly see what all is going on.

 

You'll also want to filter out "Mouse down" events that occur when the user is, for example, zooming in or something. You can see which tool is selected with the "Palette: Active Tool" property node and you can ignore zooms, etc.

 

I don't think you can shade an area inside a plot like this. For that, you would need a picture control, which is certainly the more powerful tool. I just find this method a little simpler since you never have to draw any pixels yourself.

 

Note: the VI you uploaded is in too new of a version for me to see, so it might use this stuff already. Apologies if so.

 

Second note: The multiple "Max and min" and "In range" functions should be condensed into a subVI. You can use "In Range and Coerce" on clusters directly, but that would likely introduce a dependency on the direction you drew the box. In other words, "bottom left to top right" would work normally, but "top right to bottom left" would swap your min and max values around and it wouldn't see any points. There is probably a VI that does this already but again... quick and dirty 😉

 

0 Kudos
Message 8 of 9
(1,044 Views)

@ConfusedGrad wrote:

Thanks for the examples, altenbach. The tricks of PlotImages, using event structures for mouse movement, and representing (x,y) points as complex numbers were all useful. Another missing piece was to use "Invoke Node>>Map Coordinates to XY" for the XY graph.


A few comments:

  • All move events should limit the event queue to 1. (picture)
  • You only need to calculate the new points on mouse down, not 10x per second.
  • If you place the graph terminal before the event, you don't need a timeout event, but you need an event for the stop button.

 

altenbach_1-1684966862566.png

 

 

See if this can give you some ideas....

 

altenbach_0-1684966758790.png

 

Note that the "typecast to complex" only works if the cluster has exactly two DBL elements in the right order, so be careful!

 

Message 9 of 9
(1,029 Views)