LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Create indexed 1D array

The VI i have attached is used to draw region of interests. once the cross hair is set at the position the ROI is to start, then click start recording to record the cordinates you drag the cross hair through, runnin for 100 iterations.

Draw is the VI where you draw, Sketch single is what shows each ROI, Sketch multple shows all the ROI.

 

What i would like to do is to record each recording session as an indexed array, so that the ROI's can be viewed later, separately.

 

Thanks in advance 🙂

0 Kudos
Message 1 of 10
(4,125 Views)

If I understand correctly, a solution could be to create a custom datatype that is a cluster containing a numeric control and an array of coordinates. Then you could build an array of these clusters using the numeric controls as indeces. This array would have all your recorded ROIs.

 

Hope this helps,

Norbert

Message 2 of 10
(4,106 Views)

Hi Nobert,

 

I didn't quite get that, how do I go about creating an indexed array of cluster in the first place?

 

-Amit

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

Hey Amit,

 

This is what I meant:

 

ROI.png

 

Kind Regards,

Norbert

Message 4 of 10
(4,079 Views)

with what u showed, the ROI's are created within the case, and the shift registers provided to index with the while din't actually work out. I modified a lil to get that done, but now it just works continuous and not allowing me to set a start point for the next ROI like i had in the previous. Also trying to view the indexed ROI separately with index array function but the graph is not taking the output from the function as input

0 Kudos
Message 5 of 10
(4,044 Views)

Give this a try. I added a name to your array of clusters at the shift register initialization. This allowed me to unbundle by name after the index that you care about. That unbundled array can now be plotted.

I also added a Stop Recording button, separate from the Stop button. This allows you to stop recording, but not stop the application. You still want to stop the application if the user is already recording, so I added a local variable there for the Stop button.

StartStop Rec Cursor.png

 

 

If you plan on improving upon this software more and adding things to it, I suggest you redo it with a better architecture. What you have now is dangerous and hard/impossible to scale.

The Simple State Machine template that ships with LabVIEW is really the best way for new developers to get familiar with LabVIEW while utilizing a semi-scalable architecture.

Here's a broad example of how a state machine works:

  • States: Init, Idle, Exit, DoThing1, DoThing2, DoThing3
  • Each state contains code that might take some time. Ideally, not too long because that's how long your code could be unresponsive.
  • The Idle state contains an event structure for all user interaction.
  • The front panel has a button that says "Do Thing 1".
  1. Loop Iteration 0: Application begins, first state is Init. The Init state does some initialization stuff and tells the application to go to the Idle state when finished.
  2. Loop Iteration 1: Application goes to Idle state. It sits there, waiting at the event structure.
  3. Time goes by, then user presses button "Do Thing 1". There is no code, or minimal code, within this event case. The output of this event state tells the application to go to the DoThing1 state.
  4. Loop Iteration 3: Application goes to DoThing1 state. There is code here that does some stuff. The output of DoThing1 state tells the application to go back to the Idle state.
  5. Loop Iteration 4: Application goes to Idle state where it waits at the event structure again.
  • Each of the states can tell the application to go to any state they want. Want to reinitialize? Go to the Init state again. Want to end the program? Go to the Exit state. Want each state to trigger another (like a sequence)? Have DoThing1 output DoThing2, which outputs DoThing3,  which outputs Idle.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 6 of 10
(4,026 Views)

Thank you James for insisting on using the state machine way of programming.

This is my first attempt to it, and as far as I look at it, it looks much less complicated. But again I'm having trouble when it comes to viewing my indexed cursor  plots. Please spend a few minutes more on this and help me out. Thanks in advance 🙂 .

 

1.Easy draw with cursor index is the one that I built to have multiple ROI

 

2.Easy_draw-C_indexed-plot_view is the one that i tried to view indexed cursor plot

Download All
0 Kudos
Message 7 of 10
(3,977 Views)

Another possiblity is to use a Variant Attribute.  Take your array of ROI points and store them as an attribute in a variant.  This gives you the benefit of being able to set and get using a string name not just an index.  Users like being able to name things how they want.  I made a wrapper called Variant Repository to demonstrate XNodes.  XNodes are experimenta, undocumented and in most cases should be avoided.  Because of that I also made a non-Xnode version that works on the same idea using polymorphic VIs.

 

https://lavag.org/topic/18479-cr-variant-repository/#entry113363

0 Kudos
Message 8 of 10
(3,966 Views)

Thanks Hoovah

 

But I could not digest things about xnodes. Went way over my head 😞 . My bad.

I downloaded the zip file with the xnode vis but had no clue what to do with them, I went throught the crash course on xnodes that u have linked in ur post aswell.

Isn't there an easier way to just create a 2D array with the cursor index and the cursor position array from within the event so that when the next button is clicked, the array is updated with the current cursor index and the plot against it? Then using indexed array, we can easily plot the required cursor plot.

 

Writing to an excel sheet would also suffice, if that's an easy way of makin a 2d array with the two parameters (cursor index, cursor position array)

 

Please help me.

0 Kudos
Message 9 of 10
(3,939 Views)

@amithkuttan wrote:

 

Isn't there an easier way to just create a 2D array with the cursor index and the cursor position array from within the event so that when the next button is clicked, the array is updated with the current cursor index and the plot against it? Then using indexed array, we can easily plot the required cursor plot.


Oh absolutely, sorry if it wasn't clear I was not suggesting you use XNodes AT ALL. I was suggesting you use the non-Xnode version of my Variant Repository which was the link I posted.  It just uses Variant Attributes to write and read values in a table that uses keys and values.

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