MEG and EEG data analysis with MNE-Python

Alexandre Gramfort, Martin Luessi, Eric Larson, Denis A Engemann, Daniel Strohmeier, Christian Brodbeck, Roman Goj, Mainak Jas, Teon Brooks, Lauri Parkkonen, Matti Hämäläinen, Alexandre Gramfort, Martin Luessi, Eric Larson, Denis A Engemann, Daniel Strohmeier, Christian Brodbeck, Roman Goj, Mainak Jas, Teon Brooks, Lauri Parkkonen, Matti Hämäläinen

Abstract

Magnetoencephalography and electroencephalography (M/EEG) measure the weak electromagnetic signals generated by neuronal activity in the brain. Using these signals to characterize and locate neural activation in the brain is a challenge that requires expertise in physics, signal processing, statistics, and numerical methods. As part of the MNE software suite, MNE-Python is an open-source software package that addresses this challenge by providing state-of-the-art algorithms implemented in Python that cover multiple methods of data preprocessing, source localization, statistical analysis, and estimation of functional connectivity between distributed brain regions. All algorithms and utility functions are implemented in a consistent manner with well-documented interfaces, enabling users to create M/EEG data analysis pipelines by writing Python scripts. Moreover, MNE-Python is tightly integrated with the core Python libraries for scientific comptutation (NumPy, SciPy) and visualization (matplotlib and Mayavi), as well as the greater neuroimaging ecosystem in Python via the Nibabel package. The code is provided under the new BSD license allowing code reuse, even in commercial products. Although MNE-Python has only been under heavy development for a couple of years, it has rapidly evolved with expanded analysis capabilities and pedagogical tutorials because multiple labs have collaborated during code development to help share best practices. MNE-Python also gives easy access to preprocessed datasets, helping users to get started quickly and facilitating reproducibility of methods by other researchers. Full documentation, including dozens of examples, is available at http://martinos.org/mne.

Keywords: electroencephalography (EEG); magnetoencephalography (MEG); neuroimaging; open-source; python; software.

Figures

