Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRG] Add name parameter to tonic bias and add tonic biases to different sections #922

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7e43655
tonic bias options
katduecker Jul 9, 2024
8471d4d
update defaults
katduecker Sep 17, 2024
82756c9
describe new parameters
katduecker Oct 27, 2024
52c00fe
stop tracking arm64
katduecker Oct 27, 2024
29a9a24
flake8
katduecker Oct 27, 2024
0c54729
unit tests
katduecker Oct 29, 2024
bebfaba
change sect_name to section for consistency
katduecker Oct 29, 2024
2d3154f
change sect_name to section for consistency test_gui
katduecker Oct 29, 2024
161c402
workaround backwards compatibility
katduecker Oct 29, 2024
fe03432
change CSD back
katduecker Oct 29, 2024
b8e1530
add deprecation warning
katduecker Oct 29, 2024
8215226
fix typos
katduecker Oct 29, 2024
1fc36a3
unit tests
katduecker Oct 29, 2024
fd44180
clean up section warning
katduecker Oct 29, 2024
73cc766
refactor: changed the default value from None to 'soma'
gtdang Nov 4, 2024
2303f0b
chore: updated test asset with section attributes in external_biases
gtdang Nov 4, 2024
0e2fbf8
chore: removed 'section' from ignore_keys in test_gui.check_equal_net…
gtdang Nov 4, 2024
a411607
Merge pull request #1 from brown-ccv/tonic_bias_sections
katduecker Nov 4, 2024
c62eb8d
fix test
katduecker Nov 4, 2024
75164d8
add bias_name test
katduecker Nov 4, 2024
e1f5c66
update value error
katduecker Nov 4, 2024
321f589
fix regex test
katduecker Nov 5, 2024
22722ad
Update hnn_core/tests/test_network.py
katduecker Nov 7, 2024
7ebe6b3
Update hnn_core/tests/test_network.py
katduecker Nov 7, 2024
0d015c8
Update hnn_core/tests/test_network.py
katduecker Nov 7, 2024
957f3bd
Update hnn_core/network.py
katduecker Nov 7, 2024
d9ea104
Update hnn_core/network.py
katduecker Nov 7, 2024
403339b
update whats_new and fix flake8
katduecker Nov 7, 2024
0e0edf7
update whats_new
katduecker Nov 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions hnn_core/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,8 @@ def _insert_dipole(self, sec_name_apical):
dpp.ztan = seg_lens_z[-1]
self.dipole = h.Vector().record(self.dpl_ref)

def create_tonic_bias(self, amplitude, t0, tstop, loc=0.5):
def create_tonic_bias(self, amplitude, t0, tstop, sect_name='soma',
loc=0.5):
katduecker marked this conversation as resolved.
Show resolved Hide resolved
"""Create tonic bias at the soma.

Parameters
Expand All @@ -742,7 +743,8 @@ def create_tonic_bias(self, amplitude, t0, tstop, loc=0.5):
loc : float (0 to 1)
The location of the input in the soma section.
"""
stim = h.IClamp(self._nrn_sections['soma'](loc))

stim = h.IClamp(self._nrn_sections[sect_name](loc))
stim.delay = t0
stim.dur = tstop - t0
stim.amp = amplitude
Expand Down
1 change: 1 addition & 0 deletions hnn_core/cells_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ def pyramidal_ca(cell_name, pos, override_params=None, gid=None):
override_params['L5Pyr_dend_gbar_ca'] = gbar_ca
override_params['L5Pyr_dend_gnabar_hh2'] = gbar_na
override_params['L5Pyr_dend_gkbar_hh2'] = gbar_k
override_params['L5Pyr_soma_gbar_ca'] = 10.
katduecker marked this conversation as resolved.
Show resolved Hide resolved

