Custom file name in offline experiment

I’m running PsychoPy 2022.2.4 on Win10 (anaconda). I cannot easily update Psychopy last time I tried it messed up the way images are shown in the experiment.

I’d like to change the filenames of the data saved for my experiments.

However, in most of my experiments, changing the file name in the Builder experimenter settings (under “data”) does not affect where the actual data is being saved. This has previously been reported for online experiments, but this is normal offline use. For debugging, I simplified the file name to:
u'testfilename_' + expInfo['date']

Independent of whatever I put in that field, in the resulting Python script the respective line always reads:

# Data file name stem = absolute path + name; later add .psyexp, .csv, .log, etc
filename = _thisDir + os.sep + 'data' + os.path.sep + expInfo['date']

(The ‘data’ subfolder there comes from the application preferences.)

What I tried to so far

I created a tiny test experiment that only shows a single screen and closes. This is the only one of my experiments in which the data is saved according to the filename field in the experiment settings. For this experiment the respective file in python is:

# Data file name stem = absolute path + name; later add .psyexp, .csv, .log, etc
filename = _thisDir + os.sep + u'testfilename_' + expInfo['date']

A weird obervation I made when comparing the two experiments is in the experiment where the saving does not work, there is an additional field in the ‘data’ tab of the experiment settings to define the path of the saved data, which is not there in the test experiment. Anyways, providing a folder there lets me change the folder but not the filename (and variables are not interpreted in that field; I believe this is a bug that was fixed in later versions?).

My question
What could be the reason it works with the first but not the second experiment? I checked all experiment settings and there are no differences (other than the one mentioned above). I am never messing around with filename variables in my code segments

Is no one having similar problems?

The problem would theoretically be solved by updating to version 2023.2

I did not update before because it lead to a catastrophic change in the way images were shown. Unfortunately, I cannot update to higher versions than 2023.1.3 because, again, depending on which newer version I try, that leads to different errors (logFile vanishing or randomization lists to be loaded but the variables not being used, leading to an error…).

So in summary, I could solve the problem by updating but I could not find a version that would not lead to other errors.

Hi. I am quite new to PsychoPy, but if I am understanding you correctly. You are currently showing just the coder tab (so if you want this better answered by someone else, then maybe consider changing it to coder instead).

psychoJS.experiment.dataFileName = ((“.” + “/”) + data/${expInfo["participant"]}_${expName}_${expInfo["date"]})

This is what mine is, and it is working (saved as the participant ID I enter when the screen pops up).

So perhaps try:

psychoJS.experiment.dataFileName = ((“.” + “/”) + data/${expInfo["u'testfilename_"]}_${expName}_${expInfo["date"]})

I would also suggest trying to simplify your data filename, as the _ and ’ may be causing some issues.

Hopefully, this works or at least helps (I am using 2023.2.2 so it may not). When in doubt, I would change this to coder as it is more of a coding problem I believe.

Best of luck :slight_smile: