In [1]:
import sys
sys.version_info
Out[1]:
In [2]:
import numpy as np
np.__version__
Out[2]:
In [3]:
import requests
requests.__version__
Out[3]:
In [4]:
import pandas as pd
pd.__version__
Out[4]:
In [5]:
import scipy
scipy.__version__
Out[5]:
pip install git+http://github.com/paradigm4/scidb-py.git
In [6]:
import scidbpy
scidbpy.__version__
Out[6]:
In [7]:
from scidbpy import connect
conectarse al servidor de Base de datos
In [8]:
sdb = connect('http://localhost:8080')
In [9]:
import urllib.request # urllib2 in python2 the lib that handles the url stuff
target_url = "https://physionet.org/physiobank/database/mimic3wdb/matched/RECORDS-waveforms"
data = urllib.request.urlopen(target_url) # it's a file like object and works just like a file
In [10]:
lines = data.readlines();
line = str(lines[2])
line
Out[10]:
Quitarle caracteres especiales
In [11]:
line = line.replace('b\'','').replace('\'','').replace('\\n','')
splited = line.split("/")
splited
Out[11]:
In [12]:
carpeta,subCarpeta,onda = line.split("/")
carpeta = carpeta+"/"+subCarpeta
onda
Out[12]:
In [13]:
import wfdb
In [14]:
carpeta = "p05/p050140"
onda = "p050140-2188-07-26-05-51"
In [15]:
sig, fields = wfdb.srdsamp(onda,pbdir='mimic3wdb/matched/'+carpeta, sampfrom=10000)
In [16]:
print(sig)
print("signame: " + str(fields['signame']))
print("units: " + str(fields['units']))
print("fs: " + str(fields['fs']))
print("comments: " + str(fields['comments']))
print("fields: " + str(fields))
Busca la ubicacion de la señal tipo II
In [17]:
signalII = None
try:
signalII = fields['signame'].index("II")
except ValueError:
print("List does not contain value")
if(signalII!=None):
print("List contain value")
Normaliza la señal y le quita los valores en null
In [18]:
#array = wfdb.processing.normalize(x=sig[:, signalII], lb=-2, ub=2)
array = sig[:, signalII]
array = array[~np.isnan(sig[:, signalII])]
arrayNun = np.trim_zeros(array)
array
Out[18]:
Cambiar los guiones "-" por raya al piso "_" porque por algun motivo SciDB tiene problemas con estos caracteres Si el arreglo sin valores nulos no queda vacio lo sube al SciDB
In [19]:
ondaName = onda.replace("-", "_")
In [20]:
if arrayNun.size>0 :
sdb.input(upload_data=array).store(ondaName,gc=False)
# sdb.iquery("store(input(<x:int64>[i], '{fn}', 0, '{fmt}'), "+ondaName+")", upload_data=array)
Check de list of arrays in SciDB
In [21]:
dir(sdb.arrays)
Out[21]: