MNE-Python Documentation

repository·main·Indexed 25 days ago

https://github.com/mne-tools/mne-python

An open-source Python package for exploring, visualizing, and analyzing human neurophysiological data, including MEG, EEG, sEEG, and ECoG. It provides tools for loading raw sensor data from various formats (e.g., FIF, EDF, BDF), managing channel montages, creating BEM meshes via watershed or FLASH images, and performing spherical spline interpolation to repair bad EEG channels.

Tokens
79.1K
Snippets
77
Records
860
Agent score
86%

What's inside MNE-Python

  1. Overview of Forward Models and Source Spaces in MNE-Python

    main
    MNE-Python provides tutorials and tools for defining cortical source locations (source spaces) and forward models (also known as leadfield matrices). These components are essential for modeling how neural activity at specific source locations is projected to the sensors (e.g., EEG, MEG).
  2. Overview of MNE-Python introductory tutorials

    main

    The introductory tutorials in MNE-Python provide a foundation for performing event-related analysis using EEG/MEG data. They cover the following core concepts:

    • The EEG/MEG pipeline: Basic steps for event-related analysis.
    • Core data structures: Introduction to mne.Info, events, and mne.Annotations.
    • Sensor locations: How sensor positions and montages are handled within the library.
    • Configuration: Overview of available configuration options for the MNE environment.
  3. Overview of MNE-CPP integration

    main
    MNE-CPP is a cross-platform C++ framework designed for MEG/EEG data acquisition, analysis, and visualization. Developers can integrate the MNE-CPP API into standalone projects to gain capabilities such as full I/O support for the FIF-file format or files generated by the MNE and FreeSurfer suites. It features a modular structure with sub-libraries and uses the Qt3D module for 3D visualization with OpenGL.
  4. Overview of MNE-Python preprocessing tutorials

    main
    MNE-Python provides a series of tutorials focused on preprocessing techniques for continuous neurophysiological data (such as EEG, MEG, etc.). These tutorials cover various methods for cleaning and preparing data, as well as diagnostic plotting methods to assess data quality during the preprocessing pipeline.
  5. Visualize EEG/MEG data with mne.viz

    main

    The mne.viz module provides a comprehensive suite of functions for visualizing neurophysiological data. Key visualization capabilities include:

    • Brain & Source Imaging: Functions like plot_brain, plot_bem, plot_source_estimates, and plot_volume_source_estimates for 3D brain rendering and source localization.
    • Time-Series & Evoked Data: Use plot_raw for continuous data, plot_epochs for epoch-based data, and plot_evoked (including plot_evoked_topo, plot_evoked_topomap, and plot_evoked_field) for averaged responses.
    • Topographic Maps: Functions such as plot_topomap, plot_projs_topomap, and plot_tfr_topomap for spatial distribution visualization.
    • Sensor & Montage Layouts: Use plot_sensors, plot_layout, and plot_montage to visualize electrode or sensor configurations.
    • ICA & Component Analysis: Functions like plot_ica_components, plot_ica_sources, and plot_ica_properties for inspecting Independent Component Analysis results.
    • 3D Rendering Control: Manage 3D visualization settings using set_3d_backend, use_3d_backend, set_3d_options, and set_3d_view.
  6. Understand floating-point precision in MNE-Python

    main

    MNE-Python performs all in-memory computations using 64-bit double-precision floating point format (float64). Data is typecast to float64 immediately upon being read into memory to ensure accuracy during operations like filtering and preprocessing.

    Warning on Precision Loss: By default, MNE-Python writes .fif files to disk using 32-bit format to reduce file size. If you save intermediate results to disk and reload them later, you may experience a loss in precision. To maintain 64-bit precision, you should either:

    1. Chain operations in memory and avoid saving intermediate steps.
    2. Explicitly specify the 64-bit format when saving files.
  7. Access and fetch datasets in mne.datasets

    main

    The mne.datasets module provides utilities to check for the existence of datasets, fetch them from remote sources, and locate their local data paths.

    Key functions include:

    • fetch_dataset: Generic function to fetch specific datasets.
    • has_dataset: Checks if a dataset is already available locally.
    • default_path: Returns the default directory where MNE datasets are stored.

    Many submodules (e.g., eegbci, sample, fsaverage, limo) provide specific loading or fetching functions to retrieve specialized neurophysiological data or anatomical templates.

  8. Compute inverse solutions using Beamformers

    main
    The mne.beamformer module provides beamforming algorithms such as LCMV (Linearly Constrained Minimum Variance) and DICS (Dynamic Imaging Combinatorial Spectrum). It includes methods to create beamformers, apply them to data, and estimate resolution matrices.
  9. Understand the Signal-Space Projection (SSP) method

    main

    Signal-Space Projection (SSP) is a method used to reject external disturbances (noise) from MEG/EEG data without requiring additional reference sensors. It works by identifying a 'noise subspace'—a low-dimensional basis set of field patterns that characterize the external noise. An orthogonal complement operator (the signal-space projection operator) is then applied to the data to suppress these patterns.

    Key considerations for effectiveness:

    • Completeness: The basis set must completely characterize the disturbance field patterns; otherwise, noise will leak through.
    • Orthogonality: The angles between the noise subspace and the brain signal vectors should be as close to $\pi/2$ as possible. If brain signals are close to the noise subspace, the signal itself will be attenuated.
    • Inverse Solutions: Because SSP modifies signal vectors, the projection must also be applied to the forward solution during inverse computations.

    Warning: SSP can remove both the artifact and the signal of interest. Always verify how much your signal of interest is reduced after applying SSP.

  10. Core MNE-Python data containers: Raw, Epochs, Evoked, and Info

    main

    MNE-Python's core functionality revolves around four primary classes used to represent different stages of neurophysiological data processing:

    • io.Raw: Represents continuous data (e.g., long recordings from EEG, MEG, or ECoG).
    • Epochs: Represents segmented data, where continuous data has been cut into time segments relative to specific events (e.g., stimulus onset).
    • Evoked: Represents the average of multiple epochs, typically used to study event-related potentials (ERPs) or evoked responses.
    • Info: A metadata object that describes the recording (e.g., channel types, sampling rate, channel locations, and coordinate systems) and is typically attached to Raw, Epochs, and Evoked objects.
  11. Read and write MNE data files

    main

    MNE-Python provides a wide range of read_* and write_* functions to handle various neuroimaging data formats, including EEG, MEG, source estimates, and BEM surfaces. Common data types supported include:

    • Epochs and Evoked data: read_epochs, read_evokeds, read_epochs_eeglab, read_epochs_fieldtrip, read_evokeds_fieldtrip, read_evokeds_mff.
    • Source Space and Estimates: read_source_spaces, read_source_estimate, read_forward_solution.
    • Anatomical and Surface data: read_surface, read_bem_surfaces, read_label, read_morph_map.
    • Transformations and Projections: read_trans, read_proj.
    • Events: read_events, write_events.

    For most data types, there is a corresponding write_* function to save processed data back to disk.