WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 10-30-2021, 04:59 AM
Roy Roy is offline
Member
 
Join Date: Dec 2019
Posts: 12
Cedrus Response Pad in Vizard

What's the differences between vizcedurus and vizxid modules in Vizard 7?

There are already some posts about Cedrus response pad, but a bit confusing how to use it as a response device in Vizard.
For example, what' the easy or suitable way to use the Cedrus pad as a response device like a general keyboard to get the response time and pressed key?
Reply With Quote
  #2  
Old 11-09-2021, 09:26 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
I think vizxid is the more recent of the two modules. The following code has worked for other users with a Cedrus response pad. Does this work for you?

Code:
import viz
import viztask

viz.go()

#Connect to xid device
import vizxid
vizxid.open(18) #Default: port=1 , baudRate=115200

def TestReactionTime():
	
	#Add instruction label
	label = viz.addText('Press the spacebar to start the experiment\nWhen the red square turns green, press button 3 on the cedrus pad',viz.ORTHO)
	label.alignment(viz.TEXT_CENTER_CENTER)
	label.fontSize(24)
	viz.link(viz.CenterCenter,label)
	
	#Start expirement when spacebar is pressed
	yield viztask.waitKeyDown(' ')

	#Remove the label
	label.remove()
	
	#Add quad to screen
	quad = viz.addTexQuad(viz.SCREEN)
	quad.setPosition(0.5,0.5)
	quad.setScale(4,4,4)
	
	#Data for getting values from wait conditions
	d = viz.Data()
	
	while True:
		
		#Set quad to red color
		quad.color(viz.RED)
	
		#Wait random amount of time
		yield viztask.waitTime( vizmat.GetRandom(1.5,2.5) )
		
		#Set quad color to green
		quad.color(viz.GREEN)
		
		#Wait for next frame to be drawn to screen
		yield vizxid.waitDraw()
		
		#Wait for button 3 on XID to be pressed
		yield vizxid.waitButtonDown(3,d)
		
		#Calculate reaction time
		reactionTime = d.time
		print('Reaction time:',reactionTime)

viztask.schedule( TestReactionTime() )
Reply With Quote
Reply

Tags
cedrus, response device

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cedrus Response Pad? Trevor Vizard 1 08-16-2012 04:26 PM
integrating brain-imaging response buttons with Vizard hrm Vizard 1 05-04-2012 06:24 AM
Vizard 4 Beta Testing farshizzo Announcements 0 02-01-2011 10:46 AM
Vizard 4 Beta Testing farshizzo Vizard 0 02-01-2011 10:46 AM
Vizard tech tip: Using the Python Imaging Library (PIL) Jeff Vizard 0 03-23-2009 11:13 AM


All times are GMT -7. The time now is 08:53 AM.


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