root/trunk/transformations/FacetsMLtoNeuroML.xsl

Revision 12, 11.1 kB (checked in by debeissat, 1 year ago)

facetsML becomes FacetsML!!

Line 
1 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
2     xmlns:fml="http://neuralensemble.org/FacetsML"
3     xmlns:class="http://neuralensemble.org/FacetsML/cellclass"
4     xmlns:rand="http://neuralensemble.org/FacetsML/randomNumberGenerator"
5     xmlns:net="http://morphml.org/networkml/schema"
6     xmlns:mml="http://morphml.org/morphml/schema"
7     xmlns:cml="http://morphml.org/channelml/schema"
8     xmlns:meta="http://morphml.org/metadata/schema"
9     xmlns:bio="http://morphml.org/biophysics/schema"
10     xmlns="http://morphml.org/neuroml/schema">
11     <xsl:output method="xml" indent="yes" xml:space="default"/>
12     <xsl:template match="/">
13             <xsl:apply-templates select="fml:network"/>
14     </xsl:template>
15    
16     <xsl:template match="fml:network">
17         <neuroml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18             xsi:schemaLocation="http://morphml.org/neuroml/schema Level3/NeuroML_Level3_v1.6.xsd"
19             xmlns:net="http://morphml.org/networkml/schema"
20             xmlns:mml="http://morphml.org/morphml/schema"
21             xmlns:cml="http://morphml.org/channelml/schema"
22             xmlns:meta="http://morphml.org/metadata/schema"
23             xmlns:bio="http://morphml.org/biophysics/schema"
24             xmlns="http://morphml.org/neuroml/schema"
25             lengthUnits="micron">
26         <xsl:apply-templates select="fml:cells"/>
27         <channels units="Physiological Units">
28             <cml:ion charge="1" name="non_specific" default_erev="-65.0"/>
29             <xsl:apply-templates select="//fml:cell" mode="addChannelMechanisms"/>
30         </channels>
31         <xsl:apply-templates select="fml:populations"/>
32         <xsl:apply-templates select="fml:projections"/>
33         </neuroml>
34     </xsl:template>
35    
36    
37     <xsl:template match="fml:cells">
38         <cells>
39             <xsl:apply-templates select="fml:cell"/>
40         </cells>
41     </xsl:template>   
42    
43     <xsl:template match="fml:cell">
44         <cell name="{@name}">
45             <xsl:apply-templates select="class:IF_cond_exp">
46                 <xsl:with-param name="name" select="@name"/>
47             </xsl:apply-templates>
48         </cell>
49     </xsl:template>
50    
51     <xsl:template match="fml:cell" mode="addChannelMechanisms">
52             <xsl:apply-templates select="class:IF_cond_exp" mode="addChannelMechanisms">
53                 <xsl:with-param name="name" select="@name"/>
54             </xsl:apply-templates>
55     </xsl:template>
56    
57    
58     <xsl:template match="class:IF_cond_exp">
59         <xsl:param name="name"/>
60         <meta:notes>Instance of PyNN IF_cond_exp cell type</meta:notes>
61         <mml:segments>
62             <mml:segment id="0" cable="0" name="Soma">
63                 <mml:proximal y="0" x="0" z="0" diameter="318.309886184"/>
64                 <mml:distal y="0" x="0" z="100" diameter="318.309886184"/>
65             </mml:segment>
66         </mml:segments>
67         <mml:cables>
68             <mml:cable id="0" name="Soma">
69                 <meta:group>all</meta:group>
70             </mml:cable>
71         </mml:cables>
72         <biophysics units="Physiological Units">
73             <bio:mechanism type="Channel Mechanism" name="IandF_{$name}"/>
74             <bio:mechanism type="Channel Mechanism" name="pas_{$name}">
75                 <bio:parameter name="gmax" value="5e-05">
76                     <bio:group>all</bio:group>
77                 </bio:parameter>
78             </bio:mechanism>
79             <bio:specificCapacitance>
80                 <bio:parameter value="{@cm}">
81                     <bio:group>all</bio:group>
82                 </bio:parameter>
83             </bio:specificCapacitance>
84             <bio:specificAxialResistance>
85                 <bio:parameter value="0.1">
86                     <bio:group>all</bio:group>
87                 </bio:parameter>
88             </bio:specificAxialResistance>
89             <bio:initialMembPotential>
90                 <bio:parameter value="{@v_init}">
91                     <bio:group>all</bio:group>
92                 </bio:parameter>
93             </bio:initialMembPotential>
94             <net:potentialSynapticLocation>
95                 <net:synapse_type>ExcitatorySynapse_<xsl:value-of select="$name"/></net:synapse_type>
96                 <net:synapse_direction>preAndOrPost</net:synapse_direction>
97                 <net:group>all</net:group>
98             </net:potentialSynapticLocation>
99             <net:potentialSynapticLocation>
100                 <net:synapse_type>InhibitorySynapse_<xsl:value-of select="$name"/></net:synapse_type>
101                 <net:synapse_direction>preAndOrPost</net:synapse_direction>
102                 <net:group>all</net:group>
103             </net:potentialSynapticLocation>
104         </biophysics>
105     </xsl:template>
106    
107     <xsl:template match="class:IF_cond_exp" mode="addChannelMechanisms">
108         <xsl:param name="name"/>
109         <cml:channel_type name="pas_{$name}" density="yes">
110             <meta:notes>Simple example of a leak/passive conductance</meta:notes>
111             <cml:current_voltage_relation>
112                 <cml:ohmic ion="non_specific">
113                     <cml:conductance default_gmax="5e-05"/>
114                 </cml:ohmic>
115             </cml:current_voltage_relation>
116         </cml:channel_type>
117         <cml:channel_type name="IandF_{$name}">
118             <meta:notes>Spike and reset mechanism</meta:notes>
119             <cml:current_voltage_relation>
120                 <cml:integrate_and_fire threshold="{@v_thresh}" g_refrac="0.1" t_refrac="{@tau_refrac}" v_reset="{@v_reset}"/>
121             </cml:current_voltage_relation>
122         </cml:channel_type>
123         <cml:synapse_type name="ExcitatorySynapse_{$name}">
124             <cml:doub_exp_syn rise_time="{@tau_syn_E}" max_conductance="1.0e-5" reversal_potential="{@e_rev_E}" decay_time="5.0"/>
125         </cml:synapse_type>
126         <cml:synapse_type name="InhibitorySynapse_{$name}">
127             <cml:doub_exp_syn rise_time="{@tau_syn_I}" max_conductance="1.0e-5" reversal_potential="{@e_rev_I}" decay_time="5.0"/>
128         </cml:synapse_type>
129     </xsl:template>
130    
131     <xsl:template match="fml:populations">
132         <net:populations>
133             <xsl:apply-templates select="fml:population"/>
134         </net:populations>
135     </xsl:template>
136    
137     <xsl:template match="fml:population">
138         <net:population name="{@name}">
139             <xsl:variable name="size" select="fml:dim/@size"/>
140             <net:cell_type><xsl:value-of select="fml:cell_type/@name"/></net:cell_type>
141             <net:pop_location>
142                 <net:random_arrangement>
143                     <net:population_size><xsl:value-of select="$size"/></net:population_size>
144                     <net:rectangular_location>
145                         <meta:corner x="0" y="0" z="0"/>
146                         <meta:size depth="{$size}" height="{$size}" width="{$size}"/>
147                     </net:rectangular_location>
148                 </net:random_arrangement>
149             </net:pop_location>
150         </net:population>
151     </xsl:template>
152    
153     <xsl:template match="fml:projections">
154         <net:projections units='Physiological Units'>
155             <xsl:apply-templates select="fml:projection"/>
156         </net:projections>
157     </xsl:template>
158    
159     <xsl:template match="fml:projection">
160         <net:projection name="{@name}">
161             <net:source><xsl:value-of select="@presynaptic_population_name"/></net:source>
162             <net:target><xsl:value-of select="@postsynaptic_population_name"/></net:target>
163             <net:synapse_props>
164                 <net:synapse_type>
165                     <!-- here I try to detect if the synapse to use is excitatory or inhibitory and if it is the synapse type of the source population
166                     or the synapse type of the target population -->
167                     <xsl:choose>
168                         <!-- if target attribute is specified -->
169                         <xsl:when test="@target">
170                             <xsl:choose>
171                                 <xsl:when test="contains(@target,'xcitatory')">
172                                     ExcitatorySynapse_<xsl:value-of select="@postsynaptic_population_name"/>
173                                 </xsl:when>
174                                 <xsl:when test="contains(@target,'nhibitory')">
175                                     InhibitorySynapse_<xsl:value-of select="@postsynaptic_population_name"/>
176                                 </xsl:when>
177                                 <!-- default value is ExcitatorySynapse_ -->
178                                 <xsl:otherwise>
179                                     ExcitatorySynapse_<xsl:value-of select="@postsynaptic_population_name"/>
180                                 </xsl:otherwise>
181                             </xsl:choose>
182                         </xsl:when>
183                         <xsl:otherwise>
184                             <xsl:choose>
185                                 <!-- if source attribute is specified -->
186                                 <xsl:when test="@source">
187                                     <xsl:choose>
188                                         <xsl:when test="contains(@target,'xcitatory')">
189                                             ExcitatorySynapse_<xsl:value-of select="@presynaptic_population_name"/>
190                                         </xsl:when>
191                                         <xsl:when test="contains(@target,'nhibitory')">
192                                             InhibitorySynapse_<xsl:value-of select="@presynaptic_population_name"/>
193                                         </xsl:when>
194                                         <!-- default value is ExcitatorySynapse_ -->
195                                         <xsl:otherwise>
196                                             ExcitatorySynapse_<xsl:value-of select="@presynaptic_population_name"/>
197                                         </xsl:otherwise>
198                                     </xsl:choose>
199                                 </xsl:when>
200                                 <xsl:otherwise>
201                                     <!-- default value is ExcitatorySynapse_ of the postsynaptic population -->
202                                     ExcitatorySynapse_<xsl:value-of select="@postsynaptic_population_name"/>
203                                 </xsl:otherwise>
204                             </xsl:choose>
205                         </xsl:otherwise>
206                     </xsl:choose>
207                 </net:synapse_type>
208                 <net:default_values weight="{@weight}"/>
209             </net:synapse_props>
210             <net:connectivity_pattern>
211                 <xsl:apply-templates select="@method"/>
212             </net:connectivity_pattern>
213         </net:projection>
214     </xsl:template>
215    
216     <xsl:template match="@method">
217         <xsl:choose>
218             <xsl:when test="current()='fixedProbability'">
219                 <xsl:variable name="p_connect" select="../fml:methodParameter[@name='p_connect']/@value"/>
220                 <net:fixed_probability probability='{$p_connect}'/>
221             </xsl:when>
222             <xsl:when test="current()='per_cell_connection'">
223                 <xsl:variable name="n" select="../fml:methodParameter[@name='n']/@value"/>
224                 <net:per_cell_connection num_per_source="{$n}"/>
225             </xsl:when>
226             <xsl:otherwise>
227                 <net:all_to_all/>
228             </xsl:otherwise>
229         </xsl:choose>
230     </xsl:template>
231    
232    
233 </xsl:stylesheet>
Note: See TracBrowser for help on using the browser.