Skip to content

Commit

Permalink
bringing some improvements from hackathon branch
Browse files Browse the repository at this point in the history
  • Loading branch information
epnev committed Aug 16, 2019
1 parent 43f671a commit 88bc035
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions caiman/source_extraction/cnmf/online_cnmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ def _prepare_object(self, Yr, T, new_dims=None, idx_components=None):
min(self.params.get('online', 'init_batch'), self.params.get('online', 'minibatch_shape')) - 1), 0)
self.estimates.groups = list(map(list, update_order(self.estimates.Ab)[0]))
self.update_counter = 2**np.linspace(0, 1, self.N, dtype=np.float32)
self.estimates.CC = np.ascontiguousarray(self.estimates.CC)
self.estimates.CY = np.ascontiguousarray(self.estimates.CY)
self.time_neuron_added:List = []
for nneeuu in range(self.N):
self.time_neuron_added.append((nneeuu, self.params.get('online', 'init_batch')))
Expand Down Expand Up @@ -437,6 +439,8 @@ def fit_next(self, t, frame_in, num_iters_hals=3):
t0 = 0 * self.params.get('online', 'init_batch')
w1 = (t - n0 + t0) * 1. / (t + t0) # (1 - 1./t)#mbs*1. / t
w2 = 1. / (t + t0) # 1.*mbs /t
ccf = np.ascontiguousarray(ccf)
y = np.asfortranarray(y)
for m in range(self.N):
self.estimates.CY[m + nb_, self.ind_A[m]] *= w1
self.estimates.CY[m + nb_, self.ind_A[m]] += w2 * \
Expand All @@ -451,6 +455,8 @@ def fit_next(self, t, frame_in, num_iters_hals=3):
self.params.get('online', 'minibatch_suff_stat') + 1]
y = self.estimates.Yr_buf.get_last_frames(self.params.get('online', 'minibatch_suff_stat') + 1)[:1]
# much faster: exploit that we only access CY[m, ind_pixels], hence update only these
ccf = np.ascontiguousarray(ccf)
y = np.asfortranarray(y)
for m in range(self.N):
self.estimates.CY[m + nb_, self.ind_A[m]] *= (1 - 1. / t)
self.estimates.CY[m + nb_, self.ind_A[m]] += ccf[m +
Expand Down

0 comments on commit 88bc035

Please sign in to comment.