New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding a simulation mode #2287
Adding a simulation mode #2287
Conversation
🦋 Changeset detectedLatest commit: 81886f0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 41 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This is at a stage where some review would probably be useful. The core feature set is implemented, and now it's really just a matter of implementing the simulation functions for all the plugins. This would be a good point to change my implementation if it needs changing... |
Looks great to me! It looks like there are lots of great options for generating response times, but for key choices it seems to just be a uniform random selection from "ALL_KEYS" or Another thing I'm wondering is whether it's possible to move some of the general simulation-related bits of code from the plugin and put these somewhere in the jsPsych package (SimulationAPI?), to minimize the simulation-related stuff that has to be added to each individual plugin. It looks like Finally, as far as examples/tutorials, in addition to a very basic example, it might be nice to show how to generate a more complicated, realistically-fake data set. I'm thinking this could be done using the experiment's normal timeline variables, but then adding response and RT values to those trials, but where those values are generated from slightly different proportion correct and RT distributions, based on the experimental condition. This isn't a priority though - just a thought for when everything else is finished. |
Pretty sure you just did this while I was writing the comment... 😆 |
Yes, both of these! In fact, both already work (somewhat to my surprise!). I added test cases to cover both scenarios thinking that I would then add the features, but they already work. Sometimes the core library is designed reasonably well 😁 .
Agreed. This would be great! |
Fascinating! Looks really solid! I am continually surprised at how well maintained, organised and written the library is -- I've never written code in TypeScript, yet I still manage to follow the code (or so I think)! As far as I can see most, if not all, of the features I originally thought about are implemented -- and more! The data-only mode is definitely interesting. I thought about it myself but originally reckoned that if someone needed a fake dataset, they would probably have an easier time generating it via R. But this ends up looking quite useful. I am a big fan of the 'tag' idea, where I can provide a string for an individual trial's
Would love to contribute further, but as I said, I am not familiar with TypeScript so the best I can do is try to follow the changes and try to make suggestions ^_^ |
$0.02 more:
|
I think one could just loops calls to |
My idea was that if a developer wants different testing configurations then it probably makes sense to write different |
I think this is approaching ready to (squash?) merge. I'll wait a few days before merging in case anyone wants to take a look before I do! |
One thing I just noticed: Since the updated plugins need the simulation API and we explicitly told changesets not to update peer dependencies, the I think this is something we should add to #2314 before merging it (and after merging everything else, because the changesets action force-pushes to that branch). |
work in progress
This adds a simulation mode. It's based on #1886, but updated for 7.0 and integrating some of the features more directly into plugins.
The current plan is to allow simulation through changing
jsPsych.run(timeline)
tojsPsych.simulate(timeline)
. Thesimulate()
method will also take an optionalsimulation_mode
argument, which will eventually allow both a data-only mode where the experiment doesn't actually run any trials but does generate appropriate data and follows any logic in the timeline, and also an automated mode, where all of the trials run but the interactions are automated through scripting.Plugins can support any or none of the modes. If a plugin doesn't support simulation, then the trial will be run.
The plan is to add the data-only simulation mode to all plugins for this release, and then add in the second mode as a medium-term goal. Luckily @nikbpetrov has already figured out most of the automation here, so hopefully we can merge in that work to accomplish the goal.All of the checked plugins in the list below support bothdata-only
andvisual
modes.This also makes some changes to the
jsPsych.randomization
module to add some new functionality for sampling from different probability distributions. It also adds a bunch of methods tojsPsych.pluginAPI
to support simulated events and other common simulation-related tasks.Some todo items:
simulation_options
via timeline variables.free-sortresizesketchpadsurvey-html-formvirtual-chinrestwebgazer-calibratewebgazer-init-camerawebgazer-validate