diff --git a/eeglabio/_version.py b/eeglabio/_version.py index e9005b0..2611468 100644 --- a/eeglabio/_version.py +++ b/eeglabio/_version.py @@ -1,3 +1,3 @@ """The version number.""" -__version__ = '0.0.1' +__version__ = '0.0.1-5' diff --git a/eeglabio/epochs.py b/eeglabio/epochs.py index 691731a..b192fc3 100644 --- a/eeglabio/epochs.py +++ b/eeglabio/epochs.py @@ -5,8 +5,8 @@ from .utils import cart_to_eeglab -def export_set(fname, data, sfreq, events, tmin, tmax, ch_names, - event_id=None, ch_locs=None): +def export_set(fname, data, sfreq, events, tmin, tmax, ch_names, event_id=None, + ch_locs=None, ref_channels='common'): """Export epoch data to EEGLAB's .set format. Parameters @@ -34,6 +34,12 @@ def export_set(fname, data, sfreq, events, tmin, tmax, ch_names, If None, event names will default to string versions of the event ids. ch_locs : numpy.ndarray, shape (n_channels, 3) Array containing channel locations in Cartesian coordinates (x, y, z) + ref_channels : list of str | str + The name(s) of the channel(s) used to construct the reference, + 'average' for average reference, or 'common' (default) when there's no + specific reference set. Note that this parameter is only used to inform + EEGLAB of the existing reference, this method will not reference the + data for you. See Also -------- @@ -93,6 +99,9 @@ def export_set(fname, data, sfreq, events, tmin, tmax, ch_names, epochs = fromarrays([ep_event, ep_lat, ep_types], names=["event", "eventlatency", "eventtype"]) + if isinstance(ref_channels, list): + ref_channels = " ".join(ref_channels) + eeg_d = dict(data=data, setname=fname, nbchan=data.shape[0], @@ -101,6 +110,7 @@ def export_set(fname, data, sfreq, events, tmin, tmax, ch_names, srate=sfreq, xmin=tmin, xmax=tmax, + ref=ref_channels, chanlocs=chanlocs, event=events, epoch=epochs, diff --git a/eeglabio/raw.py b/eeglabio/raw.py index 5545aa9..38e01ad 100644 --- a/eeglabio/raw.py +++ b/eeglabio/raw.py @@ -5,7 +5,8 @@ from .utils import cart_to_eeglab -def export_set(fname, data, sfreq, ch_names, ch_locs=None, annotations=None): +def export_set(fname, data, sfreq, ch_names, ch_locs=None, annotations=None, + ref_channels='common'): """Export continuous raw data to EEGLAB's .set format. Parameters @@ -27,6 +28,12 @@ def export_set(fname, data, sfreq, ch_names, ch_locs=None, annotations=None): second array (float) is onset (starting time in seconds), third array (float) is duration (in seconds) This roughly follows MNE's Annotations structure. + ref_channels : list of str | str + The name(s) of the channel(s) used to construct the reference, + 'average' for average reference, or 'common' (default) when there's no + specific reference set. Note that this parameter is only used to inform + EEGLAB of the existing reference, this method will not reference the + data for you. See Also -------- @@ -53,10 +60,13 @@ def export_set(fname, data, sfreq, ch_names, ch_locs=None, annotations=None): else: chanlocs = fromarrays([ch_names], names=["labels"]) + if isinstance(ref_channels, list): + ref_channels = " ".join(ref_channels) + eeg_d = dict(data=data, setname=fname, nbchan=data.shape[0], pnts=data.shape[1], trials=1, srate=sfreq, xmin=0, - xmax=data.shape[1] / sfreq, chanlocs=chanlocs, icawinv=[], - icasphere=[], icaweights=[]) + xmax=data.shape[1] / sfreq, ref=ref_channels, + chanlocs=chanlocs, icawinv=[], icasphere=[], icaweights=[]) if annotations is not None: events = fromarrays([annotations[0],