Skip to content

Commit

Permalink
bug fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Giovannucci committed Dec 1, 2015
1 parent 1d5ddd6 commit 5070336
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 4 additions & 2 deletions ca_source_extraction/merge_rois.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
from update_spatial_components import update_spatial_components
from update_temporal_components import update_temporal_components
import warnings
from scipy.ndimage.morphology import generate_binary_structure, iterate_structure

#%%
def mergeROIS(Y_res,A,b,C,f,d1,d2,P_,thr=0.8,mx=50,sn=None,deconv_method='spgl1',min_size=3,max_size=8,dist=3):
def mergeROIS(Y_res,A,b,C,f,d1,d2,P_,thr=0.8,mx=50,sn=None,deconv_method='spgl1',min_size=3,max_size=8,dist=3,method_exp = 'ellipse', expandCore = iterate_structure(generate_binary_structure(2,1), 2).astype(int)):
"""
merging of spatially overlapping components that have highly correlated tmeporal activity
% The correlation threshold for merging overlapping components is user specified in P.merge_thr (default value 0.85)
Expand Down Expand Up @@ -100,7 +102,7 @@ def mergeROIS(Y_res,A,b,C,f,d1,d2,P_,thr=0.8,mx=50,sn=None,deconv_method='spgl1'

cc,_,_,Ptemp = update_temporal_components(np.asarray(Y_res[ff,:]),A_merged[ff,i],b[ff],aa_2,f,p=p,deconv_method=deconv_method)

aa,bb,cc = update_spatial_components(np.asarray(Y_res),cc,f,A_merged[:,i],d1=d1,d2=d2,sn=sn,min_size=min_size,max_size=max_size,dist=dist)
aa,bb,cc = update_spatial_components(np.asarray(Y_res),cc,f,A_merged[:,i],d1=d1,d2=d2,sn=sn,min_size=min_size,max_size=max_size,dist=dist,method = method_exp, expandCore =expandCore)

A_merged[:,i] = aa.tocsr();

Expand Down
7 changes: 6 additions & 1 deletion ca_source_extraction/update_spatial_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,12 @@ def determine_search_location(A, d1, d2, method = 'ellipse', min_size = 3, max_s
elif method == 'dilate':
for i in range(nr):
A_temp = np.reshape(A[:,i].todense(),(d2,d1))
A_temp = grey_dilation(A_temp, footprint = expandCore)
if len(expandCore)> 0:
A_temp = grey_dilation(A_temp, footprint = expandCore)
else:
A_temp = grey_dilation(A_temp, (1,1))

# A_temp = grey_dilation(A_temp, footprint = expandCore)
IND[:,i] = np.squeeze(np.reshape(A_temp,(d,1)))>0
else:
IND = True*np.ones((d,nr))
Expand Down

0 comments on commit 5070336

Please sign in to comment.