In [ ]:
%matplotlib inline
Info <mne.Info>
data structureThe :class:Info <mne.Info>
data object is typically created
when data is imported into MNE-Python and contains details such as:
and so forth. See the :class:the API reference <mne.Info>
for a complete list of all data fields. Once created, this object is passed
around throughout the data analysis pipeline.
In [ ]:
import mne
import os.path as op
:class:mne.Info
behaves as a nested Python dictionary:
In [ ]:
# Read the info object from an example recording
info = mne.io.read_info(
op.join(mne.datasets.sample.data_path(), 'MEG', 'sample',
'sample_audvis_raw.fif'), verbose=False)
List all the fields in the info object
In [ ]:
print('Keys in info dictionary:\n', info.keys())
Obtain the sampling rate of the data
In [ ]:
print(info['sfreq'], 'Hz')
List all information about the first data channel
In [ ]:
print(info['chs'][0])
Get channel indices by name
In [ ]:
channel_indices = mne.pick_channels(info['ch_names'], ['MEG 0312', 'EEG 005'])
Get channel indices by regular expression
In [ ]:
channel_indices = mne.pick_channels_regexp(info['ch_names'], 'MEG *')
MNE supports different channel types:
Get channel indices by type
In [ ]:
channel_indices = mne.pick_types(info, meg=True) # MEG only
channel_indices = mne.pick_types(info, eeg=True) # EEG only
MEG gradiometers and EEG channels
In [ ]:
channel_indices = mne.pick_types(info, meg='grad', eeg=True)
Get a dictionary of channel indices, grouped by channel type
In [ ]:
channel_indices_by_type = mne.io.pick.channel_indices_by_type(info)
print('The first three magnetometers:', channel_indices_by_type['mag'][:3])
In [ ]:
# Channel type of a specific channel
channel_type = mne.io.pick.channel_type(info, 75)
print('Channel #75 is of type:', channel_type)
Channel types of a collection of channels
In [ ]:
meg_channels = mne.pick_types(info, meg=True)[:10]
channel_types = [mne.io.pick.channel_type(info, ch) for ch in meg_channels]
print('First 10 MEG channels are of type:\n', channel_types)
In [ ]:
# Only keep EEG channels
eeg_indices = mne.pick_types(info, meg=False, eeg=True)
reduced_info = mne.pick_info(info, eeg_indices)
print(reduced_info)