-
Notifications
You must be signed in to change notification settings - Fork 4
Sending_Events_and_Timing_Check
Using pyns_auto.py, we can test PsychoPy events are sent properly and in timely manner. The file uses PyNetStation module to let PsychoPy communicate with NetStation. Core components of the module are summarized in PyNetStation Code Summary.
- Clone the repository if you haven't done so by:
git clone https://github.com/vucml/psychopynetstation.git
-
Make sure PsychoPy computer is connected to NetStation computer, and that proper acquisition setup is loaded and turned 'on'.
-
Navigate to basic folder and open pyns_auto.py in either PsychoPy or simply Python
- Using Python, type:
python -i pyns_auto.py
-
This will start sending total 5 events labeled 'auto' to NetStation with +1 second increments. Also, type
beep()
to send custom event labeled 'beep'
-
Once 5 auto events are sent, Close recording in NetStation, and exit python or PsychoPy
-
Check the resulted files in: A. PsychoPy computer: check that autolog.csv is created in the basic folder B. NetStation computer: check the recording file name
We will now compare timing difference between events logged in PsychoPy and NetStation. Before, we need to export NetStation events to text file
-
In NetStation top menu bar, go to Tools > Waveform Tools
- Note, Waveform Tools is essential tool for exporting and cleaning data. It is also used in deriving ERP -
Click Add or drag the recording file to the Inputs box
-
Name the event type and change the settings as below. You can ignore the "Available event types". You can exit by clicking 'x'
-
Click 'Run' and it will process your uploaded recording file to export just the events as text file
-
Move the resulted NetStation event text file to your PsychoPy basic folder, and rename it to something like 'nslog'. From this on, this text file will be referred to as 'nslog'.
Now that we have both log files from both PsychoPy and NetStation, we will check for timing difference to make sure that there is no significant delay in events being sent to NetStation.
- In terminal,
python -i auto_compare_log.py
- In python,
auto_compare_log('nslog') # insert your renamed NetStation event name with quotation marks
This should print something like:
average delay between nslog and pylog: [6, 2, 0, 5]
average difference is 3.25ms
Here average difference is the average of the list of difference (6 + 2 + 0 + 5) / 4 ** What the function basically does is that it extracts out and cleans all the timestamps from each Psychopy log and NetStation log. Then in each of the log, the timestamps are subtracted. ie. timestamp2 - timestamp1, timestamp3 - timestamp 2, ..., and timestampN - timestamp(N-1) in order to find the relative timing difference. Then the two differences are compared to find the average relative difference.
** If you have average difference above 15-20ms, it is a bad sign that there is some delay between PsychoPy and NetStation