Skip to content

Full_Basic_EEG

Jin Jeon edited this page Nov 1, 2018 · 3 revisions

This section goes through running the pyns_exp.py basic task script. The ideal situation assumes that you have a subject/tester is wearing a cap sensor on. The script asks to blink, open/close, and look at different directions. On the NetStation's side, it will record all the events being sent from PsychoPy. The later parts of this section will use pyns_run.py to check timing.

Requirements: You should have completed: PsychoPy Setup, Hardware Setup, NetStation Setup, and ideally Sending Events & Timing Check and Photocell & DIN.

Running Basic Tasks (pyns_exp.py)

  1. Clone the repository if you haven't done so. In terminal,
git clone https://github.com/vucml/PsychoPyNetStation.git
  1. Open pyns_run.py file with either editor or coder view in PsychoPy

  2. Change custom variables (starts @ line 32) if necessary:

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#                       Custom Variables                          #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# 1=blinks
# 2=open/close
# 3=gaze
seq=[1,1,1,1,2,2,2,3,3]
shuffle(seq)
# Switches #
netstation  = True       #False to run the file locally without connecting to NetStation
recording   = True       #True starts recording NetStation automatically
photocell   = True        #True allows use of photocell device
  • In the `seq=[] add in as many 1, 2, 3s as you wish. Each digit represents a trial of blink, open/close, gaze (looking in direction) respectively. The current setting is set to last about 4 minutes.

Switches:

  • You can also turn recording = False if you do not want to save a copy of record

  • If you do not have photocell/AV device setup, set photocell = False

  • Change other variables, such as duration, position, etc if necessary

  1. Complete the experiment. The experiment will goes through basic tasks in random order of defined seq. With NetStation connected, these would be helpful indicator/baseline for EEG waveforms. Once complete, we will use .log file created from PsychoPy and event export file from NetStation.

Exporting NetStation Events

  1. 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
  2. Click Add or drag the recording file to the Inputs box.

  3. Select 'Export all events as text'. If you haven't created one, see here.

  4. Click 'Run' and it will process your uploaded recording file to export just the events as text file

  5. Move the resulted NetStation event text file to your PsychoPy basic folder, and rename it to something like 'example_nslog'. From this on, this text file will be referred to as 'example_nslog'.

Measuring Timing (pyns_run.py)

This part uses example file 'example_pylog' and 'example_nslog' for demo.

  1. Make sure you have pyns_core.py, text_to_csv.py, pyns_run.py, your Psychopy log, and NetStation event log in same folder. Then run:
python -i pyns_run.py
  1. Now type:
example1 = pyns_diff('example_pylog','example_nslog','data',
           'int','bli','sbl','oc_','scl','sop','gaz','sle','sri','s_u','sdo')
  • The 'data' is the PsychoPy log labels we want to extract, and the 'int' 'bli'...'sdo' are all custom event labels used in pyns_exp.py file to send events to NetStation.
  • pyns_run.py is soft-coded enough so that you can enter in custom variables to test your stimuli timing difference
  • Type help(pyns_diff) for detail
  1. If you had photocell connected, there is also pyns_pc:
example2 = pyns_pc('example_pylog', 'example_nslog', 'wsq', 'sbl','scl','sop','sle','sri','s_u','sdo')
  • Note there is bunch of hard-coded Warning showing up. Currently, there is some issue with measuring onset timing of the sound presented in pyns_exp.py so the 300-500ms lag is inevitable.
  • Type 'help(pyns_pc)' for detail

Example of result is the example.html in the same directory.

Once you are done, you can now try customizing your own experiment code: