[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
on
responseStart = time.time()
while not responded:
self.setAndPresentStimulus([self.fix1,
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
pygame.event.clear()
responded = True
break
isRight = self.isResponseCorrect(response,
self.trialListMatrix[trialIndex].firstStim[0])
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
trials....)
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 =
self.pictureMatrix[self.trialListMatrix[trialIndex].firstStim][0]
#set the screen locations of the stimuli
self.firstLocation = self.locations[0]
self.firstStim.parameters.position =
self.experiment.stimPositions[self.firstLocation]
"""This is what's shown on every trial"""
self.presentExperimentTrial(blockIndex,trialIndex,whichPart)
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: