Skip to content

Commit 3ca8d8a

Browse files
committed
KCSD bug fixed and faster values comp.
In oKCSD function nsx, nsy, nsz variables were deleted. In vaules() module loop was replaced with matrix operation.
1 parent 611dd0d commit 3ca8d8a

1 file changed

Lines changed: 2 additions & 10 deletions

File tree

kcsd/KCSD.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,8 @@ def values(self, estimate='CSD'):
220220
print('Invalid quantity to be measured, pass either CSD or POT')
221221
kernel = self.k_pot + self.lambd * np.identity(self.k_pot.shape[0])
222222
estimation = np.zeros((self.n_estm, self.n_time))
223-
for t in range(self.n_time):
224-
# C*(x) [Potworowski 2018 Eq 2.18]
225-
# `inv(K) V` calculated by solving `K X = V` for `X`
226-
estimation[:, t] = np.dot(estimation_table,
227-
np.linalg.solve(kernel,
228-
self.pots[:, t]))
223+
beta_new = np.dot(np.linalg.inv(kernel), self.pots)
224+
estimation = np.dot(estimation_table, beta_new)
229225
return self.process_estimate(estimation)
230226

231227
def process_estimate(self, estimation):
@@ -1221,7 +1217,6 @@ def place_basis(self):
12211217
self.R = self.R_init
12221218
self.src_x = self.own_src
12231219
self.n_src = self.src_x.size
1224-
self.nsx = self.src_x.shape
12251220

12261221

12271222
class oKCSD2D(KCSD2D):
@@ -1315,7 +1310,6 @@ def place_basis(self):
13151310
self.R = self.R_init
13161311
self.src_x, self.src_y = self.own_src
13171312
self.n_src = self.src_x.size
1318-
self.nsx, self.nsy = self.src_x.shape
13191313

13201314

13211315
class oKCSD3D(KCSD3D):
@@ -1409,8 +1403,6 @@ def place_basis(self):
14091403
self.R = self.R_init
14101404
self.src_x, self.src_y, self.src_z = self.own_src
14111405
self.n_src = self.src_x.size
1412-
self.nsx, self.nsy, self.nsz = self.src_x.shape
1413-
14141406

14151407
if __name__ == '__main__':
14161408
print('Checking 1D')

0 commit comments

Comments
 (0)