Figure 1
Figure 1
Noisy raw MEG magnetometer signals corrupted by a) slow drifts, b) line noise (at 50 or 60 Hz), and c) heartbeats present across sensors. To clean signals data were filtered between 1 and 45 Hz. Subsequently, five signal space projection (SSP) vectors were applied (3 computed from empty room noise, 2 from ECG signals). The plots were generated using the plot method of the Raw class.
Figure 2
Figure 2
An evoked response (event-related fields in planar gradiometers of an Elekta-Neuromag Vectorview system) showing traces for individual channels (bad channels are colored in red). Epochs with large peak-to-peak signals as well as channels marked as bad can be discarded from further analyses. The figure was generated using the plot method of the Evoked class.
Figure 3
Figure 3
Cortical segmentation used for the source space in the distributed model with MNE. Left: The pial (red) and white matter (green) surfaces overlaid on an MRI slice. Right: The right-hemisphere part of the source space (yellow dots), represented on the inflated surface of the left hemisphere, was obtained by subdivision of an icosahedron leading to 10242 locations per hemisphere with an average nearest-neighbor distance of 3.1 mm. Left image was produced with FreeSurfer tksurfer tool and the right one with PySurfer (http://pysurfer.github.io) which internally depends on Mayavi (Ramachandran and Varoquaux, 2010).
Figure 4
Figure 4
Source localization of an auditory N100 component. Left: Results obtained using dSPM and a surface source space based on combined MEG and EEG data. The figure was generated using the plot method of the SourceEstimate class which internally calls PySurfer. Right: Results obtained using LCMV beamformer and a volume source space based on MEG channels only. The figure was generated using Freeview shipped with FreeSurfer.
Figure 5
Figure 5
Current estimates obtained from an individual subject can be remapped (morphed), i.e., normalized, to another cortical surface, such as that of the FreeSurfer average brain “fsaverage” shown here. The normalization is done separably for both hemispheres using a non-linear registration procedure defined on the sphere (Dale et al., ; Fischl et al., 1999). Here, the N100m auditory evoked response is localized using dSPM and then mapped to “fsaverage.” Images were produced with PySurfer.
Figure 6
Figure 6
Topographic and trellis plots of two automatically identified ICA components. The component #22 corresponds to the EOG artifact with a topography on the magnetometers showing frontal signals and a waveform typical of an eye blink. The component #6 on the right captures the ECG artifact with a waveform matching 3 heart beats.
Figure 7
Figure 7
Examples of clustering. (A) Time-frequency clustering showing a significant region of activation following an auditory stimulus. (B) A visualization of the significant spatio-temporal activations in a contrast between auditory stimulation and visual stimulation using the sample dataset. The red regions were more active after auditory than after visual stimulation, and vice-versa for blue regions. Image (B) was produced with PySurfer.
Figure 8
Figure 8
Sensor space decoding. At every time instant, a linear support vector machine (SVM) classifier is used with a cross-validation loop to test if one can distinguish data following a stimulus in the left ear or in the left visual field. One can observe that the two conditions start to be significantly differentiated as early as 50 ms and maximally at 100 ms which corresponds to the peak of the primary auditory response. Such a statistical procedure is a quick and easy way to see in which time window the effect of interest occurs.
Figure 9
Figure 9
Connectivity between brain regions of interests, also called labels, extracted from the automatic FreeSurfer parcellation visualized using plot_connectivity_circle. The image of the right presents these labels on the inflated cortical surface. The colors are in agreement between both figures. Left image was produced with matplotlib and right image with PySurfer.
Figure 10
Figure 10
Source localization with non-linear sparse solvers. The left plot shows results from TF-MxNE on raw unfiltered data (due to the built-in temporal smoothing), and the right plot shows results from γ-MAP on the same data but filtered below 40 Hz. One can observe the agreement between both methods on the sources in the primary (red) and secondary (yellow) visual cortices delineated by FreeSurfer using an atlas. The γ-MAP identifies two additional sources in the right fusiform gyrus along the visual ventral stream. These sources that would not be naturally expected from such simple visual stimuli are weak and peak later in time, which makes them nevertheless plausible.

References

    1. Aine C., Sanfratello L., Ranken D., Best E., MacArthur J., Wallace T., et al. (2012). MEG-SIM: a web portal for testing MEG analysis methods using realistic simulated and empirical data. Neuroinformatics 10, 141–158 10.1007/s12021-011-9132-z
    1. Becker R. A., Cleveland W. S., Shyu M.-J., Kaluzny S. P. (1996). A Tour of Trellis Graphics. Technical Report, Bell Laboratories
    1. Benjamini Y., Hochberg Y. (1995). Controlling the false discovery rate: a practical and powerful approach to multiple testing. J. R. Stat. Soc. Ser. B 57, 289–300 10.1016/j.neuroimage.2012.07.004
    1. Buitinck L., Louppe G., Blondel M., Pedregosa F., Mueller A., Grisel O., et al. (2013). API design for machine learning software: experiences from the scikit-learn project. in European Conference on Machine Learning and Principles and Practices of Knowledge Discovery in Databases, Prague
    1. Carp J. (2012a). On the plurality of (methodological) worlds: estimating the analytic flexibility of fMRI experiments. Front. Neurosci. 6:149 10.3389/fnins.2012.00149
    1. Carp J. (2012b). The secret lives of experiments: methods reporting in the fMRI literature. Neuroimage 63, 289–300 10.1016/j.neuroimage.2012.07.004
    1. Dalal S. S., Zumer J. M., Guggisberg A. G., Trumpis M., Wong D. D. E., Sekihara K., et al. (2011). MEG/EEG source reconstruction, statistical evaluation, and visualization with NUTMEG. Comput. Intell. Neurosci. 2011:758973 10.1155/2011/758973
    1. Dale A., Fischl B., Sereno M. (1999). Cortical surface-based analysis i: segmentation and surface reconstruction. Neuroimage 9, 179–194 10.1006/nimg.1998.0395
    1. Dale A., Liu A., Fischl B., Buckner R. (2000). Dynamic statistical parametric mapping: combining fMRI and MEG for high-resolution imaging of cortical activity. Neuron 26, 55–67 10.1016/S0896-6273(00)81138-1
    1. Delorme A., Makeig S. (2004). EEGLAB: an open source toolbox for analysis of single-trial EEG dynamics including independent component analysis. J. Neurosci. Methods 134, 9–21 10.1016/j.jneumeth.2003.10.009
    1. Delorme A., Mullen T., Kothe C., Acar Z. A., Bigdely-Shamlo N., Vankov A., et al. (2011). EEGLAB, SIFT, NFT, BCILAB, and ERICA: new tools for advanced EEG processing. Intell. Neurosci. 2011:130714 10.1155/2011/130714
    1. Desikan R. S., Ségonne F., Fischl B., Quinn B. T., Dickerson B. C., Blacker D., et al. (2006). An automated labeling system for subdividing the human cerebral cortex on MRI scans into gyral based regions of interest. Neuroimage 31, 968–980 10.1016/j.neuroimage.2006.01.021
    1. Destrieux C., Fischl B., Dale A., Halgren E. (2010). Automatic parcellation of human cortical gyri and sulci using standard anatomical nomenclature. Neuroimage 53:1 10.1016/j.neuroimage.2010.06.010
    1. Dubois P. (2005). Maintaining correctness in scientific programs. Comput. Sci. Eng. 7, 80–85 10.1109/MCSE.2005.54
    1. Fischl B., Sereno M., Dale A. (1999). Cortical surface-based analysis ii: inflation, flattening, and a surface-based coordinate system. Neuroimage 9, 195–207 10.1006/nimg.1998.0396
    1. Fischl B., Van Der Kouwe A., Destrieux C., Halgren E., Ségonne F., Salat D. H., et al. (2004). Automatically parcellating the human cerebral cortex. Cereb. Cortex 14, 11–22 10.1093/cercor/bhg087
    1. Fries P. (2009). Neuronal gamma-band synchronization as a fundamental process in cortical computation. Annu. Rev. Neurosci. 32, 209–224 10.1146/annurev.neuro.051508.135603
    1. Gorgolewski K., Burns C. D., Madison C., Clark D., Halchenko Y. O., Waskom M. L., et al. (2011). Nipype: a flexible, lightweight and extensible neuroimaging data processing framework in python. Front. Neuroinform. 5:13 10.3389/fninf.2011.00013
    1. Gramfort A., Keriven R., Clerc M. (2010a). Graph-based variability estimation in single-trial event-related neural responses. IEEE Trans. Biomed. Eng. 57, 1051–1061 10.1109/TBME.2009.2037139
    1. Gramfort A., Papadopoulo T., Olivi E., Clerc M. (2010b). OpenMEEG: opensource software for quasistatic bioelectromagnetics. BioMed Eng. OnLine 9:45 10.1186/1475-925X-9-45
    1. Gramfort A., Kowalski M., Hämäläinen M. (2012). Mixed-norm estimates for the M/EEG inverse problem using accelerated gradient methods. Phys. Med. Biol. 57, 1937–1961 10.1088/0031-9155/57/7/1937
    1. Gramfort A., Luessi M., Larson E., Engemann D., Strohmeier D., Brodbeck C., et al. (2013a). MNE software for processing MEG and EEG data. Neuroimage (in press). 10.1016/j.neuroimage.2013.10.027 Available online at:
    1. Gramfort A., Strohmeier D., Haueisen J., Hämäläinen M., Kowalski M. (2013b). Time-frequency mixed-norm estimates: sparse M/EEG imaging with non-stationary source activations. Neuroimage 70, 410–422 10.1016/j.neuroimage.2012.12.051
    1. Gramfort A., Strohmeier D., Haueisen J., Hämäläinen M., Kowalski M. (2011). Functional brain imaging with M/EEG using structured sparsity in time-frequency dictionaries, in Information Processing in Medical Imaging, Vol. 6801 of Lecture Notes in Computer Science, eds Székely G., Hahn H. (Heidelberg; Berlin: Springer; ), 600–611
    1. Granger C. W. J., Hatanaka M. (1964). Spectral Analysis of Economic Time Series. Princeton, NJ: Princeton University Press
    1. Gross J., Baillet S., Barnes G., Henson R., Hillebrand A., Jensen O., et al. (2013). Good practice for conducting and reporting MEG research. Neuroimage 65, 349–363 10.1016/j.neuroimage.2012.10.001
    1. Gross J., Kujala J., Hamalainen M., Timmermann L., Schnitzler A., Salmelin R. (2001). Dynamic imaging of coherent sources: Studying neural interactions in the human brain. Proc. Natl. Acad. Sci. U.S.A. 98, 694–699 10.1073/pnas.98.2.694
    1. Hämäläinen M., Hari R., Ilmoniemi R., Knuutila J., Lounasmaa O. (1993). Magnetoencephalography - Theory, instrumentation, and applications to noninvasive studies of the working human brain. Rev. Modern Phys. 65, 413–497 10.1103/RevModPhys.65.413
    1. Hämäläinen M., Ilmoniemi R. (1994). Interpreting magnetic fields of the brain: minimum norm estimates. Med. Biol. Eng. Comput. 32, 35–42 10.1007/BF02512476
    1. Hunter J. D. (2007). Matplotlib: a 2d graphics environment. Comput. Sci. Eng. 9, 90–95 10.1109/MCSE.2007.55
    1. Hyvärinen A., Oja E. (2000). Independent component analysis: algorithms and applications. Neural networks 13, 411–430 10.1016/S0893-6080(00)00026-5
    1. Klöckner A., Pinto N., Lee Y., Catanzaro B., Ivanov P., Fasih A. (2012). PyCUDA and PyOpenCL: a scripting-based approach to GPU run-time code generation. Parallel Comput. 38, 157–174 10.1016/j.parco.2011.09.001
    1. Lachaux J.-P., Rodriguez E., Martinerie J., Varela F. J. (1999). Measuring phase synchrony in brain signals. Hum. Brain Mapp. 8, 194–208 10.1002/(SICI)1097-0193(1999)8:4<194::AID-HBM4>;2-C
    1. Larson E., Lee A. K. C. (2013). The cortical dynamics underlying effective switching of auditory spatial attention. Neuroimage 64, 365–370 10.1016/j.neuroimage.2012.09.006
    1. Litvak V., Mattout J., Kiebel S., Phillips C., Henson R., Kilner J., et al. (2011). EEG and MEG data analysis in SPM8. Comput. Intell. Neurosci. 2011:852961 10.1155/2011/852961
    1. Maris E., Oostenveld R. (2007). Nonparametric statistical testing of EEG- and MEG-data. J. Neurosci. Methods 164, 177–190 10.1016/j.jneumeth.2007.03.024
    1. Nichols T. E., Holmes A. P. (2002). Nonparametric permutation tests for functional neuroimaging: a primer with examples. Hum. Brain Mapp. 15, 1–25 10.1002/hbm.1058
    1. Nolte G., Bai O., Wheaton L., Mari Z., Vorbach S., Hallett M. (2004). Identifying true brain interaction from eeg data using the imaginary part of coherency. Clin. Neurophysiol. 115, 2292–2307 10.1016/j.clinph.2004.04.029
    1. Oostenveld R., Fries P., Maris E., Schoffelen J.-M. (2011). Field Trip: open source software for advanced analysis of MEG, EEG, and invasive electrophysiological data. Comput. Intell. Neurosci. 2011:156869 10.1155/2011/156869
    1. Pantazis D., Nichols T. E., Baillet S., Leahy R. M. (2005). A comparison of random field theory and permutation methods for the statistical analysis of MEG data. Neuroimage 25, 383–394 10.1016/j.neuroimage.2004.09.040
    1. Pascual-Marqui R. (2002). Standardized low resolution brain electromagnetic tomography (sLORETA): technical details. Methods Find. Exp. Clin. Pharmacology 24, 5–12 Available online at:
    1. Pedregosa F., Varoquaux G., Gramfort A., Michel V., Thirion B., Grisel O., et al. (2011). Scikit-learn: machine learning in Python. J. Mach. Learn. Res. 12, 2825–2830 Available online at:
    1. Ramachandran P., Varoquaux G. (2010). Mayavi: a package for 3d visualization of scientific data. Comput. Sci. Eng. 13, 40–51 10.1109/MCSE.2011.35
    1. Ridgway G. R., Litvak V., Flandin G., Friston K. J., Penny W. D. (2012). The problem of low variance voxels in statistical parametric mapping; a new hat avoids a “haircut.” Neuroimage 59, 2131–2141 10.1016/j.neuroimage.2011.10.027
    1. Schelter B., Winterhalder M., Timmer J. (2006). Handbook of Time Series Analysis. Weinheim: Wiley-VCH
    1. Scherg M., Von Cramon D. (1985). Two bilateral sources of the late AEP as identified by a spatio-temporal dipole model. Electroencephalogr. Clin. Neurophysiol. 62, 32–44 10.1016/0168-5597(85)90033-4
    1. Schoffelen J.-M., Gross J. (2009). Source connectivity analysis with MEG and EEG. Hum. Brain Mapp. 30, 1857–1865 10.1002/hbm.20745
    1. Tadel F., Baillet S., Mosher J. C., Pantazis D., Leahy R. M. (2011). Brainstorm: a user-friendly application for MEG/EEG analysis. Comput. Intell. Neurosci. 2011:879716 10.1155/2011/879716
    1. Tallon-Baudry C., Bertrand O., Wienbruch C., Ross B., Pantev C. (1997). Combined EEG and MEG recordings of visual 40 hz responses to illusory triangles in human. Neuroreport NA, 1103–1107 10.1097/00001756-199703240-00008
    1. Uusitalo M., Ilmoniemi R. (1997). Signal-space projection method for separating MEG or EEG into components. Med. Biol. Eng. Comput. 35, 135–140 10.1007/BF02534144
    1. Van der Walt S., Colbert S., Varoquaux G. (2011). The NumPy array: a structure for efficient numerical computation. Comp. Sci. Eng. 13, 22–30 10.1109/MCSE.2011.37
    1. Van Essen D., Ugurbil K., Auerbach E., Barch D., Behrens T., Bucholz R., et al. (2012). The human connectome project: A data acquisition perspective. Neuroimage 62, 2222–2231 10.1016/j.neuroimage.2012.02.018
    1. Van Veen B., van Drongelen W., Yuchtman M., Suzuki A. (1997). Localization of brain electrical activity via linearly constrained minimum variance spatial filtering. IEEE Trans. Biomed. Eng. 44, 867–880 10.1109/10.623056
    1. Wang J.-Z., Williamson S. J., Kaufman L. (1992). Magnetic source images determined by a lead-field analysis: the unique minimum-norm least-squares estimation. IEEE Trans. Biomed. Eng. 39, 665–675 10.1109/10.142641
    1. Wipf D., Nagarajan S. (2009). A unified Bayesian framework for MEG/EEG source imaging. Neuroimage 44, 947–966 10.1016/j.neuroimage.2008.02.059
    1. Wolters C. H., Köstler H., Möller C., Härdtlein J., Grasedyck L., Hackbusch W. (2007). Numerical mathematics of the subtraction method for the modeling of a current dipole in EEG source reconstruction using finite element head models. SIAM J. Sci. Comput. 30, 24–45 10.1137/060659053

Source: PubMed

Upcoming Clinical Trials

Subscribe