brainaccess.utils.acquisition#
Attributes#
Classes#
EEG acquisition class. |
|
Object to store EEG data in accumulation mode |
|
Data structure to store rolling EEG data buffer |
Module Contents#
- class brainaccess.utils.acquisition.EEG(mode='accumulate')[source]#
EEG acquisition class. Gathers data from brainaccess core and converts to MNE structure.
Creates EEG object and initializes device with default parameters.
- Parameters:
mode (str) – Data storage modes accumulate (all data is accumulated in array) or roll (only last x seconds preserved)
- annotate(msg)[source]#
Adds an annotation to the data stream. :param msg: annotation to send :type msg: str
- Parameters:
msg (str)
- Return type:
None
- calc_impedances(tim=4)[source]#
Calculate impedance in last tim seconds Impedance calculated as in https://openbci.com/community/openbci-measuring-electrode-impedance/
- Parameters:
tim (float) – Last x seconds in acquisition to get average impedance from
- Returns:
Impedances
- Return type:
list
- get_mne(tim=None, samples=None, annotations=True)[source]#
Return MNE structure. If tim is None, returns all data; otherwise, returns the last tim seconds.
- Parameters:
tim (float, optional) – Time in seconds.
samples (int, optional) – Number of samples.
annotations (bool) – Whether to include annotations.
- Returns:
Raw MNE EEG data structure.
- Return type:
mne.io.BaseRaw
- setup(mgr, device_name, cap={0: 'F3', 1: 'F4', 2: 'C3', 3: 'C4', 4: 'P3', 5: 'P4', 6: 'O1', 7: 'O2'}, zeros_at_start=0, bias=None, gain=8, sfreq=250)[source]#
Connects to device and sets channels
- Parameters:
mgr (EEGManager) – The EEG manager object.
device_name (str) – The name of the device to connect to.
cap (dict) – A dictionary mapping electrode numbers to channel names.
zeros_at_start (int) – The number of zeros to add at the beginning of the data.
bias (list, optional) – A list of channels to use for bias.
gain (int) – The gain to use for the EEG channels.
sfreq (int)
- Raises:
BrainAccessException – If no devices are found, could not connect to the device, or the stream is incompatible.
- Return type:
None
- class brainaccess.utils.acquisition.EEGData(info, lock, zeros_at_start=2)[source]#
Object to store EEG data in accumulation mode
Initializes the EEGData object.
- Parameters:
info (mne.Info) – The MNE info object.
lock (threading.Lock) – The threading lock.
zeros_at_start (int, optional) – The number of zeros to add at the beginning of the data, by default 2.
- convert_to_mne(tim=None, samples=None, annotations=True, channels_indexes=None)[source]#
Convert arrays to MNE. If tim None returns all data from acquisition start. Otherwise last tim seconds
- Parameters:
tim (float, default value = None) – time in seconds till the end to include in the output
samples (int, default value = None) – time in samples till the end to include in the output
annotations (bool, default value = True) – should annotations be included
channels_indexes (list, optional) – A list of channel indexes to include.
- load(fname)[source]#
Loads raw data from a file.
- Parameters:
fname (str) – The name of the file to load.
- class brainaccess.utils.acquisition.EEGData_roll(info, lock, zeros_at_start=1)[source]#
Data structure to store rolling EEG data buffer
Initializes the EEGData_roll object.
- Parameters:
info (mne.Info) – The MNE info object.
lock (threading.Lock) – The threading lock.
zeros_at_start (int, optional) – The number of zeros to add at the beginning of the data, by default 1.
- Raises:
BrainAccessException – If no lock is passed.
- convert_to_mne(tim=None, samples=None, annotations=True, channels_indexes=None)[source]#
Convert arrays to MNE. If tim None returns all data from acquisition start. Otherwise last tim seconds
- Parameters:
tim (float, default value = None) – time in seconds or samples to cut
samples (int, default value = None) – samples or time to cut
annotations (bool, default value = True) – should annotations be included
channels_indexes (list, optional) – A list of channel indexes to include.
- load(fname)[source]#
Loads raw data from a file.
- Parameters:
fname (str) – The name of the file to load.