Segfault when running serval simulations in a row

When Python is the interpreter, what is a good
design for the interface to the basic NEURON
concepts.

Moderator: hines

Post Reply
jere19
Posts: 1
Joined: Thu May 06, 2010 10:25 am

Segfault when running serval simulations in a row

Post by jere19 » Thu May 06, 2010 10:38 am

Hello
I've written a python function to simulate the effect of extracellular stimulation on an axon.
If i call the function once, there's no problem. But if i call it again it fails with a segmentation fault and no other message.
I tried to use Python debugger but i didn't get more info.
All i could identify is that it seems to come from the initialization. I think i'm doing something wrong, but i can't see what.

Here are the files : http://www.lirmm.fr/~laforet/pyaxon.zip
- the function itself : pyAxon.py
- a simple test file calling it : test.py


I'd really appreciate if someone could point me in the right direction.

Jeremy

ted
Site Admin
Posts: 5591
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Segfault when running serval simulations in a row

Post by ted » Mon May 10, 2010 12:20 pm

Your program is written in such a way that each call to pyAxon.simulation() tries to recreate the model axon, but without destroying the sections that already exist. It is possible to write code that does this properly, but at the cost of increased--and for your purpose, probably unwarranted--complexity. It is best to follow the KISS principle. Instead of stuffing nearly everything into a single procedure, reorganize the code in a more modular way. Specifically, separate it into the following blocks:
specification of biology
specification of instrumentation (stimulation, vector recording)
specification of simulation flow control
where the implementational details of each block depend on how you want each run to differ from its predecessors. For example, if you want to change stimulus parameters between runs (magnitude, time course, or spatial distribution), the "specification of instrumentation" block would contain procedures for adjusting the stimulus. And if you want to change diameters or channel densities between runs, the "specification of biology" would contain one or more procedures that can be called with arguments to adjust the corresponding model parameters. But the code that actually creates individual sections is called only once, during model setup.

The "specification of simulation flow control" would then be one or more procedures with nested "for" loops or iterators that accomplish the following:

Code: Select all

for each parameter combination of interest
  run a simulation and save results

Post Reply