Howdy, Stranger!

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

Supported by

Wrong Label Triggers Sent

Hi everyone,

I need some help for my experiment. I will be doing an oddball EEG experiment where speech and non speech sounds will be presented. So I need to send 4 different types of triggers : two triggers for the vowel condition (one standard and one deviant) and two for the non-speech condition (one standard and one deviant).

However, I have tested my script in the lab and the wrong label for my triggers is being sent and I don't understand why. For instance, when I try to send '0', the trigger is registered as a 'S48'. Here's my part of script where the triggers are included. Could someone please point me in the right direction?

Thank you,

Kloe

Comments

  • edited September 2020

    Hi @Kloe ,

    The serial module expects byte strings (bytes ), which you are indeed sending by first creating a str (unicode) object and then calling .encode() to turn in into a bytes objects. So far so good. However, the ASCII character '0' does is not represented by the byte 0, but rather by the byte 48. And that's why you're seeing S48.

    If you want to send byte values, you can first convert the int to a str with chr() , and then to a bytes with .encode() . Not very elegant perhaps, but it works:

    ser.write(ord(0).encode())  # Sends byte 0
    

    Does that make sense?

    Cheers!

    Sebastiaan

  • Hi Sebastian,

    Sorry for the late reply, for some reasons I did not get any notification someone commented on my post. I was starting to loose hope!

    I went to the lab and tried and it WORKED!! I almost teared up!

    Thank you so much, I really appreciate that you took the time to comment :)


    Kloe

Sign In or Register to comment.