[visionegg] Re: newbie question i'm afraid...

  • From: "Gary Lupyan" <glupyan@xxxxxxxxx>
  • To: visionegg@xxxxxxxxxxxxx
  • Date: Tue, 2 Dec 2008 11:45:06 -0500

Roger, most people I know that use visionEgg end up not using the go_loops
for trial-based experiments.  Here's what I do:

This is the code that shows the stimulus on each trial:

       responded = False
        timeElapsed = False
        self.setAndPresentStimulus([self.fix1, self.fix2,self.firstStim])
#fixation + first pic + second pic
        pygame.event.clear() #discount any keypresses that may happen early
        responseStart = time.time()
        while not responded:
self.fix2,self.firstStim]) #fixation + first pic
            for event in pygame.event.get(pygame.KEYDOWN): #go through the
stack of the keys pressed
                if event.key == self.experiment.catResp or event.key ==
self.experiment.dogResp: #only terminate trial if a valid key is pressed
                    response = event.key
                    rt = time.time() - responseStart
                    responded = True

        isRight = self.isResponseCorrect(response,

The above code is embedded in a function (presentExperimentTrial) that's
executed on every trial by a separate function like so:

        for blockIndex in range(numBlocks):
            random.shuffle(self.trialListMatrix) #shuffle the trial list
(once per block)
            for trialIndex in range(numTrials):

                #take break every X trials (for blocks that have hundreds of
                if trialIndex>0 and trialIndex %
self.experiment.takeBreakEveryXTrials == 0:
                    self.showText(self.experiment.takeBreak) #take a break

                random.shuffle(self.locations) #shuffle the locations -
every trial

                #assign stimuli to picture files (textures)

                self.firstStim.parameters.texture =

                #set the screen locations of the stimuli
                self.firstLocation = self.locations[0]
                self.firstStim.parameters.position =

                """This is what's shown on every trial"""

On Tue, Dec 2, 2008 at 10:01 AM, Roger.Santer <roger.santer@xxxxx> wrote:

>  Hello,
> I'm new to visionegg (and computer programming generally!), so apologies
> for the simplicity of this query!
> I've designed a simple stimulus that I'd like to run every time I press a
> key, returning to a particular screen in between presentations. I understand
> that I can do this using run_forever and multiple go loops, but I can't seem
> to figure it out in practice.
> I just wondered if anyone had any sample code that they wouldn't mind me
> taking a look at, so that I could get my head around how this works?
> Many thanks in advance!
> Roger

Other related posts: