def corrcoef(self): #If there is more than one channel in the seed time-series: if len(self.seed.shape) > 1: # Preallocate results Cxy = np.empty((self.seed.data.shape[0], self.target.data.shape[0]), dtype=np.float) for seed_idx, this_seed in enumerate(self.seed.data): Cxy[seed_idx] = tsa.seed_corrcoef(this_seed, self.target.data) #In the case where there is only one channel in the seed time-series: else: Cxy = tsa.seed_corrcoef(self.seed.data, self.target.data) return Cxy.squeeze()
def test_seed_correlation(): seed = np.random.rand(10) targ = np.random.rand(10, 10) our_coef_array = tsa.seed_corrcoef(seed, targ) np_coef_array = np.array(map(lambda a: np.corrcoef(seed, a)[0, 1], targ)) npt.assert_array_almost_equal(our_coef_array, np_coef_array)
def test_seed_correlation(): seed = np.random.rand(10) targ = np.random.rand(10, 10) our_coef_array = tsa.seed_corrcoef(seed, targ) np_coef_array = np.array([np.corrcoef(seed, a)[0, 1] for a in targ]) npt.assert_array_almost_equal(our_coef_array, np_coef_array)
def corrcoef(self): #If there is more than one channel in the seed time-series: if len(self.seed.shape) > 1: # Preallocate results Cxy = np.empty( (self.seed.data.shape[0], self.target.data.shape[0]), dtype=np.float) for seed_idx, this_seed in enumerate(self.seed.data): Cxy[seed_idx] = tsa.seed_corrcoef(this_seed, self.target.data) #In the case where there is only one channel in the seed time-series: else: Cxy = tsa.seed_corrcoef(self.seed.data, self.target.data) return Cxy.squeeze()