Frequently Asked Questions (FAQs)

© 2009-2011 Kayser

last updated: February 22, 2011

CSD Toolbox home page CSD toolbox home NYSPI Psychophysiology
CSD toolbox tutorial
common mistakes and errors
frequently asked questions FAQs

  May 19, 2009
(updated February 22, 2011)

1. Can I use an EEGlab or BioSemi montage that also includes spherical angles Theta and Phi?

  May 21, 2009
(updated February 22, 2011)

2. Are there any differences between the spherical coordinates provided by CSD toolbox or EEGlab / BioSemi?

FAQs May 21, 2009
(updated February 22, 2011)

3. How do I convert between the different spherical angles used in CSD toolbox and EEGlab or BioSemi, or given by generic 3-D Cartesian coordinates?

  May 21, 2009

4. Why do I get an "Inner matrix dimensions must agree" error when submitting data to the CSD.m function?

  June 3, 2009 5. What causes the "G (?-by-?) and H (?-by-?) matrix dimensions must match rows (?) of data matrix" error of function CSD.m?
  June 3, 2009 6. How do I include a linked reference (e.g., linked mastoids, linked ears) in my EEG montage?
  June 3, 2009 7. Should I include a non-cephalic reference in my EEG montage?
  June 2, 2009

8. What about applying a CSD transform to EEG spectra?

  June 3, 2009

9. Can I use CSD data to compute an inverse solution with other source localization tools, such as BESA or LORETA?

 

June 3, 2009
(updated July 21, 2010)

10. Matlab appears to use a different CSD.m routine - what is going on?

  June 17, 2010

11. After converting surface potentials to CSD, can the converted data be analyzed like surface EEG?

  June 17, 2010

12. Is the polarity of a CSD signal more informative than the polarity of the surface potential?

FAQs July 20, 2010

13. How do I generate CSD transformations from an EEGlab data file?

  June 20, 2010

14. Is there an effcient way to loop through individual, very large EEGlab data files consisting of 3-D data matrices (channels-by-samples-by-epochs)?

  July 21, 2010

15. I am running out of memory when using the CSD.m routine with large data files - are there any work-arounds?

     

1. Can I use an EEGlab or BioSemi montage that also includes spherical angles Theta and Phi?

Because EEGlab uses a different spherical coordinates system, in which the spherical angle Theta is shifted -90° compared to its CSD toolbox equivalent, the EEGlab coordinates must be converted to CSD toolbox spherical coordinates. Similarly, BioSemi uses a spherical coordinate system (cf. position coordinates) in which the angle Phi denotes vertex downward shifts as opposed to the CSD toolbox which uses the origin of the sphere as the angle reference point. The CSD toolbox function ConvertLocations.m provides an easy means to convert between these different notations (type "help ConvertLocations" at the command window to obtain help on this function).

 
Topography of a 77-channel EEG montage using spherical angles Theta and Phi as defined in EEGlab (orange) with the CSD toolbox spherical coordinate system. The EEGlab angle Theta is rotated -90° (green) compared to the CSD toolbox notation (e.g., site Nz is positioned at the location for T10, site T10 is positioned at the location for Iz, etc.).
 
Back to top Home Tutorial Errors FAQs
 

2. Are there any differences between the spherical coordinates provided by CSD toolbox or EEGlab / BioSemi?

Apart from a -90° rotation of spherical angle Theta, EEGlab places standard and extended 10-20-system electrode sites at different locations than CSD toolbox. Likewise, even after adjusting of the spherical angle Phi, some BioSemi position coordinates with nominal identity differ from those provided by the CSD toolbox. In EEGlab and BioSemi, for instance, all electrodes on the x-y plane (i.e., the circle combining the locations Fpz, T7, Oz, and T8) are located -2° below the sphere's equator. In contrast, the CSD toolbox places these locations directly on the equator (i.e., where they belong if one directly follows the logic of the 10-20-system; e.g., cf. Jurcak et al., 2007). Whereas these differences may be of minor importance when mapping volume-conducted scalp potentials, these differences will have a greater impact for the computation of CSD estimates, because the CSD computation is based on relative differences between scalp sites. For example, a prominent visual ERP component at occipital will be differently represented if, let's say, sites P9, P7, P5, P07, and P09 have a different spatial representation. This issue will ultimately also impede on the comparison of findings across studies, a limitation that can be overcome by using a reference-free CSD approach. A different consideration is using a more realistic head model rather than a simplified spherical model, but it does not appear that the EEGlab coordinates are preferrable in this regard when compared to their CSD toolbox counterparts. For these reasons, it is strongly recommended to use spherical locations as specified in the CSD toolbox look-up table (see ASCII file "10-5-System_Mastoids_EGI129.csd"). At the very least, the coordinate system used to specify electrode locations should be clearly indicated.

