Skip to content

Commit

Permalink
Nov.15
Browse files Browse the repository at this point in the history
  • Loading branch information
tianqi-cheng committed Nov 15, 2023
1 parent 5b88e52 commit 34f79fe
Showing 1 changed file with 37 additions and 7 deletions.
44 changes: 37 additions & 7 deletions hnn_core/netpyne_model.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# import itertools as it
# from copy import deepcopy
# from collections import OrderedDict
import itertools as it
from copy import deepcopy
from collections import OrderedDict

# import numpy as np
# import warnings
import numpy as np
import warnings

# from .drives import _drive_cell_event_times
# from .drives import _get_target_properties, _add_drives_from_params
Expand All @@ -17,6 +17,9 @@


from netpyne import specs, sim
from neuron import h

from netpyne.cell.inputs import createEvokedPattern


class NetPyne_Model(object):
Expand Down Expand Up @@ -113,12 +116,19 @@ def __init__(self, params, add_drives_from_params=False,
'synMech': 'exc'} # synaptic mechanism


def add_evoked_drive(self):

# def add_evoked_drive(self):

def add_evoked_drive(self, mu, sigma, numspikes, location,
n_drive_cells, synaptic_delays=0.1,
probability=1.0, event_seed=2):

# def add_evoked_drive(self, name, *, mu, sigma, numspikes, location,
# n_drive_cells='n_cells', cell_specific=True,
# weights_ampa=None, weights_nmda=None,
# space_constant=3., synaptic_delays=0.1,
# probability=1.0, event_seed=2, conn_seed=3):

"""Add an 'evoked' external drive to the network
# create drive cells and connect them to the real cells defined in the init function
Expand Down Expand Up @@ -201,17 +211,37 @@ def add_evoked_drive(self):
probability < 1.0, the random subset of gids targeted is the same.
"""


# Stimulation parameters
self.netParams.stimSourceParams['bkg'] = {'type': 'NetStim', 'rate': 10, 'noise': 0.5}
self.netParams.stimTargetParams['bkg->PYR'] = {'source': 'bkg', 'conds': {'cellType': 'PYR'}, 'weight': 0.01, 'delay': 1, 'synMech': 'exc'}
self.netParams.stimTargetParams['bkg->PYR'] = {'source': 'bkg', 'loc':location, 'conds': {'cellType': 'PYR'}, 'weight': 0.01, 'delay': synaptic_delays, 'synMech': 'exc'}


params = {'start':mu, 'startStd':sigma, 'numspikes':numspikes}
spkTimes = createEvokedPattern(params, rand=h.Random())

## Population parameters
self.netParams.popParams['artif1'] = {'cellModel': 'NetStim', 'cellType': 'bkg', 'numCells': n_drive_cells, 'start':spkTimes[0], 'number':numspikes, 'seed':event_seed, 'spkTimes': spkTimes}
self.netParams.popParams['artif2'] = {'cellModel': 'NetStim', 'cellType': 'bkg', 'numCells': n_drive_cells, 'start':spkTimes[0], 'number':numspikes, 'seed':event_seed, 'spkTimes': spkTimes} # ??? VecStim with spike times


## Cell connectivity rules
self.netParams.connParams['artif1->artif2'] = { # artif1 -> artif2 label
'preConds': {'pop': 'artif1'}, # conditions of presyn cells
'postConds': {'pop': 'artif2'}, # conditions of postsyn cells
'probability': probability,
'weight': 0.01, # synaptic weight
'delay': synaptic_delays,
'loc': location,
'synMech': 'exc'} # synaptic mechanism



def netpyne_model(params):
net = NetPyne_Model(params)
return net


def simulate_dipole_netpyne(net, dt=0.025, tstop=170):
# code to simulate netpyne model

Expand Down

0 comments on commit 34f79fe

Please sign in to comment.