Skip to content
Snippets Groups Projects
Commit b057712b authored by Köllőd Csaba's avatar Köllőd Csaba
Browse files

Dev: Saving to EDF file

- Now works fine
- data conversion must be checked
parent 66e3ff84
Branches
No related tags found
No related merge requests found
......@@ -13,7 +13,7 @@ GYRO_ACC_FS = 50
SOUND_FS = 6000
GSR_FS = 10
EEG_EMG_SCALE = 0.04470348358154 # (mV)
EEG_EMG_SCALE = 0.04470348358154 # (uV)
GYRO_SCALE = 0.0152587890625 # (deg/sec)
ACC_SCALE = 0.00006103515625 # (g)
......@@ -100,14 +100,14 @@ class FlowPacket:
for pkt in to_save:
for i, ch_dat in enumerate(pkt.data):
print(sig)
# edf.setPhysicalMaximum(sig, 2**7 * EEG_EMG_SCALE)
# edf.setPhysicalMinimum(sig, -2**7 * EEG_EMG_SCALE)
edf.setPhysicalMaximum(sig, 3000 * EEG_EMG_SCALE)
edf.setPhysicalMinimum(sig, -3000 * EEG_EMG_SCALE)
# edf.setDigitalMaximum(sig, 2**7)
# edf.setDigitalMinimum(sig, -2**7)
edf.setPhysicalDimension(sig, pkt.unit)
edf.setSamplefrequency(sig, pkt.fs)
edf.setLabel(sig, f'{pkt.type}{i}')
data_buffer.append(ch_dat)
data_buffer.append(np.array(ch_dat, order='C'))
sig += 1
edf.writeSamples(data_buffer)
......@@ -154,6 +154,8 @@ def read_packet(file):
# extra
sound = _read_block_data(file, (6000, 1), 'h', 2).T
gsr = _read_block_data(file, (10, 1), 'h', 2).T
if not np.array_equal(sound, np.zeros_like(sound)):
sound = (sound - np.mean(sound)) / (np.max(sound) - np.min(sound))
sound = PacketData(sound, 'sound', 'unit', SOUND_FS)
gsr = PacketData(gsr, 'gsr', 'unit', GSR_FS)
# print(sound, gsr)
......@@ -182,8 +184,8 @@ def read_data(path):
for file in files:
with open(file, 'rb') as f:
data = read_dat_file(f)
# data.plot()
data.to_edf('test.edf')
data.plot()
# data.to_edf('test.edf')
exit(12)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment