| Reference | Downloads | Github

Accessing data from another loop

I’m trying to get reaction times from a baseline loop, for comparison with reaction times in the current test loop. I modelled this after the instructions here.

“…In this case, to get all the keys pressed in a numpy array:[‘key_resp.keys’] #numpy array with size=[ntrials,ntypes]”

URL of experiment:

Description of the problem: TypeError: Cannot read property ‘BaselineResponse.keys’ of undefined
at Scheduler.trainingfeedbackRoutineBegin [as _currentTask] (jul.js:664)

Here’s the JS snippets in line 664
pracmeanRt = [[“BaselineResponse.rt”].mean()];

I assume that I should be accessing the loop baseline (hence, before asking it to give me the rt to obtain the mean…

Please let me know how I can fix this! Its likely something obvious, but I am afraid I’m unfamiliar with both python and JS! Thank you so much for your help!

I’ve managed to fix my problem. The code is here if anyone is interested. I think I just didn’t know how to obtain mean in JS. Here’s how I did it.

Py :
pracmeanRt =[‘BaselineResponse.rt’].mean()

JS :
var nums = [BaselineResponse.rt];
var totalSum = 0;
for(var i in nums) {
totalSum += nums[i];
var numsCnt = nums.length;
var pracmeanRt = totalSum / numsCnt;