WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Timer and Visibility Issue (https://forum.worldviz.com/showthread.php?t=6263)

hannahapz 07-04-2019 12:51 PM

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()


hannahapz 07-04-2019 01:11 PM

One thing I should probably mention is that the main_function runs on every frame.

Jeff 07-05-2019 12:14 AM

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() )



All times are GMT -7. The time now is 02:26 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC