Skip to content

Commit 079cf4f

Browse files
committed
Add a drift measurement script
1 parent e1bf0ef commit 079cf4f

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed

examples/record.yaml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
graphs:
2+
3+
- id: EEG
4+
nodes:
5+
- id: acquire
6+
module: timeflux_octaeeg.nodes.driver
7+
class: OctaEEG
8+
params:
9+
rate: 1000
10+
gain: 1
11+
names: [PO7, O1, Oz, O2, PO8, PO3, POz, PO4]
12+
- id: publish
13+
module: timeflux.nodes.zmq
14+
class: Pub
15+
params:
16+
topic: eeg
17+
edges:
18+
- source: acquire
19+
target: publish
20+
rate: 10
21+
22+
- id: Monitoring
23+
nodes:
24+
- id: subscribe
25+
module: timeflux.nodes.zmq
26+
class: Sub
27+
params:
28+
topics: [ eeg ]
29+
- id: decimate
30+
module: timeflux_dsp.nodes.filters
31+
class: DropRows
32+
params:
33+
factor: 16 # Downsample to 250 Hz
34+
- id: bandpass
35+
module: timeflux_dsp.nodes.filters
36+
class: IIRFilter
37+
params:
38+
order: 3
39+
frequencies: [1, 40]
40+
- id: ui
41+
module: timeflux_ui.nodes.ui
42+
class: UI
43+
- id: debug
44+
module: timeflux.nodes.debug
45+
class: Display
46+
edges:
47+
- source: subscribe:eeg
48+
target: ui:eeg
49+
- source: subscribe:eeg
50+
target: debug
51+
rate: 10
52+
53+
- id: Recorder
54+
nodes:
55+
- id: subscribe
56+
module: timeflux.nodes.zmq
57+
class: Sub
58+
params:
59+
topics: [ eeg ]
60+
- id: save
61+
module: timeflux.nodes.hdf5
62+
class: Save
63+
params:
64+
path: . # The HDF5 file will be saved in the current directory
65+
edges:
66+
- source: subscribe:eeg
67+
target: save:eeg
68+
rate: 1
69+
70+
- id: Broker
71+
nodes:
72+
- id: broker
73+
module: timeflux.nodes.zmq
74+
class: Broker

test/drift.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import pandas as pd
2+
3+
# fname = "20240714-104645_4000_battery.hdf5"
4+
# srate = 4000
5+
# fname = "20240714-121527_1000_usb.hdf5"
6+
# srate = 1000
7+
fname = "20240714-134022_1000_battery.hdf5"
8+
srate = 1000
9+
10+
df = pd.read_hdf(fname, "eeg")
11+
length = len(df)
12+
start = df.index[0]
13+
stop = df.index[-1]
14+
duration = (stop - start).total_seconds()
15+
rate = length / duration
16+
drift = ((srate * 3600) - (rate * 3600)) / srate
17+
18+
print(f"File:\t\t{fname}")
19+
print(f"Duration:\t{duration} seconds")
20+
print(f"Nominal rate:\t{srate} Hz")
21+
print(f"Actual rate:\t{rate} Hz")
22+
print(f"Drift:\t\t{drift} seconds/hour")

0 commit comments

Comments
 (0)