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

Tests with netpyne format #12

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
4 changes: 3 additions & 1 deletion .github/workflows/omv-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ jobs:
- name: Install OMV
run: |
pip install git+https://github.com/OpenSourceBrain/osb-model-validation
pip install scipy sympy matplotlib cython pandas tables

pip install 'numpy<=1.23.0' # see https://github.com/OpenSourceBrain/osb-model-validation/issues/91

pip install scipy sympy matplotlib cython pandas tables


- name: Run OMV tests on engine ${{ matrix.engine }}
run: |
Expand Down
49 changes: 0 additions & 49 deletions .travis.yml

This file was deleted.

5 changes: 5 additions & 0 deletions NetPyNE/HHSmall/HHSmall.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,8 @@ def generate_netParams(*argv):
simConfig.analysis['plotRaster'] = True # Plot raster
simConfig.analysis['plotTraces'] = {'include': [2]} # Plot raster
simConfig.analysis['plot2Dnet'] = True # Plot 2D net cells and connections

simConfig.validateNetParams=True

cfg = simConfig
netParams = generate_netParams(None)
6 changes: 6 additions & 0 deletions NetPyNE/HHSmall/index.npjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"mod_folder": "../HHSmall",
"simConfig": "HHSmall.py",
"python_run": "init.py",
"netParams": "HHSmall.py"
}
10 changes: 10 additions & 0 deletions NetPyNE/HHSmall/init.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""
init.py

Starting script to run NetPyNE-based model.
"""

from netpyne import sim

cfg, netParams = sim.loadFromIndexFile('index.npjson')
sim.createSimulateAnalyze(netParams, cfg)
2 changes: 2 additions & 0 deletions NetPyNE/HybridTut/HybridTut.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,5 @@
simConfig.analysis['plotTraces'] = {'include': [1,51]} # plot recorded traces for this list of cells
simConfig.analysis['plotRatePSD'] = {'include': ['allCells', 'PYR_HH', 'PYR_Izhi'], 'Fs': 200, 'smooth': 10} # plot recorded traces for this list of cells


simConfig.validateNetParams=True
5 changes: 3 additions & 2 deletions NetPyNE/TwoCells/LEMS_TwoCell_netpyne_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@
}
},
"netpyne_changeset": "",
"netpyne_version": "1.0.6",
"netpyne_version": "1.0.7",
"simConfig": {
"addSynMechs": true,
"allowConnsWithWeight0": true,
Expand All @@ -702,7 +702,7 @@
"dt": 0.01,
"dump_coreneuron_model": false,
"duration": 700.0,
"filename": "/Users/padraig/neuroConstruct/osb/showcase/NetPyNEShowcase/NeuroML2/TwoCells/LEMS_TwoCell_netpyne",
"filename": "LEMS_TwoCell_netpyne",
"gatherOnlySimData": true,
"gpu": false,
"hParams": {
Expand All @@ -719,6 +719,7 @@
"printPopAvgRates": false,
"printRunTime": false,
"printSynsAfterRule": false,
"progressBar": 2,
"pt3dRelativeToCellLocation": true,
"rand123GlobalIndex": null,
"random123": false,
Expand Down
6 changes: 6 additions & 0 deletions NetPyNE/TwoCells/index.npjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"mod_folder": "../TwoCells",
"simConfig": "reload2.py",
"python_run": "init.py",
"netParams": "reload2.py"
}
10 changes: 10 additions & 0 deletions NetPyNE/TwoCells/init.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""
init.py

Starting script to run NetPyNE-based model.
"""

from netpyne import sim

cfg, netParams = sim.loadFromIndexFile('index.npjson')
sim.createSimulateAnalyze(netParams, cfg)
8 changes: 8 additions & 0 deletions NetPyNE/TwoCells/loadNML.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from LEMS_TwoCell_netpyne import NetPyNESimulation

n = NetPyNESimulation()
n.generate_json_only()

print("Validating: %s"%n.simConfig.validateNetParams)

