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 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_()
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 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.º 5
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()
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"
                        , [moose.element(x).Rm for x in ALL_COMPARTMENTS]
                        )

    # instantiate the visualizer with the morphology object created earlier
    rm_viewer = moogli.MorphologyViewerWidget(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.º 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"
                        , [moose.element(x).Rm for x in ALL_COMPARTMENTS]
                        )

    # instantiate the visualizer with the morphology object created earlier
    rm_viewer = moogli.MorphologyViewerWidget(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
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 = map( lambda x : x.path, 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.º 9
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.º 10
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.º 11
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.º 12
0
def main():
    """
    This illustrates the use of rdesigneur to build a simple dendrite with
    spines, and then to resize them using spine fields. These are the
    fields that would be changed dynamically in a simulation with reactions
    that affect spine geometry.
    In this simulation there is a propagating reaction wave using a
    highly abstracted equation, whose product diffuses into the spines and
    makes them bigger.
    """
    makeModel()
    elec = moose.element('/model/elec')
    elec.setSpineAndPsdMesh(moose.element('/model/chem/spine'),
                            moose.element('/model/chem/psd'))

    eHead = moose.wildcardFind('/model/elec/#head#')
    oldDia = [i.diameter for i in eHead]
    graphs = moose.Neutral('/graphs')
    #makePlot( 'psd_x', moose.vec( '/model/chem/psd/x' ), 'getN' )
    #makePlot( 'head_x', moose.vec( '/model/chem/spine/x' ), 'getN' )
    makePlot('dend_x', moose.vec('/model/chem/dend/x'), 'getN')
    makePlot('dend_z', moose.vec('/model/chem/dend/z'), 'getN')
    makePlot('head_z', moose.vec('/model/chem/spine/z'), 'getN')
    makePlot('psd_z', moose.vec('/model/chem/psd/z'), 'getN')
    makePlot('headDia', eHead, 'getDiameter')
    '''
    debug = moose.PyRun( '/pyrun' )
    debug.tick = 10
    debug.runString = """print( "RUNNING: ", moose.element( '/model/chem/psd/z').n, moose.element( '/model/elec/head0' ).diameter)"""
    '''
    moose.reinit()
    moose.start(runtime)

    displayPlots()
    pylab.plot(oldDia, label='old Diameter')
    pylab.plot([i.diameter for i in eHead], label='new Diameter')
    pylab.legend()
    pylab.show()

    if doMoo:
        app = QtGui.QApplication(sys.argv)
        morphology = moogli.read_morphology_from_moose(name="",
                                                       path='/model/elec')
        widget = moogli.MorphologyViewerWidget(morphology)
        widget.show()
        return app.exec_()
    quit()
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.º 14
0
def main():
    """
    This illustrates the use of rdesigneur to build a simple dendrite with
    spines, and then to resize them using spine fields. These are the
    fields that would be changed dynamically in a simulation with reactions
    that affect spine geometry.
    In this simulation there is a propagating reaction wave using a
    highly abstracted equation, whose product diffuses into the spines and
    makes them bigger.
    """
    makeModel()
    elec = moose.element( '/model/elec' )
    elec.setSpineAndPsdMesh( moose.element('/model/chem/spine'), moose.element('/model/chem/psd') )

    eHead = moose.wildcardFind( '/model/elec/#head#' )
    oldDia = [ i.diameter for i in eHead ]
    graphs = moose.Neutral( '/graphs' )
    #makePlot( 'psd_x', moose.vec( '/model/chem/psd/x' ), 'getN' )
    #makePlot( 'head_x', moose.vec( '/model/chem/spine/x' ), 'getN' )
    makePlot( 'dend_x', moose.vec( '/model/chem/dend/x' ), 'getN' )
    makePlot( 'dend_z', moose.vec( '/model/chem/dend/z' ), 'getN' )
    makePlot( 'head_z', moose.vec( '/model/chem/spine/z' ), 'getN' )
    makePlot( 'psd_z', moose.vec( '/model/chem/psd/z' ), 'getN' )
    makePlot( 'headDia', eHead, 'getDiameter' )

    '''
    debug = moose.PyRun( '/pyrun' )
    debug.tick = 10
    debug.runString = """print "RUNNING: ", moose.element( '/model/chem/psd/z' ).n, moose.element( '/model/elec/head0' ).diameter"""
    '''
    moose.reinit()
    moose.start( runtime )

    displayPlots()
    pylab.plot( oldDia, label = 'old Diameter' )
    pylab.plot( [ i.diameter for i in eHead ], label = 'new Diameter' )
    pylab.legend()
    pylab.show()

    app = QtGui.QApplication(sys.argv)
    #widget = mv.MoogliViewer( '/model' )
    morphology = moogli.read_morphology_from_moose( name="", path = '/model/elec' )
    widget = moogli.MorphologyViewerWidget( morphology )
    widget.show()
    return app.exec_()
    quit()
Ejemplo n.º 15
0
def main():
    app = QtGui.QApplication(sys.argv)
    filename = 'barrionuevo_cell1zr.CNG.swc'
    #filename = 'h10.CNG.swc'
    moose.Neutral( '/library' )
    rdes = rd.rdesigneur()
    rdes.addSpineProto( 'spine', RM, RA, CM, \
             synList = (), chanList = (), caTau = 0.0 )
    moose.Neutral( '/model' )
    cell = moose.loadModel( filename, '/model/testSwc' )
    cell[0].spineSpecification = [ 'spine #apical# '+ spineArgLine, \
        'spine #dend# ' + spineArgLine ]
    cell[0].parseSpines()
    # moose.le( cell )
    for i in range( 8 ):
        moose.setClock( i, simdt )
    hsolve = moose.HSolve( '/model/testSwc/hsolve' )
    hsolve.dt = simdt
    hsolve.target = '/model/testSwc/soma'
    moose.reinit()

    # Now we set up the display
    compts = moose.wildcardFind( "/model/testSwc/#[ISA=CompartmentBase]" )
    compts[0].inject = inject
    ecomptPath = map( lambda x : x.path, 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 = map( lambda x: moose.element( x ).Vm, 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.º 16
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.º 17
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.º 18
0
def main():
    cm = ChannelML( {'temperature': 32 })
    cm.readChannelMLFromFile( 'CA1_migliore_reference/hd.xml' )
    cm.readChannelMLFromFile( 'CA1_migliore_reference/kap.xml' )
    cm.readChannelMLFromFile( 'CA1_migliore_reference/kad.xml' )
    cm.readChannelMLFromFile( 'CA1_migliore_reference/kdr.xml' )
    cm.readChannelMLFromFile( 'CA1_migliore_reference/na3.xml' )
    cm.readChannelMLFromFile( 'CA1_migliore_reference/nax.xml' )
    if ( len( sys.argv ) < 2 ):
        print("Usage: ", sys.argv[0], " filename")
        return

    # filename = "./Bhavika_swcplusnmlfiles/preliminarily corrected nmlfiles/ascoli+buzsaki/valid/" + sys.argv[1]
    filename = sys.argv[1]
    moose.Neutral( '/model' )
    # Load in the swc file.
    cell = moose.loadModel( filename, '/model/ca1' )

    for i in moose.wildcardFind( '/library/##' ):
        i.tick = -1

    chanDistrib = [ \
            "EM", "#", "-58e-3", \
            "initVm", "#", "-65e-3", \
            "RM", "#", "2.8", \
            "CM", "#", "0.01", \
            "RA", "#", "1.5", \
            "RA", "#axon#", "0.5", \

            "hd", "#dend#,#apical#", "5e-2*(1+(r*3e4))", \
            "kdr", "#", "100", \
            "na3", "#soma#,#dend#,#apical#", "250", \
            "nax", "#axon#", "1250", \
            "kap", "#axon#,#soma#", "300", \
            "kap", "#dend#,#apical#", "150*(1+sign(100-r*1e6)) * (1+(r*1e4))", \
            "kad", "#dend#,#apical#", "150*(1+sign(r*1e6-100))*(1+r*1e4)", \
            ]
    moose.showfields( cell[0] )
    cell[0].channelDistribution = chanDistrib
    cell[0].parseChanDistrib()
    for i in range( 8 ):
        moose.setClock( i, simdt )
    hsolve = moose.HSolve( '/model/ca1/hsolve' )
    hsolve.dt = simdt
    hsolve.target = '/model/ca1/soma'
    '''
    '''
    moose.reinit()
    makePlot( cell[0] )

    # Now we set up the display
    moose.le( '/model/ca1/soma' )
    soma = moose.element( '/model/ca1/soma' )
    kap = moose.element( '/model/ca1/soma/kap' )

    graphs = moose.Neutral( '/graphs' )
    vtab = moose.Table( '/graphs/vtab' )
    moose.connect( vtab, 'requestOut', soma, 'getVm' )
    kaptab = moose.Table( '/graphs/kaptab' )
    moose.connect( kaptab, 'requestOut', kap, 'getGk' )

    compts = moose.wildcardFind( "/model/ca1/#[ISA=CompartmentBase]" )
    '''
    for i in compts:
        if moose.exists( i.path + '/Na' ):
            print i.path, moose.element( i.path + '/Na' ).Gbar, \
                moose.element( i.path + '/K_DR' ).Gbar, \
                i.Rm, i.Ra, i.Cm
    '''
    '''
    Na = moose.wildcardFind( '/model/ca1/#/Na#' )
    print Na
    Na2 = []
    for i in compts:
        if ( moose.exists( i.path + '/NaF2' ) ):
            Na2.append(  moose.element( i.path + '/NaF2' ) )
        if ( moose.exists( i.path + '/NaPF_SS' ) ):
            Na2.append(  moose.element( i.path + '/NaPF_SS' ) )
    ecomptPath = map( lambda x : x.path, compts )
    print "Na placed in ", len( Na ), len( Na2 ),  " out of ", len( compts ), " compts."
    '''
    compts[0].inject = inject
    ecomptPath = [x.path for x in compts]

    # Graphics stuff here.
    app = QtGui.QApplication(sys.argv)
    morphology = moogli.read_morphology_from_moose(name = "", path = "/model/ca1")
    morphology.create_group( "group_all", ecomptPath, -0.08, 0.02, \
            [0.0, 0.0, 1.0, 1.0], [1.0, 0.0, 0.0, 0.1] ) 

    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_()
    t = numpy.arange( 0, runtime, vtab.dt )
    fig = plt.figure()
    p1 = fig.add_subplot(311)
    p2 = fig.add_subplot(312)
    p2.plot( t,  vtab.vector, label = 'Vm Soma' )
    p2.legend()
    p3 = fig.add_subplot(313)
    p3.plot( t, kaptab.vector, label = 'kap Soma' )
    p3.legend()
    plt.show()
Ejemplo n.º 19
0
import moogli
import moose
from moose import neuroml
from PyQt4 import Qt, QtCore, QtGui
import sys
import os

app = QtGui.QApplication(sys.argv)
filename = os.path.join(
    os.path.split(os.path.realpath(__file__))[0],
    "../neuroml/PurkinjeCellPassivePulseInput/PurkinjePassive.net.xml")
moose.neuroml.loadNeuroML_L123(filename)
morphology_distal = moogli.read_morphology_from_moose(name="",
                                                      path="/cells[0]",
                                                      radius=moogli.DISTAL)
viewer_distal = moogli.MorphologyViewerWidget(morphology_distal)
viewer_distal.setWindowTitle("Distal Radius")

morphology_averaged = moogli.read_morphology_from_moose(name="",
                                                        path="/cells[0]",
                                                        radius=moogli.AVERAGED)
viewer_averaged = moogli.MorphologyViewerWidget(morphology_averaged)
viewer_averaged.setWindowTitle("Averaged Radius")

morphology_proximal_distal = moogli.read_morphology_from_moose(
    name="", path="/cells[0]", radius=moogli.PROXIMAL_DISTAL)
viewer_proximal_distal = moogli.MorphologyViewerWidget(
    morphology_proximal_distal)
viewer_proximal_distal.setWindowTitle("Continous Variation in Radius")

viewer_distal.show()
Ejemplo n.º 20
0
def main():
    """
    This illustrates the use of rdesigneur to build a simple dendrite with
    spines, and to confirm that the chemical contents of the spines align
    with the electrical. Just a single molecule Ca is involved.
    It diffuses and we plot the distribution.
    It causes 'inject' of the relevant compartment to rise.
    """
    makeModel()

    # Create the output tables
    graphs = moose.Neutral('/graphs')
    #dendVm = addPlot( 'model/elec/dend', 'getVm', 'dendVm', 8 )
    addPlot('model/chem/dend/Ca[0]', 'getConc', 'dCa0', 18)
    addPlot('model/chem/dend/Ca[25]', 'getConc', 'dCa25', 18)
    addPlot('model/chem/dend/Ca[49]', 'getConc', 'dCa49', 18)
    addPlot('model/chem/spine/Ca[0]', 'getN', 'sCa0', 18)
    addPlot('model/chem/spine/Ca[25]', 'getN', 'sCa25', 18)
    addPlot('model/chem/spine/Ca[49]', 'getN', 'sCa49', 18)
    addPlot('model/chem/psd/Ca[0]', 'getConc', 'pCa0', 18)
    addPlot('model/chem/psd/Ca[25]', 'getConc', 'pCa25', 18)
    addPlot('model/chem/psd/Ca[49]', 'getConc', 'pCa49', 18)

    d = moose.vec('/model/chem/dend/Ca')
    s = moose.vec('/model/chem/spine/Ca')
    p = moose.vec('/model/chem/psd/Ca')
    s[5].nInit = 1000
    s[40].nInit = 5000
    moose.reinit()
    moose.start(runtime)

    fig = plt.figure(figsize=(13, 10))
    p1 = fig.add_subplot(311)
    plotVm(p1, 'dend')
    plotVm(p1, 'head')
    plotVm(p1, 'psd')
    p1.legend()
    #time = numpy.arange( 0, dendVm.vector.size, 1 ) * dendVm.dt
    #p1.plot( time, dendVm.vector, label = 'dendVm' )
    p2 = fig.add_subplot(312)
    p2.plot(d.conc, label='idendCa')
    p2.plot(s.conc, label='ispineCa')
    p2.plot(p.conc, label='ipsdCa')
    p2.legend()
    '''
    p2 = fig.add_subplot( 312 )
    for i in moose.wildcardFind( '/graphs/#Ca#' ):
        time = numpy.arange( 0, i.vector.size, 1 ) * i.dt
        p2.plot( time, i.vector, label = i.name )
    p2.legend()
    '''
    p3 = fig.add_subplot(313)
    p3.plot(getMidpts('dend'), d.conc, label='dendCa')
    #p3.plot( range( 0, len( d ) ), d.conc, label = 'dendCa' )

    p3.plot(getMidpts('spine'), s.conc, label='spineCa')
    p3.plot(getMidpts('psd'), p.conc, label='psdCa')
    p3.legend()

    plt.show()
    '''
    '''
    app = QtGui.QApplication(sys.argv)
    #widget = mv.MoogliViewer( '/model' )
    morphology = moogli.read_morphology_from_moose(name="", path='/model/elec')
    widget = moogli.MorphologyViewerWidget(morphology)
    widget.show()
    return app.exec_()
    quit()
Ejemplo n.º 21
0
    quit()

import moose
from moose import neuroml
from PyQt4 import Qt, QtCore, QtGui
import sys
import os
import random
import numpy as np

app = QtGui.QApplication(sys.argv)
filename = os.path.join( os.path.split(os.path.realpath(__file__))[0]
                       , "../neuroml/PurkinjeCellPassivePulseInput/PurkinjePassive.net.xml"
                       )
moose.neuroml.loadNeuroML_L123(filename)
morphology = moogli.read_morphology_from_moose(name = "", path = "/cells[0]")
morphology.create_group( "group-1"
                       , [ "/cells[0]/BigCellCML_0[0]/Seg0_dend_1043_1044[0]"
                         , "/cells[0]/BigCellCML_0[0]/Seg0_dend_1033_1034[0]"
                         , "/cells[0]/BigCellCML_0[0]/Seg0_dend_1019_1020[0]"
                         , "/cells[0]/BigCellCML_0[0]/Seg0_dend_1018_1019[0]"
                         , "/cells[0]/BigCellCML_0[0]/Seg0_dend_1016_1017[0]"
                         , "/cells[0]/BigCellCML_0[0]/Seg0_dend_1539_1540[0]"
                         , "/cells[0]/BigCellCML_0[0]/Seg0_dend_1579_1580[0]"
                         , "/cells[0]/BigCellCML_0[0]/Seg0_dend_1573_1574[0]"
                         , "/cells[0]/BigCellCML_0[0]/Seg0_dend_1572_1573[0]"
                         , "/cells[0]/BigCellCML_0[0]/Seg0_dend_1569_1570[0]"
                         , "/cells[0]/BigCellCML_0[0]/Seg0_dend_1559_1560[0]"
                         , "/cells[0]/BigCellCML_0[0]/Seg0_dend_1045_1046[0]"
                         , "/cells[0]/BigCellCML_0[0]/Seg0_dend_1021_1022[0]"
                         , "/cells[0]/BigCellCML_0[0]/Seg0_dend_1020_1021[0]"
Ejemplo n.º 22
0
def main():
    """
    This illustrates the use of rdesigneur to build a simple dendrite with
    spines, and to confirm that the chemical contents of the spines align
    with the electrical. Just a single molecule Ca is involved.
    It diffuses and we plot the distribution.
    It causes 'inject' of the relevant compartment to rise.
    """
    makeModel()

    # Create the output tables
    graphs = moose.Neutral( '/graphs' )
    #dendVm = addPlot( 'model/elec/dend', 'getVm', 'dendVm', 8 )
    addPlot( 'model/chem/dend/Ca[0]', 'getConc', 'dCa0', 18 )
    addPlot( 'model/chem/dend/Ca[25]', 'getConc', 'dCa25', 18 )
    addPlot( 'model/chem/dend/Ca[49]', 'getConc', 'dCa49', 18 )
    addPlot( 'model/chem/spine/Ca[0]', 'getN', 'sCa0', 18 )
    addPlot( 'model/chem/spine/Ca[25]', 'getN', 'sCa25', 18 )
    addPlot( 'model/chem/spine/Ca[49]', 'getN', 'sCa49', 18 )
    addPlot( 'model/chem/psd/Ca[0]', 'getConc', 'pCa0', 18 )
    addPlot( 'model/chem/psd/Ca[25]', 'getConc', 'pCa25', 18 )
    addPlot( 'model/chem/psd/Ca[49]', 'getConc', 'pCa49', 18 )

    d = moose.vec( '/model/chem/dend/Ca' )
    s = moose.vec( '/model/chem/spine/Ca' )
    p = moose.vec( '/model/chem/psd/Ca' )
    s[5].nInit = 1000
    s[40].nInit = 5000
    moose.reinit()
    moose.start( runtime )

    fig = plt.figure( figsize = (13,10 ) )
    p1 = fig.add_subplot( 311 )
    plotVm( p1, 'dend' )
    plotVm( p1, 'head' )
    plotVm( p1, 'psd' )
    p1.legend()
    #time = numpy.arange( 0, dendVm.vector.size, 1 ) * dendVm.dt
    #p1.plot( time, dendVm.vector, label = 'dendVm' )
    p2 = fig.add_subplot( 312 )
    p2.plot( d.conc, label = 'idendCa' )
    p2.plot( s.conc, label = 'ispineCa' )
    p2.plot( p.conc, label = 'ipsdCa' )
    p2.legend()
    '''
    p2 = fig.add_subplot( 312 )
    for i in moose.wildcardFind( '/graphs/#Ca#' ):
        time = numpy.arange( 0, i.vector.size, 1 ) * i.dt
        p2.plot( time, i.vector, label = i.name )
    p2.legend()
    '''
    p3 = fig.add_subplot( 313 )
    p3.plot( getMidpts('dend'), d.conc, label = 'dendCa' )
    #p3.plot( range( 0, len( d ) ), d.conc, label = 'dendCa' )


    p3.plot( getMidpts('spine'), s.conc, label = 'spineCa' )
    p3.plot( getMidpts('psd'), p.conc, label = 'psdCa' )
    p3.legend()

    plt.show()
    app = QtGui.QApplication(sys.argv)
    #widget = mv.MoogliViewer( '/model' )
    morphology = moogli.read_morphology_from_moose( name="", path = '/model/elec' )
    widget = moogli.MorphologyViewerWidget( morphology )
    widget.show()
    return app.exec_()
    quit()
Ejemplo n.º 23
0
import moogli
import moose
from moose import neuroml
from PyQt4 import Qt, QtCore, QtGui
import sys
import os

app = QtGui.QApplication(sys.argv)
filename = os.path.join( os.path.split(os.path.realpath(__file__))[0]
                       , "../neuroml/PurkinjeCellPassivePulseInput/PurkinjePassive.net.xml"
                       )
moose.neuroml.loadNeuroML_L123(filename)
morphology_distal = moogli.read_morphology_from_moose(name = "", path = "/cells[0]", radius = moogli.DISTAL)
viewer_distal = moogli.MorphologyViewerWidget(morphology_distal)
viewer_distal.setWindowTitle("Distal Radius")

morphology_averaged = moogli.read_morphology_from_moose(name = "", path = "/cells[0]", radius = moogli.AVERAGED)
viewer_averaged = moogli.MorphologyViewerWidget(morphology_averaged)
viewer_averaged.setWindowTitle("Averaged Radius")

morphology_proximal_distal = moogli.read_morphology_from_moose(name = "", path = "/cells[0]", radius = moogli.PROXIMAL_DISTAL)
viewer_proximal_distal = moogli.MorphologyViewerWidget(morphology_proximal_distal)
viewer_proximal_distal.setWindowTitle("Continous Variation in Radius")

viewer_distal.show()
viewer_averaged.show()
viewer_proximal_distal.show()
app.exec_()
Ejemplo n.º 24
0
def main():
    """
This illustrates the use of rdesigneur to build a simple dendrite with
spines, and then to resize them using spine fields. These are the
fields that would be changed dynamically in a simulation with reactions
that affect spine geometry.

    """
    makeModel()
    elec = moose.element('/model/elec')
    elec.setSpineAndPsdMesh(moose.element('/model/chem/spine'),
                            moose.element('/model/chem/psd'))
    caDend = moose.vec('/model/chem/dend/Ca')
    caHead = moose.vec('/model/chem/spine/Ca')
    caPsd = moose.vec('/model/chem/psd/Ca')
    eHead = moose.wildcardFind('/model/elec/#head#')
    graphs = moose.Neutral('/graphs')
    psdTab = moose.Table2('/graphs/psdTab', len(caPsd)).vec
    headTab = moose.Table2('/graphs/headTab', len(caHead)).vec
    dendTab = moose.Table2('/graphs/dendTab', len(caDend)).vec
    eTab = moose.Table('/graphs/eTab', len(eHead)).vec
    stimtab = moose.StimulusTable('/stim')
    stimtab.stopTime = 0.3
    stimtab.loopTime = 0.3
    stimtab.doLoop = True
    stimtab.vector = [
        1.0 + numpy.sin(x) for x in numpy.arange(0, 2 * PI, PI / 1000)
    ]
    estimtab = moose.StimulusTable('/estim')
    estimtab.stopTime = 0.001
    estimtab.loopTime = 0.001
    estimtab.doLoop = True
    estimtab.vector = [
        1e-9 * numpy.sin(x) for x in numpy.arange(0, 2 * PI, PI / 1000)
    ]

    for i in range(len(caPsd)):
        moose.connect(psdTab[i], 'requestOut', caPsd[i], 'getConc')
    for i in range(len(caHead)):
        moose.connect(headTab[i], 'requestOut', caHead[i], 'getConc')
    for i in range(len(caDend)):
        moose.connect(dendTab[i], 'requestOut', caDend[i], 'getConc')
    for i in range(len(eHead)):
        moose.connect(eTab[i], 'requestOut', eHead[i], 'getVm')
    moose.connect(stimtab, 'output', caDend, 'setConc', 'OneToAll')
    dend = moose.element('/model/elec/dend')
    moose.connect(estimtab, 'output', dend, 'setInject')

    moose.reinit()
    moose.start(1)

    head0 = moose.element('/model/elec/head0')
    shaft1 = moose.element('/model/elec/shaft1')
    head2 = moose.element('/model/elec/head2')

    # Here we scale the spine head length while keeping all vols constt.
    print("Spine 0: longer head, same vol\nSpine 1: longer shaft")
    print("Spine 2: Bigger head, same diffScale\n")
    elecParms = [(i.Rm, i.Cm, i.Ra) for i in (head0, shaft1, head2)]
    chemParms = [
        i.volume for i in (caHead[0], caPsd[0], caHead[1], caPsd[1], caHead[2],
                           caPsd[2])
    ]

    elec.spine[0].headLength *= 4  # 4x length
    elec.spine[0].headDiameter *= 0.5  #  1/2 x dia

    # Here we scale the shaft length. Vols are not touched.
    elec.spine[1].shaftLength *= 2  # 2 x length

    #Here we scale the spine head vol while retaining diffScale = xArea/len
    # This gives 4x vol.
    hdia = elec.spine[2].headDiameter
    sdsolve = moose.element('/model/chem/spine/dsolve')
    elec.spine[2].headLength *= 2  # 2x length
    elec.spine[2].headDiameter *= numpy.sqrt(2)  # sqrt(2) x dia
    hdia = elec.spine[2].headDiameter

    print("Checking scaling assertions: ")
    assertEq(elecParms[0][0] * 0.5, head0.Rm)
    assertEq(elecParms[0][1] * 2, head0.Cm)
    assertEq(elecParms[0][2] * 16, head0.Ra)
    assertEq(chemParms[0], caHead[0].volume)
    assertEq(chemParms[1] * 0.25, caPsd[0].volume)

    assertEq(elecParms[1][0] * 0.5, shaft1.Rm)
    assertEq(elecParms[1][1] * 2, shaft1.Cm)
    assertEq(elecParms[1][2] * 2, shaft1.Ra)
    assertEq(chemParms[2], caHead[1].volume)
    assertEq(chemParms[3], caPsd[1].volume)

    ratio = 2 * numpy.sqrt(2)
    assertEq(elecParms[2][0] / ratio, head2.Rm)
    assertEq(elecParms[2][1] * ratio, head2.Cm)
    assertEq(elecParms[2][2], head2.Ra)
    assertEq(chemParms[4] * 4, caHead[2].volume)
    assertEq(chemParms[5] * 2, caPsd[2].volume)
    print("\nAll assertions cleared")

    moose.start(2)
    for i in range(len(psdTab)):
        pylab.plot(psdTab[i].vector, label='PSD' + str(i))
    pylab.legend()
    pylab.figure()
    for i in range(len(headTab)):
        pylab.plot(headTab[i].vector, label='head' + str(i))
    pylab.legend()
    pylab.figure()
    for i in range(len(dendTab)):
        pylab.plot(dendTab[i].vector, label='dendCa' + str(i))
    pylab.legend()
    pylab.figure()
    for i in range(len(eTab)):
        pylab.plot(eTab[i].vector, label='headVm' + str(i))
        #print i, len( eTab[i].vector ), eTab[i].vector
    pylab.legend()
    pylab.show()

    app = QtGui.QApplication(sys.argv)
    #widget = mv.MoogliViewer( '/model' )
    morphology = moogli.read_morphology_from_moose(name="", path='/model/elec')
    widget = moogli.MorphologyViewerWidget(morphology)
    widget.show()
    return app.exec_()
    quit()
Ejemplo n.º 25
0
def main():
    """
    This illustrates the use of rdesigneur to build a simple dendrite with
    spines, and then to resize them using spine fields. These are the 
    fields that would be changed dynamically in a simulation with reactions
    that affect spine geometry.
    """
    makeModel()
    elec = moose.element( '/model/elec' )
    elec.setSpineAndPsdMesh( moose.element('/model/chem/spine'), moose.element('/model/chem/psd') )
    caDend = moose.vec( '/model/chem/dend/Ca' )
    caHead = moose.vec( '/model/chem/spine/Ca' )
    caPsd = moose.vec( '/model/chem/psd/Ca' )
    eHead = moose.wildcardFind( '/model/elec/#head#' )
    graphs = moose.Neutral( '/graphs' )
    psdTab = moose.Table2( '/graphs/psdTab', len( caPsd ) ).vec
    headTab = moose.Table2( '/graphs/headTab', len( caHead ) ).vec
    dendTab = moose.Table2( '/graphs/dendTab', len( caDend ) ).vec
    eTab = moose.Table( '/graphs/eTab', len( eHead ) ).vec
    stimtab = moose.StimulusTable( '/stim' )
    stimtab.stopTime = 0.3
    stimtab.loopTime = 0.3
    stimtab.doLoop = True
    stimtab.vector = [ 1.0 + numpy.sin( x ) for x in numpy.arange( 0, 2*PI, PI/1000 ) ]
    estimtab = moose.StimulusTable( '/estim' )
    estimtab.stopTime = 0.001
    estimtab.loopTime = 0.001
    estimtab.doLoop = True
    estimtab.vector = [ 1e-9*numpy.sin( x ) for x in numpy.arange( 0, 2*PI, PI/1000 ) ]

    for i in range( len( caPsd ) ):
        moose.connect( psdTab[ i ], 'requestOut', caPsd[i], 'getConc' )
    for i in range( len( caHead ) ):
        moose.connect( headTab[ i ], 'requestOut', caHead[i], 'getConc' )
    for i in range( len( caDend ) ):
        moose.connect( dendTab[ i ], 'requestOut', caDend[i], 'getConc' )
    for i in range( len( eHead ) ):
        moose.connect( eTab[ i ], 'requestOut', eHead[i], 'getVm' )
    moose.connect( stimtab, 'output', caDend, 'setConc', 'OneToAll' )
    dend = moose.element( '/model/elec/dend' )
    moose.connect( estimtab, 'output', dend, 'setInject' )

    moose.reinit()
    moose.start( 1 )

    head0 = moose.element( '/model/elec/head0' )
    shaft1 = moose.element( '/model/elec/shaft1' )
    head2 = moose.element( '/model/elec/head2' )

    # Here we scale the spine head length while keeping all vols constt.
    print("Spine 0: longer head, same vol\nSpine 1: longer shaft")
    print("Spine 2: Bigger head, same diffScale\n")
    elecParms = [ (i.Rm, i.Cm, i.Ra) for i in ( head0, shaft1, head2) ]
    chemParms = [ i.volume for i in ( caHead[0], caPsd[0], caHead[1], caPsd[1], caHead[2], caPsd[2] ) ]

    elec.spine[0].headLength *= 4 # 4x length
    elec.spine[0].headDiameter *= 0.5 #  1/2 x dia

    # Here we scale the shaft length. Vols are not touched.
    elec.spine[1].shaftLength *= 2 # 2 x length

    #Here we scale the spine head vol while retaining diffScale = xArea/len
    # This gives 4x vol.
    hdia = elec.spine[2].headDiameter
    sdsolve = moose.element( '/model/chem/spine/dsolve' )
    elec.spine[2].headLength *= 2 # 2x length
    elec.spine[2].headDiameter *= numpy.sqrt(2) # sqrt(2) x dia
    hdia = elec.spine[2].headDiameter

    print("Checking scaling assertions: ")
    assertEq( elecParms[0][0] * 0.5 , head0.Rm )
    assertEq( elecParms[0][1] * 2 , head0.Cm )
    assertEq( elecParms[0][2] * 16 , head0.Ra )
    assertEq( chemParms[0] , caHead[0].volume )
    assertEq( chemParms[1] * 0.25 , caPsd[0].volume )

    assertEq( elecParms[1][0] * 0.5 , shaft1.Rm )
    assertEq( elecParms[1][1] * 2 , shaft1.Cm )
    assertEq( elecParms[1][2] * 2 , shaft1.Ra )
    assertEq( chemParms[2] , caHead[1].volume )
    assertEq( chemParms[3] , caPsd[1].volume )

    ratio = 2 * numpy.sqrt( 2 )
    assertEq( elecParms[2][0] / ratio , head2.Rm )
    assertEq( elecParms[2][1] * ratio , head2.Cm )
    assertEq( elecParms[2][2] , head2.Ra )
    assertEq( chemParms[4] * 4 , caHead[2].volume )
    assertEq( chemParms[5] * 2 , caPsd[2].volume )
    print("\nAll assertions cleared")

    moose.start( 2 )
    for i in range( len( psdTab ) ):
        pylab.plot( psdTab[i].vector, label= 'PSD' + str(i) )
    pylab.legend()
    pylab.figure()
    for i in range( len( headTab ) ):
        pylab.plot( headTab[i].vector, label= 'head' + str(i) )
    pylab.legend()
    pylab.figure()
    for i in range( len( dendTab ) ):
        pylab.plot( dendTab[i].vector, label= 'dendCa' + str(i) )
    pylab.legend()
    pylab.figure()
    for i in range( len( eTab ) ):
        pylab.plot( eTab[i].vector, label= 'headVm' + str(i) )
        #print i, len( eTab[i].vector ), eTab[i].vector
    pylab.legend()
    pylab.show()

    app = QtGui.QApplication(sys.argv)
    #widget = mv.MoogliViewer( '/model' )
    morphology = moogli.read_morphology_from_moose( name="", path = '/model/elec' )
    widget = moogli.MorphologyViewerWidget( morphology )
    widget.show()
    return app.exec_()
    quit()