swc to hoc conversion

Managing anatomically complex model cells with the CellBuilder. Importing morphometric data with NEURON's Import3D tool or Robert Cannon's CVAPP. Where to find detailed morphometric data.
Post Reply
Annik
Posts: 27
Joined: Fri Sep 07, 2012 1:02 pm

swc to hoc conversion

Post by Annik » Fri Apr 08, 2016 3:09 pm

This is perhaps an odd question, as it's less about how to make a model work in Neuron and more about how Neuron works. My apologies if this belongs in another section.

I have used the geometry of a cell from the modelDB, which was presented as a hoc file. I set up my model to record several variables from each compartment in the cell simultaneously, and ran my simulations (so far as I can tell) successfully. To manage the data I have collected, I've read the binary files Neuron wrote into python (I know this may be a suboptimal way of doing things, but it is where I'm at right now). I wanted to present the data I had collected in a similar way as the shape plot feature. There is a small python library for reading in morphometric data (swc files), so I downloaded the original swc file corresponding to the cell geometry which I got from modelDB. I want to map the data I have collected onto the proper sections of the cell, but I don't know how to do that with an swc file because I'm not sure what points correspond to which sections in the hoc code Neuron used to make this cell,

Here is where I'm stuck: I don't know how Neuron turns swc information into hoc code which assigns names to each dendritic section. I would like to be able to do a similar thing in python so that I can map the appropriate data onto the correct points in the cell. Do you have ideas for how this might be accomplished?

Thanks,
Annik

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

Re: swc to hoc conversion

Post by ted » Tue Apr 12, 2016 11:37 am

Start by approaching the problem from a different direction. First you must make a decision: do you want to use NEURON's own InterViews-based graphics, or do you want to create your visualization with some independent library, e.g. maybe mayavi? The former is easiest, because NEURON already knows everything about the geometry and topology of the model and has all necessary procedures and functions for drawing to the screen. The latter is capable of generating much prettier figures but you need to get information from NEURON into it. Which is it that you want to do?

Annik
Posts: 27
Joined: Fri Sep 07, 2012 1:02 pm

Re: swc to hoc conversion

Post by Annik » Tue Apr 12, 2016 8:53 pm

The second route is more appealing to me. Do you have tips on how to proceed in this direction? I haven't looked at mayavi (using btmorph right now), but I will get some more information about that.

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

Re: swc to hoc conversion

Post by ted » Wed Apr 13, 2016 9:57 am

To draw pictures, you will need all of the pt3d information. You can get that by iterating over each section like so:

Code: Select all

forall {
  tell Python the following data belong to a new section
  for i=0,n3d()-1 {
    pass x3d(i), y3d(i), z3d(i), and diam3d(i) to Python
  }
}
Of course this is partly in pseudocode because I have no idea how you intend to manage those data in Python--probably append the values to vectors or lists of tuples. You'll want to treat each section's sequence of xyz coordinates as the irregularly spaced breakpoints in a 3D zigzag line with varying diameter that runs from the section's 0 end to its 1 end. You'll also want to chop that line into nseg pieces of equal length, and color each piece according to the numerical value of some range variable. The numerical values of that range variable are easy to get. For example, if you're interested in cai, and every section has at least one mechanism described by NMODL code with a USEION ca statement,

Code: Select all

forall {
  tell Python the following values belong to a new section
  for (x,0) pass cai(x) to Python
}
This is all in hoc pseudocode but it would probably be more direct to do it in Python. You'll want to review the Scripting NEURON with Python tutorial (see link on the Documentation page http://www.neuron.yale.edu/neuron/docs) for idiomatic ways to iterate over segments and sections, and you may also want to look at the code used by Foutz et al.--ModelDB entry 153196, associated with this publication
Foutz TJ, Arlow RL, McIntyre CC (2012)
Theoretical principles underlying optical stimulation of a channelrhodopsin-2 positive pyramidal neuron
J Neurophysiol. 107(12):3235-45

Annik
Posts: 27
Joined: Fri Sep 07, 2012 1:02 pm

Re: swc to hoc conversion

Post by Annik » Thu Apr 14, 2016 6:11 pm

Great, got it to work. Thanks very much!

Annik

Post Reply