psychopy.org | Reference | Downloads | Github

Variable Output order


#1

Hi there! My solution is precisely described in this forum already, but the solution provided that time doesn’t work for me (solution with panda).

is this issue known by anyone else, and has it may been resolved?


#2

Hi @HelloHello, this link does not seem to be working for me. Would you be able to describe your problem?


#3

A bit of an odd issue today - but we’ve found that if you have a routine with a response object, and you don’t respond for the very first trial - the .RT column for that response object will not appear in sequence alongside the accuracy and keys columns for the object - it appears elsewhere as one of the columns.If you respond for the very first trial, it does appear in the same object sequence as you would expect.

So it seems that when RT is blank (for no response), something in the datafile output causes the sequence to change. This causes some confusion when people are just doing straightforward merges of their CSV files - as the columns don’t fully tie up.

How can I avoid this problem; e.g. how can I assure that the Psychopy output is always identical (the order of the columns), no matter if an answer is provided for the first stimulus in each trial or not?


#4

I copied the text of the link I sent you; it means that results (data output n psychopy) is not always output in the same way; e.g.:

Version 1:
StimulusA,KeyA,CorrA,RTA,StimulusB,KeyB,CorrB,RTB

Version 2:
Happens if the first Stimulus A has no answer provided (None):
StimulusA,KeyA,CorrA,StimulusB,KeyB,CorrB,RTB,RTA

(The column of the reaction time switched to later)

This avoids automitazion of the summary of my psychopy output; which is why I’m looking to make that psychopy always generates the same output, no matter the responses for the first stimulus in each trial. How can I assure that?


#5

@HelloHello, what version of psychopy are you using?


#6

PsychoPy2


#7

Why, is it a bug that has been fixed???


#8

I am using version 1.90.1 and not able to reproduce your error. If you go to Help > About, it should tell you which version you are using.


#9

I’m using exactly the same version… Hm do I understand you correctly that the following doesn’t happen with you:

  1. Do an experiment in the builder (easy) with two consecutive routines, each routine constisting of three different stimuli. Store everything (correct responses and response reactions).
  2. Run through the experiment once while hitting a button for every stimulus of every trial in the given time limit. Check the output.
  3. Run through the experiment a second time while hitting a button for every stimulus, except for the very first stimulus of the first routine, for which you will hit nothing. If you check now this output, you will notice that the column of .rt of the first stimulus switched to another place than if you compare it to the previous experiment output. That’s what I mean.

If that doesn’t happen to your builder experiment csv outputs; could you may send your builder experiment to me?

Thanks!


#10

I see, yes I can recreate the error now. As the original post on Github says (which is now working), the different orders are found because the columns for rt are only created when the first response is recorded and so the order of columns will change depending on which trial the first RT was recorded. You can do two things to get around this 1) reorder the columns alphabetically (most generalizable option) at the end of the experiment using Pandas or 2) compile the script and modify the experiment in Coder so that the columns are written in the correct order.

if 1:

Create a code component and in the “End Experiment” tab and add:

myData = thisExp.entries
import pandas as pd
df = pd.DataFrame(myData)
columns = df.columns.values.tolist() 
columns.sort()
df = df[columns]
df.to_csv(filename+'_UPDATED.csv')

if 2:

Compile script and go to lines where your responses are written using thisExp and add a default value (e.g., -1) for RT when no response was made e.g.,

if resp1.keys in ['', [], None]:  # No response was made
    resp1.keys=None
trials.addData('resp1.keys',resp1.keys)
trials.addData('resp1.rt', -1)  # Here, you are creating an RT column even though a response was not given

#11

Haha wow David I loved your solution with the -1 assignment, that’s exactly what I was looking for! Cheers!