Skip to content

Commit 91ec3dd

Browse files
rodriguez_facundorodriguez-facundo
authored andcommitted
rebase with development
1 parent 4ee1596 commit 91ec3dd

1 file changed

Lines changed: 90 additions & 7 deletions

File tree

netpyne_ui/netpyne_geppetto.py

Lines changed: 90 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -426,14 +426,17 @@ def getAvailablePlots(self):
426426
plots = ["plotRaster", "plotSpikeHist", "plotSpikeStats","plotRatePSD", "plotTraces", "plotLFP", "plotShape", "plot2Dnet", "plotConn", "granger"]
427427
return [plot for plot in plots if plot not in list(self.simConfig.analysis.keys())]
428428

429-
def deleteParam(self, paramToDel):
430-
logging.debug("Checking if netParams."+paramToDel+" is not null")
431-
if eval("self.netParams."+paramToDel) is not None:
432-
exec("del self.netParams.%s" % (paramToDel))
433-
logging.debug('Parameter netParams.'+paramToDel+' has been deleted')
429+
def deleteParam(self, model, label):
430+
if isinstance(model, list): # just for cellParams
431+
if len(model)==1:
432+
netParams.cellParams[model[0]]["secs"].pop(label)
433+
elif len(model)==2:
434+
netParams.cellParams[model[0]]["secs"][model[1]]["mechs"].pop(label)
435+
else:
436+
pass
434437
else:
435-
logging.debug('Parameter '+paramToDel+' is null, not deleted')
436-
438+
getattr(netParams, model).pop(label)
439+
437440
def validateFunction(self, functionString):
438441
return validateFunction(functionString, self.netParams.__dict__)
439442

@@ -487,6 +490,86 @@ def header(title, spacer='-'):
487490
except:
488491
return utils.getJSONError("Error while importing the NetPyNE model", sys.exc_info())
489492

493+
494+
def propagate(self, obj, label, cond, new, old):
495+
for key in obj.keys():
496+
if label in list(obj[key][cond].keys()):
497+
if isinstance(obj[key][cond][label], str):
498+
if old==obj[key][cond][label]:
499+
if new=='' or new==None:
500+
obj[key].pop(label)
501+
else:
502+
obj[key][cond][label] = new
503+
504+
elif isinstance(obj[key][cond][label], list):
505+
if old in obj[key][cond][label]:
506+
if new=='' or new==None:
507+
obj[key][cond][label] = [ value for value in obj[key][cond][label] if value!=old]
508+
else:
509+
obj[key][cond][label] = [ value if value!=old else new for value in obj[key][cond][label] ]
510+
if len(obj[key][cond][label])==0:
511+
obj[key][cond].pop(label)
512+
else:
513+
pass
514+
515+
def propagate_field_rename(self, label, new, old):
516+
def unique(label=label, old=old):
517+
classes = []
518+
for p in netParams.popParams:
519+
if label in netParams.popParams[p]:
520+
classes.append(netParams.popParams[p][label])
521+
if classes.count(old)>1:
522+
return False
523+
else:
524+
return True
525+
526+
if label=='source':
527+
self.propagate_stim_source_rename(new, old)
528+
return True
529+
elif label=='synMech':
530+
self.propagate_syn_mech_rename(new, old)
531+
return True
532+
else:
533+
if unique():
534+
for (model, cond) in [['cellParams','conds'], ['connParams', 'preConds'], ['connParams', 'postConds'], ['stimTargetParams', 'conds']]:
535+
self.propagate(getattr(netParams, model), label, cond, new, old)
536+
return True
537+
else:
538+
return False
539+
540+
def propagate_section_rename(self, new, old):
541+
for label in netParams.cellParams:
542+
if 'secs' in netParams.cellParams[label]:
543+
for sec in netParams.cellParams[label]['secs']:
544+
if 'topol' in netParams.cellParams[label]['secs'][sec]:
545+
if 'parentSec' in netParams.cellParams[label]['secs'][sec]['topol']:
546+
if netParams.cellParams[label]['secs'][sec]['topol']['parentSec'] == old:
547+
if new == None:
548+
netParams.cellParams[label]['secs'][sec]['topol'].pop('parentSec')
549+
else:
550+
netParams.cellParams[label]['secs'][sec]['topol']['parentSec'] = new
551+
552+
def propagate_stim_source_rename(self, new, old):
553+
for label in netParams.stimTargetParams:
554+
if old==netParams.stimTargetParams[label]['source']:
555+
if new==None:
556+
netParams.stimTargetParams[label].pop('source')
557+
else:
558+
netParams.stimTargetParams[label]['source'] = new
559+
560+
def propagate_syn_mech_rename(self, new, old):
561+
for label in netParams.stimTargetParams:
562+
if 'source' in netParams.stimTargetParams[label]:
563+
if netParams.stimTargetParams[label]['source'] in netParams.stimSourceParams:
564+
if 'type' in netParams.stimSourceParams[netParams.stimTargetParams[label]['source']]:
565+
if netParams.stimSourceParams[netParams.stimTargetParams[label]['source']]['type']=='NetStim':
566+
if old==netParams.stimTargetParams[label]['synMech']:
567+
if new==None:
568+
netParams.stimTargetParams[label].pop('synMech')
569+
else:
570+
netParams.stimTargetParams[label]['synMech'] = new
571+
572+
490573
logging.info("Initialising NetPyNE UI")
491574
netpyne_geppetto = NetPyNEGeppetto()
492575
logging.info("NetPyNE UI initialised")

0 commit comments

Comments
 (0)