Skip to content

Commit

Permalink
Merge pull request #54 from didi-hou/Fix_error_computing_correlation
Browse files Browse the repository at this point in the history
Fix error computing correlation
  • Loading branch information
shimoura authored Nov 28, 2023
2 parents 086579f + 4de010f commit 7110623
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 3,050 deletions.
16 changes: 8 additions & 8 deletions figures/MAM2EBRAINS/M2E_compute_corrcoeff.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def compute_corrcoeff(M, data_path, label):
LvR_list = []
N = []
for pop in M.structure[area]:
print(area, pop)
fp = '-'.join((label,
'spikes', # assumes that the default label for spike files was used
area,
Expand All @@ -55,14 +54,15 @@ def compute_corrcoeff(M, data_path, label):
dat = ch.sort_gdf_by_id(spikes, idmin=ids[0], idmax=ids[0]+subsample+1000)
bins, hist = ch.instantaneous_spike_count(dat[1], resolution, tmin=tmin, tmax=T)
rates = ch.strip_binned_spiketrains(hist)[:subsample]
print(rates)
print("test")
print(rates.shape)

# test if only 1 of the neurons is firing, if yes, print warning message and continue
if rates.shape[0] < 2:
# print(area, pop)
print(f"WARNING: There are less than 2 neurons firing in the population: {area} {pop} due to a very small value being assigned to the parameter scale_down_to, the corresponding cross-correlation will not be computed.", area, pop)
continue

# compute cross correlation coefficient
cc = np.corrcoef(rates)
print(cc.shape)
print(cc[0].size)
# print(cc[0])
# print(cc)
cc = np.extract(1-np.eye(cc[0].size), cc)
cc[np.where(np.isnan(cc))] = 0.
cc_dict[area][pop] = np.mean(cc)
Expand Down
Loading

0 comments on commit 7110623

Please sign in to comment.