def participant(self):
        ''' Participant ID and group assignment'''

        subject = vizinput.input(
            'Please enter the participant identification number?'
        )  #Prompt for the participant's identification number.
        participantList = open(DATA_PATH + "/" + 'participant_list.txt')
        #groups = self.designOutput[0].keys()

        if not len(str(subject)) == self.PIDdigits:
            print "Invalid ID ! entered id should have one 'alphabetical' character from {0} (case sensetive) and {1} 'digits'".format(
                groups, self.PIDdigits - 1)
            sys.exit()

        for line in participantList.readlines():

            if str(subject) == line[:self.PIDdigits]:
                print "Invalid ID ! the participant Id already exists"
                sys.exit()

        participantList = open(DATA_PATH + "/" + 'participant_list.txt', 'a')
        participantList.write(str(subject) + "\n")
        participantList.close()
        IVE.PID = subject

        return subject
    def __init__(
        self,
        filePrefix="Data/participant",  # Include any directories in the path. Make sure to create the directories first.
        pid=None,  # Participant number/id (can be number or string)
        fileSuffix="_data.csv",  # Include file extension
        collectData=True,  # Set this to False to make every method call to this object do nothing and return immediately
    ):

        self.locked = not collectData
        if self.locked:
            print "Data will not be collected because collectData is set to False."
            return

        self.trackers = []

        if pid == None:
            if DataCollector.pid == None:
                DataCollector.pid = vizinput.input("Please enter the participant number.")
        else:
            DataCollector.pid = pid

        filepath = "{0}{1}{2}".format(filePrefix, DataCollector.pid, fileSuffix)
        self.datafile = open(filepath, "a")

        self._fileheader()
def participantInfo():

	subject = vizinput.input('What is the participant number?')
	age = vizinput.input('age?')
	sex = ['male','female']
	sex_choice = vizinput.choose('Sex',sex)
	handedness = ['right','left','both']
	handedness_choice = vizinput.choose('Handedness',handedness)
	ts = time.time()

	##create demographic data file
	demographic_data = open('demographic_data_rod_frame.csv','w')
	with open('data/demographic_data_rod_frame.csv', 'a') as f:
		wr = csv.writer(f, delimiter=';', lineterminator='\n', quoting=csv.QUOTE_ALL)
		row_demo = [subject, age, sex[sex_choice] ,handedness[handedness_choice] , datetime.datetime.fromtimestamp(ts).strftime('%Y-%d-%m %H:%M:%S')]
		wr.writerow(row_demo)
	return subject,datetime.datetime.fromtimestamp(ts).strftime('%Y-%d-%m %H:%M:%S')
Esempio n. 4
0
def InitRecording():
	# Condition is ALWAYS 1 here.
	pptextension.STATE = 0
	pptextension.ARMS_LIMIT_STATE = 0
	pptextension.LEGS_LIMIT_STATE = 0

#BL:start
	some_global_variables.testRun = vizinput.ask('Is this a test run?')

	global participantID, controlSchema, controlSchemaChoices, numberOfArms

	controlSchemaChoices = ['BimanualControl', 'UnimanualControl', 'HeadControl']#['Wrist rotation', 'Asymmetric']
	participantID = 'No_ID'
	controlSchema = 0
	
	if not some_global_variables.testRun:
		participantID = vizinput.input('Participant ID: ')
#		controlSchema = vizinput.choose('Choose the control schema', controlSchemaChoices)
	
	numberOfArms = vizinput.choose('Number of arms', ['3','4','5'])
	numberOfArms += 3
	print "numberOfArms = " + str(numberOfArms)
	some_global_variables.isLeftHanded = vizinput.ask('Is the user left-handed?')
	global gender
	genderChoices = ['female', 'male']
	gender = 0#vizinput.choose('Gender: ', genderChoices)
	
	global appendage
	wcChoices = ['Third Arm', 'Cylinder', 'Floating hand', 'Floating ball']
	appendage = 0#vizinput.choose('Which appendage would you like to use?', wcChoices)
	
	global skin, skinChoices
	skinChoices = ['1','2','3','4','5','6','7','8','9','10']
	skin = 0#viz.choose('Skin Color? (1 = lightest, 10 = darkest)',skinChoices)
