NetStation - Basic control of the EGI/NetStation EEG recording system via
TCP/IP network connection. (See

This function was developed and contributed to Psychtoolbox by Gergely Csibra, 2006-2008.
Code is based on Rick Gilmore’s routines, 2005. Thanks!
Code adapted to PCs (and Macs with Intel architecture) by Zhao Fan, 2008.

General syntax

[status, error] = NetStation(‘command’, …)

if status == 0, the command has been succesfully executed
otherwise see string “error” for error message


NetStation(‘Connect’, host [, port])

       Establishes TCP/IP connection to the [NetStation](NetStation) host computer.  
       "host" is the hostname as a string (e.g., '' or '')  
       "port" is the ethernet port to be used. Default is 55513.  


       Disconnects from [NetStation](NetStation) host.  

NetStation(‘Synchronize’ [, SynchLimit])

       Synchronize to the connected host. "[SynchLimit](SynchLimit)" could specify the maximum allowed difference  
       IN MILLISECONDS. Default is 2.5 ms.  


       Instructs [NetStation](NetStation) to start recording.  


       Instructs [NetStation](NetStation) to stop recording.  

NetStation(‘Event’ [,code] [,starttime] [,duration] [,keycode1] [,keyvalue1] […])
NetStation(‘EventNoAck’ [,code] [,starttime] [,duration] [,keycode1] [,keyvalue1] […])

       Send an event to the [NetStation](NetStation) host. The 'EventNoAck' variant doesn't  
       wait for acknowledgement of reception of the event, whereas the 'Event'  
       version does. Note that the 'EventNoAck' command is included for  
       completeness. It is not a good practice to skip waiting for  
       acknowledgements. If time is an important factor, Event commands can be sent  
       at a later opportunity within a session (e.g., in blocks at the end  
       of experiments).  
       "code"      The 4-char event code (e.g., 'STIM')  
                   Default: 'EVEN'  
       "starttime" The time IN SECONDS when the event started. The VBL time  
                   returned by [Screen](Screen)('[Flip](Flip)') can be passed here as a parameter.  
                   Default: current time.  
       "duration"  The duration of the event IN SECONDS.  
                   Default: 0.001.  
       "keycode"   The 4-char code of a key (e.g., 'tria').  
       "keyvalue"  The value of the key (any number or string)  
                   The keycode-keyvalue pairs can be repeated arbitrary times.  


        Flushes the read buffer.  

Uses a modified version of the TCP/UDP/IP Toolbox 2.0.5, a third party GPL’ed
open source toolbox, which is included in Psychtoolbox,
but also available from the Mathworks website:

The toolbox has been modified for lower communication latency.

Created by Gergely Csibra, 2006-2008
Based on Rick Gilmore’s routines, 2005
Adapted to PC by Zhao Fan, 2008
This function was modified by Matt Mollison to accommodate sending more than just int16s to Net Station
Improved by Justin Ales 2014.
Consolidated by Gergely Csibra, 2015

Path   Retrieve current version from GitHub | View changelog