last updated:
July 21, 2010
This basic tutorial assumes that the content of the CSD toolbox zip archive has been extracted to a local folder, and that this folder folder has been added to the MatLab search path (in MatLab, click on the [File] menu, and then on [Set Path...], select the folder and click on[Add with Subfolders...]). The tutorial is written on a level that is (hopefully) suitable to MatLab novices, but it does not teach the basic concepts of MatLab or the use of the MatLab environment. On the other hand, this tutorial should also be informative for experienced MatLab users who have not used the CSD toolbox.
Step 1: Understanding Spherical Coordinates
Scalp surface Laplacian estimates are based on the second spatial derivative of the recorded surface potentials and represent the magnitude of the radial (transcranial) current flow leaving (sinks) and entering (sources) the scalp. These reference-free current source density (CSD) estimates map the direction, location and intensity of current generators that underlie an EEG/ERP topography. Thus, the first step requires the identification of the scalp locations included in any given EEG/ERP topography in 3-D space.
Any EEG/ERP topography is based on an EEG montage, which includes the EEG recording reference. For a spherical spline surface Laplacian, one can simplify the head as a unit sphere (i.e., a sphere with a radius of 1; Fig. 1), with all EEG scalp sites located on the sphere's surface (Fig. 2).
Their surface locations can then be expressed by the direction of a vector originating in the center of the sphere (Fig. 3).
Fig. 3. Two spherical angles are sufficient todescribe any point on the surface of a unit sphere.
Whereas the assignment for the axes and angles is arbitrary, the CSD toolbox uses the following orientations (as defined in the appendix of Kayser & Tenke, 2006a): For Cartesian coordinates, the x-y plane ismarked by the great circle combining the locations Fpz, T7, Oz, and T8, with the x-axis running through T7 (-1.0)and T8 (+1.0), the y-axis running through Oz (-1.0) and Fpz (+1.0), and the z-axis running through the origin of thex-y plane (0) and Cz (+1.0). For spherical coordinates, the angle theta denotes the rotation from the x-axis towards they-axis (positive poles, respectively), whereas phi denotes the angular displacement from the x-y plane towards thepositive pole of the z-axis.
The spherical coordinates for locations where the three great circles of the x-y, x-z, and y-z planes intersect arestraightforward (e.g., for Oz: theta = -90, phi = 0; for Cz: theta = 0, phi = +90; for T8: theta = 0, phi = 0). As defined by the logic of the international 10-20 system (e.g., Oostenveld & Praamstra, 2001),intermediate locations on these great circles are quarter (22.5°) or quintile (18.0°) sections of the respectiverectangular arcs (e.g., for O1, theta is -90 - 1*18 = -108, phi = 0; for Pz, theta = -90, phi is 2 * 22.5 = +45; for P8, theta is 2 * -18 = -36, phi = 0). Similarly, locations on thesmall circle combining nasion and inion are a quarter rectangular arc downwards (e.g., for P10, theta is 2 * -18 = -36, phi = -22.5).
The remaining locations are located on small circles defined by two lateral andone midline base locations (Oostenveld & Praamstra, 2001). Determining their spherical angles is less straightforward, but can nevertheless be derived by performing some basic geometrical computations (as detailed here). If you are using non-standard scalp locations (i.e., those not covered by Step 2, you need to fully understand this systematic and specify your spherical coordinates through Theta and Phi. For this purpose, the original publication included as an example the Matlab code GetF3CoordinatesWithMirrorLocations.m, along with two Matlab functions (SphericalMidPoint.m, LineWithSphere.m) to support these geometrical computations.
Step 2: Specifying an EEG Montage
If you are using an EEG montage including onlystandard 10-20-system locations, you can easily specify your EEG montage by taking advantage of the CSD toolbox content. The CSD toolbox includes a look-up table for 330 standard scalp sites based on the systematic of the extended 10-20-system (10/20-, 10/10- or 10/5-system; cf. Jurcak et al., 2007; Fig. 4), plus additional locations for left and right preauricular points (A1/A2; LPA/RPA = T9/T10), left and right mastoids (LM/RM = TP9/TP10), and the nose tip (Nose). In addition, 129 scalp locations of a first-generation geodesic sensor net (GSN; Electrical Geodesics, Inc.) used in our report addressing the feasibility of a CSD transform for low-density EEG recordings (Kayser & Tenke, 2006b) have been included (Fig. 5). [However, in deviation from the original 129-channel GSN montage, the location for channel #17 points to the Nose instead of Nz; if appropriate, this location must be adjusted in the look-up table by replacing the values for channel #17 with the values for Nz.]
This look-up table is an ASCII file ("10-5-System_Mastoids_EGI129.csd"), in which each line lists a scalp location with their spherical coordinates Theta and Phi (Fig. 6). [The additional values in each line (Radius, X, Y, Z, off sphere surface) are gratuitous and provided only for backward compatibility.]
Fig. 6. Structure of look-up table for spherical coordinates (Theta, Phi) of 330 10-5-system and 129 geodesic locations.
The CSD toolbox function ExtractMontage.m provides an easy means to extract a specific EEG montage from this look-up table, which is best explained via a hands-on example. Included in the CSD toolbox are the data of a grand mean ERP (ASCII file "NR-C66-trr.dat"; Fig. 7) derived from 66 healthy adults (the target condition for an auditory oddball task using complex tones with a right button press; cf. Kayser & Tenke, 2006a) along with the corresponding 31-channel EEG montage (ASCII file "E31.asc"; Fig. 8). The ERP data are stored as a "Samples × Channels" matrix, meaning each row represents a single time point (200 samples/s; 200 time points ranging from 0 to 995 ms), and each column corresponds to a scalp location (ordered from Fp1 to Nose, as given by the line-by-line EEG montage listed infile "E31.asc"). Note that all values in the last column of the ERP data matrix, which corresponds to the Nose recording site, are zero because these surface potential data are nose-referenced.
Fig. 7. First and last ERP data values of rows and columns of ASCII file "NR-C66-trr.dat".
Fig. 8. First and last rows of the 31-channel EEG montage listed in ASCII file "E31.asc".
We can use the MatLab function textread.m to read the EEG montage as a cell array of strings into MatLab, by entering
>> E = textread('E31.asc','%s')
at the MatLab command window (Fig. 9). You can also open the MatLab code for this hands-on example (ExampleCode1.m) in the MatLab editor, highlight line 19 and press the
Fig. 9. Reading the EEG montage into a MatLab a cell string array E via the MatLab function textread.m (type "help textread" at the command window to obtain help on this function).
Fig. 10. Extraction of the 31-channel EEG montage to an array structureM using the CSD toolbox function ExtractMontage.m (type "help ExtractMontage" at the command window to obtain help on this function).
Next, we use the CSD toolbox function ExtractMontage.m with the look-up table for the spherical coordinates and cell string array for the EEG montage by entering
>> M = ExtractMontage('10-5-System_Mastoids_EGI129.csd',E)
at the MatLab command window (Fig. 10). The MatLab workspace should now list two matrices, E and M.
To verify the integrity of the EEG montage, which is of crucial importance for the CSD transform, we use the CSD toolbox function MapMontage.m with the matrix M by entering
>> MapMontage(M)