Example #1
0
 def test_logarithm(self):
     """logarithm basics must work."""
     dat = logarithm(self.dat)
     # works elementwise (does not alter the shape)
     self.assertEqual(self.dat.data.shape, dat.data.shape)
     # actual log was computed
     np.testing.assert_array_almost_equal(np.e**dat.data, self.dat.data)
Example #2
0
 def test_logarithm(self):
     """logarithm basics must work."""
     dat = logarithm(self.dat)
     # works elementwise (does not alter the shape)
     self.assertEqual(self.dat.data.shape, dat.data.shape)
     # actual log was computed
     np.testing.assert_array_almost_equal(np.e**dat.data, self.dat.data)
def preprocess(data, filt=None):
    dat = data.copy()
    fs_n = 250 # sample rate is 250 for us

    b, a = proc.signal.butter(5, [13 / fs_n], btype='low')
    dat = proc.filtfilt(dat, b, a)

    b, a = proc.signal.butter(5, [9 / fs_n], btype='high')
    dat = proc.filtfilt(dat, b, a)

    dat = proc.subsample(dat, 50)

    if filt is None:
        filt, pattern, _ = proc.calculate_csp(dat)
        plot_csp_pattern(pattern)
    dat = proc.apply_csp(dat, filt)

    dat = proc.variance(dat)
    dat = proc.logarithm(dat)
    return dat, filt
def preprocess(data, filt=None):
    dat = data.copy()
    fs_n = dat.fs / 2

    b, a = proc.signal.butter(5, [13 / fs_n], btype='low')
    dat = proc.filtfilt(dat, b, a)


    b, a = proc.signal.butter(5, [9 / fs_n], btype='high')
    dat = proc.filtfilt(dat, b, a)
    
    dat = proc.subsample(dat, 50)

    if filt is None:
        filt, pattern, _ = proc.calculate_csp(dat)
        plot_csp_pattern(pattern)
    dat = proc.apply_csp(dat, filt)
    
    dat = proc.variance(dat)
    dat = proc.logarithm(dat)
    return dat, filt
Example #5
0
def preprocess(dat,filt=None):
    	'''fs_n = dat.fs / 2
    	b, a = proc.signal.butter(5, [13 / fs_n], btype='low')
	dat = proc.lfilter(dat, b, a)
	b, a = proc.signal.butter(5, [8 / fs_n], btype='high')
	dat = proc.lfilter(dat, b, a)
	print dat'''
   

        dat = proc.subsample(dat, 64)
        #epo = proc.segment_dat(dat, MRK_DEF, SEG_IVAL)
	
        #fv = proc.jumping_means(epo, JUMPING_MEANS_IVALS)
        #fv = proc.create_feature_vectors(dat)

        if filt is None:
        	filt, pattern, _ = proc.calculate_csp(dat)
        	#plot_csp_pattern(pattern)
    	dat = proc.apply_csp(dat, filt)
    
   	dat = proc.variance(dat)
    	dat = proc.logarithm(dat)
    	return dat, filt
Example #6
0
 def test_logarithm_copy(self):
     """Rectify channels must not change the original parameter."""
     cpy = self.dat.copy()
     logarithm(self.dat)
     self.assertEqual(cpy, self.dat)
Example #7
0
 def test_logarithm_copy(self):
     """Rectify channels must not change the original parameter."""
     cpy = self.dat.copy()
     logarithm(self.dat)
     self.assertEqual(cpy, self.dat)