Hey, everyone.
I’m running my experiment in dot-probe task with emontional word stimuli.
The problem is: I need to randomize word presentation, but not to randomize their locations and connections with dot. (Basically I need two variasbles from xls file be random and the other - to be presented in sequentual order). It is crucial, because I need to control the order of Congruent and Incongruent trials (there should be no more then three same-type trials in the row - actually, if you have an idea, how I can randomize all variables but considering this rule it would be brilliant, but the first type is acceptable in my case)
I am really bad (seriously) in Python, so my own pathetic attempts were unsuccessfull.
Please write your comments and suggestions as full as possible (I mean mentioning the files I need to look for and parts of code, i need to work with)
And sorry for my english.
Ann.
Hi there,
don’t worry about asking for help!
Have you started making your experiment at all? I think what you want to achieve wouldn’t be too hard. If you have started already and have at least something ready (a script if you are writing this as a script, or a .psyexp file if you are building this in the Builder interface), it would be great if you could post it since it will be much easier to help you out.
If you have not started yet, I recommend that you give it a go (maybe start by having a look at the demos that you get in psychopy). You could probably make your experiment so that it randomises all variables first, and then fix the order of one of the variables once you have everything else working.
If I was doing this myself, I would probably use a normal psychopy trial loop (either using the “insert loop” part in the Builder interface, or by using the function psychopy.data.TrialHandler itself if you are writing this in code) and just randomise the variables you’d like to have randomised. I’d then have another file with the variables that you do not want randomised, and simply use the number of your current trial to find the location the word is supposed to be in.
But I think there are more than one way of doing this - I think starting by writing your code to have a running experiment first may be easiest though.
Hi!
Thanks a lot for your immediate reply!
Yes, I have already written my experiment using Builder, and it works fine except the fact it now goes fully sequential.
What I need (if we go easier route) is to have variables $Word and $NeutralWord from .xlsx file to be randomly selected.
Here they are:
dotprobe.psyexp (24.3 KB)
3.xlsx (10.6 KB)
OK, that looks great
I have to admit that I don’t have much experience with the “Builder” in psychopy, so I turned your experiment into a script so I could edit it. If you open the attached script in the psychopy coder, it should hopefully achieve what you wanted. I made two extra Excel files for this, one with all the words and one with all the neutral words.
Effectively, what I did was create two new TrialHandler objects, one for each of your sets of words. These are set to random, and the words are drawn from them. They should still be saved properly in your experiment. If someone else has a “neater” way of doing this, then they should definitely say so… This solution seems to work, but it’s not my favorite since it’s a little hacky.
Let me know if this works for you.
dotprobe.py (26.7 KB)
neutralWordsOnly.xlsx (8.6 KB)
sequentialsOnly.xlsx (10.4 KB)
wordsOnly.xlsx (9.6 KB)
Oh, thankyouthankyouthankyou!
Everything is working just perfect!
Have a small dumb question - where and how should I write command to repeat the whole trial except instruction part for n times?
Hi,
great!
If you want each trial to be repeated n times (so each word will come up n times), you need to edit lines 208-221. They look like this:
# set up handler to look after randomisation of conditions etc
trials = data.TrialHandler(nReps=1, method='sequential',
extraInfo=expInfo, originPath=-1,
trialList=data.importConditions('stimulus\\sequentialsOnly.xlsx'),
seed=None, name='trials')
# a CUSTOM word loop
wordTrials = data.TrialHandler(nReps=1, method='random',
extraInfo=expInfo, originPath=-1,
trialList=data.importConditions('stimulus\\wordsOnly.xlsx'),
seed=None, name='wordTrials')
neutralWordTrials = data.TrialHandler(nReps=1, method='random',
extraInfo=expInfo, originPath=-1,
trialList=data.importConditions('stimulus\\neutralWordsOnly.xlsx'),
seed=None, name='neutralWordTrials')
The number that determines how often each word is repeated is nReps
, so if you change that to any other number, it will repeat that amount of times. Make sure to change all three times nReps
comes up.
This will make it random what Word is paired with what neutralWord
each time though - so you may have the same Word paired with the same neutralWord
n times on one run, and completely different ones on another run. I’m not sure if this will affect your experiment but it’s important to remember that!
Only I started to be happy with my experiment…
I was forced to cut the number of words presented in the list to 10 by my colleagues . And I noticed that because of randomization some runs end up using only 4/10 words from the list and therefore repeating them too often in one run. Is there any way to deal with it?
And the second side-question: if I want to add almost the same trial except it needs to use other xlsx for emotional words (the sequence should be 5 repetition with one condition, then 5 - with the other), do I need to create whole new trial or can somehow insert it in current one?
Thank you a lot for your answers. You are saving my nerve cells and whole experiment
Hm, that’s surprising. The following need to be true:
- you need to have the same number of rows in all three spreadsheets
- nReps needs to be the same all three times it’s used
If both these points are true, your experiment should run through all words the same number of times. Could you double-check this and then let me know if you’re still having the issue of only some words being displayed?
I’m a little confused by your second question After you run through the current experiment, you want to run another set of trials with different words - but you want this to look like they are part of the same experiment? Otherwise, you could simply make a new script and run your second set of words separately.
I doublechecked. Still confused - it present’s one of the words 5 times in a row.
Can you take a look? Maybe I am just being blind to something.
dotprobe.py (27.4 KB)
neutralWordsOnly.xlsx (8.2 KB)
(two other files in the next message, because I can upload only two files per message)
Yes, you got it right. I want to run experiment with current set of words for 5 times and after that - 5 more repetitions with other words.
Hi there,
I’m sorry for responding so slowly. I’m afraid I can’t replicate your issue! When I run it, it randomises the words just like it is supposed to.
You could try changing the string 'random'
to 'fullRandom'
on lines 223 and 227 to see if maybe that helps at all?
As for going through 2 sets of 5 words each: You can loop through what you have already. I have added this to the script and attached it. I created 2 sets of files, one for loop 1 and one for loop 2. Can you check if that works for you?
Best,
Jan
sequentialsOnly1.xlsx (9.9 KB)
sequentialsOnly2.xlsx (9.9 KB)
neutralWordsOnly1.xlsx (8.5 KB)
neutralWordsOnly2.xlsx (8.5 KB)
wordsOnly1.xlsx (9.3 KB)
wordsOnly2.xlsx (9.3 KB)
dotprobe.py (28.9 KB)