[visionegg] Re: Go loops
- From: Andrew Straw <astraw@xxxxxxxxxxx>
- To: visionegg@xxxxxxxxxxxxx, smbhagat@xxxxxxxxxxxxxxx
- Date: Tue, 30 Nov 2004 11:19:03 -0800
Dear Smriti,
It's a bit hard to follow what's going on without code, but it seems
like you may be creating a new instance of Presentation on each trial,
or at least slighly abusing the FlowControl system. (Well, my fault for
foisting such a complex beast on the world!)
I have 2 alternative suggestions:
1) Drop the whole "go loop" (VisionEgg.FlowControl) thing and write your
own loops. I find this more natural when running block trials requiring
user responses such as your paradigm.
2) Instead of repeatedly calling Presentation.run_forever() (which is
only meant to be called once), make each trial a single pass through the
go() function (without entering between_go_loops). Then reset
parameters in preparation for the next trial and call go() again to repeat.
This will require some changes to the controller code what you have
already written. Here's an (untested) prototype which I just whipped up:
p = Presentation(blah,blah,blah)
def keydown(event):
"""handle responses from subject"""
# get current time since go from Presentation instance
t = p.time_sec_since_go # shorthand
if t < 5.0:
# too early, we don't care yet
return
if event.key == pygame.locals.K_q:
print '"q" key pressed'
p.parameters.go_duration = (0,'frames')
def every_frame_func(t=None):
"""gets called on every frame"""
if t > 10.0:
# subject took too long
print 'subject took too long, ending trial anyway'
p.parameters.go_duration = (0,'frames')
p.parameters.handle_event_callbacks = [(pygame.locals.KEYDOWN, keydown)]
p.add_controller(None, None,
FunctionController(during_go_func=every_frame_func) )
for i in range(200): # do 200 trials:
p.parameters.go_duration = ('forever',)
# set other stimulus parameters here
p.go()
Smriti Bhagat wrote:
Hi!
I have been using go loops with run forever and am experiencing trouble.
I want a stimulus to appear after some secs of the start of a trial, and I
want many trials repeated this way.
So typically I would have :
Start Trial -> n secs -> stimulus appears -> stimulus disappears ->
response -> next trial.
Each trial runs for fixed length of time.
For this I am doing:
during_go_func : display stimulus
between_go_func : display another stimulus
and start another p.go()
p.run_forever()
This ensures that my experiment runs forever (until stopped) and each
trial is a fixed time go loop.
This works fine, except when I make the number of trials in an experiment
more than 260, when it says too many recursions.
I am looking for a cleaner way to do this.
Any ideas?
Thanks,
-Smriti.
======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html
--
Andrew D. Straw Post-doctoral scholar
,-. Dickinson Lab
\_/ California Institute of Technology
8||} Mailcode 138-78
/ \ Pasadena CA 91125, USA
`-^
email: astraw@xxxxxxxxxxx
office: +1 626 395 5828
======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html
- References:
- [visionegg] Go loops
- From: Smriti Bhagat
Other related posts:
- » [visionegg] Go loops
- » [visionegg] Re: Go loops
Hi! I have been using go loops with run forever and am experiencing trouble.
I want a stimulus to appear after some secs of the start of a trial, and I want many trials repeated this way. So typically I would have : Start Trial -> n secs -> stimulus appears -> stimulus disappears -> response -> next trial. Each trial runs for fixed length of time.
For this I am doing:
during_go_func : display stimulus
between_go_func : display another stimulus
and start another p.go()
p.run_forever()This ensures that my experiment runs forever (until stopped) and each trial is a fixed time go loop. This works fine, except when I make the number of trials in an experiment more than 260, when it says too many recursions.
I am looking for a cleaner way to do this. Any ideas?
Thanks, -Smriti.
======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html
====================================== The Vision Egg mailing list Archives: http://www.freelists.org/archives/visionegg Website: http://www.visionegg.org/mailinglist.html
- [visionegg] Go loops
- From: Smriti Bhagat