#BL:end
	
#	global filePointerForAvatarRecording, filePointerForRuntimeScoringRecording
	if not some_global_variables.testRun:
		touchcube.openRuntimeScoringTimesRecordingFile(participantID, controlSchemaChoices[controlSchema])
		hf_playback.openAvatarRecording(participantID, controlSchemaChoices[controlSchema])
Esempio n. 5
0
def InitRecording():
	# Condition is ALWAYS 1 here.
	pptExtension.STATE = 0
	pptExtension.ARMS_LIMIT_STATE = 0
	pptExtension.LEGS_LIMIT_STATE = 0

	global name
	name = vizinput.input('Participant Name: ')

	global gender
	genderChoices = ['female', 'male']
	gender = vizinput.choose('Gender: ', genderChoices)
	
	global condition
	wcChoices = ['Third Arm', 'Cylinder', 'Floating hand', 'Floating ball']
	condition = vizinput.choose('Which condition would you like to use?', wcChoices)
	
	global skin, skinChoices
	skinChoices = ['1','2','3','4','5','6','7','8','9','10']
	skin = viz.choose('Skin Color? (1 = lightest, 10 = darkest)',skinChoices)
	
	global file
	file = hf_playback.openAvatarRecording(genderChoices[gender], name, 'w')
Esempio n. 6
0
def InitRecording():
    # Condition is ALWAYS 1 here.
    pptExtension.STATE = 0
    pptExtension.ARMS_LIMIT_STATE = 0
    pptExtension.LEGS_LIMIT_STATE = 0

    # BL:start
    global testRun
    testRun = vizinput.ask("Is this a test run?")

    global participantID, controlSchema, controlSchemaChoices, isLeftHanded

    controlSchemaChoices = ["BimanualControl", "UnimanualControl", "HeadControl"]  # ['Wrist rotation', 'Asymmetric']
    participantID = "No_ID"
    controlSchema = 2

    if not testRun:
        participantID = vizinput.input("Participant ID: ")
        controlSchema = vizinput.choose("Choose the control schema", controlSchemaChoices)

    isLeftHanded = 0  # vizinput.ask('Is the user left-handed?')
    global gender
    genderChoices = ["female", "male"]
    gender = 0  # vizinput.choose('Gender: ', genderChoices)

    global appendage
    wcChoices = ["Third Arm", "Cylinder", "Floating hand", "Floating ball"]
    appendage = 0  # vizinput.choose('Which appendage would you like to use?', wcChoices)

    global skin, skinChoices
    skinChoices = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]
    skin = 0  # viz.choose('Skin Color? (1 = lightest, 10 = darkest)',skinChoices)
    # BL:end

    # 	global filePointerForAvatarRecording, filePointerForRuntimeScoringRecording
    # 	touchcube.openRuntimeScoringTimesRecordingFile(participantID, controlSchemaChoices[controlSchema])
    hf_playback.openAvatarRecording(participantID, controlSchemaChoices[controlSchema])
Esempio n. 7
0
# Owned
__author__ = "Josh Julian"
__license__ = "MIT"

viz.fov(40)
viz.setMultiSample(4)
viz.go(viz.FULLSCREEN)
viz.mouse.setVisible(viz.OFF)
viz.antialias = 4

###############
## VARIABLES ##
###############

global subject
subject = vizinput.input('What is the sub number?')
global runNum
#runNum = vizinput.input('What is the run rumber?')
dpath = '..\Data\TrainingData\\'
runs = 6
#runNum = int(runNum)
subject = int(subject)

#tuple of test objects
TestObjects = ['cone', 'beachball', 'plant', 'pumpkin']
TestObjectLocs = [[(-4, 0.07, 9), (2, 0.29, 5), (-7, 0.07, -4),
                   (10, 0.05, -5)],
                  [(4, 0.07, 9), (-2, 0.29, 5), (7, 0.07, -4),
                   (-10, 0.05, -5)]]
scaleFactors = [0.15, 1.8, 1.25, 1.8]
Esempio n. 8
0
import viz, viztask, vizact, vizproximity, winsound, vizshape, vizinput, time