Superimposed topographies of a 77-channel EEG montage using coordinates as specified in CSD toolbox *.csd files (green) or in EEGlab *.ced/*.locs files (orange; rotated labels). Some locations are substantially shifted in EEGlab when compared to CSD toolbox locations implemented using the logic of the 10-20-system (e.g., see sites AF9/10 or P9/10).

 
Back to top Home Tutorial Errors FAQs
 

3. How do I convert between the different spherical angles used in CSD toolbox and EEGlab or BioSemi, or given by generic 3-D Cartesian coordinates?

The CSD toolbox function ConvertLocations.m converts between the CSD toolbox spherical coordiante system stored in *.csd files, the EEGlab polar and spherical coordinate systems used in *.locs and *.ced files, the BioSemi spherical coordinate system used in *.biosemi text files consisting of a channel label followed by two spherical angles (cf. position coordinates), or as given by *.xyz text files specifying generic 3-D Cartesian coordinate (channel label followed by x, y, and z coordinates). This function also allows to specify a subset of electrodes included in one of these ASCII coordinate files to generate a new and/or reordered EEG montage (type "help ConvertLocations" at the command window to obtain help on this function).

Matlab command window help screen for CSD toolbox function ConvertLocations.m.
 
Back to top Home Tutorial Errors FAQs
 

4. Why do I get an "Inner matrix dimensions must agree" error when submitting data to the CSD.m function?

The CSD toolbox function CSD.m requires as input an electrodes × samples data matrix (i.e., consisting of rows equal to the number of electrodes), and transformation matrices G and H consisting of rows and columns equal to the number of electrodes (type "help CSD.m" at the command window to obtain help on this function). If these dimensions do not match, the original code of CSD.m would result in this Matlab error:

Matlab error when using the originally published code of function CSD.m with a n × m matrix D consisting of n rows that did not correspond to the dimension of matrices G and H.

This error is typically the result of not transposing the input data matrix (e.g., submitting a samples × electrodes rather than an electrodes × samples matrix orientation; see also answer to FAQ #5. ). It can also be caused by the Matlab textread.m routine, which in some Matlab versions (e.g., Matlab 6.5, Release 13) incorrectly reads numeric values from a text file. [For the example data provided for the tutorial, the addition of zero column at the end of the data matrix can easily be corrected by removing the last column, e.g. by entering "D = D (:,1:31)" at the command line.] The user should always verify the dimensions of the data matrix (e.g., by inspecting the Matlab workspace). However, an improved error checking for the input matrix dimensions was implemented in the revised CSD toolbox function CSD.m.

The revised CSD toolbox function CSD.m provides a more helpful error message.
 
Back to top Home Tutorial Errors FAQs
 

5. What causes the "G (?-by-?) and H (?-by-?) matrix dimensions must match rows (?) of data matrix" error of function CSD.m?

The cause of this error is explained in the answer to FAQ #4. The CSD toolbox function CSD.m requires as input an electrodes × samples data matrix (i.e., consisting of rows equal to the number of electrodes), and transformation matrices G and H consisting of rows and columns equal to the number of electrodes (type "help CSD.m" at the command window to obtain help on this function). The likely origin of this error is submitting the transpose of the required data matrix (i.e., submitting a samples × electrodes rather than an electrodes × samples matrix orientation), which could be, for instance, the result of plotting the ERP waveforms, which requires preliminary transposition (see example given in step #5 of the CSD toolbox online tutorial). To understand the difference between a n × m and a m × n matrix, which contain the same data values but in different cells, envision referencing a particular cell of these matrices (i.e., the value in the cell of row 4 and column 2 of matrix D, which is referenced in Matlab as "D(4,2)", will change after transposing the matrix "D = D';", and this particular value will be in the cell of row 2 and column 4, that is, in "D(4,2)").

Enlarge figure Enlarge figure
Shematic representations (top row) and Matlab workspace representations (bottom row) of a "Samples × Channels" data matrix D before and after its transpose.
 
Back to top Home Tutorial Errors FAQs
 

6. How do I include a linked reference (e.g., linked mastoids, linked ears) in my EEG montage?

The answer to this question depends on how the data for a linked reference was recorded or stored. If two or more reference sites (e.g., left and right mastoids) were physically-linked during data acquisition, or their data were averaged off-line and the original channels were dropped (i.e., the original data is no longer available), the data from the reference locations can not be used in the CSD transform. In this case, the EEG montage consists of all recordings sites minus the reference locations, which is regrettable but nevertheless allows a sound CSD transform. However, if the data from the original reference locations are still accessible, these reference locations can and should be included in the EEG montage and must, of course, be represented in the surface potential data. For example, if the EEG was recorded with a left-mastoid reference (i.e., site LM or TP9) and the EEG data also include the right mastoid (i.e., site RM or TP10), an additional channel LM with zeros should be added to the surface potential data, and sites LM and RM should be included in the EEG montage. [Note: It is a severe error to include data of a linked reference for the CSD transform because these physically-distinct scalp locations can not be modeled as a single site on the scalp.]

 
Back to top Home Tutorial Errors FAQs
 

7. Should I include a non-cephalic reference in my EEG montage?

No, because a non-cephalic reference cannot be reasonably modeled as a scalp location. However, it is perfectly acceptable to simply use the surface potential data recorded from all scalp sites. Thus, the answer to this question is similar to when using a physically-linked cephalic reference (as described in FAQ #6).

 
Back to top Home Tutorial Errors FAQs
 

8. What about applying a CSD transform to EEG spectra?

CSD estimates can be only computed from surface potential data, which includes single EEG epochs. Thus, CSD spectra can be computed from CSD-transformed EEG epochs using the same spectral decomposition techniques (e.g., FFT) typically applied to referenced surface potentials (for an application of CSD spectra, see Tenke & Kayser, 2005). However, it makes no sense to compute "CSD spectra" from EEG power spectra because the power spectrum is a nonlinear and irreversibe data transformation (see detailed explanation here).

 
Back to top Home Tutorial Errors FAQs
 

9. Can I use CSD data to compute an inverse solution with other source localization tools, such as BESA or LORETA?

CSD estimates represent underlying current generators because a surface Laplacian provides a conservative and accurate estimate of the current flow at the scalp. However, because the CSD transformation has already eliminated properties related to volume conduction, the use of CSD estimates as an input to "inverse" programs designed to infer, quantify and localize the intracranial generators of surface potentials (e.g., BESA, LORETA) is a violation of basic assumptions on which all of these inverse solution methods rely. Despite this caveat, it is still possible to expand the applicability of CSD methods by using inverse tools with surface potential topographies corresponding to time intervals or spectral bands (or their data-driven component simplications) that were initially identified and characterized using the reference-free CSD transform.

 
Back to top Home Tutorial Errors FAQs
 

10. Matlab appears to use a different CSD.m routine - what is going on?

During prior releases of Matlab, the signal toolbox used the function CSD.m to compute Cross Spectral Density estimates. However, in Matlab revision R2009a (Version 7.8.0.347), this routine had been replaced by the function CPSD.m to compute Cross Power Spectral Density estimates, although CSD.m still worked. With the release of Matlab revision R2010a (Version 7.10.0.499), the original cross-spectral density function CSD.m has been completely removed from Matlab, so this is no longer an issue. However, if you encounter a conflict between the CSD toolbox function CSD.m and the Matlab signal toolbox function CSD.m while using a previous Matlab release, there are several practical work-arounds. For instance, it is possible to (temporarily) change the Matlab search path (in Matlab, click on the [File] menu and then on [Set Path...], and modify the search path order accordingly, or remove the path with the routine you don't want to use). Alternatively, you may consider renaming (or copying) the CSD toolbox routine CSD.m located in the CSD toolbox subdirectory "../func" (e.g., SP2CSD.m would be an appropriate new name).

 
Back to top Home Tutorial Errors FAQs
 

11. After converting surface potentials to CSD, can the converted data be analyzed like surface EEG?

Laplacian-transformed EEG/ERP may be processed with any routine typically applied to surface potential EEG/ERP (i.e., referenced) data, which include high and/or low pass filter, fast fourier transform (FFT), baseline correction, averaging of epochs, etc. However, one has to keep in mind that CSD data are reference-free (i.e., data can not be converted back into surface potentials), which prohibits all post-processing transformations that involve a recording reference (e.g., rereferencing the data).

 
Back to top Home Tutorial Errors FAQs
 

12. Is the polarity of a CSD signal more informative than the polarity of the surface potential?

Yes, it is. The choice for a surface potential reference is quasi-arbitrary, meaning that the polarity can only be interpreted in relative but not absolute terms. For instance, rereferencing the data from a vertex (Cz) recording reference to a linked-mastoids or average reference will change the polarity of the EEG/ERP signal for certain sites (regions) and/or time intervals (components), which, of course, has also implications for spectral data properties (e.g., phase, amplitude). In contrast, a surface Laplacian or CSD transform represents "true" estimates of current activity at scalp, meaning that the signal polarity (negative = sink, positive = source) is unambiguous by itself. CSD estimates are inherently reference-free by virtue of their computation (i.e., second spatial derivative), that is, they depend only on the topography of the EEG signal. As the EEG/ERP topography is not altered by different reference schemes because the subtraction of a constant (i.e., a different reference) does not alter the relative values between recording sites per sample point, CSD estimates are unique (i.e., there is only one CSD solution for a given EEG montage).

 
Back to top Home Tutorial Errors FAQs
 

13. How do I generate CSD transformations from an EEGlab data file?

The general procedure is described in the CSD toolbox tutorial, which is strongly recommended to any researcher before embarking upon the transformation of EEG/ERP data into CSD estimates. However, two excellent example scripts kindly provided by John J.B. Allen showcase how to exploit the EEG montage information included in any EEGlab data file to generate the montage-dependent "Channels × Channels" transformation matrices G and H (EEGlab_Make_G_H.m), and how to use these transformation matrices with individual EEGlab data files, consisting of "Channels × Sample Points × Epochs (Trials)" data matrices, to obtain corresponding CSD data files (EEGlab_Loop_Epochs.m).

 
Back to top Home Tutorial Errors FAQs
 

14. Is there an effcient way to loop through individual, very large EEGlab data files consisting of 3-D data matrices (channels-by-samples-by-epochs)?

As a general Matlab rule, pre-allocating memory, as opposed to sequentially allocating memory as a matrix increases in size over time, may substantially reduce overall computing time. If very large data files are to be converted, this may be an important consideration. The example script EEGlab_Loop_Epochs.m contains three different instructions to obtain CSD data from a "Channels × Sample Points × Epochs" data file used by EEGlab. The first set of instructions loops through all epochs and submits each epoch as a "Channels × Sample Points" 2-D data matrix to the CSD.m routine, which is fine; however, without the initial memory pre-allocation for the CSD data output, this would be unnecessarily time consuming as the content of the final CSD data matrix is copied every time the matrix size is increased. The second set of instructions uses the Matlab reshape.m function to temporally reorganize the "Channels × Sample Points × Epochs" 3-D data matrix into a "Channels × (Sample Points * Epochs)" 2-D data matrix to comply with submitting a "Channels × Samples" 2-D data matrix to the CSD.m function, which also works well. Surprisingly, submitting a "Channels × Sample Points × Epochs" 3-D data matrix to CSD.m, as shown in the third set of instructions, works equally well despite the extra dimension. The reason for this unexpected observation is that Matlab implements a 3-D matrix simply as a sequence of consecutive 2-D matrices. For example, if EEG.data is a "64 channels × 256 samples × 100 epochs" data matrix, the Matlab statement "size(EEG.data)" will return "64 256 100" as the answer; however, explicitly requesting only two dimensions with the statement "[chans,points] = size(EEG.data)" will return "channels = 64" and "points = 25600", the latter being equal to the product of samples * epochs (this is also how the dimensions of a 3-D data matrix are listed in the Matlab workspace). Thus, the compact one-line CSD statement in the third set of instructions produces the same results as the other two instruction sets.

 
Back to top Home Tutorial Errors FAQs
 

15. I am running out of memory when using the CSD.m routine with large data files - are there any work-arounds?

By default, Matlab uses double precision for data matrices. However, for most practical purposes regarding the CSD.m routine, single precision is fully sufficient. For instance, the Matlab statement "A = single(A);" converts a double precision matrix to single precision and reduces memory demands by half (the reverse Matlab statement "A = double(A);" re-assigns double precision to matrix A). The example script EEGlab_Loop_Epochs.m shows how these operations can easily be integrated in the Matlab syntax. If this does not solve the memory issue, the obvious next work around is to split the CSD conversion process into smaller steps at a time (e.g., looping through all data epochs as shown in the first set of instructions given in EEGlab_Loop_Epochs.m). The extreme end of this work-around is submitting one sample point at a time to the CSD.m routine (i.e, a column vector, which represents a "Channels × 1" 2-D data matrix).

 
Back to top Home Tutorial Errors FAQs