from __future__ import division from numpy import * from matplotlib.pyplot import * import _edflib import stockwell.smt as smt # eegfile="/mnt/hgfs/clee/Documents/swaineeg/NKT/EEG2100/CA75510M_1-1+_1-2+.edf" eegfile='/home/clee/Dropbox/data/swainAFIB_CA46803E_1-1+.edf' open(eegfile) e=_edflib.Edfreader(eegfile) # read a short number of samples a = zeros(2000.0) e.readsignal(0,0,2000,a) plot(a) K=4 N=2000 tapers = smt.calc_tapers(K,N) #s=smt.mtst(K,tapers,a) s=smt.mtst(K,tapers,a,0,70) figure(); imshow(s); axis('auto') la=zeros(10000,dtype='float64') #?smt.st e.readsignal(0,0,len(la),la) figure();plot(la) las = smt.st(la, 0,70) #figure(); plot(las) rlas = abs(las)
#!/usr/bin/env python # -*- coding: utf-8 -* from __future__ import division, print_function, absolute_import import numpy as np import _edflib from stacklineplot import stackplot, figure, plot from pylab import * #bdir = r"c:/Users/clee/Documents/My Dropbox/data/swainAFIB_CA46803E_1-1+.edf" bdir = r"/media/Windows7_OS/Users/clee/Documents/datasets/swaineeg/swainAFIB_CA46803E_1-1+.edf" e = _edflib.Edfreader(bdir) signal_labels = [] signal_nsamples = [] def fileinfo(edf): print("datarecords_in_file", edf.datarecords_in_file) print("signals_in_file:", edf.signals_in_file) for ii in range(edf.signals_in_file): signal_labels.append(edf.signal_label(ii)) print("signal_label(%d)" % ii, edf.signal_label(ii), end='') print(edf.samples_in_file(ii), edf.samples_in_datarecord(ii), end='') signal_nsamples.append(edf.samples_in_file(ii)) print(edf.samplefrequency(ii)) fileinfo(e) L = e.samples_in_file(27) x1s = 27 a2s = 23
#!/usr/bin/env python # -*- coding: utf-8 -* from __future__ import division, print_function, absolute_import import numpy as np import _edflib from stacklineplot import stackplot, figure, plot from pylab import * e = _edflib.Edfreader("examples/PA32135H_1-1+_1-2+_1-3+_1-4+.edf") signal_labels = [] signal_nsamples = [] def fileinfo(edf): print("datarecords_in_file", edf.datarecords_in_file) print( "signals_in_file:", edf.signals_in_file) for ii in range(edf.signals_in_file): signal_labels.append(edf.signal_label(ii)) print( "signal_label(%d)" % ii, edf.signal_label(ii),end='') print( edf.samples_in_file(ii), edf.samples_in_datarecord(ii),end='') signal_nsamples.append(edf.samples_in_file(ii)) print( edf.samplefrequency(ii)) fileinfo(e) sig1 = np.zeros(2000.0, dtype='float64') e.readsignal(1,0, 2000, sig1) nsigs = e.signals_in_file MAXSIGLEN = 20000 sigbufs = np.zeros((nsigs,MAXSIGLEN), dtype='float64') # read the first 10 sec
from __future__ import division import _edflib import stockwell.smt as smt _ip.magic("pwd ") _ip.magic("cd /mnt/hgfs/") _ip.magic("cd User") _ip.system("ls -F ") _ip.magic("cd clee") _ip.magic("cd Documents/") _ip.magic("cd swaineeg/") _ip.system("ls -F ") _ip.magic("cd NKT/") _ip.system("ls -F ") _ip.magic("cd EEG2100/") _ip.system("ls -F ") e = _edflib.Edfreader('CA75510M_1-1+_1-2+.edf') # read a short number of samples a = zeros(2000.0) e.readsignal(0, 0, 2000, a) plot(a) K = 20 N = 2000 tapers = smt.calc_tapers(K, N) s = smt.mtst(K, tapers, a) s = smt.mtst(K, tapers, a, 0, 1000) K s.shape figure() imshow(s) import scipy.signal as signal
#!/usr/bin/env python # -*- coding: utf-8 -* from __future__ import division, print_function, absolute_import import numpy as np import _edflib from stacklineplot import stackplot, figure, plot from pylab import * e = _edflib.Edfreader("shortAFIB_CA46803D_1-1+_1-2+.edf") signal_labels = [] signal_nsamples = [] def fileinfo(edf): print("datarecords_in_file", edf.datarecords_in_file) print("signals_in_file:", edf.signals_in_file) for ii in range(edf.signals_in_file): signal_labels.append(edf.signal_label(ii)) print("signal_label(%d)" % ii, edf.signal_label(ii), end='') print(edf.samples_in_file(ii), edf.samples_in_datarecord(ii), end='') signal_nsamples.append(edf.samples_in_file(ii)) print(edf.samplefrequency(ii)) def readsignals(edf, start_time, end_time, buf=None): """times in seconds""" # assume same sampling rate for all channels for a moment and use signal#0 assert end_time <= edf.file_duration
# -*- coding: utf-8 -* from __future__ import division, print_function, absolute_import import _edflib from pylab import * import scipy.signal as signal import highpassfilter as hpf import os if os.path.isfile('ekg.npy'): ekg = np.load('ekg.npy') L = len(ekg) fs = 200 else: e = _edflib.Edfreader( r"/home/clee/Dropbox/data/swainAFIB_CA46803E_1-1+.edf") L = e.samples_in_file(27) fs = e.samplefrequency(27) X1 = np.zeros(float(L)) e.readsignal(27, 0, L, X1) A2 = np.zeros(float(L)) e.readsignal(23, 0, L, A2) e.close() ekg = A2 - X1 # may as well clean these up del X1, A2 # psd(ekg[:2000]) # make a 5Hz filter