Ejemplo n.º 1
0
def build3dDisplay(rdes):
    print "building 3d Display"
    app = QtGui.QApplication(sys.argv)
    compts = moose.wildcardFind(rdes.elecid.path + "/#[ISA=CompartmentBase]")
    caElements = []
    for i in compts:
        if moose.exists(i.path + '/Ca_conc'):
            caElements.append(moose.element(i.path + '/Ca_conc'))
        else:
            caElements.append(moose.element('/library/Ca_conc'))
    eComptPath = map(lambda x: x.path, compts)
    morphology1 = moogli.read_morphology_from_moose( name = "", \
            path = rdes.elecid.path )
    morphology1.create_group( "group_all", eComptPath, -0.08, 0.02, \
        [0.0, 0.0, 1.0, 1.0], [1.0, 1.0, 0.0, 0.1] )
    viewer1 = moogli.DynamicMorphologyViewerWidget(morphology1)

    def callback1(morphology, viewer1):
        moose.start(frameRunTime)
        Vm = map(lambda x: moose.element(x).Vm, compts)
        morphology.set_color("group_all", Vm)
        currTime = moose.element('/clock').currentTime
        viewer1.yaw(0.01, 0)
        if (currTime < runtime):
            deliverStim(currTime)
            return True
        displayPlots()
        return False

    viewer1.set_callback(callback1, idletime=0)
    viewer1.pitch(PI / 2, 0)
    viewer1.zoom(0.4, 0)
    viewer1.resize(900, 900)
    #viewer1.showMaximized()
    viewer1.show()

    morphology2 = moogli.read_morphology_from_moose( name = "", \
            path = rdes.elecid.path )
    morphology2.create_group( "group_all", eComptPath, 0.0, 0.002, \
        [1.0, 0.0, 0.0, 1.0], [0.0, 1.0, 1.0, 0.1] )
    viewer2 = moogli.DynamicMorphologyViewerWidget(morphology2)

    def callback2(morphology, viewer2):
        Ca = map(lambda x: moose.element(x).Ca, caElements)
        morphology.set_color("group_all", Ca)
        viewer2.yaw(0.01, 0)
        return True

    viewer2.set_callback(callback2, idletime=0)
    viewer2.pitch(PI / 2, 0)
    viewer2.zoom(0.4, 0)
    viewer2.resize(900, 900)
    #viewer1.showMaximized()
    viewer2.show()
    app.exec_()
Ejemplo n.º 2
0
def main():
    numpy.random.seed(1234)
    rdes = buildRdesigneur()
    rdes.buildModel('/model')
    assert (moose.exists('/model'))
    moose.element('/model/elec/hsolve').tick = -1
    for i in range(0, 10):
        moose.setClock(i, 100)
    for i in range(10, 18):
        moose.setClock(i, dt)
    moose.setClock(18, plotdt)
    moose.reinit()
    buildPlots()
    # Run for baseline, tetanus, and post-tetanic settling time
    print('starting...')
    t1 = time.time()
    moose.start(baselineTime)
    caPsd = moose.vec('/model/chem/psd/Ca_input')
    caDend = moose.vec('/model/chem/dend/DEND/Ca_input')
    castim = (numpy.random.rand(len(caPsd.concInit)) * 0.8 + 0.2) * psdTetCa
    caPsd.concInit = castim
    caDend.concInit = numpy.random.rand(len(caDend.concInit)) * dendTetCa
    moose.start(tetTime)
    caPsd.concInit = basalCa
    caDend.concInit = basalCa
    moose.start(interTetTime)
    caPsd.concInit = castim
    caDend.concInit = numpy.random.rand(len(caDend.concInit)) * dendTetCa
    moose.start(tetTime)
    caPsd.concInit = basalCa
    caDend.concInit = basalCa
    moose.start(postTetTime)
    caPsd.concInit = ltdCa
    caDend.concInit = ltdCa
    moose.start(ltdTime)
    caPsd.concInit = basalCa
    caDend.concInit = basalCa
    moose.start(postLtdTime)
    print(('real time = ', time.time() - t1))

    if do3D:
        app = QtGui.QApplication(sys.argv)
        compts = moose.wildcardFind("/model/elec/#[ISA=compartmentBase]")
        ecomptPath = [x.path for x in compts]
        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] )
        viewer = moogli.DynamicMorphologyViewerWidget(morphology)

        def callback(morphology, viewer):
            moose.start(0.1)
            return True

        viewer.set_callback(callback, idletime=0)
        viewer.showMaximized()
        viewer.show()
        app.exec_()

    displayPlots()
