1

(I'm not a pyschologist nor pysychopy export but helping one) We're developing an expirement using the Coder (not Builder).

The output of an experiment is written out using the data.ExperimentHandler.addData(). When I run the application on my machine I get output like this:

,,1,1,z,f,o,o,1.254349554568762,0.8527608618387603,0.0,1.0,FSAS,,,,,,,,,,,,,,,52,male,52,

When the other person runs the application she gets:

;;0;1;z;z;j;j;105.498.479.999.369;0.501072800019756;1.0;1.0;FNES;;;;;;;;;;;;;;;23;male;0

(the difference I want to show is about format, not the values)

There are 2 differences:

  • RT values > 1 are printed wrong: the value 105.498.479.999.369 (RT less then 1.5s) should be 1.05498479999369
  • value separator is ; in my output and , in hers. I don't know what is the best value separator comma or semilcolon for later processing in R ?

I think it has to do something with regional settings.

Question: Is it possible to force the format so the application always generates the same output format independant from local settings ?

Conffusion
  • 4,335
  • 2
  • 16
  • 28
  • What does python have to do with this? – sudden_appearance Feb 05 '22 at 11:51
  • 2
    In psychoPY you develop in python. Since my question can be related to environment settings it is possible other persons not familiar with psychopy but knowledge of python, can help. If my assumption is wrong, sorry I waisted your time. – Conffusion Feb 05 '22 at 12:05

1 Answers1

1

You don't specify whether you are using the graphical Builder interface to PsychoPy to generate your Python script, or writing a custom script directly in Python.

If using the Builder interface, click the "Experiment settings" toolbar icon select the "Data" tab, and specify that the datafile delimiter should be "comma" rather than "auto".

If running your own script, then in the saveAsWideText() method of the ExperimentHandler class, similarly specify ',' as the delim parameter. The API is here: https://psychopy.org/api/data.html

In future, you will likely get better support at the dedicated PsychoPy forum at https://discourse.psychopy.org The actual PsychoPy developers and other experienced users are much more likely to see your queries there compared to here at StackOverflow.

Michael MacAskill
  • 2,411
  • 1
  • 16
  • 28
  • 1
    Thanks for your answer. We're using Coder (added it to the question). I notice the `saveAsWideText` works well but it behaves different then using just the constructor `data.ExperimentHandler(dataFileName = dataFile, extraInfo = info)`. With the constructor every call to `nextEntry()`will write the trial data to the output where `saveAsWideText()`saves at the moment it is called. We have implemented the escape key to abort so I need to call `saveAsWideText()` before quiting. I think I will keep both outputs. – Conffusion Feb 09 '22 at 20:13
  • plus one for the discourse proposal. (I am a java developer by nature so SO is my first reflex) – Conffusion Feb 09 '22 at 20:14
  • 2
    @Conffusion another option is the .psydat file output. This is a pickled representation of the TrialHandler (maybe now actually the ExperimentHandler?) object. So it can be unpickled after the fact to reconstruct the object in Python, at which point you can call whatever method you want to export the data in. See https://www.psychopy.org/general/dataOutputs.html The .psydat file is also saved automatically, so you don’t need to worry about intercepting the quit event. – Michael MacAskill Feb 09 '22 at 20:22
  • 1
    had not investigated what the psydat actually is but that is even more useful. This gives me the confidence we can easily convert afterwards if necessary. Thanks very much for this addition. – Conffusion Feb 09 '22 at 20:38
  • @Conffusion do test it out before relying on it - I haven’t played with that in years and that particular documentation doesn’t seem to have been updated over the same sort of period (eg by referring only to the TrialHandler class rather than the more modern and capable ExperimentHandler). – Michael MacAskill Feb 09 '22 at 20:42
  • The converter program described on the dataOutputs.html seems to work with my psydat file generated by ExperimentHandler. But thanks for the warning. – Conffusion Feb 09 '22 at 20:51