

In cognitive neuroscience experiments, precise time synchronization is not only a technical detail, but also a key factor in ensuring scientific and reproducible data. Especially when it comes to multimodal data acquisition (e.g., brain imaging and behavioral response), any millisecond delay or error may have a significant impact on the final results.
This article will focus on how to achieve high-precision Marker synchronization between the E-Prime stimulus presentation program and the Cortivision Functional Near Infrared (fNIRS) device through socket communication technology, from the underlying principles to hands-on configurations, to help researchers accurately lock the event moments in the design of the experiments, and to provide a reliable basis for the subsequent data analysis. Whether you are new to NIR technology or an experienced researcher seeking to optimize your experimental process, this article will provide you with practical technical references and implementation guidelines.
I. Experimental environment configuration






1. Hardware Preparation: Dual Computer Synergy, No One Can Do Without Them
NIR brain imaging experiments usually require two computers working in tandem, just as the right and left hemispheres of the brain work together:
"Brain" recorder:Cortivision NIR Mainframe
- This device is the central hub of the experiment. It is responsible for controlling the near-infrared light source, the probe head, and the real-time acquisition, pre-processing, and storage of light signals from the subject's brain. Please make sure it is set up and all necessary fiber optic probes and sensors are connected.
(Tip: Ensure that the host computer has sufficient storage space and a stable power supply for worry-free data collection over a long period of time.)
"Stimulate" the presenter:Stimulus Presentation Specialized Computer
- We highly recommend using a computer running E-Prime 3.0, a highly accurate stimulus presentation and experiment control software widely used in psychology and cognitive neuroscience. This computer is responsible for presenting carefully designed experimental materials (e.g., pictures, text, sound, video) to subjects and accurately recording their responses.(e.g., at key presses, at reactions). The logical control of the experimental flow is also done here.
(Why emphasize dedicated? Avoiding interference from background programs ensures precision in stimulus presentation.)
2. Network Connection: Stability is King, Milliseconds Count
The two computers do not operate independently; they need to communicate over a stable, low-latency network. This is critical to ensure accurate synchronization of stimulus events (Stimulus Onset) with brain signals (fNIRS Data)! Millisecond deviations can affect the results of data analysis.
Recommended Programs:
- Forming a small independent network: connecting two computers to the same LAN. The most recommended way to do this is:
o Cell phone hotspot:Convenient and fast, especially for mobile labs or temporary sites. Choose a cell phone carrier with a good signal.
o Small router direct connection:More stable and reliable. You can use an ordinary home router, connect both computers to this router with a network cable or WiFi (direct network cable connection is recommended).
Avoiding Problems:
- Disable campus network/public WiFi! These networks usually have a large number of users, fluctuating traffic, high latency and instability, which can easily result in loss of data synchronization or misplaced timestamps.
The Golden Rule: Wired First
- Although WiFi is available, it is highly recommended that both computers be connected to the same router via a network cable in order to minimize latency and eliminate the risk of packet loss. This provides the most stable physical connection and minimizes network interference.
3. Software Status Confirmation


Second, Cortiview and E-Prime synchronization configuration details






Stable and reliable data acquisition is only the foundation; achieving millisecond-accurate alignment of brain activity signals (when they occur) with external stimulus events (what happens) is the core. We achieve this by configuring socket network communication and event tagging.
Step 1: Find the "door number" of the Cortiview host - get the IP address.
1. Operate on the Cortiview host computer:
- Shortcut to summon the command window: press the Win and R keys on your keyboard at the same time.
- Run cmd: Type cmd in the Run dialog box that pops up and press Enter or click OK. A black Command Prompt window will open.
- Execute ipconfig: type ipconfig and press enter.


3. Record the IPv4 address:In the list of information for this adapter, find theIPv4 Address . . . . . . . . . . . :. Immediately following is the desired address. The format is usually192.168.x.x or 10.x.x.xetc.
(Tip: If the host has more than one network connection (e.g. wired + wireless), make sure that you record the address of the adapter that connects to the experimental LAN.)


Step 2: Setting up a "Communication Line" in E-Prime - Configuring Socket Devices
1. Open the E-Prime lab program:On the stimulus presentation computer, open the E-Prime 3.0 experimental program file (.es3).


3. Add the socket device:
- In the Properties window of the Experiment object, switch to the Devices tab.
- Click the Add button.
- In the list of devices that pops up, find and select Socket (which may be categorized under "Network" or "Other").


