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

MPI iclamp fix #332

Open
wants to merge 118 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
cf1d477
Initial draft auditory filternet
xpliu16 Feb 7, 2023
58b61fa
Trying different temporal envelope
xpliu16 Feb 10, 2023
27e5bdc
Work on spectral modulation filters
xpliu16 Feb 11, 2023
3e25b69
Auditory filternet refinement
xpliu16 Feb 26, 2023
298f344
Padding and other adjustments to auditory filters
xpliu16 Mar 2, 2023
6b2260e
Merge pull request #288 from xpliu16/aud_filternet
xpliu16 Mar 2, 2023
e98abf7
Handling delay, better documentation of filters, passing of threshold
xpliu16 Mar 14, 2023
3119343
Merge pull request #290 from xpliu16/aud_filternet
xpliu16 Mar 14, 2023
12dd888
Miscellaneous updates
xpliu16 Mar 29, 2023
55ff413
Merge pull request #295 from xpliu16/aud_filternet
xpliu16 Mar 29, 2023
5397e16
Aud filternet b_t now variable
xpliu16 Jun 2, 2023
4a67a29
Merge branch 'develop' into aud_filternet
xpliu16 Jun 2, 2023
42a3361
Merge pull request #304 from xpliu16/aud_filternet
xpliu16 Jun 2, 2023
94326fe
Fixed psi and direction reading bug
xpliu16 Jun 28, 2023
83a554a
Merge branch 'develop' of https://github.com/xpliu16/bmtk into aud_fi…
xpliu16 Jun 28, 2023
9c1954a
Merge pull request #310 from xpliu16/aud_filternet
xpliu16 Jun 28, 2023
0e1cea0
Fixed bug on "delay"
xpliu16 Jun 28, 2023
f452c2c
Merge pull request #311 from xpliu16/aud_filternet
xpliu16 Jun 28, 2023
840c205
update comsol module
nilsvanrompaey Sep 19, 2023
3f0e163
update bio_comsol example
nilsvanrompaey Sep 19, 2023
a703bcb
add comsol .mph file (without saved results)
nilsvanrompaey Sep 19, 2023
21af469
small changes
nilsvanrompaey Sep 19, 2023
89b7218
add dir structure and probe image
nilsvanrompaey Sep 19, 2023
8837f2e
fix small inconsistency
nilsvanrompaey Sep 28, 2023
9fe3e37
fix small errors
nilsvanrompaey Sep 29, 2023
0e3fef4
mpi iclamp fix
tjbanks Oct 4, 2023
37f6891
Adding example with instructions for using NSG with BioNet
kaeldai Oct 5, 2023
ae1b2c4
Merge pull request #333 from kaeldai/examples/nsg
kaeldai Oct 5, 2023
1fe1d04
Enabling numba speedup on non-separable FilterNet
shixnya Nov 1, 2023
8b0c5e5
Revert "Enabling numba speedup on non-separable FilterNet"
shixnya Nov 1, 2023
bb8dce1
Making non-separable FilterNet faster (#335)
shixnya Nov 1, 2023
3b07c06
Fixing FilterNet bug (ON/OFF offset, issue #339) (#340)
shixnya Nov 8, 2023
121044e
Made use of numba optional to prevent conflicts with NEST simulator
kaeldai Nov 14, 2023
b8896dc
adding some minor alterations to bionet to run more robustly
kaeldai Nov 14, 2023
61cb7c8
Merge pull request #341 from kaeldai/fix/numba_tests_nest
kaeldai Nov 14, 2023
741b639
adding PointNet module to insert NEST synapse weight_recorder
kaeldai Dec 27, 2023
990024e
Adding PointNet example with plastic synapses (and recordings)
kaeldai Dec 27, 2023
5669589
Adding weight_recorder module documentation
kaeldai Dec 27, 2023
4eaa609
Merge pull request #345 from kaeldai/feature/nest_weight_recorder
kaeldai Dec 27, 2023
734c3e2
add init files to fix pytest
kaeldai Feb 21, 2024
39ebecf
Merge pull request #347 from kaeldai/fix/pytest_issues
kaeldai Feb 21, 2024
4a9c230
Making physical spacing optional for drifting gratings + faster separ…
shixnya Feb 21, 2024
187681f
Including forgotten docstring (#348)
shixnya Feb 23, 2024
4e398f7
Adding example for running all-active cell simulation with full axon
kaeldai Feb 26, 2024
ba481de
Merge pull request #349 from kaeldai/example/bio_all_active_sweep
kaeldai Feb 26, 2024
aaa0882
fixing issue with writing to nwb with mpi and adding some extra docum…
kaeldai Feb 27, 2024
6e2db7a
Merge pull request #350 from kaeldai/documentation/nwb_update
kaeldai Feb 27, 2024
aba21e2
Use inspect module in add_movie for GratingMovie
HDictus Mar 13, 2024
dd4ff02
resolving merge conflicts
kaeldai Mar 13, 2024
0187d16
fixing issue with spatial_filter
kaeldai Mar 13, 2024
49a03e9
Merge pull request #352 from HDictus/movie-phase
kaeldai Mar 18, 2024
9a7c039
fixing one last issue
kaeldai Mar 20, 2024
3c4e97f
fixing merge
kaeldai Mar 20, 2024
50ef1cf
merge was not fully saved
kaeldai Mar 20, 2024
ea4e7c3
fixing import issue
kaeldai Mar 20, 2024
11fbb1a
Merge pull request #351 from AllenInstitute/aud_filternet
kaeldai Mar 20, 2024
d54264d
Fixing issue if model_template column is missing
kaeldai Mar 21, 2024
ae5d43a
Merge pull request #353 from AllenInstitute/aud_filternet
kaeldai Mar 21, 2024
7e040d0
Including forgotten docstring (#354)
shixnya Mar 21, 2024
a45d4a5
Auditory filternet tutorial draft
xpliu16 Mar 29, 2024
7804cfd
Merge pull request #355 from xpliu16/develop
xpliu16 Mar 29, 2024
2e86c2a
Auditory filternet tutorial update
xpliu16 Mar 29, 2024
efc2ab0
Merge branch 'AllenInstitute:develop' into develop
xpliu16 Mar 29, 2024
6949431
Merge pull request #356 from xpliu16/develop
xpliu16 Mar 29, 2024
025e3be
Merge pull request #330 from nilsvanrompaey/develop
kaeldai Apr 1, 2024
b9a332a
minor changes to bio_comsol example
kaeldai Apr 1, 2024
163464b
Merge pull request #357 from kaeldai/updates/comsol_example
kaeldai Apr 1, 2024
9a38165
updating version number
kaeldai Apr 1, 2024
e57c84c
Merge pull request #358 from kaeldai/feature/ver_bump_1.1.0
kaeldai Apr 1, 2024
9d7d4d9
updated aud filternet
xpliu16 Apr 16, 2024
de99e32
Merge branch 'develop' of https://github.com/xpliu16/bmtk into develop
xpliu16 Apr 16, 2024
aa16f2e
Merge pull request #359 from xpliu16/develop
xpliu16 Apr 16, 2024
bbd03c2
Fix error that random seed is not set when using SpikeGenerator(seed=0)
chenziao Apr 20, 2024
44256e3
Merge pull request #360 from chenziao/develop
kaeldai Apr 23, 2024
f31ed36
fixing minor bug with spike-trains unit test
kaeldai Apr 23, 2024
afd8fbb
Merge pull request #361 from kaeldai/fix/test_psg_variable
kaeldai Apr 23, 2024
6a9c97e
adding tutorial assests
kaeldai Apr 24, 2024
3565183
Making changes to automatically support ModelDB Hay model HOC Template
kaeldai Apr 30, 2024
9bab3c1
Fixing filter_movie/ example
kaeldai Apr 30, 2024
704e4e4
Merge pull request #364 from kaeldai/fix/lgn_movies_examples
kaeldai Apr 30, 2024
82adf09
small change to morphology to fix how sections are parsed
kaeldai May 1, 2024
f153237
Found Hoc models that would fail calls to hobj.soma[0] since it cell …
kaeldai May 2, 2024
d66d82e
adding ability for pointnet to use cell_model decorator when loading …
kaeldai May 3, 2024
22a9bdc
making updates to spontaneous syns inputs
kaeldai May 4, 2024
1f29142
adding ability in bionet and pointnet to handle custom spikes-train f…
kaeldai May 4, 2024
ad2b466
bionet iclamps can now support ranged section selection
kaeldai May 5, 2024
a6aac43
Adding ctdb download utils
kaeldai May 5, 2024
3973dc6
Updating ECP Plotting function
kaeldai May 7, 2024
2b200cd
Adding fix for when running current clamps across multiple cores
kaeldai May 7, 2024
d1f41a1
Merge pull request #366 from kaeldai/fix/multicore_iclamp
kaeldai May 7, 2024
1e2a37e
Merge pull request #362 from kaeldai/fix/aud_filternet_tut
kaeldai May 8, 2024
c475407
Fixing compartment reports to include magic statement when running mu…
kaeldai May 12, 2024
d2c1229
Merge pull request #367 from kaeldai/fix/add_membrane_magic
kaeldai May 12, 2024
17d92c0
Enabling to run run.sim() more than once (#368)
shixnya May 20, 2024
824a66a
NESTML example network
xpliu16 May 20, 2024
b3662cb
Merge pull request #369 from xpliu16/develop
kaeldai May 22, 2024
20044d7
updating way templates can be loaded to fix an ordering bug
kaeldai May 22, 2024
cd29402
fixing issues with unit tests
kaeldai Jun 14, 2024
862fd7f
Merge branch 'update/workshop-2024' of https://github.com/AllenInstit…
kaeldai Jun 14, 2024
def7f3e
Merge pull request #372 from AllenInstitute/update/workshop-2024
kaeldai Jun 14, 2024
af62e77
fixes for Ch5 of workshop tutorial; remove dt attribute in filternet …
kaeldai Jun 16, 2024
1b58f44
small fix to xstim and larger update of SEClamp module
kaeldai Jun 25, 2024
4eb01f9
Adding fix to make using NESTML a bit more robust + another NESTML ex…
kaeldai Jun 25, 2024
6409899
Fixing FilterNet behavior for frame_rate != 1000.0
shixnya Jun 26, 2024
1e67511
some minor fixes
kaeldai Jul 6, 2024
f1d7071
Merge pull request #377 from kaeldai/update/workshop-2024
kaeldai Jul 6, 2024
acd94d6
Merge pull request #378 from AllenInstitute/update/workshop-2024
kaeldai Jul 6, 2024
169c5f5
Merge branch 'AllenInstitute:develop' into develop
shixnya Jul 8, 2024
81f99e4
Update version to 1.1.1
kaeldai Jul 8, 2024
889c55d
Merge pull request #379 from AllenInstitute/version-update-1.1.1
kaeldai Jul 8, 2024
c08acac
Update version to 1.1.1
kaeldai Jul 8, 2024
a5dcedb
Allowing grating contrast to be 0.
shixnya Aug 29, 2024
9775f66
Merge branch 'AllenInstitute:develop' into develop
shixnya Aug 29, 2024
b1ebdf1
Merge pull request #375 from shixnya/develop
kaeldai Aug 29, 2024
60b6af6
mpi iclamp fix
tjbanks Oct 4, 2023
0b9c242
changes
tjbanks Sep 11, 2024
159c543
fix
tjbanks Sep 11, 2024
6b174b2
fix
tjbanks Sep 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ docs/tutorial/sim_ch*
docs/tutorial/sim_dyn_syn
examples/**/output*/**
examples/bio_simulated_annealing/updated_weights/*
examples/filter_movie/boc/*
examples/filter_movie/bob_images/*
examples/filter_movie/movies/*
/.eggs
benchmarks/.asv
**/x86_64/**
Expand Down
2 changes: 1 addition & 1 deletion bmtk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
__version__ = '1.0.8'
__version__ = '1.1.1'
50 changes: 38 additions & 12 deletions bmtk/analyzer/ecp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
import h5py
import matplotlib.pyplot as plt
import numpy as np
from decimal import Decimal

from bmtk.utils.sonata.config import SonataConfig
from bmtk.simulator.utils import simulation_reports
# from mpl_toolkits.axes_grid1.anchored_artists import AnchoredSizeBar
from mpl_toolkits.axes_grid1.anchored_artists import AnchoredSizeBar
import matplotlib.font_manager as fm


def _get_ecp_path(ecp_path=None, config=None, report_name=None):
Expand Down Expand Up @@ -55,30 +57,54 @@ def plot_ecp(config_file=None, report_name=None, ecp_path=None, title=None, show
channels = ecp_h5['/ecp/channel_id'][()]
fig, axes = plt.subplots(len(channels), 1)
fig.text(0.04, 0.5, 'channel id', va='center', rotation='vertical')
v_min, v_max = ecp_h5['/ecp/data'][()].min(), ecp_h5['/ecp/data'][()].max()
# print(v_max - v_min)
# exit()

for idx, channel in enumerate(channels):
data = ecp_h5['/ecp/data'][:, idx]
# print(channel, np.min(data), np.max(data))
axes[idx].plot(time_traces, data)
axes[idx].spines["top"].set_visible(False)
axes[idx].spines["right"].set_visible(False)
axes[idx].set_yticks([])
axes[idx].set_ylabel(channel)
axes[idx].set_ylim([v_min, v_max])

if idx+1 != len(channels):
axes[idx].spines["bottom"].set_visible(False)
axes[idx].set_xticks([])
else:
axes[idx].set_xlabel('timestamps (ms)')
# scalebar = AnchoredSizeBar(axes[idx].transData,
# 2.0, '1 mV', 1,
# pad=0,
# borderpad=0,
# # color='b',
# frameon=True,
# # size_vertical=1.001,
# # fontproperties=fontprops
# )
#
# axes[idx].add_artist(scalebar)


if idx == 0:
scale_bar_size = (v_max-v_min)/2.0
scale_bar_label = f'{scale_bar_size:.2E}'
# print(scale_bar_label)
# exit()
fontprops = fm.FontProperties(size='x-small')

scalebar = AnchoredSizeBar(
axes[idx].transData,
size=scale_bar_size,
label=scale_bar_label,
loc='upper right',
pad=0.1,
borderpad=0.5,
sep=5,
# color='b',
frameon=False,
size_vertical=scale_bar_size,
# size_vertical=1.001,
fontproperties=fontprops
)
axes[idx].add_artist(scalebar)

# label = scalebar.txt_label
# label.set_rotation(270.0)
# label.set_verticalalignment('bottom')
# label.set_horizontalalignment('left')

if title:
fig.set_title(title)
Expand Down
2 changes: 2 additions & 0 deletions bmtk/builder/builder_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ def check_properties_across_ranks(properties, graph_type='node'):
phash = hashlib.md5(pval.encode('utf-8')).hexdigest()

elif isinstance(pval, (int, float, bool)):
if np.isnan(pval):
pval = 'NONE'
phash = pval

elif isinstance(pval, (list, tuple)):
Expand Down
3 changes: 2 additions & 1 deletion bmtk/simulator/bionet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
from bmtk.simulator.bionet.pyfunction_cache import synapse_model, synaptic_weight, cell_model, add_weight_function
from bmtk.simulator.bionet.pyfunction_cache import synapse_model, synaptic_weight, cell_model, add_weight_function, model_processing, \
spikes_generator
from bmtk.simulator.bionet.config import Config
from bmtk.simulator.bionet.bionetwork import BioNetwork
from bmtk.simulator.bionet.biosimulator import BioSimulator
Expand Down
45 changes: 37 additions & 8 deletions bmtk/simulator/bionet/biocell.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from bmtk.simulator.bionet.morphology import Morphology
import six

import neuron
from neuron import h

pc = h.ParallelContext() # object to access MPI methods
Expand Down Expand Up @@ -74,9 +75,6 @@ class BioCell(Cell):
def __init__(self, node, population_name, bionetwork):
super(BioCell, self).__init__(node=node, population_name=population_name, network=bionetwork)

# Set up netcon object that can be used to detect and communicate cell spikes.
self.set_spike_detector(bionetwork.spike_threshold)

# Determine number of segments and store a list of all sections.
self._secs = []
self._secs_by_id = []
Expand Down Expand Up @@ -105,6 +103,10 @@ def __init__(self, node, population_name, bionetwork):
self._seg_coords = None
self.build_morphology()

# Set up netcon object that can be used to detect and communicate cell spikes.
self.set_spike_detector(bionetwork.spike_threshold)


def build_morphology(self):
morph_base = Morphology.load(hobj=self.hobj, morphology_file=self.morphology_file, cache_seg_props=True)

Expand All @@ -126,6 +128,10 @@ def morphology(self):
"""The actual Morphology object instanstiation"""
return self._morphology

@property
def soma(self):
return self.morphology.soma

@property
def seg_coords(self):
"""Coordinates for segments/sections of the morphology, need to make public for ecp, xstim, and other
Expand All @@ -144,7 +150,7 @@ def seg_coords(self):
return self.morphology.seg_coords

def set_spike_detector(self, spike_threshold):
nc = h.NetCon(self.hobj.soma[0](0.5)._ref_v, None, sec=self.hobj.soma[0]) # attach spike detector to cell
nc = h.NetCon(self.soma[0](0.5)._ref_v, None, sec=self.soma[0])
nc.threshold = spike_threshold
pc.cell(self.gid, nc) # associate gid with spike detector

Expand Down Expand Up @@ -437,18 +443,41 @@ def __init__(self, node, population_name, bionetwork):
self._vecstim = h.VecStim()
self._vecstim.play(self._spike_trains)

self._precell_filter = bionetwork.spont_syns_filter
self._precell_filter = bionetwork.spont_syns_filter_pre
self._postcell_filter = bionetwork.spont_syns_filter_post
assert(isinstance(self._precell_filter, dict))

def _matches_filter(self, src_node):
def _matches_filter(self, src_node, trg_node=None):
"""Check to see if the presynaptic cell matches the criteria specified"""
for k, v in self._precell_filter.items():
# Some key may not show up as node_variable
if k == 'population' and k not in src_node:
key_val = src_node.population_name
else:
key_val = src_node[k]

if isinstance(v, (list, tuple)):
if key_val not in v:
return False
else:
if key_val != v:
return False

trg_node = trg_node or self
for k, v in self._postcell_filter.items():
# Some key may not show up as node_variable
if k == 'population' and k not in trg_node:
key_val = trg_node._node.population_name
else:
key_val = trg_node[k]

if isinstance(v, (list, tuple)):
if src_node[k] not in v:
if key_val not in v:
return False
else:
if src_node[k] != v:
if key_val != v:
return False

return True

def _set_connections(self, edge_prop, src_node, syn_weight, stim=None):
Expand Down
18 changes: 10 additions & 8 deletions bmtk/simulator/bionet/bionetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ def __init__(self):
self._gid_pool = GidPool()

self.has_spont_syns = False
self.spont_syns_filter = None
self.spont_syns_filter_pre = None
self.spont_syns_filter_post = None
self.spont_syns_times = None

@property
Expand All @@ -88,7 +89,7 @@ def gid_pool(self):
def py_function_caches(self):
return nrn

def set_spont_syn_activity(self, precell_filter, timestamps):
def set_spont_syn_activity(self, precell_filter, postcell_filter, timestamps):
self._model_type_map = {
'biophysical': BioCellSpontSyn,
'point_process': PointProcessCellSpontSyns,
Expand All @@ -98,7 +99,8 @@ def set_spont_syn_activity(self, precell_filter, timestamps):
}

self.has_spont_syns = True
self.spont_syns_filter = precell_filter
self.spont_syns_filter_pre = precell_filter
self.spont_syns_filter_post = postcell_filter
self.spont_syns_times = timestamps

def get_node_id(self, population, node_id):
Expand Down Expand Up @@ -134,12 +136,12 @@ def add_nodes(self, node_population):
self._gid_pool.add_pool(node_population.name, node_population.n_nodes())
super(BioNetwork, self).add_nodes(node_population)

def get_virtual_cells(self, population, node_id, spike_trains):
def get_virtual_cells(self, population, node_id, spike_trains, spikes_generator=None, sim=None):
if node_id in self._virtual_nodes[population]:
return self._virtual_nodes[population][node_id]
else:
node = self.get_node_id(population, node_id)
virt_cell = VirtualCell(node, population, spike_trains)
virt_cell = VirtualCell(node, population, spike_trains, spikes_generator, sim)
self._virtual_nodes[population][node_id] = virt_cell
return virt_cell

Expand All @@ -151,7 +153,7 @@ def get_disconnected_cell(self, population, node_id, spike_trains):
virt_cell = self._disconnected_source_cells[population][node_id]
else:
node = self.get_node_id(population, node_id)
virt_cell = VirtualCell(node, population, spike_trains)
virt_cell = VirtualCell(node, population, spike_trains, self)
self._disconnected_source_cells[population][node_id] = virt_cell

return virt_cell
Expand Down Expand Up @@ -369,7 +371,7 @@ def find_edges(self, source_nodes=None, target_nodes=None):

return selected_edges

def add_spike_trains(self, spike_trains, node_set):
def add_spike_trains(self, spike_trains, node_set, spikes_generator=None, sim=None):
self._init_connections()

src_nodes = [node_pop for node_pop in self.node_populations if node_pop.name in node_set.population_names()]
Expand All @@ -379,7 +381,7 @@ def add_spike_trains(self, spike_trains, node_set):
if edge_pop.virtual_connections:
for trg_nid, trg_cell in self._rank_node_ids[edge_pop.target_nodes].items():
for edge in edge_pop.get_target(trg_nid):
src_cell = self.get_virtual_cells(source_population, edge.source_node_id, spike_trains)
src_cell = self.get_virtual_cells(source_population, edge.source_node_id, spike_trains, spikes_generator, sim)
trg_cell.set_syn_connection(edge, src_cell, src_cell)

elif edge_pop.mixed_connections:
Expand Down
57 changes: 21 additions & 36 deletions bmtk/simulator/bionet/biosimulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ def from_config(cls, config, network, set_recordings=True):
if sim_input.input_type == 'syn_activity':
network.set_spont_syn_activity(
precell_filter=sim_input.params['precell_filter'],
postcell_filter=sim_input.params.get('postcell_filter', {}),
timestamps=sim_input.params['timestamps']
)

Expand All @@ -346,53 +347,37 @@ def from_config(cls, config, network, set_recordings=True):

# TODO: Need to create a gid selector
for sim_input in inputs.from_config(config):
if sim_input.input_type == 'spikes' and sim_input.module in ['nwb', 'csv', 'sonata']:
if sim_input.input_type == 'spikes' and sim_input.module in ['nwb', 'csv', 'sonata', 'h5']:
io.log_info('Building virtual cell stimulations for {}'.format(sim_input.name))
path = sim_input.params['input_file']
spikes = SpikeTrains.load(path=path, file_type=sim_input.module, **sim_input.params)
# node_set_opts = sim_input.params.get('node_set', 'all')
node_set = network.get_node_set(sim_input.node_set)
network.add_spike_trains(spikes, node_set)
network.add_spike_trains(
spike_trains=spikes,
node_set=node_set,
spikes_generator=None,
sim=sim
)

elif sim_input.input_type == 'spikes' and sim_input.module == 'function':
io.log_info('Building virtual cell stimulations for {}'.format(sim_input.name))
# path = sim_input.params.get['input_file']
spikes_generator = sim_input.params['spikes_function']
node_set = network.get_node_set(sim_input.node_set)
network.add_spike_trains(
spike_trains=None,
node_set=node_set,
spikes_generator=spikes_generator,
sim=sim
)

elif sim_input.module == 'IClamp':
sim.add_mod(mods.IClampMod(input_type=sim_input.input_type, **sim_input.params))

elif sim_input.module == "SEClamp":
node_set = network.get_node_set(sim_input.node_set)
try:
len(sim_input.params['amps'])
except:
sim_input.params['amps']=[float(sim_input.params['amps'])]
sim.add_mod(mods.SEClamp(input_type=sim_input.input_type, **sim_input.params))

try:
len(sim_input.params['durations'])
except:
sim_input.params['durations']=[float(sim_input.params['durations'])]

amplitudes = sim_input.params['amps']
durations = sim_input.params['durations']
rs = None

if "rs" in sim_input.params.keys():
try:
len(sim_input.params['rs'])
except:
sim_input.params['rs']=[float(sim_input.params['rs'])]
if len(sim_input.params['rs'])>1:
sim_input.params['rs']=[float(i) for i in sim_input.params['rs']]
rs = sim_input.params["rs"]

try:
sim_input.params['gids']
except:
sim_input.params['gids'] = None
if sim_input.params['gids'] is not None:
gids = sim_input.params['gids']
else:
gids = list(node_set.gids())

sim.attach_se_voltage_clamp(amplitudes, durations, gids, rs)

elif sim_input.module == 'xstim':
sim.add_mod(mods.XStimMod(**sim_input.params))

Expand Down
6 changes: 6 additions & 0 deletions bmtk/simulator/bionet/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ def get_connection_info(self):

def set_syn_connections(self, edge_prop, src_node, stim=None):
raise NotImplementedError

def get_section(self, sec_name, sec_index):
raise NotImplementedError

def __contains__(self, node_prop):
return node_prop in self._node

def __getitem__(self, node_prop):
return self._node[node_prop]
12 changes: 11 additions & 1 deletion bmtk/simulator/bionet/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ def create_output_dir(self):
io.setup_output_dir(self.output_dir, self.log_file)

def load_nrn_modules(self):
nrn.load_neuron_modules(self.mechanisms_dir, self.templates_dir)
nrn.load_neuron_modules(
mechanisms_dir=self.mechanisms_dir,
templates_dir=self.templates_dir,
default_templates=self.use_default_templates,
use_old_import3d=self.use_old_import3d
)

def build_env(self):
self.io = io
Expand All @@ -52,3 +57,8 @@ def build_env(self):

pc.barrier()
self.load_nrn_modules()

def _set_class_props(self):
super(Config, self)._set_class_props()
self.use_old_import3d = self.run.get('use_old_import3d', False)
self.use_default_templates = self.run.get('use_old_import3d', True)
Loading
Loading