问题
I'm totally new to PsychoPy and I'm working with Builder. I'm not familiar with Python coding at all.
I have audio stimuli that have variable durations. In each trial, I want the second stimulus to start 500ms or 1500ms after the end of the first stimulus. Is there a way to do this in Builder? If I have to do it on Coder, what should I do?
Thank you very much!
回答1:
Absolutely. Think of 500ms and 1500ms as two different conditions that you loop over in addition. These two conditions are crossed with the different durations.
In you conditions file, where you have the different durations (or you could just do that using a random function of course), for every duration add two rows with a column "soa" (or whatever you want to call it) with the two values 500ms and 1500ms. In the builder interface you can choose whether order of presentation should be sequential, randomized within block or fully randomized across all trials (not just within block). Also, if you don't want it balanced (e.g. 20% 1500ms and 80% 500ms), you can just add the appropriate number of rows to achieve this balance (1 out of 5 is 1500 ms).
Nearly all demos handles trials in this way, so take a look in Builder --> Demos, click on the loop and see how it's done there. Also, read the relevant section of the online documentation and see a video tutorial also incorporating it.
回答2:
In concrete terms, when you add a Sound component in Builder, you just need to add an expression in the "Start (time)" field that takes account of the duration of the first sound stimulus and the ISI for this trial.
So if you have a column for the ISI in the conditions file as Jonas suggests (let's say it is called "ISI") and a Sound component for the first auditory stimulus (called, say, "sound1"), then you could put this in the Start field of the second sound stimulus:
$sound1.getDuration() + ISI
The $ symbol indicates that this line is to be interpreted as a Python code expression and not as a literal duration.
This assumes that sound1 starts at the very beginning of a trial. If it starts, say 1 second into the trial, then just add a constant to the expression:
$1.0 + sound1.getDuration() + ISI
Your ISI column should contain values in seconds. If you prefer milliseconds, then do this:
$sound1.getDuration() + ISI/1000.0
来源:https://stackoverflow.com/questions/24064222/variable-stimuli-duration-but-two-kinds-of-fixed-isi-in-psychopy