cell = pyramidal(cell_name, pos, override_params=override_params,
gid=gid)
Expand Down
2 changes: 1 addition & 1 deletion hnn_core/extracellular.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class ExtracellularArray:
measured values of conductivity in rat cortex (note units there are mS/cm)
"""

def __init__(self, positions, *, conductivity=0.3, method='psa',
def __init__(self, positions, *, conductivity=0.3, method='lsa',
katduecker marked this conversation as resolved.
Show resolved Hide resolved
min_distance=0.5, times=None, voltages=None):

_validate_type(positions, (tuple, list), 'positions')
Expand Down
25 changes: 17 additions & 8 deletions hnn_core/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,8 @@ def _instantiate_drives(self, tstop, n_trials=1):
self.external_drives[
drive['name']]['events'].append(event_times)

def add_tonic_bias(self, *, cell_type=None, amplitude, t0=0, tstop=None):
def add_tonic_bias(self, *, cell_type=None, sect_name='soma',
bias_name='tonic', amplitude, t0=0, tstop=None):
"""Attaches parameters of tonic bias input for given cell types

Parameters
Expand All @@ -1142,6 +1143,10 @@ def add_tonic_bias(self, *, cell_type=None, amplitude, t0=0, tstop=None):
The name of the cell type to add a tonic input. When supplied,
a float value must be provided with the `amplitude` keyword.
Valid inputs are those listed in `net.cell_types`.
sect_name : str | 'soma'
section the bias should be added to.
bias_name : str | 'tonic'
katduecker marked this conversation as resolved.
Show resolved Hide resolved
The name of the bias.
amplitude: dict | float
A dictionary of cell type keys (str) to amplitude values (float).
Valid inputs for cell types are those listed in `net.cell_types`.
Expand Down Expand Up @@ -1169,6 +1174,7 @@ def add_tonic_bias(self, *, cell_type=None, amplitude, t0=0, tstop=None):
_validate_type(amplitude, (float, int), 'amplitude')

_add_cell_type_bias(network=self, cell_type=cell_type,
sect_name=sect_name, bias_name=bias_name,
amplitude=float(amplitude),
t_0=t0, t_stop=tstop)
else:
Expand All @@ -1180,6 +1186,7 @@ def add_tonic_bias(self, *, cell_type=None, amplitude, t0=0, tstop=None):

for _cell_type, _amplitude in amplitude.items():
_add_cell_type_bias(network=self, cell_type=_cell_type,
sect_name=sect_name, bias_name=bias_name,
amplitude=_amplitude,
t_0=t0, t_stop=tstop)

Expand Down Expand Up @@ -1648,7 +1655,7 @@ def __repr__(self):


def _add_cell_type_bias(network: Network, amplitude: Union[float, dict],
cell_type=None,
cell_type=None, sect_name='soma', bias_name='tonic',
t_0=0, t_stop=None):

if network is None:
Expand All @@ -1665,15 +1672,17 @@ def _add_cell_type_bias(network: Network, amplitude: Union[float, dict],
f'{list(network.cell_types.keys())}. '
f'Got {cell_type}')

if 'tonic' not in network.external_biases:
network.external_biases['tonic'] = dict()
if bias_name not in network.external_biases:
network.external_biases[bias_name] = dict()

if cell_type in network.external_biases['tonic']:
raise ValueError(f'Tonic bias already defined for {cell_type}')
if cell_type in network.external_biases[bias_name]:
raise ValueError(f'Bias named {bias_name} already defined '
f'for {cell_type}')
katduecker marked this conversation as resolved.
Show resolved Hide resolved

cell_type_bias = {
'amplitude': amplitude,
't0': t_0,
'tstop': t_stop
'tstop': t_stop,
'sect_name': sect_name
}
network.external_biases['tonic'][cell_type] = cell_type_bias
network.external_biases[bias_name][cell_type] = cell_type_bias
8 changes: 4 additions & 4 deletions hnn_core/network_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,10 @@ def _create_cells_and_drives(self, threshold, record_vsec=False,
else:
cell.build()
# add tonic biases
if ('tonic' in self.net.external_biases and
src_type in self.net.external_biases['tonic']):
cell.create_tonic_bias(**self.net.external_biases
['tonic'][src_type])
for bias in self.net.external_biases:
if src_type in self.net.external_biases[bias]:
cell.create_tonic_bias(**self.net.external_biases
[bias][src_type])
cell.record(record_vsec, record_isec, record_ca)

# this call could belong in init of a _Cell (with threshold)?
Expand Down
Loading