Save model's biophysics and morphology programmatically to .hoc

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
vogdb
Posts: 37
Joined: Sun Aug 13, 2017 9:51 am

Save model's biophysics and morphology programmatically to .hoc

Post by vogdb »

Hi! I couldn't find the answer in similar topics: viewtopic.php?t=1855, viewtopic.php?t=364.

I have a model loaded from this kind of template:

Code: Select all

{load_file("stdrun.hoc")}
{load_file("import3d.hoc")}

begintemplate Cell_Scnn1a
  public init, morphology, geom_nseg_fixed, geom_nsec, gid
  public channel_seed
  public soma, dend, apic, axon, myelin
  create soma[1], dend[1], apic[1], axon[1], myelin[1]

  objref this, CellRef, segCounts

  public all, somatic, apical, axonal, basal, myelinated, APC
  objref all, somatic, apical, axonal, basal, myelinated, APC

proc init(/* args: morphology_dir, morphology_name */) {
  all = new SectionList()
  apical = new SectionList()
  //...

  forall delete_section()

  if(numarg() >= 2) {
    load_morphology($s1, $s2)
  } else {
    load_morphology($s1, "Scnn1a_473845048_m.swc")
  }

  geom_nseg()
  insertChannel()
  biophys()
}

proc load_morphology(/* morphology_dir, morphology_name */) {localobj morph, import, sf, extension
  strdef morph_path
  sprint(morph_path, "%s/%s", $s1, $s2)
  //...
  morph.quiet = 1
  morph.input(morph_path)

  import = new Import3d_GUI(morph, 0)
  import.instantiate(this)
}

proc distribute_distance(){local x localobj sl
  //...
}

proc geom_nseg() {
  //...
}

proc insertChannel() {
  forsec this.all {
  }
  forsec this.apical {
    insert pas
  }
  //...
  forsec this.somatic {
    insert Im
    //...
  }
}

proc biophys() {
  
  forsec CellRef.all {
    Ra = 138.28
  }
  
  forsec CellRef.apical {
    g_pas = 9.5861855476200007e-05
    //...
  }
  //...  
  forsec CellRef.somatic {
    gbar_Im = 0.0012021154978799999
    //...
  }
  
}

func sec_count(/* SectionList */) {
  //..
}

proc geom_nseg_fixed(/* chunkSize */) { local secIndex, chunkSize
  //...
}

proc geom_nsec() { local nSec
  //...
}

endtemplate Cell_Scnn1a
After the template has been loaded, I create a model from it and apply a reduction algorithm to the model that simplifies its morphology and biophysics. Can I save the updated model after this to a .hoc file? I can't use GUI unfortunately. A perfect solution would be to save in the original template format as the one above. A combination of .nml + .swc files will be sufficient too.
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Save model's biophysics and morphology programmatically to .hoc

Post by ted »

You can use the GUI's ModelView tool to export a NeuroML specification of the model cell. This is probably doable via hoc statements. I'm not sure how compatible NEURON's current NeuroML ouput is with the current NeuroML specification. Depending on what your simplification algorithm actually does, the resulting file may contain unwanted stuff (e.g. if you don't actually destroy unwanted sections).
vogdb
Posts: 37
Joined: Sun Aug 13, 2017 9:51 am

Re: Save model's biophysics and morphology programmatically to .hoc

Post by vogdb »

Am I correct that I would need to call proc exportNeuroML from share/lib/hoc/mview/mviewxml.hoc ?
vogdb
Posts: 37
Joined: Sun Aug 13, 2017 9:51 am

Re: Save model's biophysics and morphology programmatically to .hoc

Post by vogdb »

I've managed to export it into a single nml file.

Code: Select all

h.load_file('Cell_Scnn1a.hoc')
cell_hoc = h.Cell_Scnn1a('/morphologies', 'Scnn1a_473845048_m.swc')

h.load_file("mview.hoc")
mv = h.ModelView(0)
mv_xml = h.ModelViewXML(mv)
export_filepath = os.path.join('.', 'test.nml')
mv_xml.exportNeuroML(export_filepath, 2)
Now I'm struggling to separate biophysics from geometry. CellManager exports empty cell. How can I make it to export the current loaded cell in Neuron?

Code: Select all

export_filepath = os.path.join('.', 'test.nml')
bld = h.CellBuild(0)
mng = h.CellManage(bld)
f = h.File()
f.wopen('test.hoc')
mng.toplevel = 1 // i tried  toplevel=0 as well
mng.pr(f)
CellBuilder GUI has the same problem. It does not see the loaded cell even if I load it from GUI. Here is the output I receive:

Code: Select all

proc celldef() {
  topol()
  subsets()
  geom()
  biophys()
  geom_nseg()
}


proc topol() { local i
  basic_shape()
}
proc basic_shape() {
}

objref all
proc subsets() { local i
  objref all
  all = new SectionList()

}
proc geom() {
}
proc geom_nseg() {
}
proc biophys() {
}

celldef()
Post Reply