Builder View Experiment Design and Import

OS: Windows
PsychoPy version (e.g. 1.84.x): 3
Standard Standalone? (y/n) y

I have designed an experiment with practice trials and experimental runs. I’m supposed to make a couple of custom code at the beginning of the experiment, but I’m not sure how to do so.

  1. Import the dataloop provided (dataloop.pyc)
  2. Call the dataloop.set_participant () function with 1 argument: The participant ID you used at the start of the program
  3. Open a new data file for writing in the ‘data’ folder named [participant ID].csv
  4. Write the following header:

Participant, Trial, Stimulus, Time, Observation, Left, Right, Distance, x, y\n

so far, I clicked code properties and selected “Begin Experiment” and typed out the following code:

import dataloop.pyc
dataloop.set_participant()
fp=open(‘data/’+expInfo[‘participant ID’]+’.csv’,‘w’)

I’m not sure if I have done this right for 1-3 above and not sure how to do 4
Any tips would be appreciated.

It doesn’t make sense to even try to import .pyc files. They don’t contain data, and are just a compiled version of your code. A Python programmer need never touch one of these files. And the import statement in Python is not about importing data, it is about adding functionality to your code.

It seems like you have been given a list of instructions to carry out, but those instructions don’t really make sense. We probably need to know more about what you are trying to achieve.

I believe that data loop is a function. At the end of the experiment, I am also supposed to do the following:

  1. calls the dataloop.stop() function, with no arguments needed.
  2. It then closes your open data file (just to follow best practices). -> I think this is done by fp.close()

Does this change anything to my previous questions?

No. You are telling us what you are somehow “supposed” to do, without telling us what problem you actually need to solve. We don’t have any of the context or information needed to give a useful answer to your questions.