Skip to content

Commit

Permalink
read binary file with BLE board info
Browse files Browse the repository at this point in the history
  • Loading branch information
salman2135 committed Oct 18, 2023
1 parent 63f8ff2 commit 49bb736
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
7 changes: 7 additions & 0 deletions src/explorepy/packet.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class PACKET_ID(IntEnum):
EEG98 = 146
EEG32 = 148
EEG98_USBC = 150
EEG98_BLE = 151
EEG99 = 62
EEG94R = 208
EEG98R = 210
Expand Down Expand Up @@ -202,6 +203,11 @@ class EEG98_USBC(EEG):
def __init__(self, timestamp, payload, time_offset=0):
super().__init__(timestamp, payload, time_offset, v_ref=2.4, n_packet=16)

class EEG98_BLE(EEG):
"""EEG packet for 8 channel device"""

def __init__(self, timestamp, payload, time_offset=0):
super().__init__(timestamp, payload, time_offset, v_ref=2.4, n_packet=1)

class EEG99(EEG):
"""EEG packet for 8 channel device"""
Expand Down Expand Up @@ -572,6 +578,7 @@ def _convert(self, bin_data):
PACKET_ID.EEG94R: EEG94,
PACKET_ID.EEG98R: EEG98,
PACKET_ID.EEG98_USBC: EEG98_USBC,
PACKET_ID.EEG98_BLE: EEG98_BLE,
PACKET_ID.EEG32: EEG32,
PACKET_ID.CMDRCV: CommandRCV,
PACKET_ID.CMDSTAT: CommandStatus,
Expand Down
8 changes: 8 additions & 0 deletions src/explorepy/settings_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ def update_device_settings(self, device_info_dict_update):
hardware_adc = self.settings_dict.get(self.hardware_channel_mask_key)
self.settings_dict[self.software_channel_mask_key] = hardware_adc
self.settings_dict[self.adc_mask_key] = self.settings_dict.get(self.software_channel_mask_key)
if "board_id" in device_info_dict_update:
if self.settings_dict["board_id"] == "PCB_303_801D_XXX":
self.settings_dict[self.channel_count_key] = 8
self.settings_dict[self.hardware_channel_mask_key] = [1 for _ in range(8)]
if self.software_channel_mask_key not in self.settings_dict:
hardware_adc = self.settings_dict.get(self.hardware_channel_mask_key)
self.settings_dict[self.software_channel_mask_key] = hardware_adc
self.settings_dict[self.adc_mask_key] = self.settings_dict.get(self.software_channel_mask_key)

if self.channel_count_key not in self.settings_dict:
self.settings_dict[self.channel_count_key] = 8 if sum(self.settings_dict["adc_mask"]) > 4 else 4
Expand Down
10 changes: 4 additions & 6 deletions src/explorepy/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,12 +511,10 @@ def write_data(self, packet):
"""
time_vector, sig = packet.get_data(self._fs)

if len(time_vector) == 1:
data = np.array(time_vector + sig)[:, np.newaxis]
else:
if self._rec_time_offset is None:
self._rec_time_offset = time_vector[0]
data = np.concatenate((np.array(time_vector)[:, np.newaxis].T, np.array(sig)), axis=0)

if self._rec_time_offset is None:
self._rec_time_offset = time_vector[0]
data = np.concatenate((np.array(time_vector)[:, np.newaxis].T, np.array(sig)), axis=0)
data = np.round(data, 4)
if self.file_type == 'edf':
if isinstance(packet, EEG):
Expand Down

0 comments on commit 49bb736

Please sign in to comment.