cfg = n.simConfig
64 changes: 64 additions & 0 deletions NetPyNE/TwoCells/reload2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# From https://github.com/harshagurnani/GoC_Varied_Inputs/blob/ankur/Tests/single_cell/test_single_cell_netpyne_load.py

from pathlib import Path
from netpyne import sim
import json

json_file = Path('LEMS_TwoCell_netpyne_data.json')
netParams_dict = None
simConfig_dict = None

with json_file.open(mode='r') as f:
netpyne_info = json.load(f)

netParams_dict = netpyne_info['net']['params']
simConfig_dict = netpyne_info['simConfig']

'''
simConfig_dict['saveJson'] = False # Prevent overwriting json gnerated by nml export
simConfig_dict['saveDat'] = True # Save data from this run
print('> Creating, simulating, analyzing...')
sim.createSimulateAnalyze(netParams=netParams_dict, simConfig=simConfig_dict,
output=False)

print(' - simConfig_dict (%s) with keys: \n %s'%(type(simConfig_dict),simConfig_dict.keys()))
print(' - netParams_dict (%s) with keys: \n %s'%(type(netParams_dict),netParams_dict.keys()))
print(" - netParams_dict['cellParams']: \n %s"%(netParams_dict['cellParams']))
'''

from netpyne.specs.simConfig import SimConfig
from netpyne.specs.netParams import NetParams

cfg = SimConfig(simConfig_dict)
cfg.validateNetParams = True
cfg.verbose = True


for cell in netParams_dict['cellParams']:
for sec in netParams_dict['cellParams'][cell]['secs']:
if len(netParams_dict['cellParams'][cell]['secs'][sec]['ions'])==0:
netParams_dict['cellParams'][cell]['secs'][sec]['ions']['none']={'e':0,'i':0,"o":0}
for ion_name in netParams_dict['cellParams'][cell]['secs'][sec]['ions']:
ion = netParams_dict['cellParams'][cell]['secs'][sec]['ions'][ion_name]
if not 'o' in ion: ion['o'] = 0
if not 'i' in ion: ion['i'] = 0
print('>> %s - %s - %s'%(cell, sec, ion))

netParams = NetParams(netParams_dict)

print(' - simConfig (%s) with keys: \n %s'%(type(cfg),cfg.todict().keys()))
print(' - netParams (%s) with keys: \n %s'%(type(netParams),netParams.todict().keys()))




import netpyne
#netpyne.sim.validator.validateNetParams = lambda a: (False, False)

from netpyne.sim.validator import validateNetParams

print('==============================')
validateNetParams(netParams)
print('==============================')

print('> Done...')
3 changes: 2 additions & 1 deletion NetPyNE/UI/HHCellNetwork.txt_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
}
},
"netpyne_changeset": "",
"netpyne_version": "1.0.6",
"netpyne_version": "1.0.7",
"simConfig": {
"addSynMechs": true,
"allowConnsWithWeight0": true,
Expand Down Expand Up @@ -212,6 +212,7 @@
"printPopAvgRates": false,
"printRunTime": false,
"printSynsAfterRule": false,
"progressBar": 2,
"pt3dRelativeToCellLocation": true,
"rand123GlobalIndex": null,
"random123": false,
Expand Down
5 changes: 4 additions & 1 deletion NetPyNE/UI/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
'''
def convertAndImportLEMSSimulation(lemsFileName, verbose=True):

## Why do these need to be set?? TODO: take out!
sim.nhosts = 5
sim.rank = 1

fullLemsFileName = os.path.abspath(lemsFileName)
if verbose:
print(
Expand All @@ -43,7 +47,6 @@ def convertAndImportLEMSSimulation(lemsFileName, verbose=True):
print("All keys: {}".format(netpyne_info.keys()))
print("net keys: {}".format(netpyne_info['net'].keys()))


sim.loadAll(json_filename)

print("Loaded network into NetPyNE containing %s which would run for %s ms"%([d for d in sim.net.params.popParams.keys()], sim.cfg.duration))
Expand Down
Loading
Loading