Skip to content

Commit

Permalink
minor fixes.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jchen6727 committed Nov 8, 2023
1 parent bbb8cf7 commit 606676c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions netpyne/batch/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ def save(self, filename):
sim.saveJSON(filename, dataSave)

def setCfgNestedParam(self, paramLabel, paramVal):
if '.' in paramLabel: #TODO [email protected] 195196 replace with my crawler code?
paramLabel = paramLabel.split('.')
if isinstance(paramLabel, tuple):
container = self.cfg
for ip in range(len(paramLabel) - 1):
Expand Down
8 changes: 7 additions & 1 deletion netpyne/network/subconn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected] 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 = [
Expand Down
8 changes: 5 additions & 3 deletions netpyne/specs/netParams.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 [email protected] 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)

Expand Down Expand Up @@ -832,6 +832,8 @@ def todict(self):
return replaceDictODict(self.__dict__)

def setNestedParam(self, paramLabel, paramVal):
if '.' in paramLabel: #TODO [email protected] 835836 replace with my crawler code?
paramLabel = paramLabel.split('.')
if isinstance(paramLabel, list):
container = self
for ip in range(len(paramLabel) - 1):
Expand Down

0 comments on commit 606676c

Please sign in to comment.