Cannot connect to Net Station 4.4.2 with egi_pynetstation

I’m using PsychoPy 2022.2.4 and Mac OS 11.6.4. (I have also received this error when trying to run this experiment on Mac OS X 10.11 and Mac OS 10.13.)

I’m trying to use pynetstation to connect to my lab’s EGI NetStation computer. That computer is running Net Station 4.4.2 on Mac OS X 10.6. It is connected to a Net Amps 300 amplifier.

I am attempting to implement the same code from the PsychoPy documentation on pynetstation (https://psychopy.org/hardware/egiNetStation.html). When I run the PsychoPy experiment, it times out, and I receive the following messages in the log:

308.0067     INFO     Loaded monitor calibration from ['2021_07_08 12:22']
2022-11-15 11:27:52.025 python[1952:22787] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to /var/folders/51/mhhhd0r95wd3k994jbk1mwpc0000gp/T/org.opensciencetools.psychopy.savedState
Traceback (most recent call last):
  File "ntplib.pyc", line 318, in request
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/mbv0/Desktop/Research/flanker_eeg/testing_netstation/test1_lastrun.py", line 126, in <module>
    eci_client.begin_rec()
  File "/Applications/PsychoPy_v2022-2-4.app/Contents/Resources/lib/python3.8/egi_pynetstation/NetStation.py", line 103, in wrapper
    func(*args, **kwargs)
  File "/Applications/PsychoPy_v2022-2-4.app/Contents/Resources/lib/python3.8/egi_pynetstation/NetStation.py", line 198, in begin_rec
    self.ntpsync()
  File "/Applications/PsychoPy_v2022-2-4.app/Contents/Resources/lib/python3.8/egi_pynetstation/NetStation.py", line 103, in wrapper
    func(*args, **kwargs)
  File "/Applications/PsychoPy_v2022-2-4.app/Contents/Resources/lib/python3.8/egi_pynetstation/NetStation.py", line 153, in ntpsync
    response = c.request(self._ntp_ip, version=3)
  File "ntplib.pyc", line 323, in request
ntplib.NTPException: No response received from 10.10.10.42.
################# Experiment ended with exit code 1 [pid:1952] #################

I also am monitoring the TCP/IP Port log on the Net Station computer. It seems that the connection is established, but something about the NTP lines won’t work. Here is the log from the Net Station computer:

Query: NTEL
Identify: 
Attention
OK
Attention
OK
Timeout waiting for response from Attention command.

I’ve tried using some code on an older experiment machine (as I mentioned above), running a much older version of PsychoPy that uses egi.simple (as in this post), and I can establish a connection with Net Station that way, but I am concerned about precise timestamping, since millisecond precision is required for my planned experiments.

My specific questions are:

  1. Is there a fix for the error I’m receiving when I use egi_pynetstation and PsychoPy 2022.2.4?
  2. If this version of pynetstation is simply incompatible with Net Station 4.4.2, and I must use older versions of the library/PsychoPy, are there any timing problems I should be on the lookout for?

Thank you very much!

Hello,

When we wrote the new version for NTP of egi_pynetstation, we didn’t test it on versions of Net Station before 5.x. On the plus side, we do know that the package works with 300 series amplifiers.

My initial thought is that your NTP server may not be running on the Net Station Mac. There’s a script that you can run distributed by EGI/MagStim, but you’ll need to reach out to them directly: support@magstimegi.com

Can you post your code for connecting and starting to record?

Have you attempted to connect to the amplifier with either E-PRIME 2.x/3.x or PsychToolbox using NTP? That might help us track down the issue a bit more if you want to use the NTP method.

As for using the older “polling” mechanism in the PsychoPy2 package - the major things are to do an ns.sync() before events and to checkout this thread by expert Joshua Zosky

-Peter

Hi Peter,

Thanks so much for this information! I have reached out to Joshua and to EGI/MagStim for assistance.

Here is the code I’m using to connect and start recording. I have double checked that the IP address and port are correct:

#Import Netstation library
from egi_pynetstation.NetStation import NetStation

#IP address of NetStation Mac
IP_ns = '10.10.10.42'

#IP address of amplifier (if using 300
#series, this is the same as the IP address of
#NetStation. If using newer series, the amplifier
#has its own IP address)
IP_amp = '10.10.10.42'

#Port configured for ECI in NetStation
port_ns = 55513

#Start recording and send trigger to show this
eci_client = NetStation(IP_ns, port_ns)
eci_client.connect(ntp_ip = IP_amp)
eci_client.begin_rec()
eci_client.send_event(event_type = 'STRT', start = 0.0)

We have used PsychToolbox to connect to the amplifier before, but I don’t think that we did so using NTP. Here is an example of the code we used in a previous PsychToolbox-3 experiment from 2019:

% ========== EEG command start ========== %
% Establish connection w/ NetStation
[connect, messageConnect] = NetStation('Connect', '10.10.10.42'); % Connect to EEG computer 
[sync, messageSync] = NetStation('Synchronize'); % Synchronize computers
[record, messageRecord] = NetStation('StartRecording'); % Start EEG recording
% ========== EEG command end ========== %

Looking at the PsychToolbox documentation, I think [sync, messageSync] = NetStation('Synchronize'); is similar to the “polling” mechanism in the PsychoPy2 package, right?

Thanks again for your help!

Mercedes

Hi Mercedes-

Yes that code in PsychToolbox is for the polling style of communicating with Net Station. The PsychToolbox code for using NTP has a:
NetStation( ‘GetNTPSynchronize’, ntpserver ).

The PsychoPy/Python code looks correct for communicating with a 300 series amplifier (same IP for Net Station and Amp). And given that you have a Net Station log of the connection, suggests strongly that the IP is correct! That timeout message you’re getting is related to the NTP server not responding.

The EGI team will have to walk you through or send you the script for enabling the NTP server on your Net Station computer so that you can use our NTP code. Mark on the support team has helped a few other 300-series users get their setup working with our code so far.

Most importantly is to use your photocell timing kit to ensure that your setup is getting accurate and stable timing once you have your experiment coded up.

In the meantime if you do use the polling technique you should read over this thread. There is also a GitHub page that updated the old egi package for Python3. I continue to recommend getting the NTP setup working, we specifically chose to implement NTP timing as it is more accurate with less drift.

-Peter