display depth of stimulus (front, back, behind in front) - psychopy

According to http://www.psychopy.org/api/visual/textstim.html 'depth' is now deprecated and 'Depth is now controlled simply by drawing order.'
I'm using Builder 1.80.06 and have most stimuli defined in Routine dialogs but I need to draw some at runtime using code and I want them to go behind the other stimuli but can't work out how to do this.
Is there any way this can be done now?

The Code Component code really is inserted in order, as well as the code form standard components. The order of code in different Routines during creation is unspecified (you don't have control over which Routine's "Begin Experiment" code is executed first) but this doesn't affect your drawing depth anyway.
The key is that in your Routine the code in the "Every Frame" section, with the draw() command, has to be in the right order (before your standard components).

UPDATE: given the new details, I believe that Jon's answer is the correct one.
OLD ANSWER: Since 1.72.00, the order of drawing in Builder is controlled by their order in the rutine. The topmost component is drawn first, then then the second on top and so on. The bottom component is always on top.
The order of components in a routine can be changed by right-clicking on a component to bring up a contextual menu with items like "move up", "move down", "move to top", etc.
As a side note: in code, the drawing order is simply the order of the lines of code:
background.draw()
stim.draw() # on top of background
fixationCross.draw() # on top of the other.
win.flip() # show it
You can verify that Builder does exactly this by looking at the python code it generates.

Related

Calling another VI at runtime

I have created two vi's in LabVIEW: one to acquire serial data and another to plot the acquired data on an XY graph.
The second VI gets called when a Value Change event occurs on a button in the first VI. But the problem is that when the second VI is called the first VI suspends its operation, hence the values don't get updated.
Is there any solution for this?
First VI block diagram:
First VI front panel:
Second VI (ALL DATA) block diagram:
Well, you are doing some nasty stuff with global variables. This works but is not considered as good practice. (Have a look at queues and notifiers). Further, I don't see how your data gets written to those variables...
In any case, put your 2nd VI in a separate while-loop and schedule it to about 100ms (that is usually enough to update front panels or to interact with users. I'm not sure if your button-event is the right way to go. That is exactly because, the second VI waits for the callback. Just use a simple button and a true-false case to let the second VI keep running (this should even be the solution if you don't want to move the case to a second VI). Just make sure that you change the mechanics of the button to be a switch because you're checking its value not at infinite speed and you want to ensure that it gets caught every time, you click it;)
You will need to use the VI Server functionality. The exact method has changed over the years, but I believe the current recommended implementation is to use 'Start Asynchronous Call'
There is an example that you can view using the example finder. To open the example finder navigate to Help>Find Examples. Then select the 'Search' tab and search for 'asynchronous'. Finally select the VI called 'Asynchronous Call and Forget.vi'
There are other variations for asynchronous implementations, but this is probably a good place to start.

write into popup

I have to display a popup for a legend like in STMS transaction
I know how to write this tab with WRITE statement, but how can I display it in a popup?
You can achieve this by using CALL SCREEN ... STARTING AT ..., then using SUPPRESS DIALOG in the PBO processing to bypass the screen (dynpro) processor. Then, in the PAI processing, use LEAVE TO LIST-PROCESSING followed by the WRITE statements. You can follow this in the function module TMS_UI_POPUP_LEGENDE that shows the popup you mentioned as a reference. The procedure is documented in the online help as well.
In an ABAP dialog application, you're either working with screens or with (interactive) lists. To get a popup window, you have to create and CALL a custom screen (dynpro). Inside that screen, you hand over control to the list processor. That's the component responsible for taking what ever you WRITE and place it somewhere on the screen. For some - probably mostly historical - reason, the command to do so is LEAVE TO LIST-PROCESSING. I suppose that at some point, the intended flow between screens and lists was different from what it has become today, and that was the reason for naming the command this way. From a modern point of view and especially in your use case, the LEAVE aspect does not make any sense, so just take it as it is and use it.
Also note that it's LEAVETOLIST PROCESSING - LEAVE LIST-PROCESSING without TO is the opposite statement!

Drawing Interactive paths in JavaFX 8?

