Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allows for renaming channel names saved to the csv file. #272

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions eegnb/devices/eeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,16 @@ def __init__(
mac_addr=None,
other=None,
ip_addr=None,
ch_names=None
):
"""The initialization function takes the name of the EEG device and determines whether or not
the device belongs to the Muse or Brainflow families and initializes the appropriate backend.

Parameters:
device (str): name of eeg device used for reading data.

ch_names (array_like or None): array containing custom specified channel names. Useful for custom montagues
like when external electrodes are used.
"""
# determine if board uses brainflow or muselsl backend
self.device_name = device
Expand All @@ -85,6 +89,7 @@ def __init__(
self.n_channels = len(EEG_INDICES[self.device_name])
self.sfreq = SAMPLE_FREQS[self.device_name]
self.channels = EEG_CHANNELS[self.device_name]
self.ch_names = ch_names

def initialize_backend(self):
if self.backend == "brainflow":
Expand Down Expand Up @@ -346,8 +351,11 @@ def _brainflow_extract(self, data):
# transform data for saving
data = data.T # transpose data

# get the channel names for EEG data
if (
# explicitly assign channel names for EEG data
if self.ch_names is not None:
ch_names = self.ch_names
# automatically assign the channel names for EEG data
elif (
self.brainflow_id == BoardIds.GANGLION_BOARD.value
or self.brainflow_id == BoardIds.GANGLION_WIFI_BOARD.value
):
Expand Down
Loading