| Reference | Downloads | Github

PsychoPy to NetStation connect: using PyNetstation to send TCP/IP logs

This question has been answered by Josh (@imnotamember) personally, but I am reposting it here in the forum so everyone can read (Thanks Josh!).

I previously posted about how I can initialize communication between PsychoPy and NetStation using PyNetstation module. I was able to figure it out by configuring the NetStation workbench. I will number the questions below for readability wise!

  1. I was wondering if the TCP/IP logs are not saved within the recorded files since I couldn’t find them after a simple example run through.
  2. If the logs are not saved, is there a way to export/save them?
  3. These logs contain timestamps of the pulses that are sent from the stimulus computer. I was wondering if there is a way of marking these timestamps onto the EEG data, so that I can see the EEG waves in accordance with those time stamps.

Thank you.

For posterity’s sake, here is what I sent Jin over email, but feel free to ask more questions as this stuff should be better documented on my part.

  1. I don’t believe the TCP/IP Logs are stored within the EGI format EEG files for NetStation 4.5.x and below. There are copies in 5.x files (.mff format version 3 I believe). You can look further at it with the EGI manual on file formats. There is a lot of data stored within their files that isn’t EEG though, and what you’re more interested in (I’m guessing) is the data involving the “events” (a.k.a. flags, timestamps, pulses, triggers, etc.) and their metadata. I’ll save that for question 3.
  2. I honestly don’t know about this. I’ve never cared too much about the logs since all I needed was usually encapsulated in the “events.” Potentially? Check the EGI manuals on it (there is the Acquisition manual and the Hardware Manual which might help, but not sure which would provide that if it exists).
  3. You should already have that in your EEG data. Have you clicked the “Events” button during acquisition in your “Waveform Display” window? It will show your events as they arrive to NetStation. The timestamp used to insert the “events” into your EEG data must be sent in a specific manner which NetStation expects, and that’s how PyNetstation sends that info if you follow the instructions. Make sure you see something like this as you record data and send information from psychopy to NetStation:

Clicking the highlighted buttons to the “ON” state should show you the “ECI” track to see and follow events that are being added to your EEG data file. (In the below example, “Txxx”, “bgin”, and “ast_” are the “events” being added to your EEG dataset).

These will contain at minimum your timestamp, duration of the event (always 1ms, not sure why it’s included), source device (shows up as “ECI_track_xxx” or similar) and event code (Event Code is ALWAYS a 4 character combination, such as “bgin” in the above image). Here’s the tech manuals explanation of all the data you can potentially get:

These might not make sense when reading as a box, so record a dummy dataset (no net attached) while sending various types of events from psychopy, then open the EEG file and look through all it’s events in the “Events list” window to see how it all gets organized:

Hope that helps. I know it’s a lot of info, let me know what else you need.



All document & image rights belong to EGI. If you need me to pull the images/remove the links to the documentation let me know and I’ll gladly remove them.

GES Hardware Technical Manual* . (2015). Electrical Geodesics, Inc.
Net Station Acquisition Technical Manual* . (2015). Electrical Geodesics, Inc.
Net Station File Formats Technical Manual* . (2015). Electrical Geodesics, Inc.

1 Like

Hey Josh,

When I run PsychoPy code, it sends logs to the TCP/IP Port 55513 and I can see all the messages on the log panel. However, the dense waveform display panel does not show any event keys even though the red sweep line is moving.

So when checking the saved file for such example run, the mark events that I custom put it as NetStation is recording, ie. like eye blinks and eyemovements, are displayed in event listing, but none of the ECI TCP/IP port events are listed at all.

  1. I’m wondering if there should additional configuration done in NetStation side when PsychoPy messages are already successfully being shown in the TCP/IP log panel.

  2. From my understanding, for example code below for Psychopy:

    ns.send_event(key=‘test’, label=‘practice’, timestamp=egi.ms_localtime(), description=‘Any additional info in string’, padding=False)

I thought the key ’test’ would be appearing in the waveform display as ‘bgin’ or 'ast’_ like the screenshot you provided. Is it not? I’m not sure if I should have extra setting that needs to be done on NetStation side.

  1. Is there a way to change the code using DIN (Digital input) instead of TCP/IP of the code?

  2. This is a bit different issue, but when comparing timestamps in the saved log files from PsychoPy vs. the timestamp printed in TCP/IP log panel, the timestamps are almost identical. Does this mean that the Ethernet connection is extremely fast and synchronization is great? I’m just skeptical with having such identical timestamps.

Thank you!


Can’t answer fully now, but for a quick response:

  1. You shouldn’t need to do anything in NetStation to get this working.
  2. ‘test’ should be appearing, but I think your problem is related to timing issues. Can you post your event file from these eeg recordings? You can extract events from the eeg file in NetStation’s “Waveform Tools” suite. Here’s a quick guide to that:

    And select your new tool to make sure it has the following items seleceted or renamed.

    The exported file should have all your events. Send that my way.
  3. Yes you can use the DIN instead of TCP/IP. It requires a simple knowledge of serial/parallel port communications and some custom-built electronics. But it won’t make your timing any better, because…
  4. Yes, those times should be identical for 1 reason: because PyNetstation (and ethernet based communications overall) sends timestamps to NetStation, which then registers them to the recording file. This is going to put all the timing accuracy on your shoulders to determine. You need your timestamps to be accurate because you could send a crazy time like 5 years ago and it will still register (but since it isn’t currently that time, the flags won’t appear outside the first few millisecond. I’d bet that’s what your current issue is, your clock times being so off that you’re sending events either in the distant past or the future.

Let me know if this helps (even if it’s brief).


Hey Josh @imnotamember,

So when I extract the events from EEG file as you suggested, it doesn’t show the TCP/IP events. See screenshot below:

So in the left, event file that was saved, it only prints the manual marks that I inserted just to test events are recorded (eye blinks and motions), but they do not include the ‘xyz_’ events from the TCP/IP log (right figure) that was shown when NetStation was recording.
Ideally, it is supposed to show bunch of eye blinks, then ‘xyz_’ events, and then motions.

And below is the Waveform tool configuration for the event export tool:

What I realize is that there was no option for ECI: TCP/IP event types, so that is a concern.

Summarizing my questions,

  1. You mentioned about being timing issue, but I wasn’t sure what exactly it meant by that. So the time on both stim and NetStation computers are set the same (just automatic time on system preference), and also time.gmtime(0) prints the same timebase. Also, if it was timing issue, the events ‘xyz_’ should be showing up in the exported events file, right? If it is a timing problem, would looking into using NTP be a potential solution?

  2. From the fact that there was not even the option to select ‘ECI TCP/IP’ events in the Event Export tool, I’m concerned if this could be a hint to the problem.

  3. Could it be possible that events are not shown in the EEG waveform display while it is being recorded, but saved in the resulted session file?

  4. Lastly, we do have ActiveWire Card if you meant by ‘custom-built electronics’ for using DIN instead of TCP/IP. Do you know any way of trying out to use the DIN input instead? I’m trying to see if DIN could be working.

Thanks so much again. Hope the problem gets solved soon.


I solved the problem of event logged in TCP/IP log not showing on the waveform display on Netstation. I was working backward, rewriting the code again from simplest form.

The problem was in having the PyNetstation codes being embedded improperly in the experiment code. Just using the PyNetstation code allows me to send simple events and be registered as well on the display.

I’m still figuring it out, but I believe the event not being shown on waveform display is with matter of timing syncing as @imnotamember suggested.