From 606676c02086c6fc836b8a96c160ab6a4fb8bd06 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 8 Nov 2023 07:20:31 -0500 Subject: [PATCH] minor fixes. subconn with KeyError raise that is slightly more descriptive batch and netParams supporting '.' traversal updated the secList to not break when a section (generally axon) without pt3d exists --- netpyne/batch/batch.py | 2 ++ netpyne/network/subconn.py | 8 +++++++- netpyne/specs/netParams.py | 8 +++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/netpyne/batch/batch.py b/netpyne/batch/batch.py index 0cb831917..02e7e99db 100644 --- a/netpyne/batch/batch.py +++ b/netpyne/batch/batch.py @@ -192,6 +192,8 @@ def save(self, filename): sim.saveJSON(filename, dataSave) def setCfgNestedParam(self, paramLabel, paramVal): + if '.' in paramLabel: #TODO jchen6727@gmail.com 195196 replace with my crawler code? + paramLabel = paramLabel.split('.') if isinstance(paramLabel, tuple): container = self.cfg for ip in range(len(paramLabel) - 1): diff --git a/netpyne/network/subconn.py b/netpyne/network/subconn.py index 8d310a985..f91b0cc07 100644 --- a/netpyne/network/subconn.py +++ b/netpyne/network/subconn.py @@ -238,7 +238,13 @@ def subcellularConn(self, allCellTags, allPopTags): gridY = subConnParam['density']['gridY'] gridSigma = subConnParam['density']['gridValues'] - somaX, somaY, _ = posFromLoc(postCell.secs['soma'], 0.5) # get cell pos move method to Cell! + #TODO jchen.6727@gmail.com 241247 'soma' is not always the name of the soma section + try: + somaX, somaY, _ = posFromLoc(postCell.secs['soma'], 0.5) # get cell pos move method to Cell! + except KeyError: + raise KeyError( + "Error in subcellularConn: there is no section named soma in cell {}".format(postCell.gid) + ) if 'fixedSomaY' in subConnParam['density']: # is fixed cell soma y, adjust y grid accordingly fixedSomaY = subConnParam['density'].get('fixedSomaY') gridY = [ diff --git a/netpyne/specs/netParams.py b/netpyne/specs/netParams.py index e5db3bc3b..29d569c1f 100644 --- a/netpyne/specs/netParams.py +++ b/netpyne/specs/netParams.py @@ -694,7 +694,7 @@ def addCellParamsSecList(self, label, secListName, somaDist=None, somaDistY=None return secList = [] - for secName, sec in cellRule.secs.items(): + for secName, sec in cellRule['secs'].items(): if 'pt3d' in sec['geom']: pt3d = sec['geom']['pt3d'] midpoint = int(len(pt3d) / 2) @@ -708,8 +708,8 @@ def addCellParamsSecList(self, label, secListName, somaDist=None, somaDistY=None secList.append(secName) else: - print('Error adding secList: Sections do not contain 3d points') - return + #TODO jchen.6727@gmail.com 711713 more descriptive message, don't break on axon. + print("Error adding {} to {}: {} does not contain 3d points".format(secName, secListName, secName)) cellRule.secLists[secListName] = list(secList) @@ -832,6 +832,8 @@ def todict(self): return replaceDictODict(self.__dict__) def setNestedParam(self, paramLabel, paramVal): + if '.' in paramLabel: #TODO jchen6727@gmail.com 835836 replace with my crawler code? + paramLabel = paramLabel.split('.') if isinstance(paramLabel, list): container = self for ip in range(len(paramLabel) - 1):