Skip to content
Snippets Groups Projects
Commit fc160d03 authored by Didi Hou's avatar Didi Hou Committed by Administrator
Browse files

/

parent e381c335
No related branches found
No related tags found
1 merge request!35Pre-release MAM v1.1.0
This diff is collapsed.
import numpy as np
# Time-averaged population rates
# An overview over time-averaged population rates encoded in colors with areas along x-axis and populations along y-axis.
from multiarea_model import Analysis
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm
from matplotlib.ticker import FixedLocator
# def plot_time_averaged_population_rates(M, A):
# A.show_rates()
def plot_time_averaged_population_rates(M):
def plot_time_averaged_population_rates(M, area_list=None, **keywords):
"""
Plot overview over time-averaged population rates encoded in colors
with areas along x-axis and populations along y-axis.
......@@ -18,24 +16,31 @@ def plot_time_averaged_population_rates(M):
output : {'pdf', 'png', 'eps'}, optional
If given, the function stores the plot to a file of the given format.
"""
area_list = None
A = Analysis(network=M,
simulation=M.simulation,
data_list=['spikes'],
load_areas=None)
A.create_pop_rates()
if area_list is None:
area_list = ['V1', 'V2', 'VP', 'V3', 'PIP', 'V3A', 'MT', 'V4t', 'V4',
'PO', 'VOT', 'DP', 'MIP', 'MDP', 'MSTd', 'VIP', 'LIP',
'PITv', 'PITd', 'AITv', 'MSTl', 'FST', 'CITv', 'CITd',
'7a', 'STPp', 'STPa', 'FEF', '46', 'TF', 'TH', 'AITd']
matrix = np.zeros((len(area_list), len(M.network.structure['V1'])))
matrix = np.zeros((len(area_list), len(A.network.structure['V1'])))
fig = plt.figure(figsize=(6, 4))
fig = plt.figure(figsize=(12, 8))
ax = fig.add_subplot(111)
for i, area in enumerate(area_list):
# print(i, area)
# for j, pop in enumerate(M.network.structure_reversed['V1']):
for j, pop in enumerate(M.network.structure['V1']):
if pop in M.network.structure[area]:
rate = M.pop_rates[area][pop][0]
# for j, pop in enumerate(A.network.structure_reversed['V1']):
for j, pop in enumerate(A.network.structure['V1'][::-1]):
if pop in A.network.structure[area]:
rate = A.pop_rates[area][pop][0]
if rate == 0.0:
rate = 1e-5 # To distinguish zero-rate from non-existing populations
else:
......@@ -60,15 +65,16 @@ def plot_time_averaged_population_rates(M):
x_index = np.arange(4.5, 31.6, 5.0)
x_ticks = [int(a + 0.5) for a in x_index]
y_index = list(range(len(M.network.structure['V1'])))
y_index = list(range(len(A.network.structure['V1'])))
y_index = [a + 0.5 for a in y_index]
# print(M.network.structure['V1'])
ax.set_xticks(x_index)
# print(A.network.structure['V1'])
# ax.set_xticks(x_index)
ax.set_xticks([i + 0.5 for i in np.arange(0, len(area_list), 1)])
# ax.set_xticklabels(x_ticks)
ax.set_xticklabels(area_list)
ax.set_xticklabels(area_list, rotation=90, size=10.)
ax.set_yticks(y_index)
# ax.set_yticklabels(M.network.structure_reversed['V1'])
ax.set_yticklabels(M.network.structure['V1'])
# ax.set_yticklabels(A.network.structure_reversed['V1'])
ax.set_yticklabels(A.network.structure['V1'][::-1])
ax.set_ylabel('Population', size=18)
ax.set_xlabel('Area index', size=18)
t = FixedLocator([0.01, 0.1, 1., 10., 100.])
......@@ -76,7 +82,7 @@ def plot_time_averaged_population_rates(M):
plt.colorbar(im, ticks=t)
if 'output' in keywords:
plt.savefig(os.path.join(M.output_dir, '{}_rates.{}'.format(M.simulation.label,
plt.savefig(os.path.join(A.output_dir, '{}_rates.{}'.format(A.simulation.label,
keywords['output'])))
else:
fig.show()
fig.show()
\ No newline at end of file
import numpy as np
# Time-averaged population rates
# An overview over time-averaged population rates encoded in colors with areas along x-axis and populations along y-axis.
from multiarea_model import Analysis
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm
from matplotlib.ticker import FixedLocator
# def plot_time_averaged_population_rates(M, A):
# A.show_rates()
def plot_time_averaged_population_rates(M):
def plot_time_averaged_population_rates(M, area_list=None, **keywords):
"""
Plot overview over time-averaged population rates encoded in colors
with areas along x-axis and populations along y-axis.
......@@ -18,24 +16,31 @@ def plot_time_averaged_population_rates(M):
output : {'pdf', 'png', 'eps'}, optional
If given, the function stores the plot to a file of the given format.
"""
area_list = None
A = Analysis(network=M,
simulation=M.simulation,
data_list=['spikes'],
load_areas=None)
A.create_pop_rates()
if area_list is None:
area_list = ['V1', 'V2', 'VP', 'V3', 'PIP', 'V3A', 'MT', 'V4t', 'V4',
'PO', 'VOT', 'DP', 'MIP', 'MDP', 'MSTd', 'VIP', 'LIP',
'PITv', 'PITd', 'AITv', 'MSTl', 'FST', 'CITv', 'CITd',
'7a', 'STPp', 'STPa', 'FEF', '46', 'TF', 'TH', 'AITd']
matrix = np.zeros((len(area_list), len(M.network.structure['V1'])))
matrix = np.zeros((len(area_list), len(A.network.structure['V1'])))
fig = plt.figure(figsize=(6, 4))
fig = plt.figure(figsize=(12, 8))
ax = fig.add_subplot(111)
for i, area in enumerate(area_list):
# print(i, area)
# for j, pop in enumerate(M.network.structure_reversed['V1']):
for j, pop in enumerate(M.network.structure['V1']):
if pop in M.network.structure[area]:
rate = M.pop_rates[area][pop][0]
# for j, pop in enumerate(A.network.structure_reversed['V1']):
for j, pop in enumerate(A.network.structure['V1'][::-1]):
if pop in A.network.structure[area]:
rate = A.pop_rates[area][pop][0]
if rate == 0.0:
rate = 1e-5 # To distinguish zero-rate from non-existing populations
else:
......@@ -60,15 +65,16 @@ def plot_time_averaged_population_rates(M):
x_index = np.arange(4.5, 31.6, 5.0)
x_ticks = [int(a + 0.5) for a in x_index]
y_index = list(range(len(M.network.structure['V1'])))
y_index = list(range(len(A.network.structure['V1'])))
y_index = [a + 0.5 for a in y_index]
# print(M.network.structure['V1'])
ax.set_xticks(x_index)
# print(A.network.structure['V1'])
# ax.set_xticks(x_index)
ax.set_xticks([i + 0.5 for i in np.arange(0, len(area_list), 1)])
# ax.set_xticklabels(x_ticks)
ax.set_xticklabels(area_list)
ax.set_xticklabels(area_list, rotation=90, size=10.)
ax.set_yticks(y_index)
# ax.set_yticklabels(M.network.structure_reversed['V1'])
ax.set_yticklabels(M.network.structure['V1'])
# ax.set_yticklabels(A.network.structure_reversed['V1'])
ax.set_yticklabels(A.network.structure['V1'][::-1])
ax.set_ylabel('Population', size=18)
ax.set_xlabel('Area index', size=18)
t = FixedLocator([0.01, 0.1, 1., 10., 100.])
......@@ -76,7 +82,7 @@ def plot_time_averaged_population_rates(M):
plt.colorbar(im, ticks=t)
if 'output' in keywords:
plt.savefig(os.path.join(M.output_dir, '{}_rates.{}'.format(M.simulation.label,
plt.savefig(os.path.join(A.output_dir, '{}_rates.{}'.format(A.simulation.label,
keywords['output'])))
else:
fig.show()
fig.show()
\ No newline at end of file
This diff is collapsed.
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment