WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-16-2011, 06:13 PM
fivel_lab fivel_lab is offline
Member
 
Join Date: Mar 2011
Posts: 36
running experimental trials

i recently created a makeshift balance board apparatus which was to be used as part of an experiment for a visuo-motor psychology experiment. after alot of trial, error, and some invaluable advice from the folks on this forum, i finally got the physics of the experiment running, but now i'm having difficulty getting the experiment to run as a series of trials.

this is the framework i'm going off of:
Code:
def experiment():
	
	yield participantInfo()
	yield loadWorld()
	yield prePhase()
	yield testPhase()
	yield postPhase()
	
viztask.schedule(experiment)
the participant info and load world phases work well, and within the the participantInfo() phase i open a data file:
Code:
experiment_data = open(str(id) + '_experiment_data.txt','w')
	
#write participant data to file
data = "Participant ID: %s\tName: %s\tGender: %s\n\n" % (id,name,gender)
experiment_data.write(data)
and what i would like to do is open the same file within the the pre/test/post phases and write to it how long each participant is able to stay on task, which is measured by how long participants are able to keep a "ball" balanced on the center of the balance board.

right now, i have a loop set in the pre phase:
Code:
trials = [10]

#for loop for trials
for trial in trials:
     global isDone 
     isDone = False
     trialCount = 1
     global writeData  
     def isIn():
	inThere = 0
	if abs(ball.getPosition()[0]) < TARGET_REGION:
		inThere = 1
		data = '%d' % trialCount
		data = data + str(round(viz.tick(),3)) 
		data = data + '\t%d\n' % inThere
					
		experiment_data.write(data)
the stopping condition for each trial occurs when either the ball falls off the end of the balance board or the time hits 20 seconds:
Code:
while isDone is False:
     startTime=viz.tick()
     global elapsedTime 
     elapsedTime = viz.tick() - startTime
     			
			
     if abs(ball.getPosition()[0]) > BARLENGTH/2:
	ball.setPosition((CENTERPOS[0],CENTERPOS[1]+5,CENTERPOS[2]))
	trialCount = trialCount+1
	isDone = True
i know i'm throwing alot out there for a single post, but i'm pulling my hair out trying to get this to work... for now, what i'd really like to know is to write the data during the prephase to the global "experiment_data" that i created in the participantInfo phase, and how to get each trial to run properly...

any help would be greatly appreciated, thanks in advance.
Reply With Quote
  #2  
Old 03-17-2011, 05:01 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Where are your yield statement(s) for the prephase function?
Reply With Quote
  #3  
Old 03-18-2011, 09:45 AM
fivel_lab fivel_lab is offline
Member
 
Join Date: Mar 2011
Posts: 36
i didn't have yield statements. i started out using vizact.ontimer within the while-loop to implement an elapsed time function :
startTime = viz.tick()

def elapsed():
elapsedTime = viz.tick()-startTime

vizact.ontimer(0, elapsed)

i wanted to use 'elapsed' to monitor each trials time and set isDone to True when the time hit 20 seconds. the partner i am working with pointed out that the preceeding script wouldn't create a timer at the start of the while loop like i had intended but would instead create timerS nonstop once the while loop began. as a result, i think i created a massive memory leak...

how would i go about implementing a yield statement to get an elapsed time function?
Reply With Quote
  #4  
Old 03-18-2011, 02:58 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Quote:
the stopping condition for each trial occurs when either the ball falls off the end of the balance board or the time hits 20 seconds
You can use the viztask.waitAny command to wait until one of several conditions occurs. In your case these conditons would be a viztask.waitTime condition and a custom condition related to the ball's position.

The viztask documentation describes these commands and how to create a custom condition.
Reply With Quote
Reply

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
Update scripts while running? pcatalano Vizard 2 02-10-2011 12:29 PM
How to Hide Console when running from shell? Renato Lima Vizard 3 11-18-2010 03:03 PM
Problem running Vizard Jerry Vizard 4 03-06-2008 12:11 PM
Problems running R3 and R2.5 on the same computer cade_mccall Vizard 5 09-05-2006 11:26 AM
running scripts without the IDE showing hotspur1 Vizard 7 10-30-2003 10:36 AM


All times are GMT -7. The time now is 07:32 AM.


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