# Connection problem with PsychoPy to EGI netstation for EEG experiment

I posted the issue to the PsychoPy forum already, but was wondering if I could get more input from StackExchange.

So I’m having difficulty establishing connection between the Psychopy running testing machine and the machine with the actual netstation installed. I numbered the summary questions at bottom!

I have the basic following code below, but I’m assuming I am inputting a wrong IPv4 address or port number for the net station.

from __future__ import absolute_import, division, print_function
from psychopy import locale_setup, sound, gui, visual, core, data, event, logging,     clock
from psychopy.constants import (NOT_STARTED, STARTED, PLAYING, PAUSED,
STOPPED, FINISHED, PRESSED, RELEASED, FOREVER)
import numpy as np  # whole numpy lib is available, prepend 'np.'
from numpy import (sin, cos, tan, log, log10, pi, average,
from numpy.random import random, randint, normal, shuffle
import os  # handy system and path functions
import sys  # to get file system encoding

# Setup for EGI
import egi.simple as egi # for testing purposes
#import egi.simple as egi
ms_localtime = egi.ms_localtime # gives local time in ms
ns = egi.Netstation()
ns.connect('ipv4 address of the testingmachine ', 'port number of netstation machine') # change/ check by Network Utility?


And I get the following error:

File "/Users/abc/Documents/PsychoPy/cfv/cfv_egi.py", line 281, in ns.BeginSession()

File "/Users/abc/Documents/PsychoPy/cfv/egi/simple.py", line 799, in       BeginSession self._socket.write( message )

File "/Users/abc/Documents/PsychoPy/cfv/egi/socket_wrapper.py", line 58, in write self._connection.write( data )
AttributeError: Socket instance has no attribute '_connection' 6.9777 WARNING
When I change the port to another one with a server, it gives me the below:

Traceback (most recent call last): File
"/Users/abc/Documents/PsychoPy/cfv/cfv_egi.py", line 281, in ns.BeginSession()

File "/Users/abc/Documents/PsychoPy/cfv/egi/simple.py", line 804, in BeginSession return self.GetServerResponse()

File "/Users/abc/Documents/PsychoPy/cfv/egi/simple.py", line 783, in GetServerResponse
raise Eggog( "unexpected character code returned from server: '%s'" % (code, ) )
egi.simple.Eggog: unexpected character code returned from server: 'R'


So summarizing my question,

1. Is it correct that I am supposed to input the IPv4 address of the NetStation machine?

2. How do I figure out what port number I need to input? Do I use the port numbers listed from using “Network Utility” app in the mac?

3. When running the psychopy code that makes me connect to the machine, what needs to be setup in the Netstation computer? ie. do I need to have netstation software running?

Thank you. Any help or pointers would be appreciated!

• I think a specific question like this is more suitable for the PsychoPi forum and your duplicate question there has four replies. Personally, I do not post any questions on the MATLAB PsychToolbox here either; as the respective forum is more suitable for these kinds of specifics. I went over to Bio Informatics SE and they regard your question as offtopic there, so migration is not an option. It will likely not be answered here either. Would you mind if this question is closed? – AliceD Sep 25 '18 at 9:00
• @AliceD Yes, it's alright. I was hoping I could get more input from here too. Thanks! – Vinci Sep 25 '18 at 14:51
• I'll through this issue on meta as well before closing. It's a well researched question and the topic is great, it's just very specific. Thanks for your understanding. – AliceD Sep 25 '18 at 15:05
• @AliceD how about Computational Science? – Ooker Sep 29 '18 at 7:35
• @Ooker wow thanks for the pointer! I'll head over to their chat once I have my hands free. Thanks! – AliceD Sep 29 '18 at 7:46