OS (e.g. Win10): Mac PsychoPy version (e.g. 1.84.x): 20.2.10
What are you trying to achieve?:
I want to use previous stimuli in the conditions file in a subsequent routine. In other words: in the first routine participants get to see 10 words randomly (by using a loop) from a list of 80 words. In the second routine I want them to show them the 10 words that were shown in the previous routine. But because they were randomized I am not sure how to get them in the second routine.
What did you try to make it work?:
I tried to use get.Earlier.Trials but can not figure out how to make it work.
for example I added in code_2 in Test1_2 (second routine):
begin experiment:
word = ‘default’
index = -10
get.EarlierTrial(n=index)[‘word’]
end experiment:
index +1
thisExp.addData(‘word’, word)
What specifically went wrong when you tried that?:
the function get.EarlierTrial does not work this way (needs to be something before the .get: NameError: name ‘get’ is not defined), but I can’t find out how to make it work
If I try to make it a variable, this also doesn’t work (Python code not correct):
var = get.EarlierTrial(n=index)[‘word’]
For example, say that your image in your first routine is set on each trial using a variable/column header called ‘thisIm’. Add a code component to your ‘Trial_1’ routine.
In the ‘Begin experiment’ tab, write:
presentedIms=[]
Then in the Begin Routine tab, write:
presentedIms.append(thisIm) #adding the presented image to the list of images
Then, in your next routine (‘Trial_2’ where I think you want the images to again be presented) instead of getting ‘thisIm’ from a file, retrieve it from your list. So, add a code component and in the ‘Begin Experiment’ tab write:
thisTrialN = 0
then in the ‘Begin routine’ tab, write:
thisIm = presentedIms[thisTrialN]# retrieve the image in the list corresponding to this trialN
thisTrialN +=1 #increase the trial counter by 1
If you want the images to be presented in a random order in the second routine (rather than the same order that they were presented in) use shuffle(presentedIms) in the End Routine tab of your first routine
Yes it worked, super, thanks a lot! So does this mean the get.EarlierTrial is meant to use for other purposes?
One small question related to the use of the textbox (textbox 2 psychopy it says): I am trying to code whether the answer was correct (1) or not (0). In order to do so, I compare the answer in the textbox to the actual stimulus/
first I define: text = ‘Antwort:’ + wordu1
(because it was not possible to use an empty textbox with only a cursor, in this case psychopy would say text.replace was nonetype
Then in a next routine box (but within the same trial) I test the following:
if text == textbox_4.text:
score = score + 1
else:
score = score + 0
Although my result data file shows that the text and textbox are the same the score does not add up… Does this have to do with features of the textbox maybe?
Please this works! Honestly, I actually can’t say I have ever used the ‘getEarlier’ method, But it looks like this is to retrieve a single trial rather than multiple (i’ll look into it).
For your textbox query - would you please open a seperate topic for that? It helps us keep topics organised and easier for future usuers to find similar issues!