Hi, I am trying to provide feedback to participants for the picture-matching game. There are 36 questions with two options. In every 4 questions, I would like to provide accurate feedback.
I don’t know how to do that, so I started with a simple step. I tried to provide feedback every trial, but it crashed my experiment. I would appreciate it if you could help me solve the problem with the code and give suggestions about providing feedback every 4 trials instead of giving feedback every trial.
Here is my code.
This code is on the “end routine” of picture matching routine.
# correct response
if l_image == correct:
correct_response_image = "left_image"
elif r_image == correct:
correct_response_image = "right_image"
# save the correct answers
if response_image == correct_response_image:
thisExp.addData('corrAns', '1')
else:
thisExp.addData('corrAns', '0')
This code is on the “begin routine” of the feedback routine
No, the experiment is offline, but I will do the experiment online later.
I do not have Begin Experiment code in Picture Matching and Feedback Routine. However, in my last routine, there is a code on Begin Experiment to record videos of participants. The code is:
import numpy as np
import cv2 # this is the OpenCV library for computer vision
fourcc = cv2.VideoWriter_fourcc(*'XVID')
#out = cv2.VideoWriter('output.avi', fourcc, 20.0, (640, 480))
print(expInfo['participant'])
out = cv2.VideoWriter(expInfo['participant'] + '_output.avi', fourcc, 20.0, (640, 480))
webCam = cv2.VideoCapture(0) # connect to the zeroth video camera
You can’t import numpy (or cv2) online. I think that the error message is about the JavaScript, and unrelated to your offline crash. Are there any other error messages?
NameError: name ‘corrAns’ is not defined
[ WARN:0] global D:\a\opencv-python\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (438) `anonymous-namespace’::SourceReaderCB::~SourceReaderCB terminating async callback
22.9878 WARNING 0.6639703999971971: Video catchup needed, advancing self._nextFrameT from 0.0 to 0.03336666666666667
22.9878 WARNING 0.6640094999966095: Video catchup needed, advancing self._nextFrameT from 0.03336666666666667 to 0.06673333333333334
22.9878 WARNING 0.6640270999996574: Video catchup needed, advancing self._nextFrameT from 0.06673333333333334 to 0.10010000000000001
22.9879 WARNING 0.6640428000027896: Video catchup needed, advancing self._nextFrameT from 0.10010000000000001 to 0.13346666666666668
22.9879 WARNING 0.6640636000011: Video catchup needed, advancing self._nextFrameT from 0.13346666666666668 to 0.16683333333333333
22.9879 WARNING 0.6640791999961948: Video catchup needed, advancing self._nextFrameT from 0.16683333333333333 to 0.2002
22.9879 WARNING 0.6640922000005958: Video catchup needed, advancing self._nextFrameT from 0.2002 to 0.23356666666666664
22.9879 WARNING 0.6641039000023738: Video catchup needed, advancing self._nextFrameT from 0.23356666666666664 to 0.2669333333333333
22.9879 WARNING 0.6641157999983989: Video catchup needed, advancing self._nextFrameT from 0.2669333333333333 to 0.30029999999999996
22.9879 WARNING 0.6641278000024613: Video catchup needed, advancing self._nextFrameT from 0.30029999999999996 to 0.3336666666666666
22.9879 WARNING Max reportNDroppedFrames reached, will not log any more dropped frames
1.1048 WARNING Monitor specification not found. Creating a temporary one…
################# Experiment ended with exit code 1 [pid:7916] #################
4169.9774 EXP Imported picture_matching_images.xlsx as conditions, 7 conditions, 6 params
4169.9795 INFO Loaded monitor calibration from [‘2022_04_29 09:14’]
You could put the feedback routine in a loop whose nRepeats is not bool(trials.thisN % 4)? That way if there’s any remainder when dividing the trial number by 4, the feedback routine is skipped (as nRepeats is 0)