psychopy.org | Reference | Downloads | Github

Example of (minimal) manually coded psychojs study?

Is there a ‘hello-world’-style psychojs example? A similar question was asked a while ago: Examples of manually coded PsychoJS studies?. It’s my understanding that the solution of that thread pointed to the demo experiments (e.g., stroop, navon, …), but the generated .js are hundreds of lines long. That feels like a lot of API to digest in one go. Are there simpler examples, something like just rendering a rectangle – maybe scheduling only one or two events?

thanks

1 Like

Because a reasonable number of scientists are capable Python programmers, and because PsychoPy originated as a library, long before its graphical Builder View was created, there are many minimal manually coded examples of Python studies under the Demo menu of the Coder view.

Because relatively few scientists are capable real-time JavaScript programmers, it hasn’t been a priority to create any minimal hand-coded examples. Even the PsychoPy developers themselves would use Builder to create their JavaScript studies, and just add any supplementary code snippets via code components. There is still a lot of development needed to keep growing PsychoJS to feature parity with PsychoPy, and to further polish it and add new features. So I’d say creating such examples would continue to be a relatively low priority for the next wee while.

Having said that, we would certainly welcome the contribution of any high-quality examples and documentation from community members. These could be added to our online documentation. If you wanted to go that route, I guess one approach would be to create a minimal example in Builder and see what code you could strip out from the generated JavaScript. But it might be a reasonably fraught enterprise. I’m not a JavaScript programmer myself, but I think it has to jump through hoops to achieve the consecutive temporal sequence of events that is natural in Python. It might be best to leave all that scheduling and other performance-critical stuff to be handled by Builder, and just concentrate on whatever custom code you need to insert to supplement it.

I understand that might not be a satisfying answer, if you’re a capable JavaScript person and understandably want to be in control of all of your own code from the ground up. If so, it would be possible to do, but (for the time being at least), there probably won’t be much support available to you — good luck if you do want to pursue it, and hopefully you’ll share your findings.

3 Likes