NeuroML / org.neuroml.export

Export from NeuroML & LEMS
http://neuroml.org
GNU Lesser General Public License v3.0
8 stars 10 forks source link

NeuronWriter needs to replace tokens that are reserved in Python #73

Closed sanjayankur31 closed 3 years ago

sanjayankur31 commented 3 years ago

Here's an example LEMS simulation file:

<Lems>

    <!-- 

        This LEMS file has been automatically generated using PyNeuroML v0.5.11 (libNeuroML v0.2.55)

     -->

    <!-- Specify which component to run -->
    <Target component="olm_example_sim"/>

    <!-- Include core NeuroML2 ComponentType definitions -->
    <Include file="Cells.xml"/>
    <Include file="Networks.xml"/>
    <Include file="Simulation.xml"/>

    <Include file="olm_example_net.nml"/>
    <Include file="olm.cell.nml"/>
    <Include file="olm-example/leak_chan.channel.nml"/>
    <Include file="olm-example/HCNolm.channel.nml"/>
    <Include file="olm-example/Kdrfast.channel.nml"/>
    <Include file="olm-example/KvAolm.channel.nml"/>
    <Include file="olm-example/Nav.channel.nml"/>

    <Simulation id="olm_example_sim" length="300ms" step="0.01ms" target="single_olm_cell_network" seed="123">  <!-- Note seed: ensures same random numbers used every run -->

        <OutputFile id="output0" fileName="olm_example_sim.dat">
            <OutputColumn id="pop0[0]_v" quantity="pop0[0]/v"/> 
            <OutputColumn id="pop0[0]_iChannels" quantity="pop0[0]/iChannels"/> 
            <OutputColumn id="pop0[0]_Nav_dendrite_iDensity" quantity="pop0[0]/biophys/membraneProperties/Nav_dendrite/iDensity/"/> 
            <OutputColumn id="pop0[0]_Nav_soma_iDensity" quantity="pop0[0]/biophys/membraneProperties/Nav_soma/iDensity/"/> 
            <OutputColumn id="pop0[0]_Nav_axon_iDensity" quantity="pop0[0]/biophys/membraneProperties/Nav_axon/iDensity/"/> 
        </OutputFile>

    </Simulation>

</Lems>

The writer converts this to this sort of Python code:


        # ######################   File to save: olm_example_sim.dat (output0)
        py_v_pop0[0]_v_output0 = [ float(x  / 1000.0) for x in h.v_pop0[0]_v_output0.to_python() ]  # Convert to Python list for speed, variable has dim: voltage
        py_v_pop0[0]_iChannels_output0 = [ float(x  / 1.0E9) for x in h.v_pop0[0]_iChannels_output0.to_python() ]  # Convert to Python list for speed, variable has dim: current
        py_v_pop0[0]_Nav_dendrite_iDensity_output0 = [ float(x  / 0.001) for x in h.v_pop0[0]_Nav_dendrite_iDensity_output0.to_python() ]  # Convert to Python list for speed, variable has dim: currentDensity
        py_v_pop0[0]_Nav_soma_iDensity_output0 = [ float(x  / 0.001) for x in h.v_pop0[0]_Nav_soma_iDensity_output0.to_python() ]  # Convert to Python list for speed, variable has dim: currentDensity
        py_v_pop0[0]_Nav_axon_iDensity_output0 = [ float(x  / 0.001) for x in h.v_pop0[0]_Nav_axon_iDensity_output0.to_python() ]  # Convert to Python list for speed, variable has dim: currentDensity

here, since the [0] bits are included in the variable name, the script won't run. So, we need to figure out a way to replace these to come up with valid Python variable names. The simplest would to replace [xx] with _xx_ I guess, but we need to see how this may affect the running of the script.

pgleeson commented 3 years ago

@sanjayankur31 Fixed now?

sanjayankur31 commented 3 years ago

Yes, closing.