Need help with a project
So I'm VERY new to programming and WorldViz, and only have the basics down. I am, unfortunately, on a tight schedule though and need to create a simple project before April.
The project simply requires a table, 5 objects, and 9 locations. The 5 objects are randomly placed at one of the 9 locations each, and then after 3 seconds of viewing, the scene clears for 10 seconds. The scene should then reappear, with one random object moved to a location close to it's original. The viewer makes a judgement based on which object moved, and then the next 'trial' starts. I can do the timing functions (I think) and have the 3dmax models for the objects, but am unsure of how to set up the random assignments as well as 'clearing' the scene, and how to record the response. Any help with those functions is appreciated, thank you! |
This will turn the scene's visibility on and off based on a timer and reset the objects randomly in one of nine specified positions when the scene comes back
check out the Vizard docs to learn how to write to files so you can record user responses. Code:
import viz |
Hey thanks! This provides a good start. I've added in another function which brings up the object array and let's the viewer make a choice as to which object switched positions before starting again with sceneOn, but how do you make it to only move one object randomly? As it is, all the objects move when the scene turns on again.
|
Still can't figure out how to just move one object from the initial randomised scene to the returned scene. Actually, can't figure out a lot of things haha. I have a mouseclick selecting an object and should (hopefully) record the data of which object was clicked (which should also match with the object that moved, though can't figure that out, obviously), but I can't disable the mouseclicking before I need it. Any help?
|
To move one of the objects to a new place, you need to randomly select one of your objects and then randomly select one of the available positions to move it to.
Code:
import viz |
Thanks, that works great. I have an issue though where it runs through once perfectly, but then on any time after that, more than one object moves. I'll post the code, and would you be able to see where the issue lies? I added in a function ('prep') that keeps the screen blank and waits for a space press before going to 'sceneOn', and a mouseclick goes to 'prep'. Thanks
Code:
import random |
That code just goes through one trial. To see why following trials are not working I'd have to see the code you added for that
|
I have this code for the mouseclick:
Code:
def mouseclick(button): |
each time prep is called another vizact object is created.
Code:
def prep(): Probably the best thing to do is to re-arrange your code using viztask. Waiting for mouseclicks, keypresses, and timers can all be done within the task function. Check out the documentation on viztask and let me know if you have any questions. |
Didn't have time to work on this recently, but just a quick question about viztask. Do I need to rewrite the previous functions into a task, or just include them into my task with yield statements? Can I write the whole project under one task? Thanks
|
You just need one task function for this and can call sceneOn from there. You could take out vizact.ontimer from sceneOn and use viztask.waittime instead in the task function
|
So after a two month absense from working on this, I'm back at it, and realised I don't know what I'm doing! My code seems to be a mess with extraneous, or at least poorly written, code and the experiment doesn't work how I'd like. Here's my code:
Code:
import viz - subject number can be blank and it still accepts this, I need that to change - data file doesn't exist; do I create a spreadsheet and it stores there, or automatically makes one with the correct code? - pressing space now just moves an object with no timing at all or scene change - clicking anywhere at all makes the scene blank and gives me lines saying [vizard object yada yada yada moved positions] with nothing relevant, or the object name Thanks for your help, my complete lack of understanding with vizard is getting somewhat discouraging. |
Don't give up hope yet. Clearly you have some work ahead of you, but listing what your missing is a start.
First, lets fix your stimulus presentation. Your syntax in the experiment task is incorrect. Place "yield" statments in front of 'viztask.wait' functions. Do not put a yield in front of plain functions like 'sceneOn.' Code:
def experiment(): Vizard's installation directory has an example directory called file_io that has filewriting examples. If you put a tab between each of your data points and a new line between reach response the data file should import into Matlab or Excel nicely. |
Hey thanks for the help. Haven't quite got the data writing down yet, but my code now looks like this:
Code:
def Experiment(): I have the following code for when an object moves: Code:
print 'object ' + str(rand_obj) + ' moved to position ' + str(rand_position) |
|
All times are GMT -7. The time now is 05:11 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC