diff --git a/examples/workflows/plot_simulate_alpha.py b/examples/workflows/plot_simulate_alpha.py index bf41a8b60..79424a3d7 100644 --- a/examples/workflows/plot_simulate_alpha.py +++ b/examples/workflows/plot_simulate_alpha.py @@ -80,7 +80,8 @@ plot_psd(dpl[trial_idx], fmin=1., fmax=1e3, tmin=tmin, ax=axes[1], show=False) axes[1].set_xscale('log') -plt.tight_layout() + +hjhj ############################################################################### # The next step is to add a simultaneous 10 Hz :term:`distal` drive with a # lower within-burst spread of spike times (``burst_std``) compared with the diff --git a/hnn_core/cell.py b/hnn_core/cell.py index aa2168415..329c1e6b2 100644 --- a/hnn_core/cell.py +++ b/hnn_core/cell.py @@ -241,14 +241,15 @@ class Cell: Keys are name of synaptic mechanism. Each synaptic mechanism has keys for parameters of the mechanism, e.g., 'e', 'tau1', 'tau2'. - topology : list of list + topology : list of list | None The topology of cell sections. Each element is a list of 4 items in the format [parent_sec, parent_loc, child_sec, child_loc] where parent_sec and parent_loc are float between 0 and 1 specifying the location in the section to connect and parent_sec and child_sec are names of the connecting - sections. + sections. If None, no topology is specified. This may + be necessary for single-compartment cells. sect_loc : dict of list Can have keys 'proximal' or 'distal' each containing names of section locations that are proximal or distal. diff --git a/hnn_core/network.py b/hnn_core/network.py index 777406d1b..54c75cc1e 100644 --- a/hnn_core/network.py +++ b/hnn_core/network.py @@ -1074,7 +1074,17 @@ def add_tonic_bias(self, *, cell_type=None, amplitude=None, } def _add_cell_type(self, cell_name, pos, cell_template=None): - """Add cell type by updating pos_dict and gid_ranges.""" + """Add cell type by updating pos_dict and gid_ranges. + + Parameters + ---------- + cell_name : str + The name of the cell population. + pos : list of tuple (x, y, z) + The position of the cells to be added to net.pos_dict. + cell_template : None | instance of Cell + An instance of + """ ll = self._n_gids self._n_gids += len(pos) self.gid_ranges[cell_name] = range(ll, self._n_gids) diff --git a/hnn_core/viz.py b/hnn_core/viz.py index bcca880ff..88854be36 100644 --- a/hnn_core/viz.py +++ b/hnn_core/viz.py @@ -543,10 +543,24 @@ def plot_cells(net, ax=None, show=True): fig = plt.figure() ax = fig.add_subplot(111, projection='3d') - colors = {'L5_pyramidal': 'b', 'L2_pyramidal': 'c', - 'L5_basket': 'r', 'L2_basket': 'm'} - markers = {'L5_pyramidal': '^', 'L2_pyramidal': '^', - 'L5_basket': 'x', 'L2_basket': 'x'} + #colors = {'L5_pyramidal': 'b', 'L2_pyramidal': 'c', + #'L5_basket': 'r', 'L2_basket': 'm'} + + #markers = {'L5_pyramidal': '^', 'L2_pyramidal': '^', + # 'L5_basket': 'x', 'L2_basket': 'x'} + + all_colors = ['b', 'c', 'r', 'm', 'tab:orange', 'g', 'y', 'k', 'w', 'tab:brown'] + all_markers= ['^', '^', 'x', 'x', 'o', 'v', 's', 'p', 'h', '<'] + cell_names = ['L5_pyramidal', 'L2_pyramidal', 'L5_basket', 'L2_basket'] + for cell_name in net.cell_types: + if cell_name not in cell_names: + cell_names.append(cell_name) + + colors= dict() + markers= dict() + for idx, cell_name in enumerate(cell_names): + colors[cell_name] = all_colors[idx] + markers[cell_name] = all_markers[idx] for cell_type in net.cell_types: x = [pos[0] for pos in net.pos_dict[cell_type]] diff --git a/test_script.py b/test_script.py new file mode 100644 index 000000000..f9d4d0f02 --- /dev/null +++ b/test_script.py @@ -0,0 +1,66 @@ +import hnn_core +from hnn_core import jones_2009_model, simulate_dipole, Network +import numpy as np +import matplotlib as plt + +params = hnn_core.read_params('/home/mohamed/Desktop/PhD Thesis/auditory_evoked_simulation/HNN-AEF-main/HNN_Parameters/L_Contra.param') +net = jones_2009_model() + + +def martinotti_template(): + from hnn_core.cell import Section, Cell + + cell_name = 'martinotti' + pos = (5, 5, 5) + # pos = net.pos_dict['L5_basket'].copy() + + end_pts = [[0, 0, 0], [0, 0, 39.]] + sections = {'soma': Section(L=39., diam=20., cm=0.85, + Ra=200., end_pts=end_pts)} + sections['soma'].syns = ['gabaa', 'nmda'] + + synapses = { + 'gabaa': { + 'e': -80, + 'tau1': 0.5, + 'tau2': 5. + }, + 'nmda': { + 'e': 0, + 'tau1': 1., + 'tau2': 20. + } + } + sect_loc = dict(proximal=['soma'], distal=['soma']) + + return Cell(cell_name, pos, + sections=sections, + synapses=synapses, + topology=None, + sect_loc=sect_loc, + gid=None) + +x1= np.linspace(0, 7, 7) +y1= np.linspace(0, 5, 5) +xv, yv = np.meshgrid(x1, y1) +pos = list() +for (x, y) in zip(xv.ravel(), yv.ravel()): + pos.append((x, y, 0.)) + +# net._add_cell_type('L5_martinotti', pos= pos, cell_template=martinotti_template()) +# net.plot_cells() + +weights_nmda_d1 = {'L2_basket': 0.019482, 'L2_pyramidal': 0.004317, + 'L5_pyramidal': 0.080074} +synaptic_delays_d1 = {'L2_basket': 0.1, 'L2_pyramidal': 0.1, + 'L5_pyramidal': 0.1} +net.add_evoked_drive( + 'evdist1', mu=63.53, sigma=3.85, numspikes=1, weights_ampa=None, + weights_nmda=weights_nmda_d1, location='distal', + synaptic_delays=synaptic_delays_d1, event_seed=4) + +simulate_dipole(net, tstop = 100, record_vsec=False) + +# net.add_connection(src_gids='L5_martinotti', target_gids='L5_pyramidal', loc='apical_tuft', receptor='gabaa', weight= 0.025 , delay=1.0 ,lamtha=70.0 , allow_autapses= False, probability=1) + + \ No newline at end of file