ExpInfo not saved in .csv file

OS : Windows 10
PsychoPy version : 2022.1.3
Standard Standalone? (y/n) y
Offline experiments, using the Builder

Hello, I am designing a set of 3 short experiments: on one of them the experimental infos are recorded correctly in my .csv file (participant, session, date, expName, psychopyVersion, frameRate), whereas in two of them these information do not get recorded.
For all experiments, any data that I ask to be recorded with a code component written in Python (thisExp.addData(“whatever”, whatever) is indeed recorded, but not any of the experimental infos mentioned above.
The experiments run normally and are not interrupted.
I have looked in the forum and have found vaguely similar problems for online versions of experiments, but nothing like my own issue here. If you need me to copy some parts of the generated code here for further clarification, please indicate which would be helpful and I’ll gladly provide it.

Any help regarding the cause of this behavior would be very welcome, thanks in advance!

1 Like

I’m not privy to the details of your experiment

It doesn’t seem to be experiment specific, but here is an example of a short experiment where nothing gets recorded in the participant, session, date, expName, psychopyVersion, and frameRate fields of the .csv file.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
This experiment was created using PsychoPy3 Experiment Builder (v2022.1.3),
    on mai 23, 2022, at 11:27
If you publish work using this script the most relevant publication is:

    Peirce J, Gray JR, Simpson S, MacAskill M, Höchenberger R, Sogo H, Kastman E, Lindeløv JK. (2019) 
        PsychoPy2: Experiments in behavior made easy Behav Res 51: 195. 


from psychopy import locale_setup
from psychopy import prefs
from psychopy import sound, gui, visual, core, data, event, logging, clock, colors, layout
from psychopy.constants import (NOT_STARTED, STARTED, PLAYING, PAUSED,
                                STOPPED, FINISHED, PRESSED, RELEASED, FOREVER)

import numpy as np  # whole numpy lib is available, prepend 'np.'
from numpy import (sin, cos, tan, log, log10, pi, average,
                   sqrt, std, deg2rad, rad2deg, linspace, asarray)
from numpy.random import random, randint, normal, shuffle, choice as randchoice
import os  # handy system and path functions
import sys  # to get file system encoding

import psychopy.iohub as io
from psychopy.hardware import keyboard

# Ensure that relative paths start from the same directory as this script
_thisDir = os.path.dirname(os.path.abspath(__file__))
# Store info about the experiment session
psychopyVersion = '2022.1.3'
expName = 'test1'  # from the Builder filename that created this script
expInfo = {'participant': '', 'session': '001'}
dlg = gui.DlgFromDict(dictionary=expInfo, sortKeys=False, title=expName)
if dlg.OK == False:
    core.quit()  # user pressed cancel
expInfo['date'] = data.getDateStr()  # add a simple timestamp
expInfo['expName'] = expName
expInfo['psychopyVersion'] = psychopyVersion

# Data file name stem = absolute path + name; later add .psyexp, .csv, .log, etc
filename = _thisDir + os.sep + u'data/%s_%s_%s' % (expInfo['participant'], expName, expInfo['date'])

# An ExperimentHandler isn't essential but helps with data saving
thisExp = data.ExperimentHandler(name=expName, version='',
    extraInfo=expInfo, runtimeInfo=None,
    originPath='C:\\Users\\E2-MelodieA\\Documents\\Virtual WM experiment\\Protocol Design\\PschoPy tests\\Memory_Experiments\\test1_lastrun.py',
    savePickle=True, saveWideText=True,
# save a log file for detail verbose info
logFile = logging.LogFile(filename+'.log', level=logging.EXP)
logging.console.setLevel(logging.WARNING)  # this outputs to the screen, not a file

endExpNow = False  # flag for 'escape' or other condition => quit the exp
frameTolerance = 0.001  # how close to onset before 'same' frame

# Start Code - component code to be run after the window creation

# Setup the Window
win = visual.Window(
    size=[2560, 1440], fullscr=True, screen=0, 
    winType='pyglet', allowGUI=False, allowStencil=False,
    monitor='testMonitor', color=[0,0,0], colorSpace='rgb',
    blendMode='avg', useFBO=True, 
# store frame rate of monitor if we can measure it
expInfo['frameRate'] = win.getActualFrameRate()
if expInfo['frameRate'] != None:
    frameDur = 1.0 / round(expInfo['frameRate'])
    frameDur = 1.0 / 60.0  # could not measure, so guess
# Setup ioHub
ioConfig = {}

# Setup iohub keyboard
ioConfig['Keyboard'] = dict(use_keymap='psychopy')

ioSession = '1'
if 'session' in expInfo:
    ioSession = str(expInfo['session'])
ioServer = io.launchHubServer(window=win, **ioConfig)
eyetracker = None

# create a default keyboard (e.g. to check for escape)
defaultKeyboard = keyboard.Keyboard(backend='iohub')

# Initialize components for Routine "trial"
trialClock = core.Clock()
to_do_text = visual.TextStim(win=win, name='to_do_text',
    text='Tapez le nom des objets ou ce à quoi ils ressemblaient dans le cadre ci-dessous',
    font='Open Sans',
    pos=(0, 0.4), height=0.05, wrapWidth=1.0, ori=0.0, 
    color='white', colorSpace='rgb', opacity=None, 
response = visual.TextBox2(
     win, text=None, font='Open Sans',
     pos=(0, 0.3),     letterHeight=0.04,
     size=(1, 0.6), borderWidth=2.0,
     color='white', colorSpace='rgb',
     bold=False, italic=False,
     padding=0.05, alignment='top-left',
     fillColor=None, borderColor='white',
     flipHoriz=False, flipVert=False, languageStyle='LTR',
end_button = visual.ButtonStim(win, 
    text='Terminé !', font='Arvo',
    pos=(0, -0.4),
    size=(0.3, 0.1), borderWidth=2.0,
    fillColor='dimgrey', borderColor='white',
    color='white', colorSpace='rgb',
    bold=True, italic=False,
end_button.buttonClock = core.Clock()

# Create some handy timers
globalClock = core.Clock()  # to track the time since experiment started
routineTimer = core.CountdownTimer()  # to track time remaining of each (non-slip) routine 

# ------Prepare to start Routine "trial"-------
continueRoutine = True
# update component parameters for each repeat
# keep track of which components have finished
trialComponents = [to_do_text, response, end_button]
for thisComponent in trialComponents:
    thisComponent.tStart = None
    thisComponent.tStop = None
    thisComponent.tStartRefresh = None
    thisComponent.tStopRefresh = None
    if hasattr(thisComponent, 'status'):
        thisComponent.status = NOT_STARTED
# reset timers
t = 0
_timeToFirstFrame = win.getFutureFlipTime(clock="now")
trialClock.reset(-_timeToFirstFrame)  # t0 is time of first possible flip
frameN = -1

# -------Run Routine "trial"-------
while continueRoutine:
    # get current time
    t = trialClock.getTime()
    tThisFlip = win.getFutureFlipTime(clock=trialClock)
    tThisFlipGlobal = win.getFutureFlipTime(clock=None)
    frameN = frameN + 1  # number of completed frames (so 0 is the first frame)
    # update/draw components on each frame
    # *to_do_text* updates
    if to_do_text.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
        # keep track of start time/frame for later
        to_do_text.frameNStart = frameN  # exact frame index
        to_do_text.tStart = t  # local t and not account for scr refresh
        to_do_text.tStartRefresh = tThisFlipGlobal  # on global time
        win.timeOnFlip(to_do_text, 'tStartRefresh')  # time at next scr refresh
    # *response* updates
    if response.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
        # keep track of start time/frame for later
        response.frameNStart = frameN  # exact frame index
        response.tStart = t  # local t and not account for scr refresh
        response.tStartRefresh = tThisFlipGlobal  # on global time
        win.timeOnFlip(response, 'tStartRefresh')  # time at next scr refresh
    # *end_button* updates
    if end_button.status == NOT_STARTED and tThisFlip >= 0-frameTolerance:
        # keep track of start time/frame for later
        end_button.frameNStart = frameN  # exact frame index
        end_button.tStart = t  # local t and not account for scr refresh
        end_button.tStartRefresh = tThisFlipGlobal  # on global time
        win.timeOnFlip(end_button, 'tStartRefresh')  # time at next scr refresh
    if end_button.status == STARTED:
        # check whether end_button has been pressed
        if end_button.isClicked:
            if not end_button.wasClicked:
                end_button.timesOn.append(end_button.buttonClock.getTime()) # store time of first click
                end_button.timesOff.append(end_button.buttonClock.getTime()) # store time clicked until
                end_button.timesOff[-1] = end_button.buttonClock.getTime() # update time clicked until
            if not end_button.wasClicked:
                continueRoutine = False  # end routine when end_button is clicked
            end_button.wasClicked = True  # if end_button is still clicked next frame, it is not a new click
            end_button.wasClicked = False  # if end_button is clicked next frame, it is a new click
        end_button.wasClicked = False  # if end_button is clicked next frame, it is a new click
    # check for quit (typically the Esc key)
    if endExpNow or defaultKeyboard.getKeys(keyList=["escape"]):
    # check if all components have finished
    if not continueRoutine:  # a component has requested a forced-end of Routine
    continueRoutine = False  # will revert to True if at least one component still running
    for thisComponent in trialComponents:
        if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
            continueRoutine = True
            break  # at least one component has not yet finished
    # refresh the screen
    if continueRoutine:  # don't flip if this routine is over or we'll get a blank screen

# -------Ending Routine "trial"-------
for thisComponent in trialComponents:
    if hasattr(thisComponent, "setAutoDraw"):
# the Routine "trial" was not non-slip safe, so reset the non-slip timer

# Flip one final time so any remaining win.callOnFlip() 
# and win.timeOnFlip() tasks get executed before quitting

# these shouldn't be strictly necessary (should auto-save)
thisExp.saveAsWideText(filename+'.csv', delim='auto')
# make sure everything is closed down
if eyetracker:
thisExp.abort()  # or data files will save again on exit

Hello everyone,
So, I don’t know if I’m stupid and everybody here knows that, but the weird behavior of expInfo not being recorded in the .csv file seems to be due to the absence of a “Mouse” component in my experiments that didn’t work.
If I add a mouse component, even if I set it to record nothing at all (no clicks, no ending the routine, no onset/offset time, no name of anything clicked… nothing.), the expInfo (participant, session, date, frameRate…) is pushed to the output .csv file. If I don’t, it is not recorded.
Hope this answer can help other newbies in the future!