Home | | News | | Documentation | | Tutorial | | Screen Cast | | Download | |

Loading media and data output

In line 62 we call load_all_resources which imports all image and sound files from the directories passed to the function. All these files are stored in a library called self.resources and can be accessed directly by name (i.e. self.resources["sound1.wav"]). In line 66 and 67 we define two important variables, self.filename and self.datafile. self.filename will be the name of the current datafile: self.datafile.

Line 64 demonstrates a useful function for keeping track of conditions and subject numbers. get_cond_and_subj_number automatically updates the current condition based on the number of total conditions and current subject number: condition = ( subject # + 1)% total # of conditions. For example, in an experiment with 4 conditions and the current subject is 50, the condition would be (50+1)%4, or condition 3. get_cond_subj_number reads three values from a text file (here 'patterncode.txt'): current condition, total # of conditions and subject number. When get_cond_subj_number gets called, the values are automatically updated to reflect a new subject. get_cond_and_subj_number Returns three values in a list: the condition number, the total number of conditions and the current subject.

Line 71 showcases another of pypsyexp's utility, output_trial. output_trial takes a list and writes them to self.datafile, placing a blank space between each value.

Previous || 1 2 3 4 5 6 7 8 || Next

Our work is supported by grants from

Copyright 2008-2013 - Todd Gureckis - New York University