Skip to content

[WIP] Import events from CSV file

Thomas Vincent edited this page Nov 7, 2018 · 2 revisions

Stimulation events may not have been transmitted via TTL signals that get recorded in the AUX channels. In this case, synchronization between event timings has to be performed externally. For example, the experimenter can manually note the starting time of the stimulations. Temporal imprecision of around half a second is still acceptable since hemodynamic fluctuations are quite slow. A common and easy way to store stimulation events is to use the Coma Separated Value (CSV) Format. For example, it can be produced by saving events collected by psychtoobox via the csvwrite matlab function. Expyriment automatically saves event data as XPD files which are CSV files with an extra header.

The process "Events > Import from CSV table file" can import such tabular data which is assumed to be organized as follows:

  • column headers have to be defined ie the first row must be strings
  • one trial by row
  • one column indicates the label of the event
  • one column indicates the starting time of the event
  • one optional column can indicate the ending time or the duration

Here is an example of such table CSV file:

event_label, onset, duration
audio, 1.5, 5
audio, 11, 5
visual, 20, 3
visual, 25, 3

Column headers are (1srt row): "event_label", "onset", "duration". There are 4 event trials (ie 4 rows) and 2 event types: "visual" and "audio" which are stored in the first column. The second column, labelled "onset" gives the starting times of the event. The third column labelled "duration" gives their durations. Here the time unit is in second but one can use its own unit and specify it during the importation. Lastly, let's assume that the paradigm started at t=13 sec. after the beginning of the NIRS recording, ie the first event was "audio" at t=14.5 sec.

With a basic text editor (notepad, gedit...), copy and save this example in a file called "paradigm.csv". Assuming the data in "sample_nirs.zip" has been imported (see NIRS finger tapping tutorial), drag and drop the item "Subject01 |- S01_Block_FO_LH_Run01 |- Link to raw file" in the process panel. Select the process "Events > Import from CSV table file" and fill the options as in the following picture. Note that the time origin has an offset of 13 sec.

{{attachment:nst_tut_adv_pprocs_import_csv_panel.png||width="275",height="404"}}

Click on "Run". The process shows a summary of the events to import and ask for a confirmation:

{{attachment:nst_tut_adv_pprocs_import_csv_confirmation.png||width="329",height="93"}}

Click on "yes" to actually import the event. To review the imported events, open the time-series (right-click on the item, "NIRS > Display Time series"). Specify the page settings as: Start=10, Duration=40 to better view all the imported events.

{{attachment:nst_tut_adv_pprocs_import_csv_result.png|width="100%"|width="594",height="336"}}

The events are imported and added to the previously existing one (here "MOTOR" and "NIRS_mvt").

As they are dummy values, remove the imported events from the data (Events > Delete groups).