PsychoPy to NetStation: sending multiple triggers

Hi! I’m using PsychoPy 2020.2.8 and Mac OS 10.9.5. I’m using pynetstation code to send triggers to netstation for each presentation of an image. I have two images appearing in sequence in a trial, but the code I have will only drop a tag for one image. Is there code to send one tag for each image in a trial? The code I have is pasted below (in the “Each Frame” tab).

Please forgive me if this is a naive question, I’m very new to PsychoPy! Thanks for your help

if image.status == STARTED and not triggerSent:
win.callOnFlip(eci_client.send_event, event_type = ‘vep1’)
triggerSent = True

Hi!
Were you ever able to figure this out? Currently struggling with sending triggers myself for keyboard responses, although the recording/stop recording works so I know connection is properly set up…

I may need a bit more information to debug for you. In general the easiest way to send an event is using the send_event function where you can add the onset time. If you want to stay with the default code, could you try making the second image in your trial structure image2? And then duplicate the if/winflip code for that image2:

if image.status == STARTED and not triggerSent:
win.callOnFlip(eci_client.send_event, event_type = ‘vep1’)
triggerSent = True

if image2.status == STARTED and not triggerSent2:
win.callOnFlip(eci_client.send_event, event_type = ‘vep2’)
triggerSent2 = True

As for reaction times, you can get the RT from any keyboard event and send it later on using the same send_event code.

rt = my_keyboard.rt
//some code here to calculate the onset + RT
ns.send_event(event_type="resp", start=whenKbPess)

I’m not sitting next to my amplifier today, but we (Josh and I, creators of pynetstation) will work on more example scripts to illustrate these points.

Hi Peter,

I work for EGI and we have had a few customers reach out recently with questions regarding sending triggers. The article you have for Psychopy and NS compatibility is extremely useful but it seems customers have some additional questions we are not equipped to handle. Apologies as I know this is not the thread’s original purpose…

Trey Avery and I would love to learn a bit more or have a better way of addressing these questions. Do you have suggestions - is it best to have customers come to this forum, reach you directly? It might be more useful if we learn a bit more as well so we can directly assist these users and lessen what is on your plate.

Thank you,

Hi There,

Please can I check that you’ve seen our most recent hardware docs? there is specific recommendations for netstation there Sending triggers via EGI NetStation — PsychoPy v2022.2.4

Becca

We don’t currently have a ton of resources to support pynetstation.

In an ideal world, we would be able to do some combination of these:

  1. Write basic experiments (e.g. N170, P300) in PsychoPy with Net Station tags akin to the E-PRIME demo for distribution to users.
  2. Video tutorials on YouTube for creating an experiment with Net Station tags
  3. Continue to try and monitor this discourse forum for questions and occasionally answer.

All of these take time and currently I’m covering quite a few projects; I would anticipate a significant lag before I can execute on these.

In the meantime: Trey and I touched base on some great consultants that could help EGI (or your users) with the necessary support. Happy to email or meet to chat more about those.

Hi Peter,

Would love it if you could forward me those contacts (presuming they’re willing), my email is ryan.priefer@magstim.com.

I am hoping to get my hands on a NetStation laptop soon so I can sort of play around with it myself (sans amplifier at least…). A more comprehensive basic tutorial would be fantastic but I understand not a priority. I am happy to dive deeper once I have a better understanding of pynetstation and python/psychopy in general.

Thanks tons!

1 Like

Is there any way to make the event type variable? And connect to an excel file that codes for which image will be presented. Because I have 400 images so its impossible to have a component for each of them. Thank you for your response!

Yes, you can supply the send_event( ) function with a variable that refers to a column in your excel file using the $ before the column name.

You may find it useful to also supply additional information like the stimulus label and desc. This will let you parse the events more easily later on depending on what software you’re using for analyses. Any and all of these can be set as variables in your code component.

1 Like

Do you mean 400 images on screen simultaneously? You can build lists of visual components in code components.

I am sorry my bad I did not write it sown clearly. I meant images one after the other so making the trigger value a variable defined in an excel. I am stuck in making the trigger value a variable since just adding the $ does not work.
Thanks for the reply and suggestion btw

Please could you show your image component and spreadsheet? This should just be a case of having a column title in the spreadsheet (e.g. pic) appear in the image component (as $pic) set to update each repeat.

Alternatively, if your issue is actually about the trigger – please show how you can send a fixed image name as a trigger value. The $ isn’t used for variables in code components.

Hello,

i am sorry for my late response.
So my problem was not about image presentation. I have ona image component with an excel file
of all the images to be shown. I wanted to have a specific trigger for each of image (there are 4 big categories). I realized I cannot use the $ symbol in the event_type=“” of the trigger code.
But I added a label component, and the label could be defined in an excel file, evenn without the $ symbol. So now I have the label ‘triggers’ that I define in my excel file with 4 possible names (FACE;HOUSE,ANIMAL;TOOL):

if image.status == STARTED and not triggerSent:
win.callOnFlip(eci_client.send_event, event_type=‘IMAG’,label=triggers))

So I solved it like this thank you again for the reply

Hi, not sure if this was covered, but netstation will not record two events with the same time. This can be tricky, because when you’re recording both events WILL appear in the onscreen log, but in the saved file one will be dropped. We get around this by adding some latency and then fixing the timing in post.

1 Like