@@ -687,6 +687,56 @@ def _parseComptField( self, comptList, plotSpec, knownFields ):
687687 else :
688688 return comptList , kf [1 ]
689689
690+ # Returns vector of source objects, and the field to use.
691+ # Specifically for _buildMoogli() as there the coordinates of the compartments are needed.
692+ # plotSpec is of the form
693+ # [ region_wildcard, region_expr, path, field, title]
694+ def _MoogparseComptField ( self , comptList , plotSpec , knownFields ):
695+ # Put in stuff to go through fields if the target is a chem object
696+ field = plotSpec .field
697+ if not field in knownFields :
698+ print ("Warning: Rdesigneur::_parseComptField: Unknown field '{}'" .format ( field ) )
699+ return (), ""
700+
701+ kf = knownFields [field ] # Find the field to decide type.
702+ # if kf[0] in ['CaConcBase', 'ChanBase', 'NMDAChan', 'VClamp']:
703+ # objList = self._collapseElistToPathAndClass( comptList, plotSpec.relpath, kf[0] )
704+ # return objList, kf[1]
705+ if field in [ 'n' , 'conc' , 'volume' ]:
706+ path = plotSpec .relpath
707+ pos = path .find ( '/' )
708+ if pos == - 1 : # Assume it is in the dend compartment.
709+ path = 'dend/' + path
710+ pos = path .find ( '/' )
711+ chemCompt = path [:pos ]
712+ if chemCompt [- 5 :] == "_endo" :
713+ chemCompt = chemCompt [0 :- 5 ]
714+ cc = moose .element ( self .modelPath + '/chem/' + chemCompt )
715+ voxelVec = []
716+ temp = [ self ._makeUniqueNameStr ( i ) for i in comptList ]
717+ #print( temp )
718+ #print( "#####################" )
719+ comptSet = set ( temp )
720+ #em = [ moose.element(i) for i in cc.elecComptMap ]
721+ em = sorted ( [ self ._makeUniqueNameStr (i [0 ]) for i in cc .elecComptMap ] )
722+ #print( em )
723+ #print( "=================================================" )
724+
725+ voxelVec = [i for i in range (len ( em ) ) if em [i ] in comptSet ]
726+ # Here we collapse the voxelVec into objects to plot.
727+ allObj = moose .vec ( self .modelPath + '/chem/' + plotSpec .relpath )
728+ #print "####### allObj=", self.modelPath + '/chem/' + plotSpec[2]
729+ if len ( allObj ) >= len ( voxelVec ):
730+ objList = [ allObj [int (j )] for j in voxelVec ]
731+ else :
732+ objList = []
733+ print ( "Warning: Rdesigneur::_parseComptField: unknown Object: '" , plotSpec .relpath , "'" )
734+ #print "############", chemCompt, len(objList), kf[1]
735+ return objList , kf [1 ]
736+
737+ else :
738+ return comptList , kf [1 ]
739+
690740
691741 def _buildPlots ( self ):
692742 knownFields = {
@@ -769,8 +819,8 @@ def _buildMoogli( self ):
769819 pair = i .elecpath + " " + i .geom_expr
770820 dendCompts = self .elecid .compartmentsFromExpression [ pair ]
771821 spineCompts = self .elecid .spinesFromExpression [ pair ]
772- dendObj , mooField = self ._parseComptField ( dendCompts , i , knownFields )
773- spineObj , mooField2 = self ._parseComptField ( spineCompts , i , knownFields )
822+ dendObj , mooField = self ._MoogparseComptField ( dendCompts , i , knownFields )
823+ spineObj , mooField2 = self ._MoogparseComptField ( spineCompts , i , knownFields )
774824 assert ( mooField == mooField2 )
775825 mooObj3 = dendObj + spineObj
776826 numMoogli = len ( mooObj3 )
0 commit comments