@@ -540,26 +540,46 @@ def header(title, spacer='-'):
540540 return utils .getJSONError ("Error while importing the NetPyNE model" , sys .exc_info ())
541541
542542
543- def propagate (self , obj , label , cond , new , old ):
544- for key in obj .keys ():
545- if label in list (obj [key ][cond ].keys ()):
546- if isinstance (obj [key ][cond ][label ], str ):
547- if old == obj [key ][cond ][label ]:
548- if new == '' or new == None :
549- obj [key ].pop (label )
550- else :
551- obj [key ][cond ][label ] = new
552-
553- elif isinstance (obj [key ][cond ][label ], list ):
554- if old in obj [key ][cond ][label ]:
555- if new == '' or new == None :
556- obj [key ][cond ][label ] = [ value for value in obj [key ][cond ][label ] if value != old ]
543+ def propagate (self , model , label , cond , new , old ):
544+ with redirect_stdout (sys .__stdout__ ):
545+ if model == 'analysis' :
546+ analysis = getattr (self .simConfig , model )
547+ for plot in analysis .keys ():
548+ if cond in analysis [plot ].keys ():
549+ for index , item in enumerate (analysis [plot ][cond ]):
550+ if isinstance (item , str ):
551+ if new == None :
552+ analysis [plot ][cond ].pop (index )
553+ break
554+ elif item == old :
555+ analysis [plot ][cond ][index ] = new
556+ else :
557+ if isinstance (item [0 ], str ):
558+ if new == None :
559+ analysis [plot ][cond ].pop (index )
560+ break
561+ elif item [0 ] == old :
562+ analysis [plot ][cond ][index ] = [new , item [1 ]]
563+ else :
564+ obj = getattr (self .netParams , model )
565+ for key in obj .keys ():
566+ if label in list (obj [key ][cond ].keys ()):
567+ if isinstance (obj [key ][cond ][label ], str ):
568+ if old == obj [key ][cond ][label ]:
569+ if new == '' or new == None :
570+ obj [key ].pop (label )
571+ else :
572+ obj [key ][cond ][label ] = new
573+ elif isinstance (obj [key ][cond ][label ], list ):
574+ if old in obj [key ][cond ][label ]:
575+ if new == '' or new == None :
576+ obj [key ][cond ][label ] = [ value for value in obj [key ][cond ][label ] if value != old ]
577+ else :
578+ obj [key ][cond ][label ] = [ value if value != old else new for value in obj [key ][cond ][label ] ]
579+ if len (obj [key ][cond ][label ])== 0 :
580+ obj [key ][cond ].pop (label )
557581 else :
558- obj [key ][cond ][label ] = [ value if value != old else new for value in obj [key ][cond ][label ] ]
559- if len (obj [key ][cond ][label ])== 0 :
560- obj [key ][cond ].pop (label )
561- else :
562- pass
582+ pass
563583
564584 def propagate_field_rename (self , label , new , old ):
565585 def unique (label = label , old = old ):
@@ -580,8 +600,8 @@ def unique(label=label, old=old):
580600 return True
581601 else :
582602 if unique ():
583- for (model , cond ) in [['cellParams' ,'conds' ], ['connParams' , 'preConds' ], ['connParams' , 'postConds' ], ['stimTargetParams' , 'conds' ]]:
584- self .propagate (getattr ( self . netParams , model ) , label , cond , new , old )
603+ for (model , cond ) in [['cellParams' ,'conds' ], ['connParams' , 'preConds' ], ['connParams' , 'postConds' ], ['stimTargetParams' , 'conds' ], [ 'analysis' , 'include' ] ]:
604+ self .propagate (model , label , cond , new , old )
585605 return True
586606 else :
587607 return False
0 commit comments