Tutorial 3: Importing and pre-processing

This tutorial illustrates how to convert Micromed .TRC files into SPM format, then how to process these files in ImaGIN: bad channels, bipolar montage, event management… We will import three TRC files, corresponding to three seizures of the same patient. With the interactive interface, we can process the files only one after the other, all the operations illustrated below will have to be repeated three times.

Convert to SPM .mat/.dat

Select the first seizure SZ1.TRC:
Navigate to the folder tutorial_epimap/seeg/ with the left panel, then click on SZ1.TRC in the right list so it gets selected in the bottom panel, then click [Done].

Note: If you change the current MATLAB directory to tutorial_epimap/seeg/, it would make the file selections easier in the rest of the tutorial as you wouldn't have to change folder every time.

Check in your file explorer the new files that were created for this first seizure:
• SZ1.mat/SZ1.dat: Recordings converted in SPM format
• SZ1_log.txt: Text file that lists the names of the channels that were kept or deleted during this conversion.

This conversion function assumes the recordings are sEEG recordings with specific nomenclatures: the label of a channel must start with the name of the depth electrode and end with the index of the contact on the electrode (numbering starting from 1).

Add 3D positions

The 3D locations of the sEEG contacts are not available in the .TRC files. They are saved in a separate text file that we need to add manually to the SPM .mat/.dat file.

This does not produce any new file in output but adds the contacts locations in the SPM .mat file (field D.sensors.eeg.elecpos and .chanpos). The positions added to the file are in normalized MNI coordinates.

The prefix "w" indicates this volume in normalized in MNI space. We select the normalized MRI because the coordinates of the SEEG contacts were imported in MNI coordinates.

Bipolar montage

The sEEG recordings are commonly represented and processed as bipolar recordings, but the data is usually acquired using a reference common to all the electrodes. To convert it to a bipolar montage, we compute the difference between pairs of adjacent contacts.

Select menu Import > Bipolar montage: ImaGIN_BipolarMontage.m

Select data file: SZ1.mat

This function creates a new dataset with the prefix "b" for "bipolar": bSZ1.mat / bSZ1.dat

Additionally, the log file bSZ1_log.txt documents the bipolar channels that are saved in the new file (eg. "b'2b'1" represents the difference between signals "b'2" and "b'1").

Review the signals

You can use the SPM, ImaGIN or Brainstorom viewers to review the recordings.

Review file bSZ1.mat with the options available in the the Display menu: ImaGIN_DispData.m / spm_eeg_load.m / ImaGIN_DispDataBst.m

The goal is to identify the bad channels and the seizure onset for each file.

Bad channels found for file bSZ1.mat: f'2f'1 (#28), v'2v'1 (#74)

Onset of seizure in file bSZ1.mat: 120.8s after the beginning of the file.

In the ImaGIN viewer, you can browse through all the channels with the arrow buttons at the bottom-right of the figure, and edit the time window with the text boxes at the bottom-left.

You can also use the Brainstorm file viewer, documented in the online tutorials #5 and #7:

Set bad channels

If you used the Brainstorm viewer to mark the bad channels, you don't have to do this and can directly use bSZ1_bst.mat.

Set time origin

This function updates the field D.timeOnset in the input .mat file. After the execution, the time reference (t=0) becomes the seizure onset, while previously it was the beginning of the file.

Import baseline

In the next tutorial, we will compute a time-frequency decomposition of the seizure and normalize it with respect to a baseline level. We will identify and import this baseline now. The baseline could be a segment of 5s to 30s of recordings before the seizure that contains as little interictal epileptiform activity as possible.
The duration of the baseline influences the computation time for the following steps of this tutorial. We will work here with short segments of 5s for illustration purposes, between 48s and 43s before the seizure onset ([72.8, 77.8]s from the beginning of the file). Use longer segments for more accurate results.