I’m coding a behavioral data collection task using the Coder. I’ve previously dealt only with the Builder, so there’s been a steep learning curve for me! I made the switch because presentation of longer video stim is very glitchy in the Builder, leading to audiovisual mismatches and dropped frames (see this thread where we tried unsuccessfully to resolve this problem). This issue is resolved by presenting the stimuli using the Coder instead.
The task is simple - participants watch through a loop of 5 videos (each ~5 minutes long), presented sequentially, and are asked to press the space bar when they think one event in the video ends and another one begins. I would like my output .csv to contain 5 columns - one for each video, each with a list of the RT for all keys pressed during that video (effectively communicating the times during each video at which that participant is demarcating an event).
I’ve gotten the loop to work and the time to restart with each video so that RTs are video-specific rather than experiment-specific, and I’ve been able to store the RT for the first key pressed in a separate column for each video, but I want it to store the RT for all keys pressed during each video. In the Builder, I’ve always been able to simply select “store all keys” from the drop-down menu, but this obviously isn’t possible using the Coder.
I’m assuming I need to create a list and append each RT to that list to be saved in the .csv later, but I’ve not been able to get it to work.
Here’s the code just for the video presentation and response key collection:
while n != 6: #will play the 5 video clips
timer.reset()
video_selected = project_dir+'/'+video_dir+'/'+video_clip[n] #selects each video clip
videopath = str(video_selected) #set path for video
if not os.path.exists(videopath):
raise RuntimeError("Video File could not be found:" + videopath)
#play the video using VLCMovieStim
mov = visual.VlcMovieStim(win, videopath,
size=None, # set as `None` to use the native video size
pos=[0, 0],
flipVert=False,
flipHoriz=False,
loop=False, # replay the video when it reaches the end
autoStart=True) # start the video automatically when first drawn
#while the video plays...
while not mov.isFinished:
keys = kb.getKeys(['space', 'escape']) #define allowed keys
for thisKey in keys:
RT = timer.getTime()
if thisKey=='escape': #if escape selected, quit the program
mov.stop()
core.quit()
else:
thisExp.addData('RTvid'+str(n+1), RT) #if space selected, add response time to the csv
# draw elements
mov.draw() #bring the movie onto the screen
win.flip()
n = n + 1
I’m sure this is incredibly simple to solve, but I’m (clearly) a coding amateur. Any help you can provide would be greatly appreciated!
Here’s a screen shot of what my current output looks like:
And here’s what I’d like it to look like:
The last thing is that each of the videos is ~5 minutes long, and running this program appears to be incredibly computationally intensive, and sometimes it crashes. Any suggestions for how to mediate that would be appreciated.