importing an swc file

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

Moderator: hines

Post Reply
vellamike

importing an swc file

Post by vellamike »

I'm trying to import a morphology in swc format using NEURON as a python library. I've searched the documentation for quite a while but so far have failed. Can somebody point me to where in the documentation this is explained or tell me how to do it?

Thanks in advance,
Mike

UPDATE: I should clarify that I *have* been able to get access to my morphology by doing

Code: Select all

from neuron import gui
and then using the Tools->Miscellaneous->Import3D followed by export->instantiate, but this is of course very time consuming if I want to load my model hundreds of times, not to mention not very elegant, can this be simplified?
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: importing an swc file

Post by ted »

There isn't a problem here. You just haven't developed an appropriate workflow.

Morphometric data usually contains artifacts or frank errors that preclude blindly using it in computational models without first subjecting it to some examination and consideration, and possibly manual editing and repair, guided by judgment. Import3D was developed with this in mind. It has many features that are helpful in exploring morphometric data and deciding what needs fixing and how to fix it.
vellamike wrote:I'm trying to import a morphology in swc format using NEURON as a python library. I've searched the documentation for quite a while but so far have failed. Can somebody point me to where in the documentation this is explained or tell me how to do it?
In a word, don't. Take the time to examine the data. Look at the error messages and warnings that Import3D generates, and take them seriously. Beware orphan sections and trees. Examine the imported cell from the side (you know how to rotate a shape plot around the z axis?) to make sure you aren't dealing with a reconstruction that suffers from z axis drift or backlash. Check the diameter measurements to make sure that there aren't bottlenecks; also verify that there is a plausible range of diameter measurements (or are there no values < 1um?).
UPDATE: I should clarify that I *have* been able to get access to my morphology by doing

Code: Select all

from neuron import gui
and then using the Tools->Miscellaneous->Import3D followed by export->instantiate, but this is of course very time consuming
and it should be, because importation of morphometric data requires critical examination of what you're getting. Don't just accept it because it seems to work without spawning error messages.
if I want to load my model hundreds of times
Well, when you've gotten to the stage of having a model, you're well past the morphometry importaton stage, aren't you? Presumably you have scrutinized the imported data, and you're happy with it, or you wouldn't have bothered to assign biophysical parameters and decided on a discretization strategy.

The workflow is:
1. Obtain morphometric data (hopefully somebody else did the reconstruction--this is real "stoop labor").
2. Use Import3D to get it into a CellBuilder--this is the step where you agonize about the quality of the morphometric data, and it's necessarily time consuming. Once you're finished with this step, there's no need to return to it.
3. Save the CellBuilder to a session file so you can retrieve it in the future.
4. Use a copy of the CellBuider to assign biophysical parameters and specify the discretization strategy. Save this to a new session file for future reuse.
5. Use a copy of the CellBuilder created in step 4 in your model, or, if necessary, export a hoc file from that CellBuider, and use that hoc file in your model.
vellamike

Re: importing an swc file

Post by vellamike »

Thanks for the great reply Ted,

I want to assign all biophysical information in Python, the reasons being that:

1. I use many python methods to automate setting biophysical data in different ways
2. I find this much more readable
3. I try and use NEURON as a Python library as much as I can, doing as little as I can in the GUI

So after I've completed step 3 in your Workflow description I'm exporting to a hoc file immediately. I have two questions about this:

1.Is there anything fundamentally wrong with this approach?
2.Is there any thought being given to exporting as a neuroml file from cellbuilder? This would be very nice.

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

Re: importing an swc file

Post by ted »

vellamike wrote:I want to assign all biophysical information in Python, the reasons being that:

1. I use many python methods to automate setting biophysical data in different ways
2. I find this much more readable
3. I try and use NEURON as a Python library as much as I can, doing as little as I can in the GUI

So after I've completed step 3 in your Workflow description I'm exporting to a hoc file immediately.
That should work.
2.Is there any thought being given to exporting as a neuroml file from cellbuilder?
The CellBuilder already has the ability to export xml--see its Management page--and you can also export a top-level model cell (one whose sections actually exist) to xml from the Model View tool
NEURON Main Menu / Tools / Model View
then
File / Export to NeuroML
gives you a choice of Level 1 or 2.

The NeuroML specification has been a moving target, so don't be surprised if NEURON's xml import and export lags slightly behind it from time to time. My personal choice, until the standard converges and stabilizes, would be to stick with the hoc specification of topology and geometry, and use Python for everything else (except of course for mechanisms implemented with NMODL and the Channel Builder).
Post Reply