| Reference | Downloads | Github

Customising Triggers' codes in BIOSEMI Actiview (Trigger format - Decimal)


I would need help to determine a specific trigger codes to BIOSEMI Actiview (trigger format - Decimal)

Let’s put the Stroop Demo as an example:

Begin Experiment tab

import serial
port = serial.Serial(“COM3”, baudrate=115200)

Begin Routine tab


End Experiment tab


These are the codes that I’m using. Few things to note down:

  1. Triggers appear in Actiview
  2. In Begin Routine tab, I’ve used other coding format such as (They all kind of worked):
    port.write(bytes(congruent)) - Given the trigger format for Decimal of (49,0) & (48,0) [random]
    port.write(b’congruent’) - same with above
    port.write(‘1’) - same with above but only (49,0)
    port.write(b’$congruent’) - Given Decimal of (255,0)

As I understand I’ve used the “congruency” of the Stroop Task (that is in either 1 or 0) for port.write but I think I might have not supposed to do that.

2 Issues I need the solution for:

  1. I need the triggers to be sent when the stimulus is presented, and when the participant respond. But the response triggers are only sent.
  2. I need to know what decimal represents what in Actiview; Therefore, I need to determine the values/decimal to PsychoPy to send the Decimal trigger value that I want.

Please help & thank you if anyone could provide a solution

Let’s keep the issues of when to send the triggers separate for now. But to start with helping with the first issue:


This will send the bytes corresponding to the literal set of quoted letters 'congruent', which I doubt is what you want.

On serial ports, what is generally expected is that bytes will be sent that represent letters, often still ASCII codes (also the lower part of the UTF-8 unicode specification):

So sending bytes of 0 and 1 will be special null or other codes. I think you might be wanting instead to send bytes that correspond to the “letters” '0' or '1', which in ASCII/UTF-8 are the bytes represent decimal 48 and 49. So I would guess that want you want is something like:


i.e. convert the number variable congruent containing 0 or 1, into a string variable containing the characters '0' or '1', and then convert those into a proper byte representation (48 and 49) for sending.

But it’s hard to know from the post above if that is what you are after.


Thanks for reply. Now I understand. So to manipulate the values that appear on Actiview, I would put a string of characters on the excel file such that those string will be converted into ASCII/UTF bytes. Really appreciate this! - I might not translate well of my understanding here, but I do understand what you mean.

Another thing I noticed is that when I run the experiment, the values on Actiview only appears when a button is pressed rather than when a stimulus is presented.

i.e. -(while loading stimulus 1) marker 1(for stimulus1 appears) - 2sec - stimulus1 > respond (marker for stim 2 appears) - 2sec - stimulus 2 > respond (marker for stim 3 appears) - 2sec - stim 3 > respond (marker for stim 4 appears)

Therefore, how should I code it in a way that the markers appears at the same time when the stimulus appears?

Insert a code component under the stimulus you want the message to refer to (so that when the stimulus is updated, we get to know about it straight away).

In its “begin routine” tab, put something like:

stimulus1_msg_sent = False

Then in the “Each frame” tab, something like:

if stimulus1.status = STARTED and not stimulus1_msg_sent:
    port.write(something) # send the message now
    stimulus1_msg_sent = True

or even better, something like this would synchronise the sending of the message with the exact time that the window is flipped to show the upcoming stimulus:

if stimulus1.status = STARTED and not stimulus1_msg_sent:
    win.callOnFlip(port.write, something) # send the message when the window is updated
    stimulus1_msg_sent = True
1 Like