{"id":4635,"library":"mne","title":"MNE-Python","description":"MNE-Python is an open-source Python package for exploring, visualizing, and analyzing human neurophysiological data such as MEG, EEG, sEEG, ECoG, NIRS, and more. It provides modules for data input/output, preprocessing, visualization, source estimation, time-frequency analysis, connectivity analysis, machine learning, and statistics. The library is actively developed, with stable releases occurring frequently, typically every few months.","status":"active","version":"1.12.0","language":"en","source_language":"en","source_url":"https://github.com/mne-tools/mne-python","tags":["neuroscience","eeg","meg","ecog","nirs","data-analysis","signal-processing","brain-imaging","scientific-computing"],"install":[{"cmd":"pip install --upgrade mne","lang":"bash","label":"Install latest stable version"}],"dependencies":[{"reason":"Runtime environment","package":"python","optional":false},{"reason":"Core numerical operations","package":"numpy","optional":false},{"reason":"Scientific computing tools","package":"scipy","optional":false},{"reason":"2D plotting","package":"matplotlib","optional":false},{"reason":"Data fetching and caching","package":"pooch","optional":false},{"reason":"Progress bars","package":"tqdm","optional":false},{"reason":"Templating for reports","package":"jinja2","optional":false},{"reason":"Utility for decorators","package":"decorator","optional":false},{"reason":"Lazy loading of modules","package":"lazy-loader","optional":false},{"reason":"Version handling","package":"packaging","optional":false},{"reason":"Machine learning, required for mne.decoding module","package":"scikit-learn","optional":true},{"reason":"3D plotting capabilities","package":"pyvista","optional":true},{"reason":"MRI processing and surface reconstruction (external software)","package":"freesurfer","optional":true}],"imports":[{"symbol":"mne","correct":"import mne"},{"symbol":"Raw","correct":"from mne.io import Raw"},{"symbol":"Epochs","correct":"from mne import Epochs"},{"symbol":"Evoked","correct":"from mne import Evoked"},{"note":"`read_raw_fif` is in the `mne.io` submodule, not directly under `mne`.","wrong":"import mne.read_raw_fif","symbol":"read_raw_fif","correct":"from mne.io import read_raw_fif"},{"note":"`pick_types` is in the `mne.channels` submodule.","wrong":"import mne.pick_types","symbol":"pick_types","correct":"from mne.channels import pick_types"}],"quickstart":{"code":"import mne\nimport numpy as np\n\n# Set MNE_DATA for sample dataset (optional, will download if not found)\nos.environ['MNE_DATA'] = os.environ.get('MNE_DATA', mne.utils.get_config('MNE_DATA', default=''))\n\n# Load a sample dataset\ndata_path = mne.datasets.sample.data_path()\nraw_fname = data_path / 'MEG' / 'sample' / 'sample_audvis_raw.fif'\n\n# Read raw data\nraw = mne.io.read_raw_fif(raw_fname, preload=True, verbose='error')\nraw.filter(1, 40, fir_design='firwin')\n\n# Set up events and epochs\nevents = mne.find_events(raw, stim_channel='STI 014')\nevent_id = {'aud/left': 1, 'aud/right': 2, 'vis/left': 3, 'vis/right': 4}\nt_min, t_max = -0.2, 0.5\nepochs = mne.Epochs(raw, events, event_id, t_min, t_max, preload=True, verbose='error')\n\n# Compute evoked response\nevoked = epochs['aud/left'].average()\n\n# Plot evoked data\nevoked.plot()\n\nprint(f\"Processed data has {len(epochs)} epochs and {len(raw.ch_names)} channels.\")","lang":"python","description":"This quickstart demonstrates loading a sample MEG/EEG dataset, applying a basic filter to the continuous data, defining events, creating epoched data, computing an evoked response, and finally plotting the evoked activity."},"warnings":[{"fix":"Upgrade your Python environment to 3.10 or newer.","message":"MNE-Python version 1.9.0 and later requires Python 3.10 or higher. Earlier Python versions are no longer supported.","severity":"breaking","affected_versions":">=1.9.0"},{"fix":"Ensure `scikit-learn` is installed: `pip install scikit-learn`.","message":"As of MNE-Python 1.9.0, the `mne.decoding` module explicitly requires `scikit-learn` to be installed.","severity":"breaking","affected_versions":">=1.9.0"},{"fix":"For final analysis, it is generally recommended to resample `Epochs` objects using `mne.Epochs.resample()` after epoching, or to be aware of the implications if resampling `Raw` data early.","message":"Resampling raw data with `mne.io.Raw.resample()` before forming `Epochs` can cause event timing jitter, potentially impacting analyses sensitive to precise event timing.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Initialize mutable defaults inside the function, e.g., `def func(arg=None): arg = arg if arg is not None else []`.","message":"Using mutable default arguments (e.g., lists, dictionaries) in custom functions that interact with MNE-Python objects can lead to unexpected shared state across function calls, a common Python pitfall.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Carefully review channel quality, use `raw.plot(block=True)` for interactive marking, and utilize MNE-Python's tools for marking and interpolating bad channels (e.g., `raw.info['bads']`, `raw.interpolate_bads()`). Consider `autoreject` for automated detection.","message":"Incorrectly identifying or handling 'bad' channels can bias results in subsequent processing steps like SSP (Signal Space Projection) or ICA (Independent Component Analysis).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Use `subjects` instead of `subject` when calling `mne.datasets.eegbci.load_data()`.","message":"The `subject` parameter in `mne.datasets.eegbci.load_data()` was deprecated in favor of `subjects`.","severity":"deprecated","affected_versions":">=1.9.0"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}