Skip to content

Commit

Permalink
Merge pull request #59 from NeuroML/experimental
Browse files Browse the repository at this point in the history
Adding option to use string for percentage of inputs, e.g. containing…
  • Loading branch information
pgleeson authored Sep 11, 2023
2 parents 77cd6f4 + 277200c commit 5c9eb7c
Show file tree
Hide file tree
Showing 20 changed files with 13,918 additions and 13,909 deletions.
2 changes: 1 addition & 1 deletion docs/NeuroMLlite_specification.json
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@
"description": "Specific ids of _Cell_s to apply this input to (cannot be used with percentage"
},
"percentage": {
"type": "float",
"type": "Union[EvaluableExpression, List, Dict, ndarray, int, float, str]",
"description": "Percentage of Cells to apply input to"
},
"number_per_cell": {
Expand Down
3 changes: 2 additions & 1 deletion docs/NeuroMLlite_specification.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ specification:
description: Specific ids of _Cell_s to apply this input to (cannot
be used with percentage
percentage:
type: float
type: Union[EvaluableExpression, List, Dict, ndarray, int, float,
str]
description: Percentage of Cells to apply input to
number_per_cell:
type: Union[EvaluableExpression, List, Dict, ndarray, int, float,
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ An Input definition.

<tr>
<td><b>percentage</b></td>
<td>float</td>
<td>Union[EvaluableExpression, List, Dict, ndarray, int, float, str]</td>
<td><i>Percentage of Cells to apply input to</i></td>
</tr>

Expand Down
2 changes: 1 addition & 1 deletion examples/Example11_Synapses.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"stim": {
"input_source": "i_clamp",
"population": "pop0",
"percentage": 100.0
"percentage": 100
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/Example12_MultiComp.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"stim": {
"input_source": "poissonFiringSyn",
"population": "pop_pyr",
"percentage": 100.0,
"percentage": 100,
"weight": "weightInput"
}
},
Expand Down
2 changes: 1 addition & 1 deletion examples/Example2_TestNetwork.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"stim_pop0": {
"input_source": "poissonFiringSyn",
"population": "pop0",
"percentage": 80.0
"percentage": 80
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/Example3_Network.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"stim_pop0": {
"input_source": "poissonFiringSyn",
"population": "pop0",
"percentage": 80.0
"percentage": 80
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/Example4_PyNN.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
"stim": {
"input_source": "i_clamp",
"population": "pop0",
"percentage": 50.0
"percentage": 50
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions examples/Example4_PyNN.net.nml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
NeuroMLlite parameters:
input_amp = 0.99</notes>
<pulseGenerator id="i_clamp" delay="200.0ms" duration="600.0ms" amplitude="0.99nA"/>
<IF_cond_alpha id="testcell" cm="1." i_offset="0.1" tau_syn_E="0.3" tau_syn_I="0.5" v_init="-65." tau_m="20." tau_refrac="5." v_reset="-65." v_rest="-65." v_thresh="-50." e_rev_E="0." e_rev_I="-70."/>
<IF_cond_alpha id="testcell2" cm="1." i_offset="-0.1" tau_syn_E="2." tau_syn_I="10." v_init="-65." tau_m="20." tau_refrac="5." v_reset="-65." v_rest="-65." v_thresh="-50." e_rev_E="-10." e_rev_I="-80."/>
<alphaCondSynapse id="ampaSyn" tau_syn="2." e_rev="-10."/>
<alphaCondSynapse id="gabaSyn" tau_syn="10." e_rev="-80."/>
<IF_cond_alpha id="testcell" cm="1.0" i_offset="0.1" tau_syn_E="0.3" tau_syn_I="0.5" v_init="-65.0" tau_m="20.0" tau_refrac="5.0" v_reset="-65.0" v_rest="-65.0" v_thresh="-50.0" e_rev_E="0.0" e_rev_I="-70.0"/>
<IF_cond_alpha id="testcell2" cm="1.0" i_offset="-0.1" tau_syn_E="2.0" tau_syn_I="10.0" v_init="-65.0" tau_m="20.0" tau_refrac="5.0" v_reset="-65.0" v_rest="-65.0" v_thresh="-50.0" e_rev_E="-10.0" e_rev_I="-80.0"/>
<alphaCondSynapse id="ampaSyn" tau_syn="2.0" e_rev="-10.0"/>
<alphaCondSynapse id="gabaSyn" tau_syn="10.0" e_rev="-80.0"/>
<network id="Example4_PyNN">
<notes>Example 4: a network with PyNN cells &amp; inputs</notes>
<property tag="recommended_dt_ms" value="0.01"/>
Expand Down
2 changes: 1 addition & 1 deletion examples/Example4_PyNN.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ Example4_PyNN:
stim:
input_source: i_clamp
population: pop0
percentage: 50.0
percentage: 50
13,800 changes: 6,900 additions & 6,900 deletions examples/Example6_PyNN.net.nml

Large diffs are not rendered by default.

13,972 changes: 6,986 additions & 6,986 deletions examples/Example6_PyNN_noinputs.net.nml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/Example7_Brunel2000.net.nml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
tauRef = 2.0
tauSyn = 0.1
theta = 20.0</notes>
<IF_curr_alpha id="ifcell" cm="0.001" i_offset="0." tau_syn_E="0.1" tau_syn_I="0.1" v_init="0." tau_m="20." tau_refrac="2." v_reset="0." v_rest="0." v_thresh="20."/>
<IF_curr_alpha id="ifcell" cm="0.001" i_offset="0.0" tau_syn_E="0.1" tau_syn_I="0.1" v_init="0.0" tau_m="20.0" tau_refrac="2.0" v_reset="0.0" v_rest="0.0" v_thresh="20.0"/>
<alphaCurrSynapse id="ampa" tau_syn="0.1"/>
<alphaCurrSynapse id="gaba" tau_syn="0.1"/>
<SpikeSourcePoisson id="poisson_input" start="0.0ms" duration="1000000000.0ms" rate="10000.0Hz"/>
Expand Down
2 changes: 1 addition & 1 deletion examples/Example8_Extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"stim": {
"input_source": "poissonFiringSyn",
"population": "Epop",
"percentage": 50.0,
"percentage": 50,
"weight": "weightInput"
}
},
Expand Down
2 changes: 1 addition & 1 deletion examples/LEMS_SimExample3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!--
This LEMS file has been automatically generated using PyNeuroML v1.0.8 (libNeuroML v0.5.3)
This LEMS file has been automatically generated using PyNeuroML v1.0.10 (libNeuroML v0.5.3)
-->

Expand Down
2 changes: 1 addition & 1 deletion examples/LEMS_SimExample4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!--
This LEMS file has been automatically generated using PyNeuroML v1.0.8 (libNeuroML v0.5.3)
This LEMS file has been automatically generated using PyNeuroML v1.0.10 (libNeuroML v0.5.3)
-->

Expand Down
6 changes: 3 additions & 3 deletions examples/spikeratetest/Spikers.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,18 @@
"stim0": {
"input_source": "poissonFiringSyn",
"population": "pop0",
"percentage": 50.0,
"percentage": 50,
"weight": "weightInput"
},
"stim1": {
"input_source": "iclamp1",
"population": "pop1",
"percentage": 100.0
"percentage": 100
},
"stim2": {
"input_source": "iclamp1",
"population": "pop2",
"percentage": 50.0
"percentage": 50
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion neuromllite/NetworkGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def generate_network(
if input.weight
else 1
)
if flip * 100.0 < input.percentage:
if flip * 100.0 < evaluate(input.percentage, nl_model.parameters, rng):
if input.number_per_cell and input.segment_ids:
raise Exception(
"On input: %s, only one of number_per_cell or segment_ids is allowed"
Expand Down
4 changes: 2 additions & 2 deletions neuromllite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ class Input(NMLBase):
cell_ids: ValueExprType = field(
default="", validator=optional(instance_of(value_expr_types))
)
percentage: float = field(
default=None, validator=optional(instance_of(float)), converter=convert2float
percentage: ValueExprType = field(
default=None, validator=optional(instance_of(value_expr_types))
)
number_per_cell: ValueExprType = field(
default="", validator=optional(instance_of(value_expr_types))
Expand Down
8 changes: 8 additions & 0 deletions neuromllite/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ def load_network_yaml(filename):

return net

def load_simulation(filename):
"""
Load a NeuroMLlite simulation JSON/YAML file
"""
if filename.endswith(".yaml") or filename.endswith(".yml"):
return load_simulation_yaml(filename)
else:
return load_simulation_json(filename)

def load_simulation_json(filename: str) -> Optional[dict]:
"""
Expand Down

0 comments on commit 5c9eb7c

Please sign in to comment.