Ejemplo n.º 3
0
def create_vm_visualizer():
    # Moogli requires a morphology object. Create a morphology object
    # by reading the geometry details from all objects of type CompartmentBase
    # inside /cells[0]
    vm_morphology = moogli.read_morphology_from_moose(name = "", path = "/cells[0]")


    # Create a named group of compartments called 'group-all'
    # which will contain all the compartments of the model.
    # Each group has a strict upper and lower limit for the
    # variable which is being visualized.
    # Both limits map to colors provided to the api.
    # The value of the variable is linearly mapped to a color value
    # lying between the upper and lower color values.

    vm_morphology.create_group( "group-all"    # group name
                              , ALL_COMPARTMENTS  # sequence of compartments belonging to this group
                              , BASE_VM_VALUE   # base value of variable
                              , PEAK_VM_VALUE   # peak value of variable
                              , BASE_VM_COLOR # color corresponding to base value
                              , PEAK_VM_COLOR # color corresponding to peak value
                           )


    # set initial color of all compartments in accordance with their vm
    vm_morphology.set_color( "group-all"
                           , [moose.element(x).Vm for x in ALL_COMPARTMENTS]
                           )

    # instantiate the visualizer with the morphology object created earlier
    vm_viewer = moogli.DynamicMorphologyViewerWidget(vm_morphology)

    # Callback function will be called by the visualizer at regular intervals.
    # The callback can modify both the morphology and viewer object's properties
    # since they are passed as arguments.
    def callback(morphology, viewer):
        # run simulation for 1 ms
        moose.start(SIMULATION_DELTA)

        # change color of all the compartments according to their vm values.
        # a value higher than peak value will be clamped to peak value
        # a value lower than base value will be clamped to base value.
        morphology.set_color( "group-all"
                            , [moose.element(x).Vm for x in ALL_COMPARTMENTS]
                            )
        # if the callback returns true, it will be called again.
        # if it returns false it will not be called again.
        # the condition below ensures that simulation runs for 1 sec
        if moose.element("/clock").currentTime < SIMULATION_TIME : return True
        else                                                     : return False


    # set the callback function to be called after every idletime milliseconds
    vm_viewer.set_callback(callback, idletime = 0)

    # make sure that entire model is visible
    vm_viewer.pitch(math.pi / 2)
    vm_viewer.zoom(0.25)
    vm_viewer.setWindowTitle("Vm Visualization")
    return vm_viewer
Ejemplo n.º 4
0
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.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.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_()
Ejemplo n.º 5
0
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]")
    compts[0].inject = inject
    ecomptPath = [x.path for x in compts]
    morphology = moogli.read_morphology_from_moose(name="", path="/model")
    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_()
Ejemplo n.º 6
0
def main():
    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.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_()
Ejemplo n.º 7
0
def create_rm_visualizer():
    # Moogli requires a morphology object. Create a morphology object
    # by reading the geometry details from all objects of type CompartmentBase
    # inside /cells[0]
    morphology = moogli.read_morphology_from_moose(name = "", path = "/cells[0]")

    # Create a named group of compartments called 'group-all'
    # which will contain all the compartments of the model.
    # Each group has a strict upper and lower limit for the
    # variable which is being visualized.
    # Both limits map to colors provided to the api.
    # The value of the variable is linearly mapped to a color value
    # lying between the upper and lower color values.
    morphology.create_group( "group-all"    # group name
                           , ALL_COMPARTMENTS  # sequence of compartments belonging to this group
                           , BASE_RM_VALUE # base value of variable
                           , PEAK_RM_VALUE # peak value of variable
                           , BASE_RM_COLOR # color corresponding to base value
                           , PEAK_RM_COLOR # color corresponding to peak value
                           )

    # set initial color of all compartments in accordance with their rm
    morphology.set_color( "group-all"
                        , map( lambda x : moose.element(x).Rm
                             , ALL_COMPARTMENTS
                             )
                        )

    # instantiate the visualizer with the morphology object created earlier
    rm_viewer = moogli.DynamicMorphologyViewerWidget(morphology)

    # make sure that entire model is visible
    rm_viewer.pitch(math.pi / 2)
    rm_viewer.zoom(0.25)
    rm_viewer.setWindowTitle("Rm")
    return rm_viewer
Ejemplo n.º 8
0
                         , "/cells[0]/BigCellCML_0[0]/Seg0_dend_390_391[0]"
                         , "/cells[0]/BigCellCML_0[0]/Seg0_dend_389_390[0]"
                         , "/cells[0]/BigCellCML_0[0]/Seg0_dend_1079_1080[0]"
                         ]
                       , 0.0
                       , 1.0
                       , [0.0, 1.0, 0.0, 1.0]
                       , [0.0, 0.0, 1.0, 1.0]
                       )
def callback(morphology, viewer):
    morphology.set_color( "group-1"
                        , np.random.random_sample((24,)) * (100.0 - 20.0) + 20.0
                        )
    morphology.set_color( "group-2"
                        , np.random.random_sample((34,))
                        )
    viewer.roll(0.05, 0)
    viewer.pitch(0.05, 1)
    viewer.yaw(0.05, 2)
    return True

viewer = moogli.DynamicMorphologyViewerWidget(morphology)
viewer.showMaximized()
viewer.split_horizontally(0)
viewer.split_vertically(1)
viewer.zoom(0.5, 0)
viewer.zoom(0.5, 1)
viewer.zoom(0.5, 2)
viewer.set_callback(callback)
app.exec_()