def mk_mitrals(model):
  ''' Create all the mitrals specified by mitral_gids set.'''
  model.mitrals = {}
  for gid in model.mitral_gids:
    m = mkmitral.mkmitral(gid)
    model.mitrals.update({gid : m})
  util.elapsed('%d mitrals created and connections to mitrals determined'%int(pc.allreduce(len(model.mitrals),1)))
Example #2
0
def mk_mitrals(model):
  ''' Create all the mitrals specified by mitral_gids set.'''
  model.mitrals = {}
  for gid in model.mitral_gids:
    m = mkmitral.mkmitral(gid)
    model.mitrals.update({gid : m})
  util.elapsed('%d mitrals created and connections to mitrals determined'%int(pc.allreduce(len(model.mitrals),1)))
Example #3
0
def f(ii):
  i = int(ii)
  density = numpy.zeros(matrank)
  for gid in range(i , params.Nmitral, nhost):
    m = mkmitral.mkmitral(gid)
    for sec in m.secdens:
      accumulate_density(sec, density, domain)
    print gid
  return density
def msoma(mgid):
  c = mgid2pieces(mgid)
  if c and h.section_exists('soma', c):
    return c.soma
  return None

def mpriden(mgid):
  c = mgid2pieces(mgid)
  if c and h.section_exists('priden', c):
    return c.priden
  return None
  

def gsoma(ggid):
  c = ggid2pieces(ggid)
  if c and h.section_exists('soma', c):
    return c.soma
  return None

if __name__ == "__main__":
  from mkmitral import mkmitral
  gid = 259
  mcell = mkmitral(gid) # according to mkmitral.py this has tertiary branches
  print "mitral_complexity ", mitral_complexity(mcell)
  print "cell_complexity = ", lb.cell_complexity(mcell)
  pieces = secden_indices_connected_to_soma(mcell)
  pieces.append(-1)
  splitmitral(gid, mcell, pieces)
  h.topology()
  print "mgid2piece ", model.mgid2piece
Example #5
0
def export(num_cells_to_export=5):
    cells = []

    for mgid in range(num_cells_to_export):
        print mgid
        cells.append(mkmitral(mgid))

    nml_net_file = "../NeuroML2/MitralCells/Exported/PartialBulb_%iMTCells.net.nml" % num_cells_to_export
    export_to_neuroml2(None,
                       nml_net_file,
                       includeBiophysicalProperties=False,
                       separateCellFiles=True)

    for i in range(num_cells_to_export):
        print("Processing cell %i out of %i" % (i, num_cells_to_export))
        nml_cell_file = "../NeuroML2/MitralCells/Exported/Mitral_0_%i.cell.nml" % i
        nml_doc = pynml.read_neuroml2_file(nml_cell_file)
        cell = nml_doc.cells[0]

        soma_seg = next(seg for seg in cell.morphology.segments
                        if seg.name == "Seg0_soma")
        initial_seg = next(seg for seg in cell.morphology.segments
                           if seg.name == "Seg0_initialseg")
        hillock_seg = next(seg for seg in cell.morphology.segments
                           if seg.name == "Seg0_hillock")

        # Ensure hillock parent is soma
        hillock_seg.parent.segments = soma_seg.id

        # Fix initial and hillock segs by moving them to the soma
        hillock_seg.proximal = pointMovedByOffset(hillock_seg.proximal,
                                                  soma_seg.distal)
        hillock_seg.distal = pointMovedByOffset(hillock_seg.distal,
                                                soma_seg.distal)
        initial_seg.proximal = pointMovedByOffset(initial_seg.proximal,
                                                  soma_seg.distal)
        initial_seg.distal = pointMovedByOffset(initial_seg.distal,
                                                soma_seg.distal)

        # Set root to id=0 and increment others
        exportHelper.resetRoot(cell)

        # TODO: cell.position(x,y,z) used for cell positioning in networks does not work as expected
        # See: https://github.com/NeuroML/jNeuroML/issues/55
        # Skipping the translation for now
        # # Move everything back to the origin
        # originOffset = type("", (), dict(x = -soma_seg.proximal.x, y = -soma_seg.proximal.y, z = -soma_seg.proximal.z ))()
        #
        # for seg in cell.morphology.segments:
        #     seg.proximal = pointMovedByOffset(seg.proximal, originOffset)
        #     seg.distal =   pointMovedByOffset(seg.distal, originOffset)

        # Replace ModelViewParmSubset_N groups with all, axon, soma, dendrite groups
        buildStandardSegmentGroups(cell)

        # Add channel placeholders
        nml_doc.includes.append(
            neuroml.IncludeType(href="channelIncludesPLACEHOLDER"))
        cell.biophysical_properties = neuroml.BiophysicalProperties(
            id="biophysPLACEHOLDER")

        # Save the new NML
        pynml.write_neuroml2_file(nml_doc, nml_cell_file)

        # Replace placeholders with contents from MitralCell...xml files
        replaceChannelPlaceholders(nml_cell_file)

        print("COMPLETED: " + nml_cell_file)

    print("DONE")
Example #6
0
    return MGRS(mgid, isec, xm, ggid, ipri, xg, slot)
  return None
    
def multiple_cnt():
  cnt = 0;
  for mgrs in getmodel().mgrss.values():
    if mgrs.slot > 0:
      if mgrs.gd: cnt += 1
      if mgrs.md: cnt += 1
  return cnt

if __name__ == "__main__":
  import mkmitral, split
  h.load_file("granule.hoc")

  m = mkmitral.mkmitral(1)
  pieces = split.secden_indices_connected_to_soma(m)
  pieces.append(-1)
  split.splitmitral(1, m, pieces)
  pc.set_gid2node(1, pc.id())
  pc.cell(1, h.NetCon(m.soma(.5)._ref_v, None, sec=m.soma))

  g = h.Granule()
  pc.set_gid2node(10000, pc.id())
  pc.cell(10000, h.NetCon(g.soma(.5)._ref_v, None, sec=g.soma))

  mgrs = MGRS(1, 0, .8, 10000, 0, .1)
  mgrs.pr()
  mgrs2 = MGRS(1, 0, .8, 10000, 0, .1)

Example #7
0
    subtree = h.SectionList()
    subtree.subtree(sec = cell.secden[i])
    secden_cx.append(subset_complexity(subtree))
    total_cx += secden_cx[-1]

  return (total_cx, soma_etc_cx, secden_cx)

def msoma(mgid):
  c = mgid2pieces(mgid)
  if c and h.section_exists('soma', c):
    return c.soma
  return None

def gsoma(ggid):
  c = ggid2pieces(ggid)
  if c and h.section_exists('soma', c):
    return c.soma
  return None

if __name__ == "__main__":
  from mkmitral import mkmitral
  gid = 259
  mcell = mkmitral(gid) # according to mkmitral.py this has tertiary branches
  print "mitral_complexity ", mitral_complexity(mcell)
  print "cell_complexity = ", lb.cell_complexity(mcell)
  pieces = secden_indices_connected_to_soma(mcell)
  pieces.append(-1)
  splitmitral(gid, mcell, pieces)
  h.topology()
  print "mgid2piece ", model.mgid2piece
  def __init__(self, mgid):
    self.__cutted = False
    self.weights_max=True
    self.mgid = mgid

    from getmitral import getmitral as genMitral

    self.mitral = genMitral(mgid)


    self.soma = None
    self.apic = None
    self.dend = []
    self.tuft = []

    self.soma_color = (250. / 255, 210. / 255, 51. / 255)
    self.section_color = (1., 1., 1.)

    self.__vtkconvert()

    self.sel_color = (0., 1., 0.)
    self.sel_all = False

    import granules
    self.conn_info = []
    if flag_dict:
      grans=set()
      for gid in gd.mgid_dict[mgid]:
        if gid >= params.gid_granule_begin+granules.Ngranule and gid%2 == 0:
          self.conn_info.append(gd.gid_dict[gid])
          grans.add(self.conn_info[-1][3])
      print 'Mitral %d has %d synapses in %d granules'%(mgid, len(self.conn_info), len(grans))

      even = set()
      for gid in gd.mgid_dict[mgid]:
        if gid >= params.gid_granule_begin+granules.Ngranule and gid%2 == 0:
          isec,x = gd.gid_dict[gid][1:3]
          iseg = int(x*len(self.dend[isec]))
          if x >= 1: iseg = len(self.dend[isec])-1
          if (isec, iseg) not in even:
            self.dend_gids[isec][iseg].add(gid)
            even.add((isec, iseg))
          self.dend_gids[isec][iseg].add(gid-1)
          
      #for gid in gd.mgid_dict[mgid]:
      #  if gid >= params.gid_granule_begin + granules.Ngranule:
      #    if gid % 2 == 0:
      #      self.conn_info.append(gd.gid_dict[gid])
      #      
      #for gid in gd.mgid_dict[mgid]:
      #  if gid >= params.Nmitral + granules.Ngranule:
      #    if gid % 2 == 0:
      #      isec, x = gd.gid_dict[gid][1:3]
      #      iseg = int(x * len(self.dend[isec]))
      #      
      #      if x >= 1:
      #        iseg = len(self.dend[isec]) - 1
      #        
      #      self.dend_gids[isec][iseg].add(gid)
    else:
      from mkmitral import mkmitral
      from m2g_connections import determine_mitral_connections
      self.conn_info = determine_mitral_connections(mgid, mkmitral(mgid))
      

    self.interpolate = self.__interpolate(self.dend_gids) # complete the colors info using interpolation


          
    #self.gr1 = []
    #self.gr2 = []
    self.__show_weights = False
    self.__show_freqs = False
