Page 1 of 1

Loading a morphology as a hoc file

Posted: Thu Feb 25, 2021 9:02 am
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

Re: Loading a morphology as a hoc file

Posted: Thu Feb 25, 2021 9:06 am
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")`

Re: Loading a morphology as a hoc file

Posted: Thu Feb 25, 2021 11:06 am
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?

Re: Loading a morphology as a hoc file

Posted: Thu Feb 25, 2021 7:49 pm
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.

Re: Loading a morphology as a hoc file

Posted: Sun Feb 28, 2021 9:19 am
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?

Re: Loading a morphology as a hoc file

Posted: Sun Feb 28, 2021 11:31 am
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)?

Re: Loading a morphology as a hoc file

Posted: Tue Mar 02, 2021 4:45 am
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]

Re: Loading a morphology as a hoc file

Posted: Tue Mar 02, 2021 10:52 am
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
).

Re: Loading a morphology as a hoc file

Posted: Wed Mar 03, 2021 12:09 pm
by sohaib786
Amazing. Thanks!

Re: Loading a morphology as a hoc file

Posted: Wed Mar 03, 2021 2:53 pm
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