ahwillia / PyNeuron-Toolbox

Some python functions to supplement the NEURON python module
MIT License
27 stars 15 forks source link

Cannot make a model a "target" into a NEURON network #10

Open SteMasoli opened 5 years ago

SteMasoli commented 5 years ago

Hi.

I have used your code, for the past year, without issues.

Now I'm trying to make a small scale network using PyNeuron-Toolbox to load the morphology of a model. I can correctly simulate, stimulate and record the cell in the network, but when i define it as a target for other cells, NEURONS replayed with a "NoneType".

I have tried the same code with another model, with a "built in" morphology, and everything is fine.

cell = self, which is critical, is present. Maybe defining self.soma[0] causes the issue but i cannot change it back to a classic self.soma.

ahwillia commented 5 years ago

If you can find a way to fix it, I'm happy to review a PR to merge the change!

On Sun, Jun 23, 2019, 3:58 AM Stefano notifications@github.com wrote:

Hi.

I have used your code, for the past year, without issues.

Now I'm trying to make a small scale network using PyNeuron-Toolbox to load the morphology of a model. I can correctly simulate, stimulate and record the cell in the network, but when i define it as a target for other cells, NEURONS replayed with a "NoneType".

I have tried the same code with another model, with a "built in" morphology, and everything is fine.

cell = self, which is critical, is present. Maybe defining self.soma[0] causes the issue but i cannot change it back to a classic self.soma.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ahwillia/PyNeuron-Toolbox/issues/10?email_source=notifications&email_token=AAE3NUIBDBCKVSPLSBJISGLP34ULLA5CNFSM4H2YKMHKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G3EERVA, or mute the thread https://github.com/notifications/unsubscribe-auth/AAE3NUKNGL6ZGV7FCWQXRHDP34ULLANCNFSM4H2YKMHA .

ramcdougal commented 5 years ago

Can you clarify what you mean by "NEURONS replayed with a 'NoneType'"?

Note that NEURON 7.5 and later (current version is 7.7) directly support instantiating a morphology in a Python cell class; an example method follows:

def load_morphology(self):
    h.load_file('stdlib.hoc') 
    h.load_file('import3d.hoc')
    cell = h.Import3d_SWC_read()
    cell.input('c91662.swc')  # or put whatever morphology file you want here
    i3d = h.Import3d_GUI(cell, 0)
    i3d.instantiate(self)

(The above is for SWC files. Other morphology file formats work with the appropriate reader class: Import3d_SWC_read for swc, Import3d_Neurolucida3 for Neurolucida V3, Import3d_MorphML for MorphML (level 1 of NeuroML), or Import3d_Eutectic_read for Eutectic.)

SteMasoli commented 5 years ago

Hi. The following code check the existence of the cell GID and target.

if self.pc.gid_exists(tgt_gid):
    print self.pc.gid_exists(tgt_gid)
    target = self.pc.gid2cell(tgt_gid)
    print target

If i load the model using PyNeuron-Toolbox: gid_exists is correctly 3 but "target" replays with "None". Then "AttributeError: 'NoneType' object has no attribute 'L_PF'" - L_PF is the name of the list with the synapses.

Trying with your code @ramcdougal, without changing anything else, self.soma[0] included: gid_exists is correctly 3 and reports <model_net.Model_net instance at 0x7fcb27046248> The connection is made and works.

Thank you. Best

ramcdougal commented 5 years ago

I'm glad that solution worked for you.

I believe the problem you ran into is that this code wasn't associating sections with cell objects. Can you see if the change at

https://github.com/ahwillia/PyNeuron-Toolbox/commit/36ada2da6b2d508a3e7f054c40239044103a2234

fixes your original problem?

Thank you.

SteMasoli commented 5 years ago

if the change at

36ada2d

fixes your original problem?

Yes, it solved the original issue.