def create_vm_viewer(rdes): network = moogli.extensions.moose.read(rdes.elecid.path, vertices=10) normalizer = moogli.utilities.normalizer(-0.08, 0.02, clipleft=True, clipright=True) colormap = moogli.colors.UniformColorMap([ moogli.colors.Color(0.0, 0.5, 1.0, 1.0), moogli.colors.Color(1.0, 0.0, 0.0, 0.9) ]) mapper = moogli.utilities.mapper(colormap, normalizer) vms = [moose.element(x).Vm for x in list(network.shapes.keys())] network.set("color", vms, mapper) def interlude(view): moose.start(frameRunTime) #vms = [moose.element(x).Vm for x in network.shapes.keys()] #network.set("color", vms, mapper) view.pitch(0.01) currTime = moose.element('/clock').currentTime if currTime >= runtime: view.stop() viewer = moogli.Viewer("vm-viewer") viewer.attach_shapes(list(network.shapes.values())) view = moogli.View("vm-view", interlude=interlude) viewer.attach_view(view) return viewer
def createVmViewer(rdes): network = moogli.extensions.moose.read(rdes.elecid.path) normalizer = moogli.utilities.normalizer(-0.08, 0.02, clipleft=True, clipright=True) colormap = moogli.colors.UniformColorMap([ moogli.colors.Color(0.0, 0.5, 1.0, 1.0), moogli.colors.Color(1.0, 0.0, 0.0, 0.9) ]) mapper = moogli.utilities.mapper(colormap, normalizer) def prelude(view): vms = [moose.element(x).Vm for x in list(network.shapes.keys())] network.set("color", vms, mapper) view.pitch(PI / 2.0) view.down(450) view.left(100) view.h = 2.0 view.zoom(5.0) def interlude(view): if view.h > 0.10: view.h /= 1.005 view.zoom(0.005) view.yaw(0.01) viewer = moogli.Viewer("vm-viewer") viewer.attach_shapes(list(network.shapes.values())) view = moogli.View("vm-view", prelude=prelude, interlude=interlude) viewer.attach_view(view) return viewer
def main(): """ This example illustrates loading a model from an SWC file, inserting spines, and viewing it. """ app = QtGui.QApplication(sys.argv) filename = 'barrionuevo_cell1zr.CNG.swc' #filename = 'h10.CNG.swc' moose.Neutral('/library') rdes = rd.rdesigneur( \ cellProto = [[ filename, 'elec' ] ],\ spineProto = [['makeSpineProto()', 'spine' ]] ,\ spineDistrib = [ \ ['spine', '#apical#', \ 'spacing', str( spineSpacing ), \ 'spacingDistrib', str( minSpacing ), \ 'angle', str( spineAngle ), \ 'angleDistrib', str( spineAngleDistrib ), \ 'size', str( spineSize ), \ 'sizeDistrib', str( spineSizeDistrib ) ] \ ] \ ) rdes.buildModel('/model') moose.reinit() # Now we set up the display compts = moose.wildcardFind("/model/elec/#[ISA=CompartmentBase]") compts[0].inject = inject ecomptPath = [x.path for x in compts] morphology = moogli.extensions.moose.read(path="/model/elec", vertices=15) #morphology = moogli.read_morphology_from_moose(name = "", path = "/model/elec") #morphology.create_group( "group_all", ecomptPath, -0.08, 0.02, \ # [0.0, 0.5, 1.0, 1.0], [1.0, 0.0, 0.0, 0.9] ) #morphology.create_group( "group_all", ecomptPath, -0.08, 0.02, gnuplot ) #viewer = moogli.DynamicMorphologyViewerWidget(morphology) viewer = moogli.Viewer("Viewer") viewer.attach_shapes(morphology.shapes.values()) view = moogli.View("main-view") viewer.attach_view(view) #viewer.set_background_color( 1.0, 1.0, 1.0, 1.0 ) def callback(morphology, viewer): moose.start(frameRunTime) Vm = [moose.element(x).Vm for x in compts] morphology.set_color("group_all", Vm) currTime = moose.element('/clock').currentTime #print currTime, compts[0].Vm if (currTime < runtime): return True return False #viewer.set_callback( callback, idletime = 0 ) #viewer.showMaximized() viewer.show() app.exec_()
def create_viewer(path, moose_dendrite, dendZ, diaTab, psdZ): network = moogli.extensions.moose.read(path=path, vertices=15) dendrite = network.groups["dendrite"].shapes[moose_dendrite.path] chem_compt_group = dendrite.subdivide(len(dendZ)) normalizer = moogli.utilities.normalizer(0.0, 300.0, clipleft=True, clipright=True) colormap = moogli.colors.MatplotlibColorMap(matplotlib.cm.rainbow) mapper = moogli.utilities.mapper(colormap, normalizer) def readValues(tables): values = [] for i in range(len(tables)): values.append(tables[i].vector[-1]) return values def prelude(view): view.home() view.pitch(math.pi / 3.0) view.zoom(0.3) network.groups["soma"].set("color", moogli.colors.RED) network.groups["spine"].groups["shaft"].set("color", moogli.colors.RED) def interlude(view): moose.start(frameruntime) network.groups["spine"].groups["head"].set("radius", readValues(diaTab), lambda x: x * 0.5e6) network.groups["spine"].groups["head"].set("color", readValues(psdZ), mapper) chem_compt_group.set("color", readValues(dendZ), mapper) if moose.element("/clock").currentTime >= runtime: view.stop() viewer = moogli.Viewer("Viewer") viewer.attach_shapes(list(network.shapes.values())) viewer.detach_shape(dendrite) viewer.attach_shapes(list(chem_compt_group.shapes.values())) view = moogli.View("main-view", prelude=prelude, interlude=interlude) cb = moogli.widgets.ColorBar( id="cb", title="Molecule #", text_color=moogli.colors.BLACK, position=moogli.geometry.Vec3f(0.975, 0.5, 0.0), size=moogli.geometry.Vec3f(0.30, 0.05, 0.0), text_font="/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-R.ttf", orientation=math.pi / 2.0, text_character_size=20, label_formatting_precision=0, colormap=moogli.colors.MatplotlibColorMap(matplotlib.cm.rainbow), color_resolution=100, scalar_range=moogli.geometry.Vec2f(0.0, 300.0)) view.attach_color_bar(cb) viewer.attach_view(view) return viewer
def main(): """ This snippet illustrates how the Neuron class does the spine specification, without the rdesigneur intermediate. """ app = QtGui.QApplication(sys.argv) moose.Neutral('/library') makeSpineProto() model = moose.loadModel(filename, '/model') model[0].buildSegmentTree() model[0].spineDistribution = [ \ 'spine', '#apical#', \ 'spacing', str( spineSpacing ), \ 'spacingDistrib', str( minSpacing ), \ 'angle', str( spineAngle ), \ 'angleDistrib', str( spineAngleDistrib ), \ 'size', str( spineSize ), \ 'sizeDistrib', str( spineSizeDistrib ), \ '' \ ] moose.reinit() # Now we set up the display compts = moose.wildcardFind("/model/#[ISA=CompartmentBase]") #print " compartment ",compts compts[0].inject = inject ecomptPath = [x.path for x in compts] #morphology = moogli.read_morphology_from_moose(name = "", path = "/model") morphology = moogli.extensions.moose.read(path="/model/", vertices=15) # morphology.create_group( "group_all", ecomptPath, -0.08, 0.02, \ # [0.0, 0.5, 1.0, 1.0], [1.0, 0.0, 0.0, 0.9] ) viewer = moogli.Viewer("Viewer") viewer.attach_shapes(morphology.shapes.values()) view = moogli.View("main-view") viewer.attach_view(view) #viewer = moogli.DynamicMorphologyViewerWidget(morphology) def callback(morphology, viewer): moose.start(frameRunTime) Vm = [moose.element(x).Vm for x in compts] morphology.set_color("group_all", Vm) currTime = moose.element('/clock').currentTime #print currTime, compts[0].Vm if (currTime < runtime): return True return False #viewer.set_callback( callback, idletime = 0 ) #viewer.showMaximized() viewer.show() app.exec_()
def create_viewer(rdes): # print "Creating 3D Viewer" network = moogli.extensions.moose.read(path=rdes.elecid.path, vertices=10) # print "Read Network" network.set("color", moogli.colors.LIGHT_BLUE) network.groups["spine"].set("color", moogli.colors.ORANGE) # for dendrite in dendrites.values(): # dendrite.set_colors(moogli.core.Vec4f(173 / 255.0, 216 / 255.0, 230 / 255.0, 1.0)) [shape.set_radius(shape.get_apex_radius() * 4.0) for shape in list(network.groups["spine"].groups["head"].shapes.values())] # print "Creating LIFS" soma = network.shapes[rdes.soma.path] center = soma.get_center() row_axis = moogli.geometry.X_AXIS row_count = 50 row_separation = soma.get_base_radius() * 5.0 col_axis = moogli.geometry.Z_AXIS col_count = 50 col_separation = row_separation radii = soma.get_base_radius() colors = moogli.colors.GREEN vertices = 20 lifs = moogli.shapes.Sphere.grid("LIF", center, row_axis, row_count, row_separation, col_axis, col_count, col_separation, radii, colors, vertices) # print "Created LIFS" # morphology.create_group("dendrites", dendrites, 0.0, 300.0, colormap) # print "Creating Viewer" viewer = moogli.Viewer("viewer") # prelude = prelude, interlude = interlude) # print "Created Viewer" viewer.attach_shapes(list(network.shapes.values())) viewer.attach_shapes(list(lifs.shapes.values())) # print "Attached Shapes" view = moogli.View("view", interlude=interlude) viewer.attach_view(view) # print "Attached View" viewer.showMaximized() viewer.start() view.zoom( 0.4 ) view.pitch( PI/2.5 ) return viewer
def create_ca_viewer(rdes): network = moogli.extensions.moose.read(rdes.elecid.path) ca_elements = [] for compartment_path in list(network.shapes.keys()): if moose.exists(compartment_path + '/Ca_conc'): ca_elements.append(moose.element(compartment_path + '/Ca_conc')) else: ca_elements.append(moose.element('/library/Ca_conc')) normalizer = moogli.utilities.normalizer(0.0, 0.002, clipleft=True, clipright=True) colormap = moogli.colors.UniformColorMap([moogli.colors.Color(1.0, 0.0, 0.0, 1.0), moogli.colors.Color(0.0, 1.0, 1.0, 0.1)]) mapper = moogli.utilities.mapper(colormap, normalizer) cas = [element.Ca for element in ca_elements] network.set("color", cas, mapper) def prelude(view): view.pitch(PI/2) view.zoom(0.4) def interlude(view): moose.start(frameRunTime) cas = [element.Ca for element in ca_elements] network.set("color", cas, mapper) view.yaw(0.01) currTime = moose.element('/clock').currentTime if currTime < runtime: deliverStim(currTime) else: view.stop() viewer = moogli.Viewer("ca-viewer") viewer.attach_shapes(list(network.shapes.values())) view = moogli.View("ca-view", prelude=prelude, interlude=interlude) viewer.attach_view(view) return viewer
def main(): """ Demonstrates how one can visualise morphology of a neuron using the MOOSE. """ app = QtGui.QApplication(sys.argv) filename = 'barrionuevo_cell1zr.CNG.swc' moose.Neutral('/library') moose.Neutral('/model') cell = moose.loadModel(filename, '/model/testSwc') for i in range(8): moose.setClock(i, simdt) hsolve = moose.HSolve('/model/testSwc/hsolve') hsolve.dt = simdt hsolve.target = '/model/testSwc/soma' moose.le(cell) moose.reinit() # Now we set up the display compts = moose.wildcardFind("/model/testSwc/#[ISA=CompartmentBase]") compts[0].inject = inject ecomptPath = [x.path for x in compts] morphology = moogli.extensions.moose.read(path="/model/testSwc", vertices=15) viewer = moogli.Viewer("Viewer") viewer.attach_shapes(morphology.shapes.values()) view = moogli.View("main-view") viewer.attach_view(view) # morphology = moogli.read_morphology_from_moose(name = "", path = "/model/testSwc") # morphology.create_group( "group_all", ecomptPath, -0.08, 0.02, \ # [0.0, 0.5, 1.0, 1.0], [1.0, 0.0, 0.0, 0.9] ) # viewer = moogli.DynamicMorphologyViewerWidget(morphology) def callback(morphology, viewer): moose.start(frameRunTime) Vm = [moose.element(x).Vm for x in compts] morphology.set_color("group_all", Vm) currTime = moose.element('/clock').currentTime #print currTime, compts[0].Vm if (currTime < runtime): return True return False #viewer.set_callback( callback, idletime = 0 ) #viewer.showMaximized() viewer.show() app.exec_()
def create_vm_viewer(rdes): network = moogli.extensions.moose.read(rdes.elecid.path) normalizer = moogli.utilities.normalizer(-0.08, 0.02, clipleft=True, clipright=True) colormap = moogli.colors.UniformColorMap([moogli.colors.Color(0.0, 0.0, 1.0, 1.0), moogli.colors.Color(1.0, 1.0, 0.0, 0.1)]) mapper = moogli.utilities.mapper(colormap, normalizer) vms = [moose.element(x).Vm for x in list(network.shapes.keys())] network.set("color", vms, mapper) def prelude(view): view.pitch(PI/2) view.zoom(0.4) def interlude(view): moose.start(frameRunTime) vms = [moose.element(x).Vm for x in list(network.shapes.keys())] network.set("color", vms, mapper) view.yaw(0.01) currTime = moose.element('/clock').currentTime if currTime < runtime: deliverStim(currTime) else: view.stop() def postlude(view): displayPlots() viewer = moogli.Viewer("vm-viewer") viewer.attach_shapes(list(network.shapes.values())) view = moogli.View("vm-view", prelude=prelude, interlude=interlude, postlude=postlude) viewer.attach_view(view) return viewer
def create_vm_viewer(rdes, somaVm): network = moogli.extensions.moose.read(rdes.elecid.path) normalizer = moogli.utilities.normalizer(-0.08, 0.02, clipleft=True, clipright=True) colormap = moogli.colors.UniformColorMap([ moogli.colors.Color(0.0, 0.5, 1.0, 1.0), moogli.colors.Color(1.0, 0.0, 0.0, 0.9) ]) mapper = moogli.utilities.mapper(colormap, normalizer) vms = [moose.element(x).Vm for x in network.shapes.keys()] network.set("color", vms, mapper) def prelude(view): view.pitch(PI / 2.0) def interlude(view): moose.start(frameRunTime) vms = [moose.element(x).Vm for x in network.shapes.keys()] network.set("color", vms, mapper) view.yaw(0.01) currTime = moose.element('/clock').currentTime if currTime >= runtime: view.stop() def postlude(view): pylab.plot(numpy.linspace(0, runtime, len(somaVm.vector)), somaVm.vector * 1000) pylab.xlabel("Time (s)") pylab.ylabel("Vm (mV)") pylab.show() viewer = moogli.Viewer("vm-viewer") viewer.attach_shapes(network.shapes.values()) view = moogli.View("vm-view", prelude=prelude, interlude=interlude, postlude=postlude) viewer.attach_view(view) return viewer
def create_viewer(rdes): print ' doing viewer for ', rdes.soma.path network = moogli.extensions.moose.read(rdes.elecid.path) normalizer = moogli.utilities.normalizer(-0.08, 0.02, clipleft=True, clipright=True) colormap = moogli.colors.UniformColorMap([ moogli.colors.Color(0.0, 0.5, 1.0, 1.0), moogli.colors.Color(1.0, 0.0, 0.0, 0.9) ]) mapper = moogli.utilities.mapper(colormap, normalizer) vms = [moose.element(x).Vm for x in network.shapes.keys()] network.set("color", vms, mapper) viewer = moogli.Viewer("vm-viewer") viewer.attach_shapes(network.shapes.values()) view = moogli.View("vm-view", interlude=interlude) viewer.attach_view(view) viewer.show() viewer.start() view.pitch(PI / 2.0) return viewer
def makeMoogli(rd, mooObj, moogliEntry, fieldInfo): if not hasMoogli: return None mooField = moogliEntry[3] numMoogli = len(mooObj) network = moogli.extensions.moose.read(path=rd.elecid.path, vertices=15) #print len( network.groups["spine"].shapes ) #print len( network.groups["dendrite"].shapes ) #print len( network.groups["soma"].shapes ) #soma = network.groups["soma"].shapes[ '/model/elec/soma'] #print network.groups["soma"].shapes soma = network.groups["soma"].shapes[rd.elecid.path + '/soma[0]'] if (mooField == 'n' or mooField == 'conc'): updateGroup = soma.subdivide(numMoogli) displayObj = mooObj else: shell = moose.element('/') displayObj = [i for i in mooObj if i != shell] cpa = [getComptParent(i) for i in displayObj] updateGroup = moogli.Group("update") updateShapes = [network.shapes[i] for i in cpa] #print "########### Len( cpa, mooObj ) = ", len( cpa ), len( mooObj ), len( updateShapes ) updateGroup.attach_shapes(updateShapes) normalizer = moogli.utilities.normalizer(moogliEntry[5], moogliEntry[6], clipleft=True, clipright=True) colormap = moogli.colors.MatplotlibColorMap(matplotlib.cm.rainbow) mapper = moogli.utilities.mapper(colormap, normalizer) viewer = moogli.Viewer("Viewer") viewer.setWindowTitle(moogliEntry[4]) if (mooField == 'n' or mooField == 'conc'): viewer.attach_shapes(updateGroup.shapes.values()) viewer.detach_shape(soma) else: viewer.attach_shapes(network.shapes.values()) if len(rd.moogNames) == 0: view = moogli.View("main-view", prelude=prelude, interlude=interlude, postlude=postlude) else: view = moogli.View("main-view", prelude=prelude, interlude=interlude2) cb = moogli.widgets.ColorBar( id="cb", title=fieldInfo[3], text_color=moogli.colors.BLACK, position=moogli.geometry.Vec3f(0.975, 0.5, 0.0), size=moogli.geometry.Vec3f(0.30, 0.05, 0.0), text_font="/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-R.ttf", orientation=math.pi / 2.0, text_character_size=16, label_formatting_precision=0, colormap=moogli.colors.MatplotlibColorMap(matplotlib.cm.rainbow), color_resolution=100, scalar_range=moogli.geometry.Vec2f(moogliEntry[5], moogliEntry[6])) cb.set_num_labels(3) view.attach_color_bar(cb) view.rd = rd view.mooObj = displayObj view.mooGroup = updateGroup view.mooField = mooField view.mooScale = fieldInfo[2] view.mapper = mapper viewer.attach_view(view) return viewer