Description of the problem: I can’t get the experiment to initialise, I’m pretty sure this is because I use numpy.choice I’m not sure how I can change this to JS? I’ve used numpy.choice based on reading other forum posts and trial and error (rather than any in depth knowledge of python!)
Is there an easy solution or do I need to find a different way to structure my experiment?
I’ll have a go, I tried changing my code before but I got stuck on what i’d need to type into trials selected rows to replace this: $choice(32, size=1, replace=False) , any tips?
I’m presuming I haven’t defined something properly? it’s still working offline, so presumably it’s a JS error again? I’ve tried changing choose for choice in the JS code but then Ihad this error " * ReferenceError: choice is not defined"
Then when you are online, try opening the developer tools (see crib sheet if unsure there PsychoPy Python to Javascript crib sheet) to see if you get the expected printout and check your choose function is working.
OK you might need to chare your project URL with us. But before we do that, Can I share this project where I use the choose function and call it later on Pavlovia
you can click “View code<>” to download the files and take a look “under the hood” this might make it more concrete how to use these custom functions and implement them in your task!
okay so I solved the error message (as predicted I had empty columns in a conds file). But I can’t get the experiment to only choose one of my rows from the conds file to run. I’ve looked at your code but the only bit I can see to do with choices is the bit below, and I have that in mine, I just don’t know how to reference it in my trials selected rows bit
function choose(choices) {
var index = Math.floor(Math.random() * choices.length);
return choices[index];
}
So I think i’ve solved it! Thanks for your help and patience
I want to do a bit more testing, but when i’m happy i’ll update on the changes I made incase it helps anybody else.
edit:
So I solved the first issue by cutting out numpy, but then I had to find an alternative. I’ve ended up using some code in the trial routine based on the help on this post Dynamically reference the current loop - #8 by RobM except I put mine into the start and end of the routine, rather than start of the experiment.
I also discovered I had errors in my conditions files which was causing issues.
It all seems to work currently, although i’ll keep doing a bit more testing to ensure it’s randomised how I expected.
Thanks for the tips and links, it really helped knowing someone else was on hand!