(please excuse any mistakes in the way of questioning/ formatting the question since I'm new)
[Please Note that I cannot post code here as yet, and FXML code isnt worth posting right ?
Also, my GUI programming experience before this is very little... I picked up JavaFX 8 first because I use Java, and heard that FX >> Swing in many ways]
I am trying to make a GUI that allows the user to input the NumberLink puzzle numbers (through mouse action events), and then, displays the puzzle in a grid with features to draw a path, and undo it. This is almost exactly the same functionality as in Numberlink on Nikoli. The puzzle is quite interesting, and these are the rules. The goal of the UI is for the user to interactively solve the puzzle by drawing lines,etc, just as on Nikoli's site. The solver will be a later addition.
In my project, I have a Stage in which a setup Scene prompts user for rows and columns (to take size of puzzle),
next, it generates an empty grid (I'm thinking of using a GridPane here), and the user clicks the squares to enter the numbers into the square. this phase isnt a problem if I use TextFields and mouse listeners and store info in a grid... the next phase is what I'm stuck at... unless I know exactly how to do that, I cant make progress...
in the third stage, I have to display the numbers to the user just like on the Nikoli site (the highlighting number pairs on mouse hover is a necessary feature too, which I think I can handle with CSS).. and the user should draw paths between the numbers, just as on that site ( I thought VLineTo and HLineTo classes would be suitable.. but I'm not sure, and cant find any alternatives) Please help on this ...
So with this in mind, I made FXML based dummy gui layouts to test if my ideas work...
and I cant get the GridPane to have lines drawing atop it (meaning, I cant place Line objects like HLineTo on top of the grid panes).... is there any other way to do what I need to do ?
I also thought of making multiple Canvas objects in a grid (each square is its own canvas), having the numbers as Text objects, and a Canvas on top of the grid with transparency ON, and having them both on a StackPane, but then, the StackPane's children will not be synchronised.
Please help point me in the right direction, thanks (tell me if I'm missing something basic, which I think I am).
You can wrap the GridPane in an AnchorPane, then use getChildren().add(Node node).
Assuming your controller has defined <AnchorPane fx:id="anchorpane"...> and implements Initializable
#FXML private AnchorPane anchorpane;
#Override
public void initialize(URL location, ResourceBundle resources) {
Line line = new Line(double startX, double startY, double endX, double endY);
anchorpane.getChildren.add(line);
}
NOTE: The line should actually be dependent on mouse events, so it really shouldn't even be in your initialize method; but it should help you get started with what you want to do.
HTH

What is the most efficient way to quickly understand how a complex LabView VI works?

What is the best way to understand a complex LabView VI that controls a motor?
My goal is to control the motor from a joystick.
The wiring diagram shown below allows a LabView user to control the motor from the LabView GUI: move a slider up and down either increasing or decreasing the desired velocity. As the slider's value changes, it is fed into a bunch of math controls and eventually gets converted into a command string for the motor to interpret. This command string, if I understand correctly, is bunch of bytes that get written to the serial port.
Instead of using the LabView GUI to control the motor, I would like to use the joystick.
What is the best way to approach this?
The joystick has pitch,yaw,roll,and throttle. Which one relates best to the velocity of a motor?
The answer to your title "What is the most efficient way to quickly understand how a complex LabView VI works?" is probably to do some combination of the following:
Look at the VI's inputs and outputs to try and understand what they are there for. The label and caption of controls and indicators may be helpful, also right-click to check the description and tip.
As well as controls and indicators, look for other I/O: queues, notifiers, global variables, file read/writes, instrument communications, and for any data storage that persists between calls such as an uninitialised shift register.
Look at the overall structure of the VI to see how it executes, e.g. is it a one-off operation, does it execute different cases depending on some input, does it loop until a certain condition happens, does it use a state machine structure, etc
Break down the VI's structure into smaller pieces that you can understand. You could print the diagram out and annotate it by hand, or add frame decorations and text comments to the diagram to record what you deduce. If the diagram is cluttered or poorly laid out, rearrange it as you go along (use Ctrl-click and drag on the diagram background to add blank space where you need it).
Set probes on key wires and watch them while the VI runs to see what happens
If possible, manually set the VI's controls to example values and run it to see what happens (this may not work if the VI depends on other parts of a program running at the same time)
Write a test wrapper VI that calls the complex VI and supplies it with example data or inputs to see what happens.
To address your specific question about the VI diagram you've posted, I can see various controls for quantities such as Velocity, Position, Amplitude, Max A (amplitude?), Frequency and so on. You need to decide which of these quantities should be controlled by which axis or output of your joystick. Then you need to add code that reads those values from your joystick, and modify the existing code so that the parameters you want to control are supplied by the joystick values instead of the front panel controls. You could probably just put the joystick reading code inside the existing loop, wire the joystick outputs to join up with the wires from the front panel controls you want to replace, and then change the relevant front panel controls to indicators from the right-click menu so that they will show the values you are getting from the joystick.
The best way is to write one from scratch. But you could analyse the code by clicking the Highlight Execution button to display an animation of the block diagram execution when you run the VI, and use probes to check intermediate values. And you probably should also do an on-line course, e.g. LabVIEW Training: Learn LabVIEW in Three or Six Hours
My answer to your third question is "throttle.".

LINQPad: Anyway to make the Dump() results be initially collapsed?

Couldn't find it anywhere (google or stackoverflow).
Is there a way to force Dump()'s output to be automatically collapsed?
Update:
Some more info, to bring more focus to the question.
As mentioned below Collapsing can be done after the output as rendered via keyboard shortcust (Alt+1, Alt+2, Alt+3)
And can rendering depth can be determined by passing an int depth param, but that does not allow to expand the results.
Is there some way to change the CSS formatting? I'm not that fluent in CSS, so this might be the solution.
Why I need this:
What I want is to make the output 'cleaner', and dive in when something of interest show's up.
I'm running a query repeatedly, and don't need all of the output all the time, but still using my human abilities to detect change, instead of coding the detection.
Update: November 2013
As Joe (the author himself!) mentions in the comments, LINQPad no longer has the limitation described.
It is now possible to state 0 and collapse the information after it's rendered.
No, although you can call Dump with a number to force it to display to that nesting depth:
.Dump(0)
You can also use the formatting shortcuts (Alt+1, Alt+2, Alt+3) to collapse the whole display to one, two or three levels.
Another option is to dump to grids. Call Dump(true) or use the toolbar button. Grids show only one level and subsequent levels are shown upon demand with hyperlinks.