diff --git a/examples/bioRxiv281717/example_parallel_network.py b/examples/bioRxiv281717/example_parallel_network.py index decfc21c..d1456466 100644 --- a/examples/bioRxiv281717/example_parallel_network.py +++ b/examples/bioRxiv281717/example_parallel_network.py @@ -136,6 +136,8 @@ GNU General Public License for more details. ''' from __future__ import division +from mpi4py import MPI +import neuron import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt @@ -150,8 +152,6 @@ h5py.version.hdf5_version)) import os from time import time -from mpi4py import MPI -import neuron import LFPy from example_parallel_network_plotting import decimate diff --git a/examples/bioRxiv281717/example_parallel_network_parameters.py b/examples/bioRxiv281717/example_parallel_network_parameters.py index 8d1c42b2..1244f506 100644 --- a/examples/bioRxiv281717/example_parallel_network_parameters.py +++ b/examples/bioRxiv281717/example_parallel_network_parameters.py @@ -49,6 +49,27 @@ neuron.h.load_file("import3d.hoc") +####################### +# Functions +####################### +def get_pre_m_type(post): + '''little helper function to return the most populuous excitatory m_type + within the layer of m_type post, assuming this is representative for + excitatory external connections onto postsynaptic cells ''' + if post.startswith('L23'): + return 'L23_PC' + elif post.startswith('L4'): + return 'L4_PC' + elif post.startswith('L5'): + return 'L5_TTPC1' + elif post.startswith('L6'): + return 'L6_IPC' + +####################### +# Parameters +####################### + + # test mode (1 cell per pop, all-to-all connectivity) TESTING = False @@ -202,21 +223,21 @@ # Excitatory ('L4_PC', 'cAD', 'L4_PC_cADpyr230_1', 2674, dict(radius=210, loc=PSET.layer_data[3]['center'], scale=100., cap=[1078., 97.]), - dict(x=np.pi/2, y=0.), ['dend', 'apic'], ['dend', 'apic'], 0.05, 5.), + dict(x=np.pi/2, y=0.), ['dend', 'apic'], ['dend', 'apic'], 0.125, 5.), # Inhibitory ('L4_LBC', 'dNAC', 'L4_LBC_dNAC222_1', 122, dict(radius=210, loc=PSET.layer_data[3]['center'], scale=100., cap=[938., 670]), - dict(x=np.pi/2, y=0.), ['soma', 'dend', 'apic'], ['dend', 'apic'], 0.05, 5.), + dict(x=np.pi/2, y=0.), ['soma', 'dend', 'apic'], ['dend', 'apic'], 0.125, 5.), # Layer 5 # Excitatory ('L5_TTPC1', 'cAD', 'L5_TTPC1_cADpyr232_1', 2403, dict(radius=210, loc=PSET.layer_data[4]['center'], scale=125., cap=[719, 73.]), - dict(x=np.pi/2, y=0.), ['dend', 'apic'], ['dend', 'apic'], 0.045, 5.), + dict(x=np.pi/2, y=0.), ['dend', 'apic'], ['dend', 'apic'], 0.1, 5.), # Inhibitory ('L5_MC', 'bAC', 'L5_MC_bAC217_1', 395, dict(radius=210, loc=PSET.layer_data[4]['center'], scale=125., cap=[378., 890]), - dict(x=np.pi/2, y=0.), ['soma', 'dend', 'apic'], ['dend', 'apic'], 0.05, 5.), + dict(x=np.pi/2, y=0.), ['soma', 'dend', 'apic'], ['dend', 'apic'], 0.125, 5.), ], dtype = [('m_type', '|{}32'.format(stringType)), ('e_type', '|{}32'.format(stringType)), ('me_type', '|{}32'.format(stringType)), ('POP_SIZE', 'i8'), ('pop_args', dict), @@ -228,6 +249,7 @@ # names as used to denote individual cell types # POP_SIZE : number of neurons for each morphological type as given on https://bbp.epfl.ch/nmc-portal/microcircuit + # pop_args : dict, radius, mean position (loc) and standard deviation (scale) of the soma positions # rotation_args : dict, default rotations around x and y axis applied to each cell in the population using LFPy.NetworkCell.set_rotation() method. @@ -651,13 +673,13 @@ PSET.connParamsExtrinsic = dict( # synapse type syntype = 'ProbAMPANMDA_EMS', - # synapse parameters (chosen using pre==post) + # synapse parameters (assumes parameters of excitatory population in the layer) synparams = [dict( - Use = syn_param_stats['{}:{}'.format(post, post)]['Use_mean'], - Dep = syn_param_stats['{}:{}'.format(post, post)]['Dep_mean'], - Fac = syn_param_stats['{}:{}'.format(post, post)]['Fac_mean'], + Use = syn_param_stats['{}:{}'.format(get_pre_m_type(post), post)]['Use_mean'], + Dep = syn_param_stats['{}:{}'.format(get_pre_m_type(post), post)]['Dep_mean'], + Fac = syn_param_stats['{}:{}'.format(get_pre_m_type(post), post)]['Fac_mean'], tau_r_AMPA = 0.2, - tau_d_AMPA = syn_param_stats['{}:{}'.format(pre, post)]['tau_d_mean'], + tau_d_AMPA = syn_param_stats['{}:{}'.format(get_pre_m_type(post), post)]['tau_d_mean'], tau_r_NMDA = 0.29, tau_d_NMDA = 43, e=0, diff --git a/examples/bioRxiv281717/figure_2.py b/examples/bioRxiv281717/figure_2.py index 5ef04db4..15cced0c 100644 --- a/examples/bioRxiv281717/figure_2.py +++ b/examples/bioRxiv281717/figure_2.py @@ -12,9 +12,8 @@ import numpy as np import matplotlib.pyplot as plt from matplotlib.gridspec import GridSpec -from mpl_toolkits.axes_grid.axislines import SubplotZero -from matplotlib.collections import PolyCollection, LineCollection, PatchCollection -from matplotlib import colors, patches +from mpl_toolkits.axisartist.axislines import SubplotZero +from matplotlib.collections import PolyCollection import neuron # set some plotting parameters @@ -258,7 +257,7 @@ def draw_lineplot( def remove_axis_junk(ax, lines=['right', 'top']): - for loc, spine in ax.spines.iteritems(): + for loc, spine in ax.spines.items(): if loc in lines: spine.set_color('none') ax.xaxis.set_ticks_position('bottom') @@ -305,7 +304,7 @@ def remove_axis_junk(ax, lines=['right', 'top']): zips = [] xz = cell.get_idx_polygons() for x, z in xz: - zips.append(zip(x, z)) + zips.append(list(zip(x, z))) for ax in [ax0]: polycol = PolyCollection(zips, linewidths=(0.5), @@ -336,7 +335,7 @@ def remove_axis_junk(ax, lines=['right', 'top']): zips = [] offset = 0. for x, z in cell.get_pt3d_polygons(): - zips.append(zip(x-offset, z+offset)) + zips.append(list(zip(x-offset, z+offset))) polycol = PolyCollection(zips, edgecolors='none', facecolors='gray', diff --git a/examples/bioRxiv281717/figure_4.py b/examples/bioRxiv281717/figure_4.py index d5915f51..10a5d057 100644 --- a/examples/bioRxiv281717/figure_4.py +++ b/examples/bioRxiv281717/figure_4.py @@ -22,7 +22,6 @@ from matplotlib.ticker import MaxNLocator import os import numpy as np -import scipy.signal as ss import h5py from LFPy import NetworkCell import example_parallel_network_plotting as plotting diff --git a/examples/bioRxiv281717/figure_5.py b/examples/bioRxiv281717/figure_5.py index 3b72883e..db5a8066 100644 --- a/examples/bioRxiv281717/figure_5.py +++ b/examples/bioRxiv281717/figure_5.py @@ -18,15 +18,11 @@ from __future__ import division import matplotlib.pyplot as plt from matplotlib.gridspec import GridSpec, GridSpecFromSubplotSpec -from matplotlib.collections import PolyCollection -from mpl_toolkits.axes_grid.axislines import SubplotZero -import mpl_toolkits.axes_grid.axes_size as Size -from mpl_toolkits.axes_grid import Divider +from mpl_toolkits.axisartist.axislines import SubplotZero import os import numpy as np -import scipy.signal as ss import h5py -from LFPy import NetworkCell, FourSphereVolumeConductor, MEG +from LFPy import FourSphereVolumeConductor, MEG import example_parallel_network_plotting as plotting from mpi4py import MPI @@ -53,7 +49,7 @@ def plot_spike_raster(ax, PSET, T): for i, (m_name, name) in enumerate(zip(PSET.populationParameters['m_type'], PSET.populationParameters['me_type'])): x = [] y = [] - ax.hlines(f['SPIKES'][name]['gids'].value.min(), T[0], T[1], 'k', lw=0.25) + ax.hlines(f['SPIKES'][name]['gids'][()].min(), T[0], T[1], 'k', lw=0.25) for gid, spt in zip(f['SPIKES'][name]['gids'], f['SPIKES'][name]['times']): if len(spt) > 0: y += [gid]*spt.size @@ -121,7 +117,7 @@ def plot_spike_raster(ax, PSET, T): for i, (m_name, name) in enumerate(zip(PSET.populationParameters['m_type'], PSET.populationParameters['me_type'])): ax = axes[i] plotting.remove_axis_junk(ax) - data = np.hstack(f['SPIKES'][name]['times'].value.flat) + data = np.hstack(f['SPIKES'][name]['times'][()].flat) ax.hist(data, bins=bins, color=colors[i][:-1], label=m_name) ax.axis(ax.axis('tight')) ax.set_xlim(PSET.TRANSIENT, PSET.TRANSIENT+1000.) @@ -146,7 +142,7 @@ def plot_spike_raster(ax, PSET, T): ax = fig.add_subplot(gs0[:-2]) f = h5py.File(os.path.join(PSET.OUTPUTPATH, 'example_parallel_network_output.h5'), 'r') for data, title, color in zip( - [f['SUMMED_OUTPUT'].value['imem']], + [f['SUMMED_OUTPUT'][()]['imem']], ['extracellular potentials, summed'], ['k']): ax.set_title(title) @@ -169,12 +165,12 @@ def plot_spike_raster(ax, PSET, T): # PANEL D ECoG potential ax = fig.add_subplot(gs0[-1]) f = h5py.File(os.path.join(PSET.OUTPUTPATH, 'example_parallel_network_output.h5'), 'r') - data = f['SUMMED_ECOG'].value['imem'] + data = f['SUMMED_ECOG'][()]['imem'] title = 'ECoG potential, summed' color = 'k' ax.set_title(title) vlimround = plotting.draw_lineplot(ax=ax, - data=plotting.decimate(f['SUMMED_OUTPUT'].value['imem'][0, ].reshape((1, -1)), + data=plotting.decimate(f['SUMMED_OUTPUT'][()]['imem'][0, ].reshape((1, -1)), q=PSET.decimate_q), dt=PSET.dt*PSET.decimate_q, scalebar=False, diff --git a/examples/bioRxiv281717/figure_6.py b/examples/bioRxiv281717/figure_6.py index 4104d2b4..4caa89e5 100644 --- a/examples/bioRxiv281717/figure_6.py +++ b/examples/bioRxiv281717/figure_6.py @@ -18,15 +18,9 @@ from __future__ import division import matplotlib.pyplot as plt from matplotlib.gridspec import GridSpec -from matplotlib.collections import PolyCollection -from mpl_toolkits.axes_grid.axislines import SubplotZero -import mpl_toolkits.axes_grid.axes_size as Size -from mpl_toolkits.axes_grid import Divider import os import numpy as np -import scipy.signal as ss import h5py -from LFPy import NetworkCell, FourSphereVolumeConductor, MEG import example_parallel_network_plotting as plotting from mpi4py import MPI @@ -69,7 +63,7 @@ ax = fig.add_subplot(gs[:8, j]) f = h5py.File(os.path.join(PSET.OUTPUTPATH, 'example_parallel_network_output.h5'), 'r') for data, title, color in zip( - [f['SUMMED_OUTPUT'].value[me_type]], + [f['SUMMED_OUTPUT'][()][me_type]], [m_type], ['k']): ax.set_title(title) @@ -127,7 +121,7 @@ f = h5py.File(os.path.join(PSET.OUTPUTPATH, 'example_parallel_network_output.h5'), 'r') for m_type, me_type, color in zip(list(PSET.populationParameters['m_type'])+['summed'], list(PSET.populationParameters['me_type'])+['imem'], colors+['k']): - data = f['SUMMED_OUTPUT'].value[me_type] + data = f['SUMMED_OUTPUT'][()][me_type] ax.semilogx(data[:, tind:].var(axis=1), y, lw=2, label=m_type, color=color) f.close() ax.set_yticks(y) diff --git a/examples/bioRxiv281717/figure_7_8/example_parallel_network.py b/examples/bioRxiv281717/figure_7_8/example_parallel_network.py index 4b1863b0..228e862a 100644 --- a/examples/bioRxiv281717/figure_7_8/example_parallel_network.py +++ b/examples/bioRxiv281717/figure_7_8/example_parallel_network.py @@ -125,6 +125,8 @@ GNU General Public License for more details. ''' from __future__ import division +from mpi4py import MPI +import neuron import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt @@ -139,12 +141,10 @@ h5py.version.hdf5_version)) import os from time import time -from mpi4py import MPI -import neuron import LFPy from example_parallel_network_plotting import decimate import sys -import NeuroTools.parameters as ps +import parameters as ps # set up MPI environment @@ -263,7 +263,7 @@ if RANK == 0: parameters_time = time() - tic # open file object for writing - logfile = file(os.path.join(PSET.OUTPUTPATH, 'log.txt'), 'w', 0) + logfile = open(os.path.join(PSET.OUTPUTPATH, 'log.txt'), 'w') logfile.write('initialization {}\n'.format(initialization_time)) print('Parameters in {} seconds'.format(parameters_time)) logfile.write('parameters {}\n'.format(parameters_time)) @@ -574,7 +574,6 @@ label=name, ) ax.add_collection(polycol) - ax.axis(ax.axis('equal')) ax.set_xlim(-400, 400) axis = ax.axis() ax.hlines(np.r_[0., -PSET.layer_data['thickness'].cumsum()], diff --git a/examples/bioRxiv281717/figure_7_8/example_parallel_network_parameters.py b/examples/bioRxiv281717/figure_7_8/example_parallel_network_parameters.py index a44f186e..04a84c5d 100644 --- a/examples/bioRxiv281717/figure_7_8/example_parallel_network_parameters.py +++ b/examples/bioRxiv281717/figure_7_8/example_parallel_network_parameters.py @@ -44,6 +44,27 @@ RANK = COMM.Get_rank() +####################### +# Functions +####################### +def get_pre_m_type(post): + '''little helper function to return the most populuous excitatory m_type + within the layer of m_type post, assuming this is representative for + excitatory external connections onto postsynaptic cells ''' + if post.startswith('L23'): + return 'L23_PC' + elif post.startswith('L4'): + return 'L4_PC' + elif post.startswith('L5'): + return 'L5_TTPC1' + elif post.startswith('L6'): + return 'L6_IPC' + +####################### +# Parameters +####################### + + # load some neuron-interface files needed for the EPFL cell types neuron.h.load_file("stdrun.hoc") neuron.h.load_file("import3d.hoc") @@ -205,21 +226,21 @@ # # Excitatory # ('L4_PC', 'cAD', 'L4_PC_cADpyr230_1', 2674, # dict(radius=210, loc=PSET.layer_data[3]['center'], scale=100., cap=[1078., 97.]), - # dict(x=np.pi/2, y=0.), ['dend', 'apic'], ['dend', 'apic'], 0.05, 5.), + # dict(x=np.pi/2, y=0.), ['dend', 'apic'], ['dend', 'apic'], 0.125, 5.), # # Inhibitory # ('L4_LBC', 'dNAC', 'L4_LBC_dNAC222_1', 122, # dict(radius=210, loc=PSET.layer_data[3]['center'], scale=100., cap=[938., 670]), - # dict(x=np.pi/2, y=0.), ['soma', 'dend', 'apic'], ['dend', 'apic'], 0.05, 5.), + # dict(x=np.pi/2, y=0.), ['soma', 'dend', 'apic'], ['dend', 'apic'], 0.125, 5.), # Layer 5 # Excitatory ('L5_TTPC1', 'cAD', 'L5_TTPC1_cADpyr232_1', 2403, dict(radius=210, loc=PSET.layer_data[4]['center'], scale=125., cap=[719, 73.]), - dict(x=np.pi/2, y=0.), ['dend', 'apic'], ['dend', 'apic'], 0.045, 5.), + dict(x=np.pi/2, y=0.), ['dend', 'apic'], ['dend', 'apic'], 0.1, 5.), # Inhibitory ('L5_MC', 'bAC', 'L5_MC_bAC217_1', 395, dict(radius=210, loc=PSET.layer_data[4]['center'], scale=125., cap=[378., 890]), - dict(x=np.pi/2, y=0.), ['soma', 'dend', 'apic'], ['dend', 'apic'], 0.05, 5.), + dict(x=np.pi/2, y=0.), ['soma', 'dend', 'apic'], ['dend', 'apic'], 0.125, 5.), ], dtype = [('m_type', '|{}32'.format(stringType)), ('e_type', '|{}32'.format(stringType)), ('me_type', '|{}32'.format(stringType)), ('POP_SIZE', 'i8'), ('pop_args', dict), @@ -654,13 +675,13 @@ PSET.connParamsExtrinsic = dict( # synapse type syntype = 'ProbAMPANMDA_EMS', - # synapse parameters (chosen using pre==post) + # synapse parameters (assumes parameters of excitatory population in the layer) synparams = [dict( - Use = syn_param_stats['{}:{}'.format(post, post)]['Use_mean'], - Dep = syn_param_stats['{}:{}'.format(post, post)]['Dep_mean'], - Fac = syn_param_stats['{}:{}'.format(post, post)]['Fac_mean'], + Use = syn_param_stats['{}:{}'.format(get_pre_m_type(post), post)]['Use_mean'], + Dep = syn_param_stats['{}:{}'.format(get_pre_m_type(post), post)]['Dep_mean'], + Fac = syn_param_stats['{}:{}'.format(get_pre_m_type(post), post)]['Fac_mean'], tau_r_AMPA = 0.2, - tau_d_AMPA = syn_param_stats['{}:{}'.format(pre, post)]['tau_d_mean'], + tau_d_AMPA = syn_param_stats['{}:{}'.format(get_pre_m_type(post), post)]['tau_d_mean'], tau_r_NMDA = 0.29, tau_d_NMDA = 43, e=0, diff --git a/examples/bioRxiv281717/figure_7_8/example_parallel_network_parameterspace.py b/examples/bioRxiv281717/figure_7_8/example_parallel_network_parameterspace.py index 9f8f3c71..9545b334 100644 --- a/examples/bioRxiv281717/figure_7_8/example_parallel_network_parameterspace.py +++ b/examples/bioRxiv281717/figure_7_8/example_parallel_network_parameterspace.py @@ -6,7 +6,7 @@ import operator import pickle import hashlib -import NeuroTools.parameters as ps +import parameters as ps def sort_deep_dict(d): diff --git a/examples/bioRxiv281717/figure_7_8/figure_7_8.py b/examples/bioRxiv281717/figure_7_8/figure_7_8.py index 48b11734..fd43d312 100644 --- a/examples/bioRxiv281717/figure_7_8/figure_7_8.py +++ b/examples/bioRxiv281717/figure_7_8/figure_7_8.py @@ -17,7 +17,6 @@ import os import numpy as np import example_parallel_network_parameterspace as ps -#from example_parallel_network_parameterspace import * from example_parallel_network_parameters import PSET import matplotlib.pyplot as plt from matplotlib.ticker import ScalarFormatter diff --git a/examples/bioRxiv281717/figure_7_8/requirements.txt b/examples/bioRxiv281717/figure_7_8/requirements.txt new file mode 100644 index 00000000..353d0364 --- /dev/null +++ b/examples/bioRxiv281717/figure_7_8/requirements.txt @@ -0,0 +1 @@ +-e git+git@github.com:espenhgn/parameters.git@fix_py3#egg=parameters diff --git a/examples/bioRxiv281717/requirements.txt b/examples/bioRxiv281717/requirements.txt index 690a9546..353d0364 100644 --- a/examples/bioRxiv281717/requirements.txt +++ b/examples/bioRxiv281717/requirements.txt @@ -1,2 +1 @@ -#essential -parameters>=0.2.1 +-e git+git@github.com:espenhgn/parameters.git@fix_py3#egg=parameters