Process EEG data with the Live Environment

In this tutorial we will learn how to use the live-environment to train the node chains on the data streamed from an external EEG server and classify new instances based on the trained node chains.

Preparation

Before we start we have to look more closely to the content and the structure of the example parameter file for the live environment.

data_files:
    eeg_data_file_train: 
    eeg_data_file_test: 

potentials:

    - flow_id: "SineWave"
      positive_event: "Target"
      positive_prediction: "PerceivedTarget"
      negative_event: "Standard"
      negative_prediction: "MissedTarget"
      prewindowing_flow: "node_chains/online_sinewave_prewindowing.yaml"
      postprocess_flow: "node_chains/online_sinewave_postprocessing.yaml"
      threshold_adaptation_flow: "node_chains/online_threshold_adaptation_flow.yaml"
      windower_spec_path_prediction: "online_sinewave_window_spec.yaml"
      windower_spec_path_train: "online_sinewave_window_spec.yaml"
      windower_spec_path_stream: "stream_window_spec_block_1000.yaml"
      ignore_num_first_examples: 10
      confusion_matrix: True

data_source:
    nullmarker_stride_ms: 1000
    default_port: 51244
    predict_offline: {ip: "localhost", port: 51244}
    predict: {ip: "localhost", port: 51244}
    train: {ip: "localhost", port: 51244}
    prewindow: {ip: "localhost", port: 51244}
    
live_server:
    live_server_ip: "localhost"
    live_xmlrpc_port: 16254

mars:
    mars_ip: "192.168.100.46"
    mars_port: 8080
            
flow_persistency_directory: "./flow_storage"
prewindowed_data_directory: "./prewindowed_data_storage"

record:
    subject: "NJ89"
    experiment: "sine-wave-test"
  • data_files
    This files can be left empty for testing purposes.
  • potentials
    This field describes every flow which is executed during the live processing. In this example there is only one flow called SineWave. It uses a dataset which is encoded in the raw-eeg format and is located in the default storage directory. Specific node chains for the processing of the data are referenced for the different processing steps (e.g. prewindowing, postprocessing).
  • eeg_server
    Here you can fill in the parameters for a online recording/processing session. The setup of the online streaming is described in the tutorial Setup and build the eegmanager.
  • live_server
    ???
  • mars
    ???
  • flow_persistency_directory
    The directory, in which the pickled flows are stored.
  • prewindowed_data_directory
    The directory where the data after the prewindowing step is stored.
  • record
    When using pySPACE-live the data which is processed also gets recorded in the raw-eeg format (.eeg/.vhdr/.vmrk) for later reference or analysis. The field subject is meant for any subject related identification. The experiment field is there to describe the experiment. Both fileds are used to create the filename of the resulting raw-data files. The data is saved to the storage directory which is specified in your spec-file.

For purposes, other than testing the pySPACE-live environment with artificial data, please feel free to adapt it to your need (e.g. fill in more potentials or node chains).

Execute the Test for pySPACE-live

To make sure, everything is well defined and configured, we execute the unit-test for the pySPACE-live environment. In order to do that navigate to the folder

cd $(pyspace)/pySPACE/tests/system_tests/live

In there you will find test_live.py Execute the test by invoking the following command:

python test_live.py --param example_param_file.yaml --conf <your-config>.yaml

After that you will see the output of the different steps which are preformed in pySPACE-live.