| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
import sys |
| 18 |
import biosig |
| 19 |
import numpy as np |
| 20 |
import matplotlib.pyplot as plt |
| 21 |
import json |
| 22 |
|
| 23 |
def printf(format, *args): |
| 24 |
sys.stdout.write(format % args) |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
FILENAME="20250314_S5_C1_CellChar.cfs" |
| 30 |
HDR=biosig.header(FILENAME) |
| 31 |
|
| 32 |
|
| 33 |
H=json.loads(HDR) |
| 34 |
print(H["Filename"]) |
| 35 |
print(H["TYPE"]) |
| 36 |
print(H["Samplingrate"]) |
| 37 |
Fs=H["Samplingrate"] |
| 38 |
NS=len(H["CHANNEL"]) |
| 39 |
T0=H["StartOfRecording"] |
| 40 |
print(Fs,NS,T0) |
| 41 |
|
| 42 |
|
| 43 |
A=biosig.data(FILENAME) |
| 44 |
NS=np.size(A,1) |
| 45 |
|
| 46 |
fig = plt.figure() |
| 47 |
ax = fig.add_subplot(111) |
| 48 |
h = plt.plot(np.arange(np.size(A,0))/H["Samplingrate"],A[:,0]); |
| 49 |
ax.set_xlabel('time [s]') |
| 50 |
|
| 51 |
|
| 52 |
rec={"dt" : 1000.0/Fs, "xunits": "ms", "channel" : [] } |
| 53 |
for chan in list(range(NS)): |
| 54 |
name=H["CHANNEL"][chan]["Label"] |
| 55 |
unit=H["CHANNEL"][chan]["PhysicalUnit"] |
| 56 |
printf("#%d:\t%s\t[%s]\n", chan, name, unit) |
| 57 |
|
| 58 |
|
| 59 |
selpos=[0] |
| 60 |
if "EVENT" in H: |
| 61 |
for k in list(range(len(H["EVENT"]))): |
| 62 |
if (H["EVENT"][k]["TYP"] == '0x7ffe'): |
| 63 |
selpos.append(round(H["EVENT"][k]["POS"]*H["Samplingrate"])) |
| 64 |
|
| 65 |
selpos.append(np.size(A,0)) |
| 66 |
|
| 67 |
|
| 68 |
m=0 |
| 69 |
c=0 |
| 70 |
d = A[selpos[c]:selpos[c+1]-1,m] |
| 71 |
|
| 72 |
|
| 73 |
fig, ax = plt.subplots(nrows=NS) |
| 74 |
k=0 |
| 75 |
for m in list(range(NS)): |
| 76 |
for c in list(range(len(selpos)-1)): |
| 77 |
k = k+1 |
| 78 |
d = np.asarray(A[selpos[c]:selpos[c+1]-1,m]) |
| 79 |
ax[m].plot(np.arange(np.size(d,0))/H["Samplingrate"], d, 'r-') |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
plt.show() |
| 86 |
|