WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 07-04-2019, 11:51 AM
hannahapz hannahapz is offline
Member
 
Join Date: Apr 2018
Posts: 22
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()
Reply With Quote
  #2  
Old 07-04-2019, 12:11 PM
hannahapz hannahapz is offline
Member
 
Join Date: Apr 2018
Posts: 22
One thing I should probably mention is that the main_function runs on every frame.
Reply With Quote
  #3  
Old 07-04-2019, 11:14 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
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() )
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 06:22 AM.


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