Loading a morphology as a hoc file

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
sohaib786
Posts: 20
Joined: Thu Feb 14, 2019 4:31 am

Loading a morphology as a hoc file

Post by sohaib786 »

Hi Ted

I am trying to load a morphology as a hoc file in GUI instead of using the import3d<cell builder tool (because i don't have the swc file).
When I do this, I don't get something similar to the cell builder tool. I double checked that using the model view option.

Can you point where I am going wrong.

Thanks
ramcdougal
Posts: 224
Joined: Fri Nov 28, 2008 3:38 pm
Location: Yale School of Public Health

Re: Loading a morphology as a hoc file

Post by ramcdougal »

Can you expand your comment? What do you get and how is it different from what you expected?

If there's a HOC file morphology, you can load it from the GUI or from e.g. `h.load_file("my_morphology.hoc")`
ted
Site Admin
Posts: 5890
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Loading a morphology as a hoc file

Post by ted »

I am trying to load a morphology as a hoc file in GUI
I think I understand this up to the word "file." Specifically, you're saying that you have a hoc file that contains statements that will create and connect sections and assign the correct length and diameter properties to them.

I'm guessing that by saying you're doing this "in GUI" that maybe you're using the NEURON Main Menu toolbar's "File / load hoc" to make NEURON read your "morphology hoc file."
When I do this, I don't get something similar to the cell builder tool.
If the "morphology hoc file" contains only statements that create sections, connect them, and assign diameters and lengths to them, you won't see a CellBuilder because the file didn't contain any statement that creates a CellBuilder.
I double checked that using the model view option.
Model View, shmodel View. Just bring up a Shape plot (NEURON Main Menu / Graph / Shape plot). Do you get a box that tells you No accessed section: Can't start a PlotShape or do you get a graph window that shows a line drawing of a model cell?
ramcdougal
Posts: 224
Joined: Fri Nov 28, 2008 3:38 pm
Location: Yale School of Public Health

Re: Loading a morphology as a hoc file

Post by ramcdougal »

If you want to create a CellBuilder from a HOC morphology, you can load the HOC morphology, then open a CellBuilder, click the Management tab, then Import - top level. Confirm by clicking "go ahead and import" and then you can work with it in the CellBuilder.
sohaib786
Posts: 20
Joined: Thu Feb 14, 2019 4:31 am

Re: Loading a morphology as a hoc file

Post by sohaib786 »

Thanks for your prompt responses.
What do you get and how is it different from what you expected?
I am expecting to load the morphology (similar to loading a swc file), check different parameters to make sure I can use it for my simulations.

What I tried to do-


1) Double click and load the hoc file. It did not bring up the morphology, and I got this when i tried bringing the shape plot
No accessed section: Can't start a PlotShape

This I got in the command prompt

Code: Select all

NEURON -- VERSION 7.8.1 release/7.8.1 (47cd8c85) 2020-07-18
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2019
See http://neuron.yale.edu/neuron/credits

loading membrane mechanisms from C:\Users\Jackie.MEDICINE\Desktop\NEURON\project
\previous_models\Piriform-master\nrnmech.dll
Additional mechanisms from files
 GABA.mod HHstshort.mod glutamate.mod glutamate_ves.mod
Could not open C:/Users/Jackie.MEDICINE/AppData/Roaming/Microsoft/Windows/Start
Menu/Programs/Anaconda3 (64-bit)/Anaconda Prompt.lnk
Could not open C:/Users/Jackie.MEDICINE/AppData/Roaming/Microsoft/Windows/Start
Menu/Programs/Anaconda3 (64-bit)/Anaconda Prompt.lnk
Cannot find executable python3 or python
failed: C:\nrn\mingw\usr\bin\bash C:/nrn/bin/nrnpyenv.sh  --NEURON_HOME=C:/nrn
oc>
2) I tried loading through python

