Skip to content

Commit

Permalink
Add a drift measurement script
Browse files Browse the repository at this point in the history
  • Loading branch information
mesca committed Jul 14, 2024
1 parent e1bf0ef commit 079cf4f
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
74 changes: 74 additions & 0 deletions examples/record.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
graphs:

- id: EEG
nodes:
- id: acquire
module: timeflux_octaeeg.nodes.driver
class: OctaEEG
params:
rate: 1000
gain: 1
names: [PO7, O1, Oz, O2, PO8, PO3, POz, PO4]
- id: publish
module: timeflux.nodes.zmq
class: Pub
params:
topic: eeg
edges:
- source: acquire
target: publish
rate: 10

- id: Monitoring
nodes:
- id: subscribe
module: timeflux.nodes.zmq
class: Sub
params:
topics: [ eeg ]
- id: decimate
module: timeflux_dsp.nodes.filters
class: DropRows
params:
factor: 16 # Downsample to 250 Hz
- id: bandpass
module: timeflux_dsp.nodes.filters
class: IIRFilter
params:
order: 3
frequencies: [1, 40]
- id: ui
module: timeflux_ui.nodes.ui
class: UI
- id: debug
module: timeflux.nodes.debug
class: Display
edges:
- source: subscribe:eeg
target: ui:eeg
- source: subscribe:eeg
target: debug
rate: 10

- id: Recorder
nodes:
- id: subscribe
module: timeflux.nodes.zmq
class: Sub
params:
topics: [ eeg ]
- id: save
module: timeflux.nodes.hdf5
class: Save
params:
path: . # The HDF5 file will be saved in the current directory
edges:
- source: subscribe:eeg
target: save:eeg
rate: 1

- id: Broker
nodes:
- id: broker
module: timeflux.nodes.zmq
class: Broker
22 changes: 22 additions & 0 deletions test/drift.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pandas as pd

# fname = "20240714-104645_4000_battery.hdf5"
# srate = 4000
# fname = "20240714-121527_1000_usb.hdf5"
# srate = 1000
fname = "20240714-134022_1000_battery.hdf5"
srate = 1000

df = pd.read_hdf(fname, "eeg")
length = len(df)
start = df.index[0]
stop = df.index[-1]
duration = (stop - start).total_seconds()
rate = length / duration
drift = ((srate * 3600) - (rate * 3600)) / srate

print(f"File:\t\t{fname}")
print(f"Duration:\t{duration} seconds")
print(f"Nominal rate:\t{srate} Hz")
print(f"Actual rate:\t{rate} Hz")
print(f"Drift:\t\t{drift} seconds/hour")

0 comments on commit 079cf4f

Please sign in to comment.