Skip to content

Commit e66335b

Browse files
committed
moogList properly handled
1 parent b4aac15 commit e66335b

File tree

3 files changed

+56
-6
lines changed

3 files changed

+56
-6
lines changed

python/rdesigneur/moogul.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def drawForTheFirstTime( self, ax ):
218218
class MooNeuron( MooDrawable ):
219219
''' Draws collection of line segments of defined dia and color'''
220220
def __init__( self,
221-
neuronId,
221+
mooObj,
222222
fieldInfo,
223223
field = 'Vm',
224224
relativeObj = '.',
@@ -235,12 +235,12 @@ def __init__( self,
235235
colormap = colormap, lenScale = lenScale,
236236
diaScale = diaScale, autoscale = autoscale,
237237
valMin = valMin, valMax = valMax )
238-
self.neuronId = neuronId
238+
self.mooObj = mooObj
239239
self.updateCoords()
240240

241241
def updateCoords( self ):
242242
''' Obtains coords from the associated cell'''
243-
self.compts_ = moose.wildcardFind( self.neuronId.path + "/#[ISA=CompartmentBase]" )
243+
self.compts_ = self.mooObj
244244
# Matplotlib3d isn't able to do full rotations about an y axis,
245245
# which is what the NeuroMorpho models use, so
246246
# here we shuffle the axes around. Should be an option.

python/rdesigneur/rdesigneur.py

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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 )

python/rdesigneur/rmoogli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def makeMoogli( rd, mooObj, args, fieldInfo ):
3939
valMin = ymin, valMax = ymax )
4040
viewer.addDrawable( reacSystem )
4141
else:
42-
neuron = moogul.MooNeuron( rd.elecid, fieldInfo,
42+
neuron = moogul.MooNeuron( mooObj, fieldInfo,
4343
field = mooField, relativeObj = relObjPath,
4444
valMin = ymin, valMax = ymax )
4545
print( "min = {}, max = {}".format(ymin, ymax) )

0 commit comments

Comments
 (0)