comparison cnmf.py @ 18:b4bf37f94e92

prepared to add another annotation
author mitian
date Wed, 09 Dec 2015 16:27:10 +0000
parents c01fcb752221
children
comparison
equal deleted inserted replaced
17:c01fcb752221 18:b4bf37f94e92
136 # Find non filtered boundaries 136 # Find non filtered boundaries
137 bound_idxs = None 137 bound_idxs = None
138 while True: 138 while True:
139 if bound_idxs is None: 139 if bound_idxs is None:
140 try: 140 try:
141 if CNMF: F, G = cnmf(X, rank, niter=niter) 141 if CNMF: F, G0 = cnmf(X, rank, niter=niter)
142 else: F, G = nmf(X, rank, niter=niter) 142 else: F, G0 = nmf(X, rank, niter=niter)
143 except: 143 except:
144 return np.empty(0), [1] 144 return np.empty(0), np.empty(0), [1]
145 145
146 # Filter G 146 # Filter G
147 G = filter_activation_matrix(G.T, R) 147 G = filter_activation_matrix(G0.T, R)
148 if bound_idxs is None: 148 if bound_idxs is None:
149 bound_idxs = np.where(np.diff(G) != 0)[0] + 1 149 bound_idxs = np.where(np.diff(G) != 0)[0] + 1
150 150
151 if len(np.unique(bound_idxs)) <= 2: 151 if len(np.unique(bound_idxs)) <= 2:
152 rank += 1 152 rank += 1
153 bound_idxs = None 153 bound_idxs = None
154 else: 154 else:
155 break 155 break
156 156
157 return G, bound_idxs 157 # Obtain decomposition matrices Rd
158 R = F.dot(G0)
159 print 'R, F, G', R.shape, F.shape, G.shape
160 return F, G0, R, bound_idxs