real_tg_dist = (0, 6.5, 0.5)

viz.go()

view = viz.MainView
view.setPosition([0, 10, 3.5])
view.setEuler(45, 90, 0)
subject_no = vizinput.input('Subject_no: ')

serverName = 'srushton-PC'
labNetwork = viz.addNetwork(serverName)

# Setup VRPN
vrpn = viz.add('vrpn7.dle')
head = vrpn.addTracker('Tracker0@localhost', 9)
body = vrpn.addTracker('Tracker0@localhost', 10)
tracker = vrpn.addTracker('Tracker0@localhost', 4)
head.swapPos([1, 2, -3])
head.swapQuat([-1, -2, 3, 4])
body.swapPos([1, 2, -3])
body.swapQuat([-1, -2, 3, 4])

ground = viz.add('ground.osgb')
target_1 = vizshape.addCylinder(height=3, radius=0.02)
target_1.color(viz.RED)
target_1.setPosition([0, 0, 0])
target_2 = vizshape.addCylinder(height=3, radius=0.02)
target_2.color(viz.RED)
target_2.setPosition([0, 0, 7])
import viz
import vizinput

viz.setMultiSample(4)
viz.fov(60)
viz.go()

#Prompt for the participant's identification number.
subject = vizinput.input('What is the participant number?')

viz.move([0,0,2])

#Add the environment
piazza = viz.addChild('piazza.osgb')

#Add the pigeon.
pigeon = viz.addAvatar('pigeon.cfg',pos=[-0.9, 2.88, 11.3],euler=[100,0,0])
pigeon.state(1)

#ask the question we will record data for
critical_question = viz.addText('Do you see a pigeon?',viz.SCREEN)

yes = viz.addText('Yes!',viz.SCREEN)
no = viz.addText('No!',viz.SCREEN)

critical_question.alignment(viz.ALIGN_CENTER_TOP)
critical_question.setPosition(.5,.9)

yes.alignment(viz.ALIGN_LEFT_TOP)
yes.setPosition(.25,.75)
Esempio n. 10
0
__license__ = "MIT"


viz.fov(40)
viz.setMultiSample(4)
viz.go(viz.FULLSCREEN)
viz.mouse.setVisible(viz.OFF)
viz.antialias = 4
viz.vsync(viz.ON)

###################
##OPEN DATA FILE ##
###################

global runNum
subject = vizinput.input('What is the sub number?') 
runNum = vizinput.input('What is the run rumber?') 
dpath = '..\Data\TestingData\\'
runNum = int(runNum)
runLength = 8.075*60 #in seconds

fname = dpath + 'TEST_tracking_'+str(subject)+'_'+ str(runNum)+'.txt'

###check for existing data file <-uncomment for actual testing, along with input function above
if os.path.isfile(fname):
	print('file name already exists')
	viz.quit()

#open data file
tracking_data = open(fname, 'a')
Esempio n. 11
0
    'How strong was your sense of presence in this environment?',
    'How strong was your sense of  "actualy being" in this environment?',
    'How realistic did the environment appear to you?'
]

sceneRotation = []
indexScene = "demo"
indexQuestion = "0"

################################################
####### Participant ID and filemangement #######
################################################

###Create/open data files###
subject = vizinput.input(
    'Please enter the participant identification number?'
)  #Prompt for the participant's identification number.
participant_data = open(
    DATA_PATH + "/" + "Individual_data" + '/' + str(subject) + '.txt', 'a')
group_data = open(DATA_PATH + "/" + 'group_.txt', 'a')
participantList = open(DATA_PATH + "/" + 'participant_list.txt')
#open a data file and to fill it with tracking data#
tracking_data = open(
    DATA_PATH + "/" + "Tracking" + "/" + 'tracking' + str(subject) + '.txt',
    'a')

###Check for Existing and Correct ID format and add it to the participants list###
for line in participantList.readlines():
    if str(subject) == line[:4]:
        print "Invalid ID ! the participant Id already exists"
        sys.exit()
Esempio n. 12
0
import time
import datetime
from datetime import date
from string import maketrans
import itertools, csv, time

#start vrpn
vrpn = viz.addExtension('vrpn7.dle')

