A more all-round solution for all kinds of objects is to run import copy in the beginning of the experiment and then add data like thisExp.addData("foo", py(foo)) in the other codeblocks (if you have a complicated object, use epcopy instead). One can also do thisExp.addData("foo", ). The simplest is probably to replace the addData calls with thisExp.addData("foo", tuple(foo)) which converts the mutable list to an immutable tuple. But not for immutables, like numbers, tuples and strings! That's why your script works for digits but not for the list. It applies to all python mutables: lists, dicts, functions, and classes. This assignment-by-reference can be extremely beautiful and handy, but sometimes cause headache like in your example. Since the log is only saved in the end of the experiment, all the rows in "foo" now points to the "foo variable" which now holds the value. In your case, the TrialHandler receives the reference, which simply points to the "foo" variable which is updated throughout the experiment. New = 'Oops' # original is now as is new (which is just a reference or pointer New = original # new is simply a reference to original! It is not a copy. This is explained in detail elsewhere but briefly, original = It's probably because python assigns by reference rather than copy. Is there a way to force the output to capture/display any of these variables as they are when the addData() is invoked rather than waiting until the end of the loop? Is there a way to make the list output perform as the others do? For example, you can achieve this in E-Prime with the SlideState.HitTest (x, y) method, where x and y are mouse coordinates. What is the logic and rationale behind this? When the participant clicks on a stimulus, I need the name of that stimulus item available for use in the rest of the script. But calling out individual elements of the list displays as individual variables do. Is this the expected output? If so, why? Note that the individual variables, x, y, and z, are displaying updated values each time through the loop (at the end of the loop), while the list foo shows only the final value after the loop iterates all five times, but it shows this in every line. The relevant columns of the CSV output file are as follows: trials.thisRepN trials.thisTrialN trials.thisN trials.thisIndex x y z foo fooY Hi There, Yes I think there is an issue with line colour at the moment online - could you instead. However, we would also like a trigger to. The program runs locally, but the linecolor does not change. The routines "One", "Two", and "Three" form a loop in that order executed five times. In a behavioural experiment involving TMS-EEG, we have managed to get the TMS pulse to show as a trigger on TMSi through PsychoPy. There is no other code, no other components. "Three", in a loop, the following code in "End Routine": z = z + 3 "Two", in a loop, the following code in "End Routine": y = y + 2 "One", in a loop, the following code in "End Routine": x = x + 1 "Init", not in a loop, the following code in "Begin Experiment": x = 0 I have a test PsychoPy Builder script that I am using to investigate some counter-intuitive behaviour.
0 Comments
Leave a Reply. |