Skip to content

Commit 1c62c73

Browse files
author
Lucas Rebscher
committed
Merge branch 'development' into feature/batch_support
2 parents 845d154 + 0d52ffd commit 1c62c73

4 files changed

Lines changed: 144 additions & 6 deletions

File tree

netpyne_ui/netpyne_geppetto.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,12 @@ def importModel(self, modelParameters):
513513
# Import Model attributes
514514
self.netParams = getattr(net_params_module_name, str(modelParameters["netParamsVariable"]))
515515

516+
if isinstance(self.netParams, dict):
517+
self.netParams = specs.NetParams(self.netParams)
518+
519+
if isinstance(self.simConfig, dict):
520+
self.simConfig = specs.SimConfig(self.simConfig)
521+
516522
for key, value in self.netParams.cellParams.items():
517523
if hasattr(value, 'todict'):
518524
self.netParams.cellParams[key] = value.todict()
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
from netpyne import specs
2+
3+
# Network parameters
4+
netParams = {} # object of class NetParams to store the network parameters
5+
6+
netParams['cellParams'] = {}
7+
netParams['popParams'] = {}
8+
netParams['stimSourceParams'] = {}
9+
netParams['stimTargetParams'] = {}
10+
netParams['synMechParams'] = {}
11+
netParams['connParams'] = {}
12+
13+
## Cell parameters
14+
secs = {} # dict with section info
15+
secs['soma'] = {'geom': {}, 'mechs': {}}
16+
secs['soma']['geom'] = {'diam': 12, 'L': 12, 'Ra': 100.0, 'cm': 1} # soma geometry
17+
secs['soma']['mechs']['hh'] = {'gnabar': 0.12, 'gkbar': 0.036, 'gl': 0.0003, 'el': -54.3} # soma hh mechanism
18+
19+
secs['dend'] = {'geom': {}, 'mechs': {}}
20+
secs['dend']['geom'] = {'diam': 1.0, 'L': 200.0, 'Ra': 100.0, 'cm': 1}
21+
secs['dend']['topol'] = {'parentSec': 'soma', 'parentX': 1.0, 'childX': 0} # dend geometry
22+
secs['dend']['mechs']['pas'] = {'g': 0.001, 'e': -70} # dend pas mechanism
23+
24+
netParams['cellParams']['pyr'] = {'secs': secs} # add dict to list of cell parameters
25+
26+
## Population parameters
27+
netParams['popParams']['E'] = {'cellType': 'pyr', 'numCells': 40}
28+
29+
# Stimulation parameters
30+
netParams['stimSourceParams']['IClamp1'] = {'type': 'IClamp', 'dur': 5, 'del': 20, 'amp': 0.1}
31+
netParams['stimTargetParams']['IClamp1->cell0'] = {'source': 'IClamp1', 'conds': {'cellList':[0]}, 'sec':'dend', 'loc':1.0}
32+
33+
34+
# Synaptic mechanism parameters
35+
netParams['synMechParams']['exc'] = {'mod': 'Exp2Syn', 'tau1': 0.1, 'tau2': 1.0, 'e': 0}
36+
37+
38+
# Connectivity parameters
39+
netParams['connParams']['E->E'] = {
40+
'preConds': {'pop': 'E'},
41+
'postConds': {'pop': 'E'},
42+
'weight': 0.005, # weight of each connection
43+
'probability': 0.1,
44+
'delay': 5, # delay min=0.2, mean=13.0, var = 1.4
45+
'synMech': 'exc',
46+
'sec': 'dend'}
47+
48+
# Simulation options
49+
simConfig = specs.SimConfig() # object of class SimConfig to store simulation configuration
50+
51+
simConfig.duration = 0.2*1e3 # Duration of the simulation, in ms
52+
simConfig.dt = 0.1 # Internal integration timestep to use
53+
simConfig.verbose = False # Show detailed messages
54+
simConfig.recordTraces = {'V_soma':{'sec':'soma','loc':0.5,'var':'v'},
55+
'V_dend': {'sec': 'dend', 'loc': 1.0, 'var':'v'}} # Dict with traces to record
56+
simConfig.recordCells = [0]
57+
simConfig.recordStep = 0.1 # Step size in ms to save data (eg. V traces, LFP, etc)
58+
simConfig.filename = 'gui_tut1' # Set file output name
59+
simConfig.saveJson = False # Save params, network and sim output to pickle file
60+
simConfig.analysis['iplotTraces'] = {'include': [0], 'overlay': True}
61+
simConfig.analysis['iplotRaster'] = {'markerSize': 5, 'showFig': True}
62+
63+
64+
if __name__ == '__main__':
65+
netpyne_geppetto.netParams=netParams
66+
netpyne_geppetto.simConfig=simConfig
67+
68+
#from netpyne import sim
69+
#sim.createSimulateAnalyze(netParams, simConfig)
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import unittest
2+
import os
3+
import sys
4+
import logging
5+
import json, urllib.request
6+
7+
import netpyne
8+
9+
from netpyne import specs, sim
10+
from netpyne_ui.netpyne_model_interpreter import NetPyNEModelInterpreter
11+
import neuron
12+
import subprocess
13+
14+
from netpyne_ui.netpyne_geppetto import NETPYNE_WORKDIR_PATH
15+
from netpyne_ui.netpyne_geppetto import NetPyNEGeppetto
16+
17+
netpyne.__gui__ = False
18+
sys.path.insert(0, NETPYNE_WORKDIR_PATH)
19+
20+
class TestNetPyNEModelInterpreter(unittest.TestCase):
21+
22+
@classmethod
23+
def setUpClass(cls):
24+
HERE = os.path.dirname(os.path.realpath(__file__))
25+
ROOT = os.path.dirname(HERE)
26+
cls.path = NETPYNE_WORKDIR_PATH
27+
modelpath = os.path.join(NETPYNE_WORKDIR_PATH, 'mod')
28+
subprocess.call(["rm", "-r", os.path.join(modelpath, "x86_64")])
29+
owd = os.getcwd()
30+
os.chdir(modelpath)
31+
p = subprocess.check_output(["nrnivmodl"])
32+
os.chdir(owd)
33+
try:
34+
neuron.load_mechanisms(modelpath)
35+
except:
36+
logging.error("Error loading mechanisms", exc_info=True)
37+
38+
def test_dict_import_1(self):
39+
print("------------------------------------")
40+
print("Dictionary transform importModel:")
41+
print("------------------------------------")
42+
43+
# response = urllib.request.urlopen("https://www.opensourcebrain.org/projects/netpyneshowcase/repository/revisions/test_py36/raw/NetPyNE/UI/HHCellNetwork.txt.json")
44+
netpyne_info = {} #json.loads(response.read())
45+
46+
# print(type(netpyne_info['net']['params']))
47+
48+
path = next(filter(lambda p: os.path.join('tests', 'backend') in p, sys.path), None)
49+
50+
netpyne_info['compileMod'] = False
51+
netpyne_info['loadMod'] = False
52+
netpyne_info['modFolder'] = "mod"
53+
netpyne_info['netParamsPath'] = os.path.join(path, 'models')
54+
netpyne_info['netParamsModuleName'] = "gui_import_dict"
55+
netpyne_info['netParamsVariable'] = "netParams"
56+
netpyne_info['simConfigPath'] = os.path.join(path, 'models')
57+
netpyne_info['simConfigModuleName'] = "gui_import_dict"
58+
netpyne_info['simConfigVariable'] = "simConfig"
59+
60+
netpyne = NetPyNEGeppetto()
61+
netpyne.importModel(netpyne_info)
62+
63+
if __name__ == '__main__':
64+
try:
65+
unittest.main()
66+
except SystemExit as inst:
67+
if inst.args[0]: # raised by sys.exit(True) when tests failed
68+
raise

webapp/components/topbar/SwitchPageButton.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,8 @@ class SwitchPageButton extends Component {
4343
}
4444

4545
handleClick = (selectedOption) => {
46-
const instantiate = this.props.modelState === MODEL_STATE.NOT_INSTANTIATED;
4746
if (selectedOption === CREATE_NETWORK) {
48-
if (instantiate) {
49-
this.props.createNetwork();
50-
} else {
51-
this.props.showNetwork();
52-
}
47+
this.props.createNetwork();
5348
} else if (selectedOption === SIMULATE) {
5449
if (this.props.experimentInDesign) {
5550
this.props.openLaunchDialog();

0 commit comments

Comments
 (0)