#Ask for mode
presentations = ['oculus', 'normal']
presentationMode = vizinput.choose('Presentation Mode', presentations)

#Prompt for the participant's demographic

subject = vizinput.input('What is the participant number?')
age = vizinput.input('age?')
sex = ['male', 'female']
sex_choice = vizinput.choose('Sex', sex)
handedness = ['right', 'left', 'both']
handedness_choice = vizinput.choose('Handedness', handedness)
run = vizinput.input('Which run?')
ts = time.time()

##create demographic data file
demographic_data = open('demographic_data.csv', 'w')
with open('data/demographic_data.csv', 'a') as f:
    wr = csv.writer(f,
                    delimiter=';',
                    lineterminator='\n',
                    quoting=csv.QUOTE_ALL)
def EnterProximity_end_sensor(end_sensor):
	end_of_trial=viz.tick()
	global matrix_id
	global right
	global times_crossed
	global subj_numb
	global tri_per_subj
	global a
	global b
	global error_iter
	
	
	trial=b+1
	box_size=control_array[a]
	distance=distance_between_targets1*2
	reaction_time=round((reaction_timer_final-reaction_timer_initial),2)
	movement_time= round((end_of_trial-reaction_timer_initial),2)
	num_cycles= times_crossed-1
	if error_iter==0:
		left_error= (times_entered_left_plane_error1-times_entered_left_plane)
		right_error= (times_entered_right_plane_error1-times_entered_right_plane)-1
		total_error=right_error+left_error
		global_time_entered_l=times_entered_left_plane
		global_time_entered_r=times_entered_right_plane
	elif error_iter==1: 
		left_error= (times_entered_left_plane_error2-times_entered_left_plane2)
		right_error= (times_entered_right_plane_error2-times_entered_right_plane2)-1
		total_error=right_error+left_error
		global_time_entered_l=times_entered_left_plane2
		global_time_entered_r=times_entered_right_plane2
	elif error_iter==2: 
		left_error= (times_entered_left_plane_error3-times_entered_left_plane3)
		right_error= (times_entered_right_plane_error3-times_entered_right_plane3)-1
		total_error=right_error+left_error
		global_time_entered_l=times_entered_left_plane3
		global_time_entered_r=times_entered_right_plane3
	elif error_iter==3: 
		left_error= (times_entered_left_plane_error4-times_entered_left_plane4)
		right_error= (times_entered_right_plane_error4-times_entered_right_plane4)-1
		total_error=right_error+left_error
		global_time_entered_l=times_entered_left_plane4
		global_time_entered_r=times_entered_right_plane4
	elif error_iter==4: 
		left_error= (times_entered_left_plane_error5-times_entered_left_plane5)
		right_error= (times_entered_right_plane_error5-times_entered_right_plane5)-1
		total_error=right_error+left_error
		global_time_entered_l=times_entered_left_plane5
		global_time_entered_r=times_entered_right_plane5
	elif error_iter==5: 
		left_error= (times_entered_left_plane_error6-times_entered_left_plane6)
		right_error= (times_entered_right_plane_error6-times_entered_right_plane6)-1
		total_error=right_error+left_error
		global_time_entered_l=times_entered_left_plane6
		global_time_entered_r=times_entered_right_plane6
	elif error_iter==6: 
		left_error= (times_entered_left_plane_error7-times_entered_left_plane7)
		right_error= (times_entered_right_plane_error7-times_entered_right_plane7)-1
		total_error=right_error+left_error
		global_time_entered_l=times_entered_left_plane7
		global_time_entered_r=times_entered_right_plane7
	elif error_iter==7: 
		left_error= (times_entered_left_plane_error8-times_entered_left_plane8)
		right_error= (times_entered_right_plane_error8-times_entered_right_plane8)-1
		total_error=right_error+left_error
		global_time_entered_l=times_entered_left_plane8
		global_time_entered_r=times_entered_right_plane8
	elif error_iter==8: 
		left_error= (times_entered_left_plane_error9-times_entered_left_plane9)
		right_error= (times_entered_right_plane_error9-times_entered_right_plane9)-1
		total_error=right_error+left_error
		global_time_entered_l=times_entered_left_plane9
		global_time_entered_r=times_entered_right_plane9
	elif error_iter==9: 
		left_error= (times_entered_left_plane_error10-times_entered_left_plane10)
		right_error= (times_entered_right_plane_error10-times_entered_right_plane10)-1
		total_error=right_error+left_error
		global_time_entered_l=times_entered_left_plane10
		global_time_entered_r=times_entered_right_plane10
	elif error_iter==10: 
		left_error= (times_entered_left_plane_error11-times_entered_left_plane11)
		right_error= (times_entered_right_plane_error11-times_entered_right_plane11)-1
		total_error=right_error+left_error
		global_time_entered_l=times_entered_left_plane11
		global_time_entered_r=times_entered_right_plane11
	elif error_iter==11: 
		left_error= (times_entered_left_plane_error12-times_entered_left_plane12)
		right_error= (times_entered_right_plane_error12-times_entered_right_plane12)-1
		total_error=right_error+left_error
		global_time_entered_l=times_entered_left_plane12
		global_time_entered_r=times_entered_right_plane12
	elif error_iter==12: 
		left_error= (times_entered_left_plane_error13-times_entered_left_plane13)
		right_error= (times_entered_right_plane_error13-times_entered_right_plane13)-1
		total_error=right_error+left_error
		global_time_entered_l=times_entered_left_plane13
		global_time_entered_r=times_entered_right_plane13
	elif error_iter==13: 
		left_error= (times_entered_left_plane_error14-times_entered_left_plane14)
		right_error= (times_entered_right_plane_error14-times_entered_right_plane14)-1
		total_error=right_error+left_error
		global_time_entered_l=times_entered_left_plane14
		global_time_entered_r=times_entered_right_plane14
	elif error_iter==14: 
		left_error= (times_entered_left_plane_error15-times_entered_left_plane15)
		right_error= (times_entered_right_plane_error15-times_entered_right_plane15)-1
		total_error=right_error+left_error
		global_time_entered_l=times_entered_left_plane15
		global_time_entered_r=times_entered_right_plane15
	elif error_iter==15: 
		left_error= (times_entered_left_plane_error16-times_entered_left_plane16)
		right_error= (times_entered_right_plane_error16-times_entered_right_plane16)-1
		total_error=right_error+left_error
		global_time_entered_l=times_entered_left_plane16
		global_time_entered_r=times_entered_right_plane16
	elif error_iter==16: 
		left_error= (times_entered_left_plane_error17-times_entered_left_plane17)
		right_error= (times_entered_right_plane_error17-times_entered_right_plane17)-1
		total_error=right_error+left_error
		global_time_entered_l=times_entered_left_plane17
		global_time_entered_r=times_entered_right_plane17
	elif error_iter==17: 
		left_error= (times_entered_left_plane_error18-times_entered_left_plane18)
		right_error= (times_entered_right_plane_error18-times_entered_right_plane18)-1
		total_error=right_error+left_error
		global_time_entered_l=times_entered_left_plane18
		global_time_entered_r=times_entered_right_plane18
	elif error_iter==18: 
		left_error= (times_entered_left_plane_error19-times_entered_left_plane19)
		right_error= (times_entered_right_plane_error19-times_entered_right_plane19)-1
		total_error=right_error+left_error
		global_time_entered_l=times_entered_left_plane19
		global_time_entered_r=times_entered_right_plane19
	elif error_iter==19: 
		left_error= (times_entered_left_plane_error20-times_entered_left_plane20)
		right_error= (times_entered_right_plane_error20-times_entered_right_plane20)-1
		total_error=right_error+left_error
		global_time_entered_l=times_entered_left_plane20
		global_time_entered_r=times_entered_right_plane20
	
	
	
	print ('right_error:'+ str(right_error-1))
	print ('left_error:'+ str(left_error))
	main_data.write(' '*1+ str(subj_numb))
	main_data.write(' '*4+ str(matrix_id))
	main_data.write(' '*3 + str(trial))
	main_data.write(' '*4 + str(box_size))
	main_data.write(' '*4 + str(distance*2))
	main_data.write(' '*2 + str(reaction_time))
	main_data.write(' '*1+ str(movement_time))
	main_data.write(' '*3 + str(num_cycles))
	
	main_data.write(' '*3+str(global_time_entered_l))
	main_data.write(' '*1+str(global_time_entered_r))
	main_data.write(' '*1 + str(total_error)+'\n')
	if b+1==int(tri_per_subj):
		subj_numb=vizinput.input('Please input the Subject Number:\n ')
		tri_per_subj=vizinput.input('Please input how many trials this subject will go through:\n ')
		print('in da loop')
		b=-1	
	b+=1
	a+=1	
	error_iter+=1
	print(a)
	print(b)
	start_node.translate(x_translate1,y_height1-2.49,z_depth1)
	end_node.translate(0,100,0)
	end_box.translate(0,100,0)
	right_node1.translate(0,100,0)
