def get_DSTL(self, signal): ''' Compute the DSTL of a signal Input: signal in RawEDF format Output DSTL matrix Most parts are in C++, as loops are not efficient in Python ''' dt = 12 n_channels = len(signal.ch_names) embedded_signals = self.embed_signals(signal, d=7, lag=6) print(np.isinf(np.sum(embedded_signals))) DSTL = dstl.stlm(embedded_signals) # ~ STLm = np.zeros(n_channels) # ~ N = len(embedded_signals[0]) # ~ for channel in range(0,n_channels): # ~ print(channel) # ~ for i in range(0,N-dt): # ~ print(i, N-dt) # ~ d0, d_dt = self.get_perturbations(embedded_signals[channel], i, dt) # ~ STLm[channel] += np.log2(d0/d_dt) # ~ STLm[channel] *= 1./((N-dt)*dt) # ~ DSTL = np.zeros(int(n_channels * (n_channels-1) /2)) # ~ idx=0 # ~ for channel_a in range(0,n_channels-1): # ~ for channel_b in range(channel_a+1,n_channels): # ~ DSTL[channel_a,channel_b] = STLm[channel_a,channel_b] # ~ idx += 1 return DSTL
import numpy as np import dstl a=np.array([[1,2,3],[4,5,6]]) #a=np.array([1,2,3], dtype='float64') a=np.array([[1,2,3],[4,5,6]], dtype='float64') b=dstl.stlm(a) #print(a)