Trying to use SectionRefs crashing the simulation.

Anything that doesn't fit elsewhere.
Post Reply
NickHananeia
Posts: 10
Joined: Fri Jun 14, 2019 1:09 pm

Trying to use SectionRefs crashing the simulation.

Post by NickHananeia »

Hi,

I'm trying to integrate some new functionality into a mountain of legacy code, and this functionality comes from something that's written half in Python and half in HOC, so I'm unsure of what my errors are doing.

I'm trying to add a spine to my detailed morphology, and I'm trying to use exactly the same spine as in someone else's project.

So I added this function to my cell's template:

Code: Select all

proc add_spine_ra(){localobj sref
	PI = 3.14159265359  
	sref = $o1
	x = $2
	neck_diam = $3
	neck_len = $4
	spine_head_area = $5
	ra = $6
	create spine[2]

	L_head = 2*sqrt(spine_head_area /4/PI) //sphere has the same surface area as cylinder with L=diam
											
	diam_head = L_head
	
	spine[0]{
		L = neck_len
		diam = neck_diam
		insert pas
		cm =CM
	    g_pas=1/RM
		e_pas = E_PAS
		Ra = ra
		regspines.append()
	}
	spine[1]{
		L = L_head
		diam = diam_head
		insert pas
		cm =CM
	    g_pas=1/RM
		e_pas = E_PAS
		Ra = ra
		regspines.append()

	}
	connect  spine[1](0) ,spine[0](1)
	sref.sec{ 
		connect spine[0](0), x
	}
}
The original source of where this was called was written in Python, and my current code is in HOC so I had to make some adjustments.

In my code I access a target section, and try to type this:

Code: Select all

target_section = new SectionRef()
	
	
	//add a spine to the cell
	add_spine_ra(target_section, 0.5, 0.25,1.35,2.8,201.78)
This causes a segmentation fault, and I'm totally unsure what I'm doing wrong. What I aim to do is place a spine at the halfway segment of the section I'm aiming at, and as far as I know I just need to pass the function a section ref and a segment index (in addition to its parameters). I aim to get this working first for currently accessed section, then adapt for an arbitrary number of them.

This is a bit of a sloppy hack job here, since my original idea (use my external tools to add a spine) doesn't seem to be working right.
ted
Site Admin
Posts: 6287
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Trying to use SectionRefs crashing the simulation.

Post by ted »

Try getting something working on a real simple toy model with just a couple of sections and minimal membrane properties at the top level (not wrapped in a class definition). Use nothing but hoc at first. Then try calling it from python.

After that, if your real application involves a section that belongs to an instance of a cell class, wrap your toy model cell inside a class definition, and get your code working with that--again, using nothing but hoc at first, then try calling it from python.

Also, a few questions: what version of NEURON are you using, and in what software environment (Mac, Windows, Linux)? and if not the latest version (8.whatever), is there a reason why not?
NickHananeia
Posts: 10
Joined: Fri Jun 14, 2019 1:09 pm

Re: Trying to use SectionRefs crashing the simulation.

Post by NickHananeia »

I'm using 7.8.2.

I'll try that soon - I suspect that the issue is related to my extracellular stimulation implementation not playing nice with runtime changes to the morphology of the cell.
Post Reply