#	left_node1.translate(right-50,0,0)
#	right_node1.setPosition(0,100,0)

	print('Entered end_sensor')
	num_cycles=0
import vizconnect_config



#General screen setup. 
viz.setMultiSample(4)
viz.fov(60)

#Sometimes, the first "start" sound does not work. The second time, it always works, therefore, I have the start sound
#play when the program starts. This way, there is no chance of the sound not working when the experiment starts. 
viz.playSound('boing!.wav')

"""In viz_matrix, we have many arrays of possible orders of box lengths. Each has a distinct identifiying number, called
 a 'matrix id.' By knowing this in advance, the user inputs the matrix id when the program starts, and the viz_matrix
program will find the respective matrix for the trials.""" 
matrix_id=vizinput.input('Input Matrix ID Number:\n ')
#throughout the program, you may see "prints." This is only seen in the interactive window, and is used only for debugging
#the subject does not see any of the printed messages during experimentation. 
print('matrix_id'+ str(matrix_id))


#our control_array is the array that we have chosen when typing in the matrx_id
control_array=viz_matrix.matrix_controller(matrix_id)
#x is the length of the control array. our program acts differently based on the size of x. in other words,
# there are many conditional trees that are dependant on the size of x. 
x=len(control_array)
#max_lst=[]
#for p in control_array:
#	max_lst.append(p)
#max_lst.sort()
#max_lst.reverse()
import vizproximity
# viztime is used primarily for the viz.tick() function, which captures the value of the internal clock
# that goes on in during vizard's runtime.
import time
# vizinput is used along w/ vizinfo to gather input throughout the program
import vizinput
# Vizconnect is used for tracking the position and orientation of the head and hand.
import vizconnect
import Vizconnect_config_4limbs_avatar_copy
import hand  # (From fitz test) Kept in case it was needed.
import random  # Used to cycle test list.
import time  # Used for it's CPU clock time function

