Last active
November 25, 2018 01:17
-
-
Save Tehsurfer/31824df9e7dee57aced8b872e3f3794e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import numpy as np | |
count = 0 | |
indexlist = [] | |
above12 = [] | |
filename = "C:\\Users\jkho021\Projects\SPARC\mapclient\src\mapclient\ecgDataExtended2.json" | |
data = {} | |
with open(filename) as f: | |
data['cache'] = json.load(f) | |
for i, val in enumerate(data['cache']['19']): | |
if val > 12.05: | |
indexlist.append(i) | |
count += 1 | |
above12.append(val) | |
else: | |
above12.append(0) | |
dif = [] | |
for i in range(0, len(indexlist) - 1): | |
dif.append(indexlist[i + 1] - indexlist[i]) | |
# | |
# for key in data['cache']: | |
# dataedit[key] = data['cache'][key][1:12213] | |
# | |
# for key in data['cache']: | |
# additionaldata[key] = data['cache'][key][8221:12213] | |
start = int((indexlist[1] - indexlist[0]) / 2 + indexlist[0]) | |
additionalbeatstart = indexlist[15] | |
additionalbeatend = indexlist[17] | |
insertadditionalbeat = indexlist[17] + 1 | |
additionalbeat = {} | |
for key in data['cache']: | |
additionalbeat[key] = data['cache'][key][additionalbeatstart:additionalbeatend] | |
newdata = {} | |
for key in data['cache']: | |
newdata[key] = data['cache'][key][start:indexlist[18]] + additionalbeat[key] | |
dataexport = {} | |
dataexport['values'] = newdata | |
dataexport['times'] = np.linspace(0,17,len(newdata['1'])).tolist() | |
with open('ecgDataFitted.json', 'w') as fp: | |
json.dump(dataexport, fp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment