Skip to content

AssertionError: Cell keyword argument morphology not recognized as neuron.h.SectionList #22

@to-br

Description

@to-br

In version 9.0.0 of neuron, upon creating a cell using an instance of neuron.h.SectionList as morphology argument, the keyword was not recognized. This led to an assertion error: "AssertionError: Could not recognize Cell keyword argument morphology as neuron.h.SectionList instance".

Steps to reproduce the behavior
import neuron
h = neuron.h
import LFPy
print(neuron.version)

soma = h.Section(name='soma')
soma.L = 20
soma.diam = 20
soma.insert('hh')

secs = h.SectionList()
secs.append(soma)

print("Type of SectionList:", type(secs))

cell_params = dict(
v_init=-65,
tstop=10,
dt=0.1,
)

cell = LFPy.Cell(morphology=secs,**cell_params)

Output:
AssertionError: Could not recognize Cell keyword argument morphology as neuron.h.SectionList instance

Possible solution:
In cell.py replace
assert isinstance(self.morphology, type(neuron.h.SectionList)),
("Could not recognize Cell keyword argument morphology as " +
"neuron.h.SectionList instance")
with
if not hasattr(self.morphology, "wholetree"):
raise TypeError ("Could not recognize Cell keyword argument morphology as " +
"neuron.h.SectionList instance")

Setup:

  • OS: Ubuntu 22.04
  • Python version: Python 3.12.3
  • NEURON version: 9.0.0
  • LFPy version: 2.2.4 (installed via pip)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions