Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Defining response

Hi everybody,

I need a little help with coding so that I can record my keyboard responses. For my experiment, the subject is required to press either of two keys: "x" or "y" as they watch a video. I have defined the variable "correct_response" in the loop table for all the videos. However, in case no response is given I would like that to be logged as well. i.e. the "correct" variable should either be 1,0 or None. I got some help from this thread

if event: key = event[1] if var.correct_response == key: correct=1 else: correct=0 response.add(response=key, correct=correct, ....)
but I still dont know how to add the no response condition.

Comments

  • Hi,

    You can add somewhere a little script that does something along the line:


    if current_response == None: # if there was no response on that trial response.add()

    Do get the gist?

    Eduard

    Buy Me A Coffee

  • Hello Eduard...
    Should i add the script after the video? And doesn't the "else" part in the previous script include the no response condition? ( because when no response is given the value for correct is logged as 0)...
    Also...I just wanted to confirm, the time it took for a subject to respond to a video is calculated as response_time=clock.time()-time_video??

  • Hi

    Should i add the script after the video?

    Yes.

    And doesn't the "else" part in the previous script include the no response condition?

    No, because the else part is only executed if there was an event. No event, no else, no correct. The reason you still have a variable correct, is that it will be carried over from earlier in the experiment, I guess. So, if you would press a correct key first, and no key on trial two, you're correct variable would probably be 1. Right? You could also solve it, to initiate your variable in the beginnig of every block (before the video) to None, so that it will be None per default and only change to 0 or 1 if a key was pressed. Makes sense?

    Also...I just wanted to confirm, the time it took for a subject to respond to a video is calculated as response_time=clock.time()-time_video

    If time_video is the onset of the video, that will be correct.

    Eduard

    Buy Me A Coffee

  • edited April 2017

    Thanks Eduard!
    I have added responses.add(response='No key pressed', correct=None, response_tie= None) at the beginning of the script so that the default position is None just as you suggested. This has solved the problem :)

Sign In or Register to comment.