Search found 160 matches

by ramcdougal
Mon Feb 02, 2015 4:48 pm
Forum: NEURON + Python
Topic: SWC files
Replies: 33
Views: 17781

Re: SWC files

Yes. Here's a function to load and instantiate a single cell: def instantiate_swc(filename): """load an swc file and instantiate it""" # load the NEURON library (just in case h is defined otherwise elsewhere) from neuron import h # a helper library, included with NEURON h.load_file('import3d.hoc') #...
by ramcdougal
Fri Nov 07, 2014 7:01 am
Forum: NEURON + Python
Topic: Running multiple simulations in one process
Replies: 19
Views: 10456

Re: Running multiple simulations in one process

The exception is critical to the point being discussed. When there is an exception, the local stack frame is not immediately released (and hence variables are not freed), but is preserved in case other code wishes to examine what went wrong. To reproduce the error, copy and paste the code as is into...
by ramcdougal
Thu Nov 06, 2014 5:46 pm
Forum: NEURON + Python
Topic: Running multiple simulations in one process
Replies: 19
Views: 10456

Re: Running multiple simulations in one process

The behavior you describe is a property of Python not of NEURON. Here's a NEURON-free example: class A: def __del__(self): print 'obj deleted' def test(): a = A() raise Exception() test() print 'done test' If you run this interactively, it'll print out the error message and then print "done test"......
by ramcdougal
Tue Oct 28, 2014 6:27 pm
Forum: NEURON + Python
Topic: Running multiple simulations in one process
Replies: 19
Views: 10456

Re: Running multiple simulations in one process

If you wanted to be super-safe, you could only ever have one copy of a NEURON object (e.g. of a section) that was held by Python and have everything else work with a weakref proxy object. For good measure, you could have the gc module force a garbage collection before any NEURON initialization or ad...
by ramcdougal
Tue Oct 28, 2014 4:58 pm
Forum: NEURON + Python
Topic: Running multiple simulations in one process
Replies: 19
Views: 10456

Re: Running multiple simulations in one process

Is the issue that you have no control over the code that is being run? i.e Are you trying to write reusable code (if so, follow Ted's advice)? Or are you trying to run arbitrary simulations whose code you do not control? If it is the latter, are you sure you need it to only be in one process? Why? I...
by ramcdougal
Wed Sep 24, 2014 2:44 pm
Forum: Reaction-diffusion in NEURON
Topic: Patch to geometry.py
Replies: 3
Views: 6782

Re: Patch to geometry.py

The main repository now includes your patch. Thanks again.
by ramcdougal
Tue Sep 23, 2014 1:24 pm
Forum: Reaction-diffusion in NEURON
Topic: Patch to geometry.py
Replies: 3
Views: 6782

Re: Patch to geometry.py

Thanks. That change makes the API more consistent.

I've added it to my development version of the code.
by ramcdougal
Wed Aug 20, 2014 7:11 pm
Forum: Reaction-diffusion in NEURON
Topic: Active Transport
Replies: 4
Views: 7550

Re: Active Transport

You're almost there with the part that's not active transport. A few notes: rxd.Species (and rxd.Parameter) work on rxd.Region objects which you can think of as high-level concepts, like: all of the cytosol, all of the ER, etc. The regions argument to rxd.Rate (and rxd.Reaction, etc) currently only ...
by ramcdougal
Thu Aug 07, 2014 10:23 pm
Forum: NEURON + Python
Topic: Changing hoc variables after xopen but before instantiation
Replies: 3
Views: 2851

Re: Changing hoc variables after xopen but before instantiat

One solution is to declare a top-level variable that is used for initialization and set that. For example, consider example.hoc's use of initvalue: // default value for creating new Example objects initvalue = 17 begintemplate Example public value, print_value external initvalue proc print_value() {...
by ramcdougal
Sat Aug 02, 2014 12:55 pm
Forum: NEURON + Python
Topic: Neuron and Python, NetCon Error
Replies: 2
Views: 2390

Re: Neuron and Python, NetCon Error

To fix this, you must specify the containing section explicitly with a sec=, as in nc4 = h.NetCon(cell2(0.5)._ref_v,syn_5_2,0,10,0.5, sec=cell2) This is because NEURON needs to know what thread/etc contains the pointer, and this information is not accessible via the raw pointer. As an aside, note th...
by ramcdougal
Thu Jul 24, 2014 11:40 pm
Forum: NEURON + Python
Topic: Section stack overflow
Replies: 7
Views: 4190

Re: Section stack overflow

Replace the first h.pt3dclear() with h.pt3dclear(sec=soma) and the second with h.pt3dclear(sec=i), then you should be able to remove the "push" calls. The section stack is what provides HOC it's ability to say things like soma { L = 10 nseg = 11 } It's used exactly when something depends on the curr...
by ramcdougal
Wed Jul 23, 2014 5:44 pm
Forum: NEURON + Python
Topic: Section stack overflow
Replies: 7
Views: 4190

Re: Section stack overflow

Your problem doesn't lie in creating the sections; it lies in "i.push()". You're pushing "i" onto the section stack without ever popping anything from the section stack, so the stack grows and grows. In my opinion, one should never use Section.push. In your specific case, none of your code accesses ...
by ramcdougal
Wed Jul 09, 2014 5:32 pm
Forum: Reaction-diffusion in NEURON
Topic: Overriding _w_currents() in rxd.py
Replies: 4
Views: 7429

Re: Overriding _w_currents() in rxd.py

You are correct; when _currents(rhs) is invoked, rhs already contains the collected currents (ica + ina + ik + etc...), so the current and the voltage derivative (contained in rhs) both must be changed separately. This is because nrn_nonvint_block_current is invoked after nrn_rhs in src/nrnoc/treese...
by ramcdougal
Mon Jul 07, 2014 6:52 pm
Forum: NEURON + Python
Topic: A Python interface for NEURON using ctypes
Replies: 2
Views: 1623

Re: A Python interface for NEURON using ctypes

If you're using NEURON 7.3 or higher, neuron.nrn_dll() returns a ctypes object corresponding to the NEURON library. The main difficulty here is that the C API exists only informally; there is no documentation or promise of what functions will have a stable interface, but you are encouraged to poke a...
by ramcdougal
Thu Jun 26, 2014 4:29 pm
Forum: NEURON + Python
Topic: Segfault when running long simulation with many neurons
Replies: 3
Views: 2710

Re: Segfault when running long simulation with many neurons

There is a subtle and unfortunate distinction between h.run and neuron.run. The full code of neuron.run (defined here ) is: def run(tstop): """ function run(tstop) Run the simulation (advance the solver) until tstop [ms] """ h('tstop = %g' % tstop) h('while (t < tstop) { fadvance() }') You'll notice...