Hi,
I am working in python and I experience a number of issues. I would like to know how do I list the mechanisms that have been loaded in Neuron from the nrnmech.dll file...I would like to use these to load particular mechanisms in a multicompartment neuron. I know how to do the later but it seems that I cant find the former answer..
list the mechanisms loaded from the nrnmech.dll.file
Moderator: hines
-
- Posts: 5
- Joined: Tue Nov 18, 2014 7:38 pm
-
- Site Admin
- Posts: 6383
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Re: list the mechanisms loaded from the nrnmech.dll.file
It's not a good idea to do that, unless you enjoy setting booby traps for yourself and anyone who tries to reuse your code. Specification of the mechanisms used by a model should be made by hoc or Python statements.
-
- Posts: 5
- Joined: Tue Nov 18, 2014 7:38 pm
Re: list the mechanisms loaded from the nrnmech.dll.file
Hi Ted, thank you for your reply.
I am not sure what you mean and why this is not a good idea or why am I setting a trap for me and others
Let me rephrase in case I have caused a confusion.
I simply want to create a list of strings (bearing the names of the DENSITY mechanisms contained in the rnrmech.dll file) e.g. ['Ka', 'kv', 'CaL', etc] then choose which ones to insert in each compartment of my neuron. My neuron has 1500 compartments and is a biolorealistic neuron from my recordings (Neurolucida reconstruction)
I have 100's of ion channel mechanisms and I would like to be able to choose which ones I insert in my model, then systematically choose others and compare the results on the simulations.
class Morph_HumanNeuron:
def __init__(self, morph_file_path):
# Initialize the cell and load the morphology from the provided .asc file
self.cell = self.load_morphology(morph_file_path)
def load_morphology(self, morph_file_path):
# Import the morphology from the .asc file (Neurolucida)
h.load_file("import3d.hoc")
cell = h.Import3d_Neurolucida3()
cell.input(morph_file_path)
imprt = h.Import3d_GUI(cell, False)
imprt.instantiate(None)
morph_plot = h.PlotShape( )
return cell, morph_plot
def create_secList(self):
# Create a list of all sections (compartments) in the cell
secList = []
for sec in h.allsec():
secList.append(sec)
return secList
def create_mechList(self):
# Create a list of all DENSITY MECHANISMS available
mechList = []
HOW DO I SNIFF OUT THE DENSITY MECHANISM NAMES
THAT HAVE BEEN LOADED VIA THER NRNMECH.DLL AND ARE AVAILABLE FOR USE?
return mechList
def insert_mechanism(self):
# Insert the mechanism desired into specific sections or based on section type
for idx, sec in enumerate(secList):
if sec == secList[0]:
print('soma found')
sec.nseg = 1
sec.cm = 1
sec.Ra = 35.4
for seg in sec:
# simply load just the the two first density mechnims of the mechList
sec.insert(mechList[0])
sec.insert(mechList[1]))
elif sec == secList[1]:
print('axon found')
sec.nseg = 1
sec.cm = 1
sec.Ra = 35.4
for seg in sec:
sec.insert('hh')
sec.gnabar_hh = 0.72
sec.gkbar_hh = 0.035
sec.gl_hh = 3e-4
sec.el_hh = -74.3
sec.ek = -97
else:
sec.nseg = 10
sec.cm = 1
sec.Ra = 35.4
for seg in sec:
sec.insert('pas')
sec.g_pas = 0.001
sec.e_pas = -74.3
-
- Site Admin
- Posts: 6383
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Re: list the mechanisms loaded from the nrnmech.dll.file
This isn't hard. In your model setup code use conditional statements code whose execution is controlled e.g. by command line switches or statements in a text file. That way you'll have a textual record of what was actually done.I have 100's of ion channel mechanisms and i would like to be able to choose which ones I insert in my model
Discussion:
The chief task of a model developer is to ensure a close match between the conceptual model in one's head, and what is actually in the computer. For declarative languages such as CellML and NeuroML, this isn't a problem. Not so with procedural programming languages like C or Python to create model specifications--with those, you don't know what's in the computer until the last model specification statement has been executed.
"Fine, but a disciplined programmer can write procedural code that works correctly."
Sure, but now you propose an approach that depends not only on the correctness of procedural code, but also on the correctness of a binary file whose contents depend on manual actions of the person who manages the mod files. That's multiplying the opportunities for something to go wrong (omit or include the wrong file, and you can get code that executes without complaint even though it's generating garbage results). And development and debugging tools and strategies that rely on analysis of your procedural code won't help.
The results of executing model specification code shouldn't depend on the contents of a binary file. It is best for the specification of a model to be completely explicit, and expressed in one or more human-readable files. Otherwise development, debugging, reproducibility, and the ability of yourself and others to understand and reuse your code are compromised.