Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
epnev committed Aug 22, 2019
2 parents 72f9bc4 + 4911022 commit 462be25
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion caiman/components_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def evaluate_components_CNN(A, dims, gSig, model_name:str=os.path.join(caiman_da

loaded_model = model_from_json(loaded_model_json)
loaded_model.load_weights(model_name + '.h5')
loaded_model.compile('sgd', 'mse')
#loaded_model.compile('sgd', 'mse')
else:
if os.path.isfile(os.path.join(caiman_datadir(), model_name + ".h5.pb")):
model_file = os.path.join(caiman_datadir(), model_name + ".h5.pb")
Expand Down
11 changes: 7 additions & 4 deletions caiman/source_extraction/cnmf/estimates.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ def normalize_components(self):

nA = np.sqrt(np.ravel(self.A.power(2).sum(axis=0)))
nA_mat = scipy.sparse.spdiags(nA, 0, nA.shape[0], nA.shape[0])
nA_inv_mat = scipy.sparse.spdiags(1. / nA, 0, nA.shape[0], nA.shape[0])
nA_inv_mat = scipy.sparse.spdiags(1. / (nA + np.finfo(np.float32).eps), 0, nA.shape[0], nA.shape[0])
self.A = self.A * nA_inv_mat
self.C = nA_mat * self.C
if self.YrA is not None:
Expand Down Expand Up @@ -1310,9 +1310,12 @@ def remove_duplicates(self, predictions=None, r_values=None, dist_thr=0.1,
else:
components_to_keep = np.arange(self.A.shape[-1])



self.select_components(idx_components=components_to_keep)
if self.idx_components is None:
self.idx_components = np.arange(self.A.shape[-1])
self.idx_components = np.intersect1d(self.idx_components, components_to_keep)
self.idx_components_bad = np.setdiff1d(np.arange(self.A.shape[-1]), self.idx_components)
if select_comp:
self.select_components(use_object=True)

return components_to_keep

Expand Down
2 changes: 1 addition & 1 deletion caiman/source_extraction/cnmf/map_reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def run_CNMF_patches(file_name, shape, params, gnb=1, dview=None,
logging.info("Constructing background")

Im = scipy.sparse.csr_matrix(
(1. / mask, (np.arange(d), np.arange(d))), dtype=np.float32)
(1. / (mask + np.finfo(np.float32).eps), (np.arange(d), np.arange(d))), dtype=np.float32)

if not del_duplicates:
A_tot = Im.dot(A_tot)
Expand Down
4 changes: 2 additions & 2 deletions caiman/source_extraction/cnmf/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ def __init__(self, fnames=None, dims=None, dxy=(1, 1),
'decay_time': decay_time,
'dxy': dxy,
'var_name_hdf5': var_name_hdf5,
'caiman_version': '1.6',
'caiman_version': '1.6.1',
'last_commit': None,
'mmap_F': None,
'mmap_C': None
Expand Down Expand Up @@ -812,7 +812,7 @@ def __init__(self, fnames=None, dims=None, dxy=(1, 1),
if self.init['gSig'] is None:
self.init['gSig'] = [-1, -1]
if self.init['gSiz'] is None:
self.init['gSiz'] = [2*gs + 3 for gs in self.init['gSig']]
self.init['gSiz'] = [2*gs + 1 for gs in self.init['gSig']]
self.init['gSiz'] = [gz if gz % 2 else gz + 1 for gz in self.init['gSiz']]

if gnb <= 0:
Expand Down
4 changes: 2 additions & 2 deletions caiman/source_extraction/cnmf/temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def update_temporal_components(Y, A, b, Cin, fin, bl=None, c1=None, g=None, sn=N
A = scipy.sparse.hstack((A, b)).tocsc()
S = np.zeros(np.shape(Cin))
Cin = np.vstack((Cin, fin))
#C = Cin.copy()
C = Cin.copy()
nA = np.ravel(A.power(2).sum(axis=0))

logging.info('Generating residuals')
Expand All @@ -213,7 +213,7 @@ def update_temporal_components(Y, A, b, Cin, fin, bl=None, c1=None, g=None, sn=N
# creating the patch of components to be computed in parrallel
parrllcomp, len_parrllcomp = update_order_greedy(AA[:nr, :][:, :nr])
logging.info("entering the deconvolution ")
C, S, bl, YrA, c1, sn, g, lam = update_iteration(parrllcomp, len_parrllcomp, nb, Cin, S, bl, nr,
C, S, bl, YrA, c1, sn, g, lam = update_iteration(parrllcomp, len_parrllcomp, nb, C, S, bl, nr,
ITER, YrA, c1, sn, g, Cin, T, nA, dview, debug, AA, kwargs)
ff = np.where(np.sum(C, axis=1) == 0) # remove empty components
if np.size(ff) > 0: # Eliminating empty temporal components
Expand Down
8 changes: 4 additions & 4 deletions caiman/tests/comparison_humans_online.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
'p': 1, # order of indicator dynamics
'gnb': 2, # number of background components
'epochs': 2, # number of passes over the data
'rval_thr': 0.75, # spatial correlation threshold
'max_thr': 0.15, # parameter for thresholding components when cleaning up shapes
'rval_thr': 0.80, # spatial correlation threshold
'max_thr': 0.25, # parameter for thresholding components when cleaning up shapes
'mot_corr': False, # flag for motion correction (set to False to compare directly on the same FOV)
'min_num_trial': 10, # maximum number of candidate components per frame
'use_peak_max': True,
Expand Down Expand Up @@ -129,7 +129,7 @@
# % YST
params_movie[3] = {
'folder_name': 'YST/',
'epochs': 2,
'epochs': 3,
'ds_factor': 1,
'fr': 10,
'decay_time': .75,
Expand All @@ -140,7 +140,7 @@
# % neurofinder.04.00.test
params_movie[4] = {
'folder_name': 'N.04.00.t/',
'epochs': 2,
'epochs': 3,
'ds_factor': 1,
'fr': 8,
'gSig': [7, 7], # expected half size of neurons
Expand Down

0 comments on commit 462be25

Please sign in to comment.