Skip to content

Pop._morphSegCoords can cause KeyError if diversity and XStim are enabled #852

@john-judge

Description

@john-judge

Describe the bug

KeyError when using the new extracellular stimulation feature ('XStim') with multiple cell morphology diversity. When diversity is enabled it may be that some cell types have multiple morphologies and some only a single. calcRelativeSegCoords seems to fail to distinguish how self._morphSegCoords is structured in this edge case.

Related to the issue #772 with LFP. XStim feature also calls into Pop.calcRelativeSegCoords().

I turned on cfg.includeParamsLabel = True as directed by the fix in #772, as I was seeing KeyErrors with 'label'. After that, still had a KeyError with self._morphSegCoords missing some 'label's.

Then inspected network.pop.py on line 641, diversity handling for populating Pop._morphSegCoords is branched based on number of cells and was not working properly. I put in a quick fix that works for my case only; expected behavior was restored.

Reproducing the bug

Steps to reproduce the behavior:

  1. Multicompartment model with multiple morphologies and diversity =True. I believe at least one population need to have only 1 morphology subpopulation to hit this edge case but I have not confirmed this.
  2. Add cfg stim 'XStim' for extracellular stim per the docs
  3. cfg.includeParamsLabel = True
  4. Call addStims()
  5. KeyError for 'label' in CompartCell in calcAbsSegCoords

Expected behavior

No KeyError, but rather Pop._morphSegCoords properly populates. I think branching logic in calcRelativeSegCoords line 641 for diversity handling should be more robust.

System information

  • OS and version: CentOS Stream 9
  • NetPyNE version: Development branch

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions