def ahurst(settings, signal, data): object = wla.toolbox() transtype = settings.transtype l = settings.l type = settings.type refl = settings.refl j_0 = settings.j_0 j_min = settings.j_min j_max = settings.j_max#Must set j_0 wvar needs this bias = settings.bias p = settings.p n = len(signal.e1) #Assume same length of all epochs!!!! print l, type, refl, j_0, j_min, j_max, bias, p, n for i in range(0,j_0): data.y1.append(0) data.y2.append(0) data.y3.append(0) for j in range (0, j_0): data.y_hat1.append(0) data.y_hat2.append(0) data.y_hat3.append(0) for k in range(0,2*j_0): data.ci1.append(0) data.ci2.append(0) data.ci3.append(0) #e4 = list_to_array(data.e4) e1 = list_to_array(signal.e1) e2 = list_to_array(signal.e2) e3 = list_to_array(signal.e3) y1 = list_to_array(data.y1) y2 = list_to_array(data.y2) y3 = list_to_array(data.y3) #y4 = list_to_array(data.y4) y_hat1 = list_to_array(data.y_hat1) y_hat2 = list_to_array(data.y_hat2) y_hat3 = list_to_array(data.y_hat3) #wvar4 = list_to_array(data.y_hat4) ci1 = list_to_array(data.ci1) ci2 = list_to_array(data.ci2) ci3 = list_to_array(data.ci3) #ci4 = list_to_array(data.ci4) out1 = list_to_array(data.out1) out2 = list_to_array(data.out2) out3 = list_to_array(data.out3) #out4 = list_to_array(data.out4) #if settings.filetype is 1: #object.ahurst(transtype, l, type, bias, refl, n, j_0, j_min, j_max, p, e1, y1, y_hat1, ci1, out1)#What about j_0??? #object.ahurst(transtype, l, type, bias, refl, n, j_0, j_min, j_max, p, e2, y2, y_hat2, ci2, out2) #object.ahurst(transtype, l, type, bias, refl, n, j_0, j_min, j_max, p, e3, y3, y_hat3, ci3, out3) #if settings.filetype is 0: # object.ahurst(transtype, l, type, bias, refl, n, j_min, j_max, p, e4, y4, wvar4, out4)#Error with wvar for i in range(0,3): data.out1[i] = carray_get(out1,i) data.out2[i] = carray_get(out2,i) data.out3[i] = carray_get(out3,i)
def wa(settings, signal, data): object = wla.toolbox() transtype = settings.transtype l = settings.l type = settings.type refl = settings.refl j_0 = settings.j_0 n = len(signal.etime) #Assume constant length!! print transtype, l, type, refl, j_0, n for i in range(0, 2*(j_0+1)): data.boundaries.append(0) e1 = list_to_array(signal.signal) e2 = list_to_array(signal.e2) e3 = list_to_array(signal.e3) boundaries = list_to_array(data.boundaries) wv1 = new_cmatrix(j_0+1,n) wv2 = new_cmatrix(j_0+1,n) wv3 = new_cmatrix(j_0+1,n) object.wa(transtype, l, type, refl, j_0, n, boundaries, e1, wv1) object.wa(transtype, l, type, refl, j_0, n, boundaries, e2, wv2) object.wa(transtype, l, type, refl, j_0, n, boundaries, e3, wv3) #Check for filetype and do extra round... if transtype is 0: for i in range(j_0+1,0,-1): level = i-1 dummy = 0 tmp_list1 = [] for j in range(0,n): tmp_list1.append(0) for k in range(0,n,2**i): tmp_list1[k] = (cmatrix_get(wv1,level,dummy)) dummy +=1 data.wv1.append(tmp_list1) #boundaries too... elif transtype is 1: for i in range(j_0+1,0,-1): #Now it plots only the first half of V_j0 j = i-1 tmp_list1 = [] tmp_list2 = [] tmp_list3 = [] for k in range(0,n): tmp_list1.append(cmatrix_get(wv1,j,k)) tmp_list2.append(cmatrix_get(wv2,j,k)) tmp_list3.append(cmatrix_get(wv3,j,k)) data.wv1.append(tmp_list1) data.wv2.append(tmp_list2) data.wv3.append(tmp_list3) data.boundaries[0] = carray_get(boundaries, 2*j_0) data.boundaries[j_0+1] = carray_get(boundaries, 2*j_0+1) j = 1 for i in range(j_0,0,-1): data.boundaries[j] = carray_get(boundaries, i-1) j += 1 j = j_0+2 for i in range(2*j_0,j_0,-1): data.boundaries[j] = carray_get(boundaries, i-1) j += 1
def shurst(data): l = 8 type = 2 bias = 0 refl = 0 j_0 = 11 j_min = 5 j_max = 11 n = len(data.e2) n_b = 2 signal = list_to_array(data.e2) object = wla.toolbox() object.shurst(l, type, refl, j_0, j_min, j_max, n, n_b, signal)
def mra(settings, signal, data): object = wla.toolbox() transtype = settings.transtype l = settings.l type = settings.type refl = settings.refl j_0 = settings.j_0 n = len(signal.e1) for i in range(0, 2*(j_0+1)): data.boundaries.append(0) e1 = list_to_array(signal.e1) e2 = list_to_array(signal.e2) e3 = list_to_array(signal.e3) boundaries = list_to_array(data.boundaries) ds1 = new_cmatrix(j_0+1,n) ds2 = new_cmatrix(j_0+1,n) ds3 = new_cmatrix(j_0+1,n) object.mra(transtype, l, type, refl, j_0, n, boundaries, e1, ds1) object.mra(transtype, l, type, refl, j_0, n, boundaries, e2, ds2) object.mra(transtype, l, type, refl, j_0, n, boundaries, e3, ds3) for i in range(j_0+1,0,-1): j = i-1 tmp_list1 = [] tmp_list2 = [] tmp_list3 = [] for k in range(0,n): tmp_list1.append(cmatrix_get(ds1,j,k)) tmp_list2.append(cmatrix_get(ds2,j,k)) tmp_list3.append(cmatrix_get(ds3,j,k)) data.ds1.append(tmp_list1) data.ds2.append(tmp_list2) data.ds3.append(tmp_list3) data.boundaries[0] = carray_get(boundaries, 2*j_0) data.boundaries[j_0+1] = carray_get(boundaries, 2*j_0+1) j = 1 for i in range(j_0,0,-1): data.boundaries[j] = carray_get(boundaries, i-1) j += 1 j = j_0+2 for i in range(2*j_0,j_0,-1): data.boundaries[j] = carray_get(boundaries, i-1) j += 1
def ihurst(settings, signal, data): object = wla.toolbox() l = settings.l type = settings.type refl = settings.refl j_0 = settings.j_0 j_min = settings.j_min j_max = settings.j_max n = len(signal.e1) print l, type, refl, j_0, j_min, j_max, n for i in range(0, n): data.hurst1.append(0) data.hurst2.append(0) data.hurst3.append(0) e1 = list_to_array(signal.e1) e2 = list_to_array(signal.e2) e3 = list_to_array(signal.e3) hurst1 = list_to_array(data.hurst1) hurst2 = list_to_array(data.hurst2) hurst3 = list_to_array(data.hurst3) out1 = list_to_array(data.out1) out2 = list_to_array(data.out2) out3 = list_to_array(data.out3) object.ihurst(l, type, refl, j_0, j_min, j_max, n, e1, hurst1, out1) object.ihurst(l, type, refl, j_0, j_min, j_max, n, e2, hurst2, out2) object.ihurst(l, type, refl, j_0, j_min, j_max, n, e3, hurst3, out3) for i in range(0,3): data.out1[i] = carray_get(out1,i) data.out2[i] = carray_get(out2,i) data.out3[i] = carray_get(out3,i) for i in range(0,n): data.hurst1[i] = carray_get(hurst1,i) data.hurst2[i] = carray_get(hurst2,i) data.hurst3[i] = carray_get(hurst3,i)
def analysis(): object = wla.toolbox() signal_list = []#Set signal as "global" here y_list = [] #Get these as input yhat_list = []#Convert to arrays here ci_list = [] output_list = [0,0,0] hurst_list = [] boundaries_list = [] ## # # for value in open('/Users/vegard/Master/Hurst05.dat'): #('/Users/vegard/Master/ocean2.dat'): # signal_list.append(float(value.split()[1])) #For reading Ingve's files... # hurst_list.append(0) # #signal_list.append(float(value)) # for i in range(j_min-1,j_max): # y_list.append(0) # for j in range(0, 3*j_max): # wvar_list.append(0) # for k in range(0, 2*(j_max+1)): # boundaries_list.append(0) # n = len(signal_list) # signal = list_to_array(signal_list) # y = list_to_array(y_list) # wvar = list_to_array(wvar_list) # output = list_to_array(output_list) # hurst = list_to_array(hurst_list) # boundaries = list_to_array(boundaries_list) # wv = new_cmatrix(j_max+1,n) # ds = new_cmatrix(j_max+1,n) # object = wla.toolbox() # # # # if(wa.get_active() == 1): # transtype = wa.get_transtype() # l = wa.get_l() # type = wa.get_type() # refl = wa.get_refl() # j_max = wa.get_jmax() # # #Get epochs # object.wa(transtype, l, type, refl, j_max, n, boundaries, signal, w) # # if(mra.get_active() == 1): # transtype = mra.get_transtype() # l = mra.get_l() # type = mra.get_type() # refl = mra.get_refl() # j_max = mra.get_jmax() # # #Get epochs # object.mra(transtype, l, type, refl, j_max, n, boundaries, signal, ds) # # if(ahurst.get_active() == 1): # transtype = ahurst.get_transtype() # l = ahurst.get_l() # type = ahurst.get_type() # refl = ahurst.get_refl() # j_min = ahurst.get_jmin() # j_max = ahurst.get_jmax() # bias = ahurst.get_bias() # p = ahurst.get_p() # # #Get epochs # object.ahurst(transtype, l, type, bias, refl, n, j_min, j_max, p, signal, y, wvar, output) # # # if(ihurst.get_active() == 1): # l = ihurst.get_l() # type = ihurst.get_type() # refl = ihurst.get_refl() #Not implemented yet in C++ # j_min = ihurst.get_jmin() # j_max = ihurst.get_jmax() # # #Get epochs # object.ihurst(l, type, j_min, j_max, len(signal_list), signal, hurst, output) # transtype = 1 l = 8 type = 2 bias = 0 refl = 0 j_0 = 6 j_min = 2 j_max = 6 p = 95 for value in open('/Users/vegard/Master/ecg.dat'): #('/Users/vegard/Master/ocean2.dat'): #signal_list.append(float(value.split()[1])) #For reading Ingve's files... hurst_list.append(0) signal_list.append(float(value)) for i in range(0,j_0): y_list.append(0) for j in range(0, j_0): yhat_list.append(0) for k in range(0,2*j_0): ci_list.append(0) for k in range(0, 2*(j_max+1)): boundaries_list.append(0) n = len(signal_list) signal = list_to_array(signal_list) y = list_to_array(y_list) yhat = list_to_array(yhat_list) ci = list_to_array(ci_list) output = list_to_array(output_list) hurst = list_to_array(hurst_list) boundaries = list_to_array(boundaries_list) wv = new_cmatrix(j_max+1,n) #ds = new_cmatrix(j_max+1,n) #object = wla.toolbox() #For iHurst use j_min:1, j_max:10 object.ahurst(transtype, l, type, bias, refl, n, j_0, j_min, j_max, p, signal, y, yhat, ci, output)
signal_list = [] #for value in open('/Users/vegard/Master/ecg.dat'): #('/Users/vegard/Master/ocean2.dat'): # signal_list.append(float(value.split()[1])) #signal_list.append(float(value)) l = 8 type = 2 bias = 0 refl = 0 j_0 = 6 j_min = 1 j_max = 6 n = len(signal_list) n_b = 6 signal = list_to_array(signal_list) object = wla.toolbox() # object.shurst(l, type, refl, j_0, j_min, j_max, n, n_b, signal) analysis() #ahurstdata = Data() #ihurstdata = Data() #genset = Settings() #ahurstset = Settings() #ihurstset = Settings() #test = [1,2,3] #tittel = "Testfil" #ofilename = "/Users/vegard/Master/saves/testfile" #ahurstdata.out1 = test #ahurstdata.out2 = test #ahurstdata.out3 = test #save(ofilename, tittel, genset, ahurstset, ihurstset, ahurstdata, ihurstdata)