CX_rois = ['PB','NO','FB','EB','AB(L)','AB(R)'] #CX_rois = ['PB'] empty_rois = [] h_results = {'h':[],'h_randwire':[],'h_randweight':[]} #hpy = lambda x: np.random.randn() reldir = '../' for roi in CX_rois: try: print(roi) path = os.path.join(reldir,conf.results_dir,'CX_study','roi='+roi+'.txt') if roi not in empty_rois and not os.path.exists(path): n,conn = fetch_adjacency(adjpath=os.path.join(reldir,conf.datasets_dir,'noncropped_traced_'+roi)) nlist,adj = conn2adj(conn) print('adj size =',adj.shape,'non-zero elements =',conn.shape[0]) #fh h = hpy(adj) #fh random rewiring N = adj.shape[0] perm = np.random.permutation(N) h_randwire = hpy(adj[:, perm]) #fh random weight shuffling nonz = np.nonzero(adj) weights = adj[nonz] np.random.shuffle(weights) adj[nonz] = weights
#hpy = lambda x: np.random.randn() reldir = '../' for roi in CX_rois: try: if roi not in empty_rois: n, conn = fetch_adjacency(adjpath=os.path.join( reldir, conf.datasets_dir, 'noncropped_traced_' + roi)) for th in ths: print(th, roi) path = os.path.join(reldir, conf.results_dir, 'CX_study_th', f'th={th};roi={roi}.txt') if not os.path.exists(path): temp = conn[conn['weight'] > th] nlist, adj = conn2adj(temp) if temp.shape[0] > 0: print('adj size =', adj.shape, 'non-zero elements =', temp.shape[0]) #fh h = hnx(adj) #fh random rewiring # N = adj.shape[0] # temp = [] # for i in range(20): # perm = np.random.permutation(N) # temp += [hnx(adj[:,perm])] # h_randwire_mean,h_randwire_std = np.mean(temp),np.std(temp)
neur_CX_split,conn_CX_split = {}, {} for roi in CX_rois: n,conn = fetch_adjacency(adjpath=os.path.join(reldir,conf.datasets_dir,'noncropped_traced_'+roi)) neur_CX_split[roi],conn_CX_split[roi] = n,conn #main loop for roi in CX_rois: n,conn = neur_CX_split[roi], conn_CX_split[roi] for th in ths: print(th,roi) path = os.path.join(reldir,conf.results_dir,expname,f'th={th};roi={roi}.txt') if not os.path.exists(path): conn1 = restrict_th(conn,th) conn_out = restrict_max_comp(conn1) size_maxcomp = len(find_max_comp_neurons(conn_out)) nlist,adj = conn2adj(conn_out) if conn_out.shape[0]>0: print('adj size =',adj.shape,'non-zero elements =',conn_out.shape[0]) #fh h = hnx(adj) print(f'th={th};h={h};size(max_comp)={size_maxcomp}') with open(path,'w') as f: #f.write(f'{h} {h_randwire_mean} {h_randwire_std} {h_randweight_mean} {h_randweight_std}') f.write(f'{h} {th} {size_maxcomp}') else: print(roi,': skipping, result exists')