![]() ![]() I know this is a lot more detailed, and less intuitive then the above, but you can use dictionaries in lots of places, and they are pretty darn handy.Īs I have been cutting and pasting from a file of ours, the above code will likely not work out of the box for you, but will hopefully provide some useful guide posts for your own explorations. In your case you would have values for dty = amount and at the end of a trial, you would use the function writerow() to put the latest values in their right place in the spreadsheet. Here are some example lines from a dictionary where I am setting the values for the conditions of an expriments, note that some of these lines have keys where the value is another dictionary - the dictionaries are nested. Analysing your data PsychoPy saves several data files for different uses: A Microsoft Excel (spreadsheet) file that you can use for most analyses A psydat. hinttranslate(Save a detailed log (more detailed than the excel/csv files) of the. #d is the name of the dictionary you have createdĬdw = csv.DictWriter(fh,fieldnames = d.keys(),quoting = csv.QUOTE_MINIMAL) To help you get started, weve selected a few PsychoPy examples. For instance: import csv #to use the spreadsheet export Before the first trial you can use a function to write the keys as the column headings of a spreadsheet, and then each trial add lines with the values. PsychoPy output files contain information about the experiment, including response times and accuracies for each trial. You start somewhere are the beginning of your program to create the dictionary with all the keys you want, and then as the program runs you store the values in the dictionary. If you like writing your own code, and want to learn a bit more Python, look into dictionaries which store things as "key" and "value" pairs. I've tried a few things, but it doesn't seem that I'm close. I would like to output the following variables into the data file: 'TotalLater', 'TotalNow', and 'amount'. Here is some relevant code: if branch = 1:įeedback = 'You chose $%.2f in two weeks' %(amount)įeedback = 'You did not make a choice. It's almost complete, but I'm trying to output a few variables that I created in a code component into my data file for the experiment, and I haven't been able to figure out how to do that. It's almost complete, but I'm trying to output a few variables that I created in a code component into my data file for the experiment, and I haven't been able to figure out how to do that. 1 I'm working in PsychoPy to design an experiment. I'm working in PsychoPy to design an experiment. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |