From f609e1c085716b400c46a39f7729d1aaba473892 Mon Sep 17 00:00:00 2001 From: Mainak Jas Date: Wed, 5 May 2021 12:41:48 -0400 Subject: [PATCH] MAINT: unify celltype, cell_type, and cell_name --- hnn_core/cell.py | 2 +- hnn_core/cells_default.py | 28 ++++++++++++++-------------- hnn_core/network_builder.py | 3 ++- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/hnn_core/cell.py b/hnn_core/cell.py index eff90fa77..6ed5f2ec3 100644 --- a/hnn_core/cell.py +++ b/hnn_core/cell.py @@ -163,7 +163,7 @@ def _set_biophysics(self, p_secs): # in a section. This method is significantly faster than using # a for loop to iterate over all segments to set mech values - # Value depends on distance from the soma. Soma is set as + # If value depends on distance from the soma. Soma is set as # origin by passing cell.soma as a sec argument to h.distance() # Then iterate over segment nodes of dendritic sections # and set gbar_ar depending on h.distance(seg.x), which returns diff --git a/hnn_core/cells_default.py b/hnn_core/cells_default.py index 90bd603ce..4227475a5 100644 --- a/hnn_core/cells_default.py +++ b/hnn_core/cells_default.py @@ -165,6 +165,13 @@ def basket(pos, cell_name='L2Basket', gid=None): cell : instance of BasketSingle The basket cell. """ + if cell_name == 'L2Basket': + sect_loc = dict(proximal=['soma'], distal=['soma']) + elif cell_name == 'L5Basket': + sect_loc = dict(proximal=['soma'], distal=[]) + else: + raise ValueError(f'Unknown basket cell type: {cell_name}') + p_secs = dict() p_secs['soma'] = _get_basket_soma_props(cell_name) p_syn = _get_basket_syn_props() @@ -175,26 +182,21 @@ def basket(pos, cell_name='L2Basket', gid=None): for sec_name in p_secs: p_secs[sec_name]['sec_pts'] = sec_pts[sec_name] - if cell_name == 'L2Basket': - sect_loc = dict(proximal=['soma'], distal=['soma']) - elif cell_name == 'L5Basket': - sect_loc = dict(proximal=['soma'], distal=[]) - cell = Cell(cell_name, pos=pos, gid=gid) cell.build(p_secs, p_syn, topology, sect_loc) return cell -def pyramidal(pos, celltype, override_params=None, gid=None): +def pyramidal(pos, cell_name, override_params=None, gid=None): """Pyramidal neuron. Parameters ---------- pos : tuple Coordinates of cell soma in xyz-space - celltype : str - 'L5_pyramidal' or 'L2_pyramidal'. The pyramidal cell type. + cell_name : str + 'L5Pyr' or 'L2Pyr'. The pyramidal cell type. override_params : dict or None (optional) Parameters specific to L2 pyramidal neurons to override the default set gid : int or None (optional) @@ -203,9 +205,8 @@ def pyramidal(pos, celltype, override_params=None, gid=None): yet attached to a network. Once the GID is set, it cannot be changed. """ - if celltype == 'L5_pyramidal': + if cell_name == 'L5Pyr': p_all_default = get_L5Pyr_params_default() - cell_name = 'L5Pyr' # units = ['pS/um^2', 'S/cm^2', 'pS/um^2', '??', 'tau', '??'] mechanisms = { 'hh2': ['gkbar_hh2', 'gnabar_hh2', @@ -221,9 +222,8 @@ def pyramidal(pos, celltype, override_params=None, gid=None): 'apical_2', 'apical_tuft', 'apical_oblique', 'basal_1', 'basal_2', 'basal_3'] sec_pts, _, _, yscale, topology = _secs_L5Pyr() - elif celltype == 'L2_pyramidal': + elif cell_name == 'L2Pyr': p_all_default = get_L2Pyr_params_default() - cell_name = 'L2Pyr' mechanisms = { 'km': ['gbar_km'], 'hh2': ['gkbar_hh2', 'gnabar_hh2', @@ -232,7 +232,7 @@ def pyramidal(pos, celltype, override_params=None, gid=None): 'apical_oblique', 'basal_1', 'basal_2', 'basal_3'] sec_pts, _, _, yscale, topology = _secs_L2Pyr() else: - raise ValueError(f'Unknown pyramidal cell type: {celltype}') + raise ValueError(f'Unknown pyramidal cell type: {cell_name}') p_all = p_all_default if override_params is not None: @@ -256,7 +256,7 @@ def pyramidal(pos, celltype, override_params=None, gid=None): syns = ['gabaa', 'gabab'] else: syns = list(p_syn.keys()) - if celltype == 'L5_pyramidal': + if cell_name == 'L5Pyr': p_secs[key]['mechs'][ 'ar']['gbar_ar'] = lambda x: 1e-6 * np.exp(3e-3 * x) p_secs[key]['syns'] = syns diff --git a/hnn_core/network_builder.py b/hnn_core/network_builder.py index 9d0607761..2ac11887d 100644 --- a/hnn_core/network_builder.py +++ b/hnn_core/network_builder.py @@ -393,7 +393,8 @@ def _create_cells_and_drives(self, threshold, record_vsoma=False, # XXX Why doesn't a _Cell have a .threshold? Would make a # lot of sense to include it, as _ArtificialCells do. cell = pyramidal_cell(src_pos, override_params=None, - celltype=src_type, gid=gid) + cell_name=_short_name(src_type), + gid=gid) else: basket_cell = type2class[src_type] cell = basket_cell(src_pos,