From 473942ebb9c8939a3e417f9d87012b2837121196 Mon Sep 17 00:00:00 2001 From: wagdy88 Date: Mon, 6 Mar 2023 17:34:33 -0500 Subject: [PATCH] WIP --- hnn_core/cell.py | 5 ++-- hnn_core/network.py | 12 +++++++- hnn_core/viz.py | 69 ++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 79 insertions(+), 7 deletions(-) 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..c9d7513bd 100644 --- a/hnn_core/viz.py +++ b/hnn_core/viz.py @@ -543,10 +543,71 @@ 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) +# import hnn_core +# from hnn_core import jones_2009_model, simulate_dipole +# import matplotlib as plt + +# net = jones_2009_model(add_drives_from_params= True) +# params = hnn_core.read_params('/home/mohamed/Desktop/PhD Thesis/auditory_evoked_simulation/HNN-AEF-main/HNN_Parameters/L_Contra.param') + +# def martinotti(n_cells): +# from hnn_core.cell import Section, Cell + +# cell_name = 'martinotti' +# pos = [(5, 5, 5)] * n_cells +# # pos = net.pos_dict['L5_basket'].copy() + +# end_pts = [[0, 0, 0], [0, 0, 39.]] +# soma = Section(L=39., diam=20., cm=0.85, +# Ra=200., end_pts=end_pts) +# soma.syns = ['gabaa', 'nmda'] + +# synapses = { +# 'gabaa': { +# 'e': -80, +# 'tau1': 0.5, +# 'tau2': 5. +# }, +# 'nmda': { +# 'e': 0, +# 'tau1': 1., +# 'tau2': 20. +# } +# } +# sect_loc = ['proximal'] + +# return Cell(cell_name, pos, +# sections=soma, +# synapses=synapses, +# topology=None, +# sect_loc=sect_loc, +# gid=0) + +# net.plot_cells() +# net._add_cell_type('L5_martinotti', pos='L5_basket' ,cell_template = None) + +# simulate_dipole(net, tstop = 100, record_vsec= 'all') + +# 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) + + + 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]]