# main_data is the text file where all the data is written and saved to. The format currently is accurate with notepad. May
# be off in other text editors.
name = vizinput.input('Input name of file: ')
main_data = open(name, 'a')

# The scale of the square boxes. Changing this will dynamically change the size of all of them.
bSize = 0.2

# General variables
enterSensorCount = [
    0
] * 8  # Used to count the number of times a tracker enters a sensor.
appendages = ["temp", "rhf",
              "lhf"]  # used to verify correct limb. Temp is used as a buffer.
requiredAppendage = appendages[0]  # The appendage to look for
appendagesItterator = 0  # current location in the appendages array

# Start Sensor variables
Esempio n. 16
0
import vizinput

viz.setMultiSample(4)
viz.fov(60)

# Start Vizard with a prompt dialog box
viz.go(viz.PROMPT)

import vizinfo
vizinfo.add('This script demonstrates how to gather input from the user at startup.')

#Retrieve text from the prompt
speed = viz.get(viz.INITMESG)

#Ask user for name
name = vizinput.input('What is your name?')

choices = ['Blue','Green','Orange']
colors = [[0,0,1],[0,1,0],[1,0.5,0]]
#Ask user for favorite color
favColor = vizinput.choose('Which of the following colors is your most favorite?',choices)

#Create text object of user name
text = viz.addText(name)
text.setPosition([0,3,7])
text.color(colors[favColor])

# Try to convert the text into a number.
# If the text is invalid, then set the rotation speed to 90.
try:
    rotateSpeed = float(speed)