updated analysis software
This commit is contained in:
@@ -72,8 +72,9 @@ def process_ppg(d, t):
|
||||
|
||||
accs = []
|
||||
gyros = []
|
||||
imu_sparse = 0
|
||||
def process_imu(d, t):
|
||||
global accs, gyros
|
||||
global accs, gyros, imu_sparse
|
||||
for e in t['elements']:
|
||||
block = d[e['offset']:e['offset'] + e['size']]
|
||||
element_size = int(len(block) / e['n_elements'])
|
||||
@@ -91,58 +92,67 @@ def process_imu(d, t):
|
||||
else:
|
||||
pass
|
||||
#assert False
|
||||
if len(gyros) > 400:
|
||||
gyros = gyros[-400:]
|
||||
if len(accs) > 400:
|
||||
accs = accs[-400:]
|
||||
fig, axs = plt.subplots(2)
|
||||
g = np.array(gyros)
|
||||
a = np.array(accs)
|
||||
axs[0].set_ylabel("dps")
|
||||
axs[0].plot(g[:,0])
|
||||
axs[0].plot(g[:,1])
|
||||
axs[0].plot(g[:,2])
|
||||
axs[1].set_ylabel("g")
|
||||
axs[1].plot(a[:,0])
|
||||
axs[1].plot(a[:,1])
|
||||
axs[1].plot(a[:,2])
|
||||
plt.savefig("acc_gyro.png")
|
||||
plt.close()
|
||||
|
||||
imu_sparse += 1
|
||||
if imu_sparse % 5 == 4:
|
||||
if len(gyros) > 1600:
|
||||
gyros = gyros[-1600:]
|
||||
accs = accs[-1600:]
|
||||
fig, axs = plt.subplots(2)
|
||||
g = np.array(gyros)
|
||||
a = np.array(accs)
|
||||
#np.save("gyros.npy", g)
|
||||
#np.save("accs.npy", a)
|
||||
a -= np.mean(a, axis = 0).reshape(1,3)
|
||||
axs[0].set_ylabel("dps")
|
||||
axs[0].plot(g[:,0])
|
||||
axs[0].plot(g[:,1])
|
||||
axs[0].plot(g[:,2])
|
||||
axs[1].set_ylabel("g")
|
||||
axs[1].plot(a[:,0])
|
||||
axs[1].plot(a[:,1])
|
||||
axs[1].plot(a[:,2])
|
||||
plt.savefig("acc_gyro.png")
|
||||
plt.close()
|
||||
|
||||
ecgs = []
|
||||
t1s = []
|
||||
t2s = []
|
||||
strains = []
|
||||
|
||||
adc_sparse = 0
|
||||
def process_adc(d, t):
|
||||
global ecgs, t1s, t2s, strains
|
||||
global ecgs, t1s, t2s, strains, adc_sparse
|
||||
for e in t['elements']:
|
||||
block = d[e['offset']:e['offset'] + e['size']]
|
||||
element_size = int(len(block) / e['n_elements'])
|
||||
if e['name'] == b'ekg_readings_cnts[50]':
|
||||
ecgs = ecgs + [(2.4 / (1<<24)) * int.from_bytes(block[4 * i : 4 * i + 4], byteorder = 'little', signed = True) for i in range(50)]
|
||||
if len(ecgs) > 200:
|
||||
ecgs = ecgs[-2048:]
|
||||
t1s = t1s[-205:]
|
||||
t2s = t2s[-205:]
|
||||
strains = strains[-205:]
|
||||
fig, axs = plt.subplots(4)
|
||||
axs[0].set_title("ECG")
|
||||
axs[1].set_title("Strain")
|
||||
axs[2].set_title("oT")
|
||||
axs[3].set_title("iT")
|
||||
axs[0].plot(ecgs)
|
||||
axs[1].plot(strains)
|
||||
axs[2].plot(t1s)
|
||||
axs[3].plot(t2s)
|
||||
plt.savefig("adcs.png")
|
||||
plt.close()
|
||||
adc_sparse += 1
|
||||
if adc_sparse % 10 == 9:
|
||||
if len(ecgs) > 200:
|
||||
ecgs = ecgs[-2048:]
|
||||
t1s = t1s[-205:]
|
||||
t2s = t2s[-205:]
|
||||
strains = strains[-205:]
|
||||
fig, axs = plt.subplots(1)
|
||||
axs.set_title("ECG")
|
||||
#axs[1].set_title("Strain")
|
||||
#axs[2].set_title("oT")
|
||||
#axs[3].set_title("iT")
|
||||
axs.plot(ecgs)
|
||||
#axs[1].plot(strains)
|
||||
#axs[2].plot(t1s)
|
||||
#axs[3].plot(t2s)
|
||||
fig.tight_layout()
|
||||
plt.savefig("adcs.png")
|
||||
plt.close()
|
||||
if e['name'] == b'str_readings_cnts[5]':
|
||||
strains = strains + [(2.4 / (1<<24)) * int.from_bytes(block[4 * i : 4 * i + 4], byteorder = 'little', signed = True) for i in range(5)]
|
||||
strains = strains + [int.from_bytes(block[4 * i : 4 * i + 4], byteorder = 'little', signed = True) for i in range(5)]
|
||||
if e['name'] == b'oT_readings_cnts[5]':
|
||||
t1s = t1s + [(2.4 / (1<<24)) * int.from_bytes(block[4 * i : 4 * i + 4], byteorder = 'little', signed = True) for i in range(5)]
|
||||
t1s = t1s + [int.from_bytes(block[4 * i : 4 * i + 4], byteorder = 'little', signed = True) for i in range(5)]
|
||||
if e['name'] == b'iT_readings_cnts[5]':
|
||||
t2s = t2s + [(2.4 / (1<<24)) * int.from_bytes(block[4 * i : 4 * i + 4], byteorder = 'little', signed = True) for i in range(5)]
|
||||
t2s = t2s + [int.from_bytes(block[4 * i : 4 * i + 4], byteorder = 'little', signed = True) for i in range(5)]
|
||||
|
||||
|
||||
def read_and_process(types, cons, size):
|
||||
index = 0
|
||||
|
||||
Reference in New Issue
Block a user