Search found 267 matches

by ramcdougal
Wed Feb 04, 2015 11:44 pm
Forum: NEURON + Python
Topic: SWC files
Replies: 33
Views: 41147

Re: SWC files

If you're using PyNEURON, you have to manually set a NEURONHOME environment variable in order for it to find the HOC libraries. The need for this extra step is unfortunate, but it's a simple process (see, for example, here -- updated 20191029, link broken so removed but this is no longer necessary i...
by ramcdougal
Wed Feb 04, 2015 1:02 pm
Forum: NEURON + Python
Topic: SWC files
Replies: 33
Views: 41147

Re: SWC files

My sincere apologies. I copied the function out of another file I wrote and didn't test it on its own; it requires the GUI tools to be loaded. I've modified the import accordingly. Please try this version: def instantiate_swc(filename): """load an swc file and instantiate it"&quo...
by ramcdougal
Mon Feb 02, 2015 4:48 pm
Forum: NEURON + Python
Topic: SWC files
Replies: 33
Views: 41147

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...
by ramcdougal
Fri Nov 07, 2014 7:01 am
Forum: NEURON + Python
Topic: Running multiple simulations in one process
Replies: 19
Views: 28431

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: 28431

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 tes...
by ramcdougal
Tue Oct 28, 2014 6:27 pm
Forum: NEURON + Python
Topic: Running multiple simulations in one process
Replies: 19
Views: 28431

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: 28431

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: 8281

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: 8281

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: 9321

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: 4061

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: 4043

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: 6472

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 o...
by ramcdougal
Wed Jul 23, 2014 5:44 pm
Forum: NEURON + Python
Topic: Section stack overflow
Replies: 7
Views: 6472

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...
by ramcdougal
Wed Jul 09, 2014 5:32 pm
Forum: Reaction-diffusion in NEURON
Topic: Overriding _w_currents() in rxd.py
Replies: 4
Views: 9169

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...