If you are using Vizard for research you will most probably want to record data while you are running a world. This tutorial will go over a simple data collection script.
Let's imagine that we are conducting groundbreaking research on the visibility of pigeons. For our experiment, we will let the participant navigate through a world until he or she can identify our targeted bird. To get started, let's create a world with the pigeon and the necessary text:
If you have trouble getting the code in this tutorial to work, you can find the complete example script data.py in the \tutorials\data directory.
First add the following lines including a prompt for the participant's identification number.
Set up the scene.
Write the critical question on the screen, along with the possible answers and their corresponding check boxes.
Run the script.
Now we'll add a variable that records the time when the program was started. We'll also open a data file and create a function to detect when one of the buttons has been pushed.
Mark the time that the program was started.
Open a file to collect the data on this subject. The 'a' here means that we will be appending our new data to the existing data in this file.
Finally, get the data from the button press.
Now run your script. Notice that when you click on one of the buttons, the world automatically closes. That's because we put a viz.quit() command in the button function.
Because we know the orientation and position of the participant at any given moment, we can record that data throughout the session. So, add the following line to open another data file and to fill it with tracking data. Notice that each individual subject will have his or her own file.
Create the head tracking timer and function.
The timer function will be called once every second to collect tracking data as long as the world is open.
Run the script again with a new subject number to gather some tracking data.
Now go the script's directory and open your data files. The file "pigeon_data.txt" should contain a response to the critical question as well as the elapsed time for each subject number you used. You should also have a "tracking_[subject number].txt" file for each subject containing that subject's tracking data.