Page 1 of 1

Issue with asc vs swc file format

Posted: Mon Aug 05, 2024 11:00 pm
by louiepatch
Hi all, I have encountered an issue recently that I am not sure how to solve.

I am instantiating a neuron using a python class that loads a neurolucida .asc file:

Code: Select all

from neuron import h, gui
h.load_file('import3d.hoc')
h.load_file("stdlib.hoc")

class toyCell_a:  
    def __init__(self):
        self.load_morphology()
    def __str__(self):
        return 'cellID'
    def load_morphology(self):
        cell = h.Import3d_Neurolucida3()
        cell.input('file.asc')
        i3d = h.Import3d_GUI(cell, False)
        i3d.instantiate(self) 

cell_a = toyCell_a()
When I try to use the NEURON GUI to access variables of any python section, I get an error. For example, if I open a voltage axis graph, and in the "plot what" menu select _pysec.cellID.apic[11].v(0.5), I get the following error:

Code: Select all

NEURON: syntax error
 near line 1
 {hoc_pointer_(&_pysec.cellID.apic[11].v( 0.5 ))}
                       ^
        doNotify()
Exception in gui thread
I don't encounter this issue if I:
- Create the neuron outside of a class, ie just load the .asc file and instantiate the neuron as a top-level function
- Change the morphology file to an .swc format and load using h.Import3d_SWC_read(), while still creating the neuron within a class

And finally if I remove def __str__(self): function from the cell class, I see no python sections listed at all.

I am using NEURON 8.2.6 and Python 3.11.9

Is this a bug, or am I using these functions incorrectly?

Thanks for any help.


EDIT: I just tried changing the str function to match the variable name I assign when calling the toyCell_a class:

Code: Select all

def __str__(self):
        return 'cell_a'
and now I do not encounter any issues when trying to access python sections via the GUI