Example #9
0
def __main__():
    num_cells_to_export = 1

    cells = []
    for mgid in range(num_cells_to_export):
      print mgid
      cells.append(mkmitral(mgid))

    nml_net_file = "../NeuroML2/MitralCells/Exported/PartialBulb_%iMTCells.net.nml" % num_cells_to_export
    export_to_neuroml2(None, 
                       nml_net_file,
                       includeBiophysicalProperties=False,
                       separateCellFiles=True)

    for i in range(num_cells_to_export):

        print("Processing cell %i out of %i"%(i, num_cells_to_export))

        nml_cell_file = "../NeuroML2/MitralCells/Exported/Mitral_0_%i.cell.nml" % i

        nml_doc = pynml.read_neuroml2_file(nml_cell_file)

        cell = nml_doc.cells[0]

        import pydevd
        pydevd.settrace('10.211.55.3', port=4200, stdoutToServer=True, stderrToServer=True, suspend=True)
        
        # Set root to id=0 and increment others
        exportHelper.resetRoot(cell)

        somaSeg = [seg for seg in cell.morphology.segments if seg.name == "Seg0_soma"][0]
        initialSeg = [seg for seg in cell.morphology.segments if seg.name == "Seg0_initialseg"][0]
        hillockSeg = [seg for seg in cell.morphology.segments if seg.name == "Seg0_hillock"][0]

        # Fix initial and hillock segs by moving them to the soma
        hillockSeg.proximal = pointMovedByOffset(hillockSeg.proximal, somaSeg.distal)
        hillockSeg.distal = pointMovedByOffset(hillockSeg.distal, somaSeg.distal)
        initialSeg.proximal = pointMovedByOffset(initialSeg.proximal, somaSeg.distal)
        initialSeg.distal = pointMovedByOffset(initialSeg.distal, somaSeg.distal)

        # Move everything back to the origin
        originOffset = type("", (), dict(x = -somaSeg.proximal.x, y = -somaSeg.proximal.y, z = -somaSeg.proximal.z ))()

        for seg in cell.morphology.segments:
            seg.proximal = pointMovedByOffset(seg.proximal, originOffset)
            seg.distal =   pointMovedByOffset(seg.distal, originOffset)

        # Replace ModelViewParmSubset_N groups with all, axon, soma, dendrite groups
        buildStandardSegmentGroups(cell)

        # Add channel placeholders
        nml_doc.includes.append(neuroml.IncludeType(href="channelIncludesPLACEHOLDER"))
        cell.biophysical_properties = neuroml.BiophysicalProperties(id="biophysPLACEHOLDER")

        # Save the new NML
        pynml.write_neuroml2_file(nml_doc, nml_cell_file)

        # Replace placeholders with contents from MitralCell...xml files
        replaceChannelPlaceholders(nml_cell_file)

        print("COMPLETED: " + nml_cell_file)

    print("DONE")
    return None


def multiple_cnt():
    cnt = 0
    for mgrs in getmodel().mgrss.values():
        if mgrs.slot > 0:
            if mgrs.gd: cnt += 1
            if mgrs.md: cnt += 1
    return cnt


if __name__ == "__main__":
    import mkmitral, split
    h.load_file("granule.hoc")

    m = mkmitral.mkmitral(1)
    pieces = split.secden_indices_connected_to_soma(m)
    pieces.append(-1)
    split.splitmitral(1, m, pieces)
    pc.set_gid2node(1, pc.id())
    pc.cell(1, h.NetCon(m.soma(.5)._ref_v, None, sec=m.soma))

    g = h.Granule()
    pc.set_gid2node(10000, pc.id())
    pc.cell(10000, h.NetCon(g.soma(.5)._ref_v, None, sec=g.soma))

    mgrs = MGRS(1, 0, .8, 10000, 0, .1)
    mgrs.pr()
    mgrs2 = MGRS(1, 0, .8, 10000, 0, .1)