Skip to content
Snippets Groups Projects
Commit 5c699591 authored by Maximilian Schmidt's avatar Maximilian Schmidt
Browse files

Fix issues of figure scripts

parent 82cc6718
Branches
Tags
1 merge request!1Add all necessary files for the multi-area model
......@@ -17,11 +17,21 @@ with open(os.path.join(datapath, 'viscortex_processed_data.json'), 'r') as f:
proc = json.load(f)
density = proc['neuronal_densities']
if density is None:
print("Since we cannot publish the underlying density data, we"
"here hard-code the list of areas sorted by their overall"
"density.")
areas_sorted_density = ['V1', 'V2', 'V3', 'VP', 'V4', 'MT', 'V4t',
'PITv', 'PITd', 'VOT', 'V3A', 'LIP', 'MIP', 'MDP', 'PO', 'PIP',
'MSTl', 'VIP', 'MSTd', 'DP', 'TF', 'FEF', 'CITv', 'CITd', 'AITv',
'AITd', 'STPa', 'STPp', 'FST', '46', '7a', 'TH']
else:
ordered_density = OrderedDict(
sorted(list(density.items()), key=lambda t: t[1]['overall'], reverse=True))
areas_sorted_density = list(ordered_density.keys())
average_indegree = {}
for area in list(ordered_density.keys()):
for area in areas_sorted_density:
s = 0
for pop in population_list:
for source_area in list(area_list):
......@@ -32,7 +42,7 @@ for area in list(ordered_density.keys()):
indegrees = []
num_list = []
for area in list(ordered_density.keys()):
for area in areas_sorted_density:
indegrees.append(average_indegree[area])
num_list.append(M.N[area]['total'])
......
......@@ -13,6 +13,9 @@ from plotcolors import myred, myblue
from multiarea_model import MultiAreaModel
from multiarea_model.multiarea_helpers import create_mask
NEURON_DENSITIES_AVAILABLE = False
if NEURON_DENSITIES_AVAILABLE:
"""
Layout
"""
......@@ -146,18 +149,13 @@ SLN_array = np.array(data[:, 10], dtype=np.float)
densities = np.array(data[:, 7], dtype=np.float)
# Call R script to perform SLN fit
try:
proc = subprocess.Popen(["Rscript",
os.path.join(datapath, 'SLN_logdensities.R')],
stdout=subprocess.PIPE)
out = proc.communicate()[0].decode('utf-8')
R_fit = [float(out.split('\n')[1].split(' ')[1]),
float(out.split('\n')[1].split(' ')[3])]
except OSError:
print("No R installation, taking hard-coded fit parameters.")
print("We currently cannot publish the R code because of "
"copyright issues, there taking hard-coded fit parameters. "
"See Schmidt et al. (2018) for a full explanation "
"of the procedure.")
R_fit = [-0.1516142, -1.5343200]
print(R_fit)
ax = axes['A']
ax.plot(densities, SLN_array, '.', linewidth=1.5, color=myblue)
x = np.arange(-2., 2., 0.1)
......@@ -307,3 +305,7 @@ c.insert(pyx.epsfile.epsfile(
c.insert(pyx.epsfile.epsfile(
9.3, 12., "Fig5_syn_illustration.eps", width=7.))
c.writeEPSfile("Fig5_cc_laminar_pattern.eps")
else:
print("Figure 5 can currently not be produced because "
"we cannot publish the underlying raw data.")
......@@ -62,8 +62,11 @@ g_abs = create_graph(conn_matrix_abs, area_list)
"""
Determine clusters using the map equation.
"""
# This path determines the location of the infomap
# installation and needs to be provided to execute the script
infomap_path = None
modules, modules_areas, index = apply_map_equation(
conn_matrix, area_list, filename='Model')
conn_matrix, area_list, filename='Model', infomap_path=infomap_path)
f = open('Model.map', 'r')
line = ''
......@@ -113,7 +116,9 @@ for ii in range(1000):
for jj in range(32):
ind = np.extract(np.arange(32) != jj, np.arange(32))
null_model[:, jj][ind] = null_model[:, jj][ind][np.random.shuffle(ind)]
modules, modules_areas, index = apply_map_equation(null_model, area_list, filename='null')
modules, modules_areas, index = apply_map_equation(null_model, area_list,
filename='null',
infomap_path=infomap_path)
g_null = create_graph(null_model, area_list)
mod_list.append(modularity(g_null, modules[index]))
......
......@@ -251,7 +251,7 @@ for target_area in area_list:
source_areas=[source_area],
complete_area_list=area_list,
external=False)
pM = path_length_matrix[indices]
pM = path_length_matrix[indices[:, :-1]]
pM = pM.reshape(
(len(M.structure[target_area]), len(M.structure[source_area])))
imin = np.unravel_index(np.argmin(pM), pM.shape)
......
......@@ -63,8 +63,12 @@ def apply_map_equation(graph_matrix, node_list, filename='', infomap_path=None):
"""
if infomap_path:
os.chdir(infomap_path)
os.system('Infomap --directed --clu --map --verbose ' +
ret = os.system('./Infomap --directed --clu --map --verbose ' +
base_dir + '/' + net_fn + ' ' + base_dir)
if ret != 0:
raise OSError("Executing infomap failed. Did you install "
"infomap and provide the correct path by "
"defining the variable infomap_path?")
os.chdir(base_dir)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment