From 2d77708dcafc0bb395d98d8a0857b6ff6afbcd2c Mon Sep 17 00:00:00 2001 From: Maximilian Schmidt <max.schmidt@fz-juelich.de> Date: Mon, 11 Jun 2018 09:23:57 +0900 Subject: [PATCH] Formatting in Fig2 script, delete deprecated 1D Data script --- .../SchueckerSchmidt2017/Fig2_EE_example.py | 23 ++- .../Fig2_EE_example_1D_data.py | 194 ------------------ .../SchueckerSchmidt2017/Fig2_EE_network.py | 18 +- 3 files changed, 30 insertions(+), 205 deletions(-) delete mode 100644 figures/SchueckerSchmidt2017/Fig2_EE_example_1D_data.py diff --git a/figures/SchueckerSchmidt2017/Fig2_EE_example.py b/figures/SchueckerSchmidt2017/Fig2_EE_example.py index 5d8621d..51703ac 100644 --- a/figures/SchueckerSchmidt2017/Fig2_EE_example.py +++ b/figures/SchueckerSchmidt2017/Fig2_EE_example.py @@ -6,8 +6,6 @@ import pyx from matplotlib import gridspec from matplotlib.colors import ListedColormap from plotcolors import myred, myblue -import pyx -import os from Fig2_EE_network import network1D, network2D """ @@ -52,8 +50,6 @@ pl.rcParams['ytick.labelsize'] = scale * 8 pl.rcParams['xtick.labelsize'] = scale * 8 # use latex to generate the labels in plots -# not needed anymore in newer versions -# using this, font detection fails on adobe illustrator 2010-07-20 pl.rcParams['text.usetex'] = True pl.rcParams['text.latex.preamble'] = [r"\usepackage{amsmath}"] @@ -66,7 +62,6 @@ nrows = 2. ncols = 2. width = 4.61 # inches for 1.5 JoN columns height = 5.67 -print(width, height) pl.rcParams['figure.figsize'] = (width, height) fig = pl.figure() @@ -124,6 +119,8 @@ for label in ['A', 'B', 'C', 'D', 'E', 'F', 'G']: """ 1D network """ + + ax = axes['A'] ax.yaxis.set_ticks_position('none') ax.xaxis.set_ticks_position('none') @@ -146,6 +143,14 @@ ax_inset.tick_params(axis='y', labelsize=4, pad=1) x = np.arange(0, 150., 1.) + +""" +Panel C (top): Transfer function +for three cases: +- normal network +- noiseless neurons +- neurons without refractory period +""" ax = axes['C'] ax.xaxis.set_ticks_position('none') ax.spines['bottom'].set_color('none') @@ -189,6 +194,10 @@ ax.set_xlim([-3, 70]) ax.set_ylim([-3, 70]) +""" +Panel C (bottom): Transfer function +for three levels of external stimulation. +""" ax = axes['C2'] colors = ['k', '0.3', '0.7'] markers = ['d', '+', '.'] @@ -413,7 +422,7 @@ y0 = 0. x1 = 0.015 y1 = 0.015 -# vector fiels +# vector fields netp = network_params_base net = network2D(netp) range_vector = np.arange(0., 51., 10.) @@ -440,7 +449,7 @@ nullcline_x0 = net.nullclines_x0(x0_vec) ax.plot(nullcline_x0, x0_vec, '--', color='black', label='x0') ax.plot(x0_vec, nullcline_x0, '--', color='black', label='x0') -# set limes +# set plot limits axG.set_xlim((x0 * 1e2, x1 * 1e2)) axG.set_ylim((y0 * 1e2, y1 * 1e2)) ax.set_xlim([-5, 50]) diff --git a/figures/SchueckerSchmidt2017/Fig2_EE_example_1D_data.py b/figures/SchueckerSchmidt2017/Fig2_EE_example_1D_data.py deleted file mode 100644 index 548f6fb..0000000 --- a/figures/SchueckerSchmidt2017/Fig2_EE_example_1D_data.py +++ /dev/null @@ -1,194 +0,0 @@ -import os -import pylab as pl -import numpy as np -from plotcolors import myred, myblue -from matplotlib.colors import ListedColormap -from multiarea_model.theory import Theory -from multiarea_model.theory_helpers import nu0_fb -from multiarea_model.default_params import single_neuron_dict -from multiarea_model.multiarea_helpers import convert_syn_weight - - -class network: - def __init__(self, params, theory_spec): - self.label = '1D' - self.params = {'input_params': params['input_params'], - 'neuron_params': {'single_neuron_dict': single_neuron_dict}, - 'connection_params': {'replace_cc': None, - 'replace_cc_input_source': None} - } - - self.add_DC_drive = np.zeros(1) - self.structure = {'A': {'E'}} - self.structure_vec = ['A-E'] - self.area_list = ['A'] - self.K_matrix = np.array([[params['K'], params['K']]]) - self.W_matrix = np.array([[params['W'], params['W']]]) - self.J_matrix = convert_syn_weight(self.W_matrix, - self.params['neuron_params']['single_neuron_dict']) - self.theory = Theory(self, theory_spec) - - - def Phi(self, rate): - mu, sigma = self.theory.mu_sigma(rate) -# print(mu, sigma) - NP = self.params['neuron_params']['single_neuron_dict'] - return list(map(lambda mu, sigma: nu0_fb(mu, sigma, - 1.e-3*NP['tau_m'], - 1.e-3*NP['tau_syn_ex'], - 1.e-3*NP['t_ref'], - NP['V_th'] - NP['E_L'], - NP['V_reset'] - NP['E_L']), - mu, sigma)) - - -""" -space showing bifurcation -""" - -rate_exts_array = np.arange(150., 170.1, 1.) - -network_params = {'K': 210., - 'W': 10.} -theory_params = {'T': 20., - 'dt': 0.01} - - -# for i, rate_ext in enumerate(rate_exts_array): -# input_params = {'rate_ext': rate_ext} -# network_params.update({'input_params': input_params}) - -# net = network(network_params, theory_params) -# r = net.theory.integrate_siegert()[1][:, -1] -# print(r) - -# x = np.arange(0, 30., 0.02) -# for i, rate_ext in enumerate([150., 160., 170.]): -# input_params = {'rate_ext': rate_ext} -# network_params.update({'input_params': input_params}) -# net = network(network_params, theory_params) -# y = np.fromiter([net.Phi(xi) for xi in x], dtype=np.float) -# pl.plot(x, y) - -# pl.savefig('Fig2_EE_example_1D_data.eps') - - -fig = pl.figure() -x = np.arange(0, 70., 1.) - -for rate_ext in [150., 160., 170.]: - input_params = {'rate_ext': rate_ext} - network_params.update({'input_params': input_params}) - net = network(network_params, theory_params) - y = np.fromiter([net.Phi(x[i])[0] for i in range(len(x))], dtype=np.float) - pl.plot(x, y) -pl.plot(x, x, '--') -pl.show() -# for i, dic in enumerate(mfp.par_list(PS)): -# print(dic) -# para_dic, label = mfp.hashtag(dic) -# mf = meanfield_multi(para_dic, label) -# inits = np.arange(0, 50, 10) -# Fps = [] -# for init in inits: -# solution = mf.fsolve([init, init]) -# if solution['eps'] == 'The solution converged.': -# Fps.append(mf.fsolve([init, init])['rates'][0]) -# Fps = np.unique(np.round(Fps, decimals=2)) -# Fps_array.append(Fps) - -# h5.add_to_h5('mf_data.h5', {'EE_example': { -# 'Fps_array': Fps_array}}, 'a', overwrite_dataset=True) - - -# rate_exts_array = np.arange(150., 170.1, 10.) -# rate_exts = np.array([[x, x] for x in rate_exts_array]) -# PS = para.ParameterSpace({ # 'g': para.ParameterRange(np.arange(-3.5,-3.0,0.1)), -# 'g': 1., -# 'rate': para.ParameterRange(rate_exts), -# 'model': 'Brunel', -# 'gamma': 1., -# 'rates_init_int': np.array([80, 80]), -# 'W': 0.01, -# 'K': 210., -# }) -# print(PS) -# cmap = pl.get_cmap('Greys_r') - - -# ################## rate instability ############### - -# x = np.arange(0, 150, 1.0) -# x_long = np.arange(0, 10000, 10.0) -# NUM_COLORS = len(mfp.par_list(PS)) - - -# for i, dic in enumerate(mfp.par_list(PS)): -# para_dic, label = mfp.hashtag(dic) -# mf = meanfield_multi(para_dic, label) -# dic_refrac = copy.deepcopy(dic) -# dic_refrac.update({'tau_refrac': 0}) -# para_dic_refrac, label_refrac = mfp.hashtag(dic_refrac) -# mf_refrac = meanfield_multi(para_dic_refrac, label_refrac) -# t = [mf.Phi(np.array([xval, xval]), return_leak=False) for xval in x] -# t_noisefree = [mf.Phi_noisefree(np.array([xval, xval])) for xval in x] -# t_refrac = [mf_refrac.Phi(np.array([xval, xval]), -# return_leak=False) for xval in x] - -# t_long = [mf.Phi(np.array([xval, xval]), return_leak=False) -# for xval in x_long] -# h5.add_to_h5('mf_data.h5', {'EE_example': {label: {'t': t, 't_noisefree': t_noisefree, -# 't_long': t_long, 't_refrac': t_refrac}}}, 'a', overwrite_dataset=True) - -# ########################## Stabilization ################ - -# x = np.arange(0., 50., 0.1) -# rate = 160. -# start = 17.0 -# drate = 1. - -# dic = { # 'g': para.ParameterRange(np.arange(-3.5,-3.0,0.1)), -# 'g': 1., -# 'rate': np.array([rate, rate]), -# 'model': 'Brunel', -# 'gamma': 1., -# 'W': 0.01, -# 'K': 210., -# } - -# ######### base state ########## - -# para_dic, mf_label = mfp.hashtag(dic) -# mf = meanfield_multi(para_dic, mf_label) -# res_la_base = mf.fsolve(np.ones(2) * start) -# res_in_base = mf.fsolve(np.ones(2) * start) -# print('res', res_la_base) -# t = [mf.Phi(np.array([xval, xval])) for xval in x] -# savedic = {'res_la_base': res_la_base, 'res_in_base': res_in_base, 't': t} -# h5.add_to_h5('mf_data.h5', {'EE_example': { -# mf_label: savedic}}, 'a', overwrite_dataset=True) - -# ######## increased rate ####### - -# dic.update({'rate': np.array([rate + drate, rate + drate])}) -# para_dic, mf_label = mfp.hashtag(dic) -# mf_2 = meanfield_multi(para_dic, mf_label) -# res_in_2 = mf_2.fsolve(np.ones(2) * start) -# t_2 = [mf_2.Phi(np.array([xval, xval])) for xval in x] -# savedic = {'res_in_2': res_in_2, 't_2': t_2} -# h5.add_to_h5('mf_data.h5', {'EE_example': { -# mf_label: savedic}}, 'a', overwrite_dataset=True) - -# ####### stabilized ####### - -# matrix_prime, v, shift, delta = mft.stabilize( -# mf, mf_2, fixed_point=res_la_base['rates'][0], method='least_squares') -# print('1D K_prime', matrix_prime) -# dic.update({'K_stable': matrix_prime}) -# para_dic, mf_label = mfp.hashtag(dic) -# mf_s = meanfield_multi(para_dic, mf_label) -# res_in_s = mf_s.fsolve(np.ones(2) * start) -# t_s = [mf_s.Phi(np.array([xval, xval])) for xval in x] -# savedic = {'res_in_s': res_in_s, 't_s': t_s} -# h5.add_to_h5('mf_data.h5', {'EE_example': { -# mf_label: savedic}}, 'a', overwrite_dataset=True) diff --git a/figures/SchueckerSchmidt2017/Fig2_EE_network.py b/figures/SchueckerSchmidt2017/Fig2_EE_network.py index de516c6..a0c3b4d 100644 --- a/figures/SchueckerSchmidt2017/Fig2_EE_network.py +++ b/figures/SchueckerSchmidt2017/Fig2_EE_network.py @@ -1,15 +1,18 @@ -import os -import pylab as pl import numpy as np + from scipy import optimize -from plotcolors import myred, myblue -from matplotlib.colors import ListedColormap from multiarea_model.theory import Theory from multiarea_model.theory_helpers import nu0_fb from multiarea_model.default_params import single_neuron_dict, nested_update from multiarea_model.multiarea_helpers import convert_syn_weight from copy import copy +""" +Network class for the 1D case: +1 excitatory population with recurrent connectivity and external +stimulation. +""" + class network1D: def __init__(self, params): @@ -66,6 +69,13 @@ class network1D: return result_dic +""" +Network class for the 2D case: +2 excitatory populations with recurrent connectivity and external +stimulation. +""" + + class network2D: def __init__(self, params): self.label = '2D' -- GitLab