Code: Select all

 h.load_file(r"C:\Users\Jackie.MEDICINE\Desktop\NEURON\project\previous_models\Piriform-master\piri30_09_17.hoc")
 
NEURON: Can't open  C:UsersJackie.MEDICINEDesktopNEURONprojectprevious_modelsPiriform-masterpiri30_09_17.hoc
 near line 1
 {xopen("C:UsersJackie.MEDICINEDesktopNEURONprojectprevious_modelsPiriform-masterpiri30_09_17.hoc")}
                                                                                                    ^
        xopen("C:UsersJac...")
      execute1("{xopen("C:...")
    load_file("C:\Users\J...")
0.0


3 GUI, File>Load hoc option, that didn't work either.
Confirm by clicking "go ahead and import" and then you can work with it in the CellBuilder.
When I use this it only shows me a soma in the plot.

I suspect there is a problem becasue the hoc file is linked to mod files, or there is some problem with anaconda.

All the mod files used are present in the same folder and compiled.

Another Question:
Is there a way to convert a hoc file to swc format?
ted
Site Admin
Posts: 5890
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Loading a morphology as a hoc file

Post by ted »

The mod files have nothing to do with the problems you're having.
Could not open C:/Users/Jackie.MEDICINE/AppData/Roaming/Microsoft/Windows/Start
Menu/Programs/Anaconda3 (64-bit)/Anaconda Prompt.lnk
Could not open C:/Users/Jackie.MEDICINE/AppData/Roaming/Microsoft/Windows/Start
Menu/Programs/Anaconda3 (64-bit)/Anaconda Prompt.lnk
Cannot find executable python3 or python
This means you won't be able to use Python as an interpreter. A totally separate problem from the one that led you to start this thread. For the sake of clarity, we won't address this in this thread.
No accessed section: Can't start a PlotShape
This means the hoc file contains no "top level" statements (statements outside of a "template", i.e. class definition) that create sections. Time to examine the hoc file. Does it contain a statment of the form
begintemplate Foo
where Foo is a single string of characters not including punctuation (might or might not be capitalized)?
sohaib786
Posts: 20
Joined: Thu Feb 14, 2019 4:31 am

Re: Loading a morphology as a hoc file

Post by sohaib786 »

Does it contain a statment of the form
begintemplate Foo
Yes.

Following are the starting statements
begintemplate celltemplate
public soma,dend,all,dends,basal,apcounter,apvec,nil,LOTlist,CClist,FocalList,Vvec,numdend,primedends//,FocalDends,NumberActiveDends
objref all,dends,basal,apcounter,apvec,nil,LOTlist,CClist,Vvec[2]
ted
Site Admin
Posts: 5890
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Loading a morphology as a hoc file

Post by ted »

Everything between
begintemplate celltemplate
and
endtemplate celltemplate
defines a class. If those statements include one or more "create" statements and "connect" statements, it's a cell class. If that's the case, what you have is a hoc file that defines a cell class but doesn't create any instance of that class.

If you want to create a model cell that is based on this class definition, just execute

Code: Select all

objref foo // or whatever you want to call the instance
foo = new celltemplate()
and presto! you'll have a model cell whose sections are called foo.soma etc. (assuming one of the create statements is
create soma
).
sohaib786
Posts: 20
Joined: Thu Feb 14, 2019 4:31 am

Re: Loading a morphology as a hoc file

Post by sohaib786 »

Amazing. Thanks!
ted
Site Admin
Posts: 5890
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Loading a morphology as a hoc file

Post by ted »

A nice consequence of defining a cell class: you can use it to make as many instances as you like. Each instance will have its own name, membrane potentials, ionic currents, etc.. Very useful for modeling networks. Example:
objref pyrlist
pyrlist = new List()
for i = 0,9 pyrlist.append(new Pyr()) // assuming Pyr is the name of a cell class
print pyrlist.o(3).soma.v(0.5) // assuming the section called soma is a public member of Pyr
Post Reply