@@ -445,8 +445,33 @@ def getMechParams(self, mechanism):
445445
446446 def getAvailablePlots (self ):
447447 plots = ["plotRaster" , "plotSpikeHist" , "plotSpikeStats" ,"plotRatePSD" , "plotTraces" , "plotLFP" , "plotShape" , "plot2Dnet" , "plotConn" , "granger" ]
448+
448449 return [plot for plot in plots if plot not in list (self .simConfig .analysis .keys ())]
449450
451+ def getInclude (self , model ):
452+ with redirect_stdout (sys .__stdout__ ):
453+ if model in list (netpyne_geppetto .simConfig .analysis .keys ()):
454+ if 'include' in list (netpyne_geppetto .simConfig .analysis [model ].keys ()):
455+ return netpyne_geppetto .simConfig .analysis [model ]['include' ]
456+ else :
457+ return False
458+ else :
459+ return False
460+
461+ def getGIDs (self ):
462+ # pop sizes and gids returned in a dict
463+ out = {}
464+ with redirect_stdout (sys .__stdout__ ):
465+ for key in self .netParams .popParams .keys ():
466+ if 'numCells' in self .netParams .popParams [key ]:
467+ out [key ] = self .netParams .popParams [key ]['numCells' ]
468+ else :
469+ out [key ] = 0
470+
471+ out ['gids' ] = int (np .sum ([v for k , v in list (out .items ())]))
472+
473+ return out
474+
450475 def deleteParam (self , model , label ):
451476 try :
452477 if isinstance (model , list ): # just for cellParams
@@ -522,26 +547,48 @@ def header(title, spacer='-'):
522547 return utils .getJSONError ("Error while importing the NetPyNE model" , sys .exc_info ())
523548
524549
525- def propagate (self , obj , label , cond , new , old ):
526- for key in obj .keys ():
527- if label in list (obj [key ][cond ].keys ()):
528- if isinstance (obj [key ][cond ][label ], str ):
529- if old == obj [key ][cond ][label ]:
530- if new == '' or new == None :
531- obj [key ].pop (label )
532- else :
533- obj [key ][cond ][label ] = new
534-
535- elif isinstance (obj [key ][cond ][label ], list ):
536- if old in obj [key ][cond ][label ]:
537- if new == '' or new == None :
538- obj [key ][cond ][label ] = [ value for value in obj [key ][cond ][label ] if value != old ]
550+ def propagate (self , model , label , cond , new , old ):
551+ with redirect_stdout (sys .__stdout__ ):
552+ if model == 'analysis' :
553+ analysis = getattr (self .simConfig , model )
554+ for plot in analysis .keys ():
555+ if cond in analysis [plot ].keys ():
556+ for index , item in enumerate (analysis [plot ][cond ]):
557+ if isinstance (item , str ):
558+ if item == old :
559+ if new == None :
560+ analysis [plot ][cond ].remove (item )
561+ break
562+ else :
563+ analysis [plot ][cond ][index ] = new
564+ else :
565+ if isinstance (item [0 ], str ):
566+ if item [0 ] == old :
567+ if new == None :
568+ analysis [plot ][cond ].pop (index )
569+ break
570+ else :
571+ analysis [plot ][cond ][index ] = [new , item [1 ]]
572+ else :
573+ obj = getattr (self .netParams , model )
574+ for key in obj .keys ():
575+ if label in list (obj [key ][cond ].keys ()):
576+ if isinstance (obj [key ][cond ][label ], str ):
577+ if old == obj [key ][cond ][label ]:
578+ if new == '' or new == None :
579+ obj [key ].pop (label )
580+ else :
581+ obj [key ][cond ][label ] = new
582+ elif isinstance (obj [key ][cond ][label ], list ):
583+ if old in obj [key ][cond ][label ]:
584+ if new == '' or new == None :
585+ obj [key ][cond ][label ] = [ value for value in obj [key ][cond ][label ] if value != old ]
586+ else :
587+ obj [key ][cond ][label ] = [ value if value != old else new for value in obj [key ][cond ][label ] ]
588+ if len (obj [key ][cond ][label ])== 0 :
589+ obj [key ][cond ].pop (label )
539590 else :
540- obj [key ][cond ][label ] = [ value if value != old else new for value in obj [key ][cond ][label ] ]
541- if len (obj [key ][cond ][label ])== 0 :
542- obj [key ][cond ].pop (label )
543- else :
544- pass
591+ pass
545592
546593 def propagate_field_rename (self , label , new , old ):
547594 def unique (label = label , old = old ):
@@ -562,8 +609,8 @@ def unique(label=label, old=old):
562609 return True
563610 else :
564611 if unique ():
565- for (model , cond ) in [['cellParams' ,'conds' ], ['connParams' , 'preConds' ], ['connParams' , 'postConds' ], ['stimTargetParams' , 'conds' ]]:
566- self .propagate (getattr ( self . netParams , model ) , label , cond , new , old )
612+ for (model , cond ) in [['cellParams' ,'conds' ], ['connParams' , 'preConds' ], ['connParams' , 'postConds' ], ['stimTargetParams' , 'conds' ], [ 'analysis' , 'include' ] ]:
613+ self .propagate (model , label , cond , new , old )
567614 return True
568615 else :
569616 return False
0 commit comments