Skip to content

Commit 220249e

Browse files
author
facu.r
committed
merge with development
2 parents bfd98b4 + 3344d3c commit 220249e

2 files changed

Lines changed: 52 additions & 2 deletions

File tree

netpyne_ui/netpyne_geppetto.py

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,57 @@ def deleteParam(self, paramToDel):
438438

439439
def validateFunction(self, functionString):
440440
return utils.ValidateFunction(functionString, netParams.__dict__)
441-
441+
442+
def generateScript(self, metadata):
443+
def convert2bool(string):
444+
return string.replace('true', 'True').replace('false', 'False')
445+
446+
def header(title, spacer='-'):
447+
return '\n# ' + title.upper() + ' ' + spacer*(77-len(title)) + '\n'
448+
449+
try :
450+
params = ['popParams' , 'cellParams', 'synMechParams']
451+
params += ['connParams', 'stimSourceParams', 'stimTargetParams']
452+
453+
fname = metadata['scriptName'] if metadata['scriptName'][-3:]=='.py' else metadata['scriptName']+'.py'
454+
455+
with open(fname, 'w') as script:
456+
script.write('from netpyne import specs, sim\n')
457+
script.write(header('documentation'))
458+
script.write("''' Script generated with NetPyNE-UI. Please visit:\n")
459+
script.write(" - https://www.netpyne.org\n - https://github.com/MetaCell/NetPyNE-UI\n'''\n")
460+
script.write(header('script', spacer='='))
461+
script.write('netParams = specs.NetParams()\n')
462+
script.write('simConfig = specs.SimConfig()\n')
463+
script.write(header('single value attributes'))
464+
for attr, value in netParams.__dict__.items():
465+
if attr not in params:
466+
if value!=getattr(specs.NetParams(), attr):
467+
script.write('netParams.' + attr + ' = ')
468+
script.write(convert2bool(json.dumps(value, indent=4))+'\n')
469+
470+
script.write(header('network attributes'))
471+
for param in params:
472+
for key, value in getattr(netParams, param).items():
473+
script.write("netParams." + param + "['" + key + "'] = ")
474+
script.write(convert2bool(json.dumps(value, indent=4))+'\n')
475+
476+
script.write(header('network configuration'))
477+
for attr, value in simConfig.__dict__.items():
478+
if value!=getattr(specs.SimConfig(), attr):
479+
script.write('netParams.' + attr + ' = ')
480+
script.write(convert2bool(json.dumps(value, indent=4))+'\n')
481+
482+
script.write(header('create simulate analyze network'))
483+
script.write('sim.createSimulateAnalyze(netParams=netParams, simConfig=simConfig)\n')
484+
485+
script.write(header('end script', spacer='='))
486+
487+
return self.getJSONReply()
488+
489+
except:
490+
return self.getJSONError("Error while importing the NetPyNE model", traceback.format_exc())
491+
442492
class LoopTimer(threading.Thread):
443493
"""
444494
a Timer that calls f every interval

utilities/install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def main(argv):
4646
clone('https://github.com/openworm/pygeppetto.git','pygeppetto','v0.4.1-M1')
4747
subprocess.call(['pip', 'install', '-e', '.'], cwd='./pygeppetto/')
4848

49-
clone('https://github.com/Neurosim-lab/netpyne.git','netpyne','0.7.9')
49+
clone('https://github.com/Neurosim-lab/netpyne.git','netpyne','v0.7.9')
5050
subprocess.call(['pip', 'install', '-e', '.'], cwd='./netpyne/')
5151

5252
clone('https://github.com/openworm/org.geppetto.frontend.jupyter.git','org.geppetto.frontend.jupyter','v0.4.1-M2','', True )

0 commit comments

Comments
 (0)