Input/Output Functions#

This section documents the input/output functions for loading and saving EEG data in various formats.

BIDS Loading#

eegprep.pop_load_frombids(filename, *, bidsmetadata=True, bidschanloc=True, bidsevent='replace', eventtype=None, infer_locations=None, dtype=<class 'numpy.float32'>, numeric_null=array([], dtype=float64), return_report=False, verbose=True)#

Load an EEG data file of a supported format from a BIDS dataset.

Supported formats are EDF, BrainVision, EEGLAB SET, BDF.

Return type:

Union[Dict[str, Any], Tuple[Dict[str, Any], Dict[str, Any]]]

Parameters:

Parameters#

filenamestr

Path to the EEG data file in a BIDS dataset.

bidsmetadatabool

Whether to override any metadata in the EEG file with

metadata from BIDS.

bidschanlocbool

Whether to override any channel information (incl. locations)

in the EEG file with channel information from BIDS.

bidseventbool or str

Whether to load in and override any event data in the EEG file with

event data from BIDS. Can be one of the following: * ‘replace’/True: replace events from EEG file with those from the BIDS event file * ‘merge’: selectively override events from EEG file with those from the BIDS event file * ‘append’: append events from the BIDS event file to those from the EEG file;

WARNING: this mode can result in duplicate events; use with caution

  • False/None: do not load events from BIDS, keep those from the EEG file

eventtypestr or None

Optionally the column name in the BIDS events file to use for event

types; if not set, will be inferred heuristically.

infer_locationsbool or str or None

Whether to infer channel locations if necessary from the

channel labels (if 10-20 labeling system). * True: infer locations from channel labels; override existing locations if any * False: leave locations as-is, even if missing * None: infer only if no channels have locations * str: filename of a locations file to infer locations from; see files in

resources/montages directory (this can be used to disambiguate between alternative montages that use the same naming system)

dtypenp.dtype

The data type to use for the EEG data.

numeric_nullAny

The value to use for empty numeric fields in the EEG data.

  • the default is np.array([]) for MATLAB/pop_loadset compatibility

return_reportbool

whether to return an import report dictionary as a second output

verbosebool

whether to log verbose output

Returns#

EEGdict

A dictionary containing the EEG data and metadata.

Reportdict, optional

optionally the import report to return, if desired.

EEGLAB Format#

eegprep.pop_loadset(file_path=None)#

Load EEGLAB dataset from .set or .mat file.

Parameters#

file_pathstr

Path to the EEGLAB .set file.

Returns#

dict

EEGLAB dataset dictionary.

eegprep.pop_loadset_h5(file_name)#

Load EEG data from HDF5 file.

Parameters#

file_namestr

Path to the HDF5 file

Returns#

EEGdict

EEG data structure

eegprep.pop_saveset(EEG, file_name)#

Save EEG data to file.

Parameters#

EEGdict

EEG data.

file_namestr

File name.

Format Conversion#

eegprep.eeg_eeg2mne(EEG)#

Convert EEG data structure to MNE Raw object.

Parameters#

EEGdict

EEG data structure

Returns#

rawmne.io.Raw

MNE Raw object

eegprep.eeg_mne2eeg(raw)#

Convert MNE Raw object to EEG data structure.

Parameters#

rawmne.io.Raw

MNE Raw object

Returns#

EEGdict

EEG data structure

eegprep.eeg_mne2eeg_epochs(epochs, ica)#

Convert MNE epochs with ICA to EEGLAB dataset format.

Parameters#

epochsmne.Epochs

MNE epochs object.

icamne.preprocessing.ICA

MNE ICA object.

Returns#

dict

EEGLAB-compatible dataset dictionary.