Importing a full experiment from PsychoPy as seamlessly as possible
I'm a newbie with OpenSesame working on a multi-site data-collection project. Most involved labs will be using an experiment coded up in PsychoPy3 (Builder v2021.2.3) in PsychoPy, but some want to be able to run the experiment entirely using OpenSesame. I was pleased to see that OpenSesame uses Psychopy in the backend, which should ease the process.
Given that we'd like the experiment to run exactly the same way on both platforms (following along with the same experimenter instruction script) and produce compatible output (as well as to save myself some time learning a new interface), ideally I'd be able to simply import the .py script generated by PsychoPy in its entirety into OpenSesame. It'd be great if we could retain everything, down to the organization of the initial prompts for subject number and other demographic information. It'd also be handy to retain the existing file structure (where the script can find the .xlsx file to pull in the word stimuli and spit out the output in the same format as in PsychoPy).
As a very clunky first attempt to do this, I tried creating a blank experiment in OpenSesame and popping in a new_inline_script and pasting in the full text of my .py code from PsychoPy. That got hung up on some of the very early lines of code (
NameError: name '__file__' is not defined):
# Ensure that relative paths start from the same directory as this script
_thisDir = os.path.dirname(os.path.abspath(__file__))
If that were the only issue, I don't imagine it would be too bad to get everything up and running. But, given that this error cropped up so early on, I feared what was to come. I wish I had a programmer on hand (or the time) to start re-building the many thousands of lines of code, but I was hoping one or more of you might be able to provide some hacks to make the porting from PsychoPy as straightforward and painless as possible.
I've seen some other discussion posts here indicating that it may be necessary to to import some extra modules, based on error messages. That would be easy enough, if need be (especially if the experimenters don't need to install anything new, which we're trying to minimize). But might one of you point me to a quick-start way to handle the import to minimize the number of coding tweaks that would be necessary?
Apologies for the newbie/non-programmer question--and many thanks in advance for your suggestions :-).
Hope everyone is keeping well and safe out there,
Without trying myself it will be hard to estimate whether this will be the only issue or whether there is going to be a long rat-tail of issues propagating down the sequence. However, I am mildly optimistic that most of the script should run fine, as I believe most of the problems should be linked to overhead stuff, like setting up paths, etc.
So, I think it is worthwhile to attempt the migration to Opensesame. Especially if you are a little experienced with programming, you should be able to get somewhere. In case you get stuck, feel free to report back here and ask for help. (Then also with sharing your code, ideally).
Hope this helps a bit,
Appreciate it, Eduard. I'll give it a try and be sure to post any snags that I can't work my way out of.
If anyone else has some quick workarounds in the meantime, do feel free to post here, as well. I'd be most grateful.
Much obliged everyone,