4. Precise setting of Socket parameters:
- Ensure that the newly added Socket device is selected.
- In the Properties pane on the right, find the following key setting items:
o Server:Fill in the IPv4 address of the Cortiview host recorded in Step 1 here in its entirety.
o Port:This port number defaults to 8889. This is the port on which the Cortiview software listens for event marker signals by default. (You can change the NIR host port number at a later time if you need to.)
- Other parameters (such as Timeout) are usually fine to leave as default unless there are special needs.
- VERIFICATION: After completing the setup, be sure to save your E-Prime lab program.


Step 3: Putting a "flare gun" on the stimulus event - binding the stimulus event Mark
1. Locate the target stimulus:


2. Open Task Events:




3. Add a Send Mark event:
- Click the Add button to add a new event.
- Configure the properties of the new event:
o Event: select the exact point in time when the stimulus started. Most commonly used:
§ OnsetTime:That precise moment when the stimulus begins to be presented (most commonly used).
§ StartTime:The moment when the object starts processing (ready for rendering) (usually very close to OnsetTime, but OnsetTime refers more precisely to the start of rendering).
o Action: Select Send to perform the "send" action when the event selected above occurs.
o DataType: select Byte. means we will send an integer of 1 byte length.
o Custom: Enter a unique integer between 1 and 255 as the Mark code.
§ Key role:Different stimulus types or experimental conditions (e.g. looking at picture A vs. looking at picture B, or memory task vs. rest) must be encoded using different Marks. This is so that when the Cortiview data is analyzed at a later stage, it is possible to know exactly what conditions were presented based on this Mark value, and thus extract the brain signals of the corresponding time period for analysis.
§ Example:Bind Mark=1 to "Positive Mood Picture", Mark=2 to "Negative Mood Picture" and Mark=3 to "Neutral Picture".


4. Duplicate bindings:
For each key stimulus in the experiment that required precise labeling of its presentation onset moment, Step 3 was repeated to bind a unique Mark event to it.
III. Synchronized verification and troubleshooting






Signs of Success:


Phenomenon: No Mark signal; Solution: Check the network interoperability of the two machines.
Phenomenon: Only white dotted lines are seen; Solution: Confirm the socket port number
Phenomenon: Mark delay fluctuation; Solution: switch wired connection
IV. Supplementary technical principles






In cognitive neuroscience experiments, achieving high-precision synchronization of event markers (Marks) is a critical part of ensuring data quality. Socket-based network communication is gradually becoming the mainstream choice for the new generation of synchronization schemes.
1. Why use socket communication:
Socket communication is based on the widely used TCP/IP protocol, which has the advantages of cross-platform compatibility, low-latency transmission, and flexible use, and is capable of stably transmitting 1~255 Byte of event-encoded information. This makes it an ideal solution to replace the parallel port triggering method, especially suitable for event synchronization tasks between stimulus programs (e.g., E-Prime, Presentation) and acquisition devices (e.g., Cortivision NIRSport, etc.) in modern experimental systems.
2. Time accuracy tips:
Although the fNIRS technique is not extremely sensitive to millisecond-level delays, to maximize the accuracy of event timing, we recommend that network communication delays be kept within 10ms.
A simple command: ping the target IP address can be used to quickly assess the current network response time and troubleshoot potential latency risks in advance.
3. Operational mnemonics:
IP find right, port set right, event binding, real-time monitoring.
V,Extended Recommendations






For multi-conditional experiments, it is recommended that the Mark coding table be embedded in the E-Prime script comment field (e.g., 1=neutral stimulus, 2=emotional stimulus) to enhance experimental traceability.
Company Profile


With excellent innovation ability, Hengbest Technology has been awarded many invention patents, software copyrights and registered trademarks, selected in many authoritative lists such as National High-tech Enterprises, and participated in the compilation of national standards and group standards. The company has been serving universities and research institutes for a long time, and has cooperated deeply with many national societies such as the Chinese Society of Ergonomics, the Chinese Psychological Society, the Architectural Society of China, etc. The company organizes and participates in more than 40 academic conferences every year to promote technical exchanges and the development of the industry.
恒挚 Technology upholds the concept of "doing our part for the cause of scientific research", and is committed to becoming a leading scientific research-supporting science and technology enterprise, contributing to the progress of national science and technology and social development, and joining hands with partners from all walks of life to achieve a better future empowered by science and technology.


Scan the code to follow us

