Response triggers to EEG

You are using some old-fashioned code to set properties of the parallel module itself, rather than a specific instance of a parallel port. In your case, you already have a parallel port created graphically (your p_port component), so you don’t need to import the parallel library or set the port address: all of that is already done for you. So delete your “Begin experiment” code.

I don’t really know the structure of your experiment, but I suspect your current “begin routine” code should actually be in the “End routine” tab instead: at the start of the routine, there will not have been any key pressed yet: it only makes sense to check this later. Then I’d suggest that your code could then be something like:

if len(key_resp_3.keys) > 0:

    if key_resp_3.keys[0] == corrAns:
        p_port.setData(98) # send via a specific object
    else:
        p_port.setData(99)

Note that I also removed the and response.corr check from the first if statement. Otherwise, you would never send a 99 value. Actually, maybe the first if len(key_resp_3.keys) > 0: isn’t necessary at all either? If the keyboard component is set to force the end of the routine, then I guess by definition there must be a response by this stage?

If so, the code could perhaps just be:

if key_resp_3.corr:
    p_port.setData(98)
else:
    p_port.setData(99)

Please note I edited your post above so the code is properly formatted, as per the link below. Please do this in the future. In particular, it allows us to see the indenting, which carries meaning in Python, and appears to be absent in the code snippet above.

1 Like