Skip to content

Commit

Permalink
Merge pull request #62 from didi-hou/plot_enhance
Browse files Browse the repository at this point in the history
Plots enhancing
  • Loading branch information
shimoura authored Mar 13, 2024
2 parents 681447b + cb9c0fe commit af20593
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 22 deletions.
10 changes: 5 additions & 5 deletions figures/MAM2EBRAINS/M2E_firing_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,18 @@ def plot_firing_rate_over_areas(M, data_path):
matrix.append(binned_spikes)

matrix = np.array(matrix)
normalized_matrix = (matrix - np.min(matrix)) / (np.max(matrix) - np.min(matrix))
# normalized_matrix = (matrix - np.min(matrix)) / (np.max(matrix) - np.min(matrix))

fig = pl.figure()
fig.suptitle('Normalized instantaneous firing rate over simulated areas', fontsize=16, x=0.45, y=0.95)
fig = pl.figure(figsize=(12, 5))
fig.suptitle('Instantaneous firing rate over simulated areas', fontsize=16, x=0.45, y=0.95)
ax = pl.subplot()

cmap = pl.get_cmap('YlOrBr')

# masked_matrix = np.ma.masked_where(np.isnan(matrix), matrix)
ax.patch.set_hatch('x')
im = ax.pcolormesh(normalized_matrix, cmap=cmap, edgecolors='None')
ax.set_xlim(0, normalized_matrix[0].size)
im = ax.pcolormesh(matrix, cmap=cmap, edgecolors='None', vmin=0)
ax.set_xlim(0, matrix[0].size)

ax.set_xticks([i for i in np.arange(0, 100, 10)])
ax.set_xticklabels([i for i in np.arange(500, 600, 10)])
Expand Down
6 changes: 3 additions & 3 deletions figures/MAM2EBRAINS/M2E_visualize_interareal_connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ def visualize_interareal_connectivity(M):
nrows = 1
ncols = 2
# width = 6.8556
width = 15
width = 12
panel_wh_ratio = 0.7 * (1. + np.sqrt(5)) / 2. # golden ratio

height = width / panel_wh_ratio * float(nrows) / ncols
# print(width, height)
pl.rcParams['figure.figsize'] = (width, height)

fig = pl.figure()
fig.suptitle('Interareal probabilistic connectivity for full-scale (left) and down-scaled (right) multi-area model', fontsize=16, y=1.05)
fig.suptitle('Area-level connectivity of the full-scale and down-scaled MAM expressed as relative indegrees for each target area', fontsize=15, x=0.5, y=1.05)
axes = {}

# gs1 = gridspec.GridSpec(2, 2)
gs1 = gridspec.GridSpec(1, 2)
# gs1.update(left=0.06, right=0.95, top=0.95, bottom=0.1, wspace=0.1, hspace=0.3)
gs1.update(left=0.06, right=0.95, top=0.95, bottom=0.1, wspace=0.3, hspace=0.3)
gs1.update(left=0.1, right=0.95, top=0.95, bottom=0.1, wspace=0.3, hspace=0.3)

# axes['A'] = pl.subplot(gs1[:1, :1])
# axes['B'] = pl.subplot(gs1[:1, 1:2])
Expand Down
35 changes: 23 additions & 12 deletions figures/MAM2EBRAINS/M2E_visualize_time_ave_pop_rates.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def plot_time_averaged_population_rates(M, data_path, area_list=None, **keywords
# matrix = np.zeros((len(area_list), len(A.network.structure['V1'])))
matrix = np.zeros((len(area_list), len(M.structure['V1'])))

fig = plt.figure(figsize=(12, 4))
fig = plt.figure(figsize=(12, 3))
fig.suptitle('Time-averaged firing rate over simulated populations', fontsize=15, x=0.43)
ax = fig.add_subplot(111)

Expand All @@ -51,20 +51,23 @@ def plot_time_averaged_population_rates(M, data_path, area_list=None, **keywords
rate = np.nan
matrix[i][j] = rate

cm = plt.cm.jet
cm = cm.from_list('mycmap', [(0., 64./255., 192./255.), # custom dark blue
(0., 128./255., 192./255.), # custom light blue
'white',
(245./255., 157./255., 115./255.), # custom light red
(192./255., 64./255., 0.)], N=256) # custom dark red
# cm = plt.cm.jet
# cm = cm.from_list('mycmap', [(0., 64./255., 192./255.), # custom dark blue
# (0., 128./255., 192./255.), # custom light blue
# 'white',
# (245./255., 157./255., 115./255.), # custom light red
# (192./255., 64./255., 0.)], N=256) # custom dark red
cm = plt.get_cmap('YlOrBr')
cm.set_under('0.3')
cm.set_bad('k')
# cm.set_bad('k')
cm.set_bad('white')

matrix = np.transpose(matrix)
masked_matrix = np.ma.masked_where(np.isnan(matrix), matrix)
ax.patch.set_hatch('x')
im = ax.pcolormesh(masked_matrix, cmap=cm, edgecolors='None', norm=LogNorm(
vmin=0.01, vmax=100.))
# im = ax.pcolormesh(masked_matrix, cmap=cm, edgecolors='None', norm=LogNorm(
# vmin=0.01, vmax=100.))
im = ax.pcolormesh(masked_matrix, cmap=cm, edgecolors='None', vmin=0)
ax.set_xlim(0, matrix[0].size)

x_index = np.arange(4.5, 31.6, 5.0)
Expand All @@ -82,9 +85,17 @@ def plot_time_averaged_population_rates(M, data_path, area_list=None, **keywords
ax.set_yticklabels(['6I', '6E', '5I', '5E', '4I', '4E', '2/3I', '2/3E'])
ax.set_ylabel('Population', size=13)
ax.set_xlabel('Area index', size=13)
t = FixedLocator([0.01, 0.1, 1., 10., 100.])
# t = FixedLocator([0.01, 0.1, 1., 10., 100.])
# t = FixedLocator([0, 10, 20, 30, 40, 50])

# Iterate over the data and add 'X' for masked cells
for i in range(masked_matrix.shape[0]):
for j in range(masked_matrix.shape[1]):
if masked_matrix.mask[i, j]:
ax.text(j + 0.5, i + 0.5, 'X', va='center', ha='center', color='black', fontsize=23)

plt.colorbar(im, ticks=t)
# plt.colorbar(im, ticks=t)
plt.colorbar(im)

if 'output' in keywords:
# plt.savefig(os.path.join(A.output_dir, '{}_rates.{}'.format(A.simulation.label,
Expand Down
6 changes: 4 additions & 2 deletions multi-area-model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,9 @@
{
"cell_type": "markdown",
"id": "2714fd2b-df6e-45b9-a7f4-f240a8c65ecf",
"metadata": {},
"metadata": {
"tags": []
},
"source": [
"### 3.2. Normalized instantaneous firing rate over simulated areas <a class=\"anchor\" id=\"section_3_2\"></a>"
]
Expand Down Expand Up @@ -566,7 +568,7 @@
"id": "b6746ea4-91bd-44f5-acb6-83df15b05480",
"metadata": {},
"source": [
"An overview of time-averaged firing rate over simulated populations encoded in colors with areas along x-axis and populations along y-axis."
"An overview of time-averaged firing rate over simulated populations encoded in colors with areas along x-axis and populations along y-axis. The cells of population 4E and 4I in area TH are labeled with X as area TH does not have layer 4."
]
},
{
Expand Down

0 comments on commit af20593

Please sign in to comment.