I have a general question about the trialHandler
's command .next()
in PsychoJS.
Does anybody know what its PsychoJS equivalent is? I can’t find it in the API list of commands.
Thanks!
I have a general question about the trialHandler
's command .next()
in PsychoJS.
Does anybody know what its PsychoJS equivalent is? I can’t find it in the API list of commands.
Thanks!
Hi
I’m also curious about this. I’m struggling to understand the .next() command on PsychoJs.
I’m loading an excell file and grabbing a random row on each trial
On Python it works as follows:
trialList=data.importConditions(‘TripletList - Copy.xlsx’)
trials = data.TrialHandler(trialList,1, method=‘random’,
dataTypes=None, extraInfo=None, seed=None, originPath=None,
autoLog=True)
thisTrial = trials.next()
emotion=thisTrial[‘emotion’]
s1=thisTrial[‘s1’]
s2=thisTrial[‘s2’]
s3=thisTrial[‘s3’]
trials = new TrialHandler({
psychoJS: psychoJS,
nReps: 1, method: TrialHandler.Method.RANDOM,
extraInfo: expInfo, originPath: undefined,
trialList: “TripletList - Copy.xlsx”,
seed: undefined, name: ‘trials’});
thisTrial = trials.NEXT
console.log(thisTrial)
emotion=thisTrial[‘emotion’]
s1=thisTrial[‘s1’]
s2=thisTrial[‘s2’]
s3=thisTrial[‘s3’]
Any suggestion how to get this to work in PsychoJs?
Thanks!
I’m working on a demo which needs this and was surprised to find that there haven’t been any answers in the forum that I can find.
As indicated elsewhere
thisPath = myPaths.next(); leads to the error that .next is not a function and
thisPath = myPaths.NEXT; doesn’t give an error but thisPath is then undefined.
The demo I’m working on is set to public
Any ideas @sotiri ? I could use a workaround by adding an index variable but we do need an answer about .next().
Interesting, thanks for flagging @wakecarter, OK let me take a look, x
Hi there,
Would getFutureTrial(n)
achieve what you need? returns info on the n
th future trial JSDoc: Class: TrialHandler
Hope this helps,
Becca
Good hunch @Becca, thanks. As it happens calling next()
on the TrialHandler instance is meant to update internal stats, such as thisIndex
as well as returning the current trial and so getFutureTrial()
would only work the first run. Fortunately, exposing the [Symbol.iterator]
used under the hood with TrialHandler.forEach()
does the trick. Please note however @wakecarter that auto-translating works for Begin Routine and only partly for Each Frame because of the number parsing required to derive pathStart
. You can find the details in the support fork, in particular the Before Experiment tab, but a permanent fix should be included with the next release, x
Thanks. Please could you add me (Wake) to the support fork so I can see it?
Yes of course, sorry, should be OK now
Thanks @sotiri . You might be interested in my new variation. The only Both code I’ve got in the trial routine is translating pathN = myPaths.thisN to pathN = myPaths.getTrialIndex()
No problem, looks good yes, x