#1
|
|||
|
|||
Timer and Visibility Issue
This is my goal:
1) A appears for 500 msec (this is the cue) 2) Inter-stimulus interval of 650 msec (ISI) 3) B appears for 500 msec (this is the main stimulus) and then disappears Right now, I have 1) and 2) successfully coded, but B doesn't want to go away (it stays on-screen). When I try to time B to become invisible, it never appears in the first place. Below is the code representing this situation. The main_function calls the Timer/Visibility functions. A and B represent the cue and stimulus object nodes, respectively. Code:
def cueshow(): cue.setPosition([x,y,z]) cue.visible(viz.ON) #make target visible starttimer(0, 0.5) # cue is visible for 500 msec callback(viz.TIMER_EVENT,CueTimer) #then make cue invisible def CueTimer(num): cue.visible(viz.OFF) def stimshow(): starttimer(0, 1.15) # wait 1.15 seconds (500 msec of when cue first appears + 650 msec ISI) callback(viz.TIMER_EVENT,StimTimer) # then make target visible def StimTimer(num): node.setPosition([x,y,z]) node.visible(viz.ON) def stimhide(): starttimer(1, 1.65) # wait 1.65 seconds until turning stimulus off callback(viz.TIMER_EVENT,StimHideTimer) def StimHideTimer(num): node.visible(viz.OFF) def main_function(): A.cueshow() B.stimshow() B.stimhide() |
#2
|
|||
|
|||
One thing I should probably mention is that the main_function runs on every frame.
|
#3
|
|||
|
|||
Try using a task function to control the program flow. For example:
Code:
''' Press spacebar to start ''' import viz import vizinfo import viztask viz.go() vizinfo.InfoPanel() dojo = viz.addChild('dojo.osgb') cue = viz.addChild('soccerball.osgb',pos=[0,1.8,2]) cue.visible(viz.OFF) stim = viz.addChild('basketball.osgb',pos=[0,1.8,2]) stim.visible(viz.OFF) def experimentTask(): yield viztask.waitKeyDown(' ') cue.visible(viz.ON) yield viztask.waitTime(0.5) cue.visible(viz.OFF) yield viztask.waitTime(0.65) stim.visible(viz.ON) yield viztask.waitTime(0.5) stim.visible(viz.OFF) viztask.schedule( experimentTask() ) |
|
|