![]() ![]() For this, we just need to add the following lines of code in the end of of our experiment script. The last thing we need is to save the file when the experiment is complete. Notice that the code needs to be indented relative to the for loop-command. # get date and time for unique logfile name # participant id (ID is the variable written from the intro dialogue box) Lets imagine that we already made a directory called "logfiles". It is a good idea to establish a dedicated directory for the logfiles. In the example below we assume that the participant id is the first argument in the ID variable from the dialogue box. The participant id will often come from inputs to the dialogue box (see previous chapter). We can generate a unique name by adding a participant id and a time stamp to the name. Later, when the experiment is complete we want to save the data frame with a unique name to make sure that we don't mistakenly overwrite it (PsychoPy will generally not warn us if are about to overwrite a logfile). Usually this definition of the the data frame would be best placed in the early part of the script. However, what can happen later on is that the order of columns in the resulting data frame can become rather disorganised, so we recommend defining the columns before starting to write data to these: # define columnsĬolumns = In principle it would be enough to write data = pd.DataFrame(). In order to write trial-by-trail data into a data frame, we first need to define such a data frame. #Psychopy scale reset full#Notice that if we import is pandas "as pd" we can use this short form later on rather than writing the full name "pandas". Lets import the Pandas module and some psychopy modules that comes handy later on including the "data" module: # import modules Python is not by default working with data frames, but we can import a module, called Pandas, that makes it easy to organise data in a data frame format ready for analysis in most stats softwares. csv file with detailed information about stimuli and responses. That is, it is critical that our experiment script write data to a file. In cognitive science experiments, we will usually collect data from multiple participants in order to later analyse these. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |