Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(neuron/netpyne): use %r instead of %e or %s #110

Open
wants to merge 11 commits into
base: development
Choose a base branch
from
13 changes: 9 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@ jobs:
strategy:
fail-fast: false
matrix:
java: [ '8', '11', '16', '17', '19']
runs-on: [ubuntu-latest, macos-latest, windows-2019 ]
java: [ '8', '11', '16', '17', '19', '21' ]
runs-on: [ubuntu-latest, macos-12, windows-2019] # Note macos-12, not latest/14, due to hdf5 install issue
exclude:
- runs-on: macos-latest
java: "8"
- runs-on: macos-latest
java: "16"

name: Test on Java ${{ matrix.Java }} on ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.Java }}
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.Java }}
distribution: 'temurin'
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: nelonoel/[email protected]

- name: Set up JDK 11
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'temurin'
java-package: jdk

- name: Set up Python 3.9
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.9

Expand All @@ -34,29 +34,29 @@ jobs:
pip install ghp-import

- name: Checkout NeuroML2
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: NeuroML/NeuroML2
ref: development
path: NeuroML2

- name: Checkout org.lemsml
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: LEMS/jLEMS
ref: development
path: jLEMS


- name: Checkout org.neuroml.model.injectingplugin
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: NeuroML/org.neuroml.model.injectingplugin
ref: development
path: org.neuroml.model.injectingplugin

- name: Checkout org.neuroml.model
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: NeuroML/org.neuroml.model
ref: development
Expand Down
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>org.neuroml.export</groupId>
<artifactId>org.neuroml.export</artifactId>
<packaging>bundle</packaging>
<version>1.10.0</version>
<version>1.10.1</version>
<name>org.neuroml.export</name>
<url>http://maven.apache.org</url>

Expand All @@ -18,12 +18,12 @@
<dependency>
<groupId>org.neuroml.model</groupId>
<artifactId>org.neuroml.model</artifactId>
<version>1.10.0</version>
<version>1.10.1</version>
</dependency>
<dependency>
<groupId>org.lemsml</groupId>
<artifactId>jlems</artifactId>
<version>0.11.0</version>
<version>0.11.1</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
Expand All @@ -49,7 +49,7 @@
&lt;br /&gt;
&lt;br /&gt;
</top>
<bottom>Copyright NeuroML Contributors 2023</bottom>
<bottom>Copyright NeuroML Contributors 2024</bottom>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -91,8 +91,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
Expand Down
28 changes: 24 additions & 4 deletions src/main/java/org/lemsml/export/dlems/DLemsWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -673,16 +673,29 @@ private void writeDLemsForComponent(JsonGenerator g, Component comp, HashMap<Str
g.writeObjectFieldStart(DLemsKeywords.PARAMETERS.get());
writeParameters(g, comp);
g.writeEndObject();

Component bpComp = comp.quietGetChild("biophysicalProperties");
if (bpComp==null)
{
try{
Cell cell = (Cell)Utils.convertLemsComponentToNeuroML(comp, true, lems).get(comp.getID());
bpComp = lems.getComponent(cell.getBiophysicalProperties().getId());
}
catch (NeuroMLException ne)
{
throw new ContentError("Unable to parse cell's biophysicalProperties", ne);
}
}

for (Component specie: comp.getChild("biophysicalProperties").getChild("intracellularProperties").getChildrenAL("speciesList")) {
for (Component specie: bpComp.getChild("intracellularProperties").getChildrenAL("speciesList")) {

try{
g.writeStringField(specie.getID()+"_initial_internal_conc", ""+Utils.getMagnitudeInSI(specie.getAttributeValue("initialConcentration")));
g.writeStringField(specie.getID()+"_initial_external_conc", ""+Utils.getMagnitudeInSI(specie.getAttributeValue("initialExtConcentration")));
}
catch (NeuroMLException ne)
{
throw new ContentError("Unabel to parse NeuroML", ne);
throw new ContentError("Unable to parse NeuroML", ne);
}
}

Expand Down Expand Up @@ -894,7 +907,7 @@ private void addNrnSecNameFract(Component comp, int segId, JsonGenerator g) thro

if(!cachedNrnSecNames.get(comp.getID()).containsKey(segId))
{
Cell cell = (Cell)Utils.convertLemsComponentToNeuroML(comp).get(comp.getID());
Cell cell = (Cell)Utils.convertLemsComponentToNeuroML(comp, true, lems).get(comp.getID());

NamingHelper nh = new NamingHelper(cell);
Segment segment = CellUtils.getSegmentWithId(cell, segId);
Expand Down Expand Up @@ -933,7 +946,14 @@ private void extractQuantityInfo(String quantity, JsonGenerator g) throws IOExce
Component comp = popIdsVsComponents.get(lqp.getPopulation());

if (comp.getComponentType().isOrExtends("cell")) {
for (Component seg: comp.getChild("morphology").getChildrenAL("segments")) {
Component morphComp = comp.quietGetChild("morphology");

if (morphComp==null) {
morphComp=lems.getComponent(comp.getTextParam("morphology"));
}


for (Component seg: morphComp.getChildrenAL("segments")) {
if (seg.id.equals(lqp.getSegmentId()+"")) {
g.writeStringField(DLemsKeywords.SEGMENT_ID.get(), lqp.getSegmentId()+"");
g.writeStringField(DLemsKeywords.SEGMENT_NAME.get(), seg.getName());
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/neuroml/export/eden/EDENWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public void setSupportedFeatures()
{
sli.addSupportInfo(format, ModelFeature.ABSTRACT_CELL_MODEL, SupportLevelInfo.Level.HIGH);
sli.addSupportInfo(format, ModelFeature.COND_BASED_CELL_MODEL, SupportLevelInfo.Level.HIGH);
sli.addSupportInfo(format, ModelFeature.EXT_MORPH_BIOPHYS_CELL_MODEL, SupportLevelInfo.Level.HIGH);
sli.addSupportInfo(format, ModelFeature.SINGLE_COMP_MODEL, SupportLevelInfo.Level.HIGH);
sli.addSupportInfo(format, ModelFeature.NETWORK_MODEL, SupportLevelInfo.Level.HIGH);
sli.addSupportInfo(format, ModelFeature.MULTI_CELL_MODEL, SupportLevelInfo.Level.HIGH);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/neuroml/export/info/InfoTreeCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static InfoNode createInfoTreeFromComponent(final Component component) th
{
InfoNode infoRoot = new InfoNode();

LinkedHashMap<String, Standalone> standalones = Utils.convertLemsComponentToNeuroML(component);
LinkedHashMap<String, Standalone> standalones = Utils.convertLemsComponentToNeuroML(component, true, null);

for(Standalone element : standalones.values())
{
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/org/neuroml/export/netpyne/NetPyNEWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public void setSupportedFeatures()
{
sli.addSupportInfo(format, ModelFeature.ABSTRACT_CELL_MODEL, SupportLevelInfo.Level.HIGH);
sli.addSupportInfo(format, ModelFeature.COND_BASED_CELL_MODEL, SupportLevelInfo.Level.HIGH);
sli.addSupportInfo(format, ModelFeature.EXT_MORPH_BIOPHYS_CELL_MODEL, SupportLevelInfo.Level.HIGH);
sli.addSupportInfo(format, ModelFeature.SINGLE_COMP_MODEL, SupportLevelInfo.Level.HIGH);
sli.addSupportInfo(format, ModelFeature.NETWORK_MODEL, SupportLevelInfo.Level.HIGH);
sli.addSupportInfo(format, ModelFeature.MULTI_CELL_MODEL, SupportLevelInfo.Level.HIGH);
Expand Down Expand Up @@ -472,6 +473,11 @@ public static void main(String[] args) throws Exception
//lemsFiles.add(new File("../neuroConstruct/osb/olfactorybulb/networks/MiglioreEtAl14_OlfactoryBulb3D/NeuroML2/Channels/test/LEMS_OlfactoryTest_12.xml"));
//lemsFiles.add(new File("../neuroConstruct/osb/generic/hodgkin_huxley_tutorial/Tutorial/Source/LEMS_HH_Simulation.xml"));
//lemsFiles.add(new File("../git/multi/temp/LEMS_ISN_net.xml"));
//lemsFiles.add(new File("../neuroConstruct/osb/cerebral_cortex/networks/ACnet2/neuroConstruct/generatedNeuroML2/LEMS_ACNet2.xml"));
lemsFiles.add(new File("../git/morphology_include/LEMS_m_in_b_in.xml"));
lemsFiles.add(new File("../git/morphology_include/LEMS_m_out_b_in.xml"));
lemsFiles.add(new File("../git/morphology_include/LEMS_m_out_b_out.xml"));
//lemsFiles.add(new File("../git/morphology_include/LEMS_m_in_b_out.xml"));

for (File lemsFile : lemsFiles)
{
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/neuroml/export/neuron/NamingHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.neuroml.model.Segment;
import org.neuroml.model.SegmentGroup;
import org.neuroml.model.util.CellUtils;
import org.neuroml.model.util.NeuroMLException;

/**
*
Expand All @@ -31,7 +32,7 @@ public NamingHelper(Cell cell)
this.cell = cell;
}

public String getNrnSectionName(Segment seg)
public String getNrnSectionName(Segment seg) throws NeuroMLException
{

String uniqueId = cell.getId() + ":" + seg.getId();
Expand Down
31 changes: 20 additions & 11 deletions src/main/java/org/neuroml/export/neuron/NeuronWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public void setSupportedFeatures()
{
sli.addSupportInfo(format, ModelFeature.ABSTRACT_CELL_MODEL, SupportLevelInfo.Level.MEDIUM);
sli.addSupportInfo(format, ModelFeature.COND_BASED_CELL_MODEL, SupportLevelInfo.Level.MEDIUM);
sli.addSupportInfo(format, ModelFeature.EXT_MORPH_BIOPHYS_CELL_MODEL, SupportLevelInfo.Level.HIGH);
sli.addSupportInfo(format, ModelFeature.SINGLE_COMP_MODEL, SupportLevelInfo.Level.MEDIUM);
sli.addSupportInfo(format, ModelFeature.NETWORK_MODEL, SupportLevelInfo.Level.LOW);
sli.addSupportInfo(format, ModelFeature.MULTI_CELL_MODEL, SupportLevelInfo.Level.MEDIUM);
Expand Down Expand Up @@ -1433,7 +1434,7 @@ else if(cc.getComponentType().isOrExtends(NeuroMLElements.CONTINUOUS_CONNECTION_
}

//columnsPostTraces.get(outfileId).add(bIndent+" f_" + outfileId + "_f2.write('%e\\t'% py_v_" + timeRef + "[i] ");
columnsPostTraces.get(outfileId).add(bIndent+" f_" + outfileId + "_f2.write('%e\\t");
columnsPostTraces.get(outfileId).add(bIndent+" f_" + outfileId + "_f2.write('%r\\t");
writingVariables.get(outfileId).add("py_v_" + timeRef + "[i], ");

ArrayList<String> colIds = new ArrayList<String>();
Expand Down Expand Up @@ -1476,7 +1477,7 @@ else if(cc.getComponentType().isOrExtends(NeuroMLElements.CONTINUOUS_CONNECTION_
/*columnsPostTraces.get(outfileId).add(
" + '%e\\t'%(py_v_" + colId + "[i]) ");*/

columnsPostTraces.get(outfileId).add("%e\\t");
columnsPostTraces.get(outfileId).add("%r\\t");
writingVariables.get(outfileId).add("py_v_" + colId + "[i], ");

}
Expand Down Expand Up @@ -2071,7 +2072,7 @@ private Cell getCellFromComponent(Component cellComponent) throws LEMSException,
}
else
{
cell = Utils.getCellFromComponent(cellComponent);
cell = Utils.getCellFromComponent(cellComponent, lems);
compIdsVsCells.put(cellComponent.getID(), cell);
}
return cell;
Expand Down Expand Up @@ -2105,7 +2106,11 @@ public IntracellularProperties convertCellWithMorphology(Component cellComponent
{
BiophysicalProperties bp = cell.getBiophysicalProperties();
ip = bp.getIntracellularProperties();
bpComp = cellComponent.getChild("biophysicalProperties");
bpComp = cellComponent.quietGetChild("biophysicalProperties");
if (bpComp==null)
{
bpComp = lems.getComponent(bp.getId());
}
mpComp = bpComp.getChild("membraneProperties");
ipComp = bpComp.getChild("intracellularProperties");
}
Expand Down Expand Up @@ -3936,8 +3941,8 @@ public static void main(String[] args) throws Exception

ArrayList<File> lemsFiles = new ArrayList<File>();

lemsFiles.add(new File("../neuroConstruct/osb/hippocampus/interneurons/WangBuzsaki1996/NeuroML2/LEMS_ComponentType/LEMS_WangBuzsaki.xml"));
lemsFiles.add(new File("../neuroConstruct/osb/generic/HindmarshRose1984/NeuroML2/LEMS_Regular_HindmarshRoseNML.xml"));
//lemsFiles.add(new File("../neuroConstruct/osb/hippocampus/interneurons/WangBuzsaki1996/NeuroML2/LEMS_ComponentType/LEMS_WangBuzsaki.xml"));
//lemsFiles.add(new File("../neuroConstruct/osb/generic/HindmarshRose1984/NeuroML2/LEMS_Regular_HindmarshRoseNML.xml"));
//lemsFiles.add(new File("../neuroConstruct/osb/showcase/StochasticityShowcase/NeuroML2/LEMS_Inputs0.xml"));
//lemsFiles.add(new File("../neuroConstruct/osb/invertebrate/celegans/CElegansNeuroML/CElegans/pythonScripts/c302/examples/LEMS_c302_C1_Oscillator.xml"));

Expand All @@ -3947,14 +3952,14 @@ public static void main(String[] args) throws Exception
//lemsFiles.add(new File("../neuroConstruct/osb/cerebellum/networks/VervaekeEtAl-GolgiCellNetwork/NeuroML2/LEMS_Pacemaking.xml"));
//lemsFiles.add(new File("../NeuroML2/LEMSexamples/LEMS_NML2_Ex9_FN.xml"));
lemsFiles.add(new File("../NeuroML2/LEMSexamples/LEMS_NML2_Ex5_DetCell.xml"));
lemsFiles.add(new File("../NeuroML2/LEMSexamples/LEMS_NML2_Ex15_CaDynamics.xml"));
lemsFiles.add(new File("../neuroConstruct/osb/cerebral_cortex/networks/IzhikevichModel/NeuroML2/LEMS_2007One.xml"));
//lemsFiles.add(new File("../NeuroML2/LEMSexamples/LEMS_NML2_Ex15_CaDynamics.xml"));
//lemsFiles.add(new File("../neuroConstruct/osb/cerebral_cortex/networks/IzhikevichModel/NeuroML2/LEMS_2007One.xml"));
//lemsFiles.add(new File("../org.neuroml.export/src/test/resources/examples/LEMS_SpikePass2.xml"));
/*
lemsFiles.add(new File("../neuroConstruct/osb/showcase/StochasticityShowcase/NeuroML2/LEMS_NoisyCurrentInput.xml"));
lemsFiles.add(new File("../neuroConstruct/osb/showcase/StochasticityShowcase/NeuroML2/LEMS_OUCurrentInput_test.xml"));
lemsFiles.add(new File("../neuroConstruct/osb/cerebral_cortex/networks/IzhikevichModel/NeuroML2/LEMS_FiveCells.xml"));*/
lemsFiles.add(new File("../git/ca1/NeuroML2/channels/test_Cadynamics/NeuroML2/LEMS_test_Ca.xml"));
//lemsFiles.add(new File("../git/ca1/NeuroML2/channels/test_Cadynamics/NeuroML2/LEMS_test_Ca.xml"));
//lemsFiles.add(new File("../NeuroML2/LEMSexamples/LEMS_NML2_Ex20a_AnalogSynapsesHH.xml"));
//lemsFiles.add(new File("../NeuroML2/LEMSexamples/LEMS_NML2_Ex20_AnalogSynapses.xml"));
//lemsFiles.add(new File("../NeuroMLlite/neuromllite/LEMS_Sim_ten_cells_spikes_nest.xml"));
Expand All @@ -3976,7 +3981,11 @@ public static void main(String[] args) throws Exception
//
// lemsFiles.add(new File("../neuroConstruct/osb/cerebral_cortex/multiple/PospischilEtAl2008/NeuroML2/channels/Na/LEMS_Na.xml"));
// lemsFiles.add(new File("../neuroConstruct/osb/cerebral_cortex/multiple/PospischilEtAl2008/NeuroML2/channels/Kd/LEMS_Kd.xml"));
// lemsFiles.add(new File("../neuroConstruct/osb/cerebral_cortex/networks/ACnet2/neuroConstruct/generatedNeuroML2/LEMS_MediumNet.xml"));
lemsFiles.add(new File("../neuroConstruct/osb/cerebral_cortex/networks/ACnet2/neuroConstruct/generatedNeuroML2/LEMS_ACNet2.xml"));
lemsFiles.add(new File("../git/morphology_include/LEMS_m_in_b_in.xml"));
lemsFiles.add(new File("../git/morphology_include/LEMS_m_out_b_in.xml"));
lemsFiles.add(new File("../git/morphology_include/LEMS_m_in_b_out.xml"));

// lemsFiles.add(new File("../OpenCortex/examples/LEMS_ACNet.xml"));
//
//lemsFiles.add(new File("../OpenCortex/examples/LEMS_SpikingNet.xml"));
Expand All @@ -3995,7 +4004,7 @@ public static void main(String[] args) throws Exception
// lemsFiles.add(new File("../NeuroML2/LEMSexamples/LEMS_NML2_Ex25_MultiComp.xml"));
// lemsFiles.add(new File("../neuroConstruct/osb/showcase/NetPyNEShowcase/NeuroML2/LEMS_HybridTut.xml"));
// lemsFiles.add(new File("../OpenCortex/examples/LEMS_L23TraubDemo_1cells_0conns.xml"));
lemsFiles.add(new File("../NeuroML2/LEMSexamples/LEMS_NML2_Ex0_IaF.xml"));
//lemsFiles.add(new File("../NeuroML2/LEMSexamples/LEMS_NML2_Ex0_IaF.xml"));

//lemsFiles.add(new File("../neuroConstruct/osb/invertebrate/celegans/CElegansNeuroML/CElegans/pythonScripts/c302/examples/LEMS_c302_C1_Muscles.xml"));
//lemsFiles.add(new File("../neuroConstruct/osb/invertebrate/celegans/CElegansNeuroML/CElegans/pythonScripts/c302/examples/LEMS_c302_C1_Syns.xml"));
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/org/neuroml/export/svg/Network3D.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.HashMap;
import java.util.List;
import org.neuroml.model.util.CellUtils;
import org.neuroml.model.util.NeuroMLException;

public class Network3D
{
Expand All @@ -19,13 +20,13 @@ public Network3D(String comment)
lines = new ArrayList<Line3D>(100);
}

public Network3D(Cell cell)
public Network3D(Cell cell) throws NeuroMLException
{
this.comment = "Cell: "+cell.getId();
lines = extractLines(cell, null);
}

public void addCell(Cell cell, float offsetX, float offsetY, float offsetZ, String defaultColor)
public void addCell(Cell cell, float offsetX, float offsetY, float offsetZ, String defaultColor) throws NeuroMLException
{
lines.addAll(extractLines(cell, offsetX, offsetY, offsetZ, defaultColor));
}
Expand Down Expand Up @@ -201,13 +202,13 @@ private Network3D rotate(double degreesAroundZ, double degreesAroundY)
}


private ArrayList<Line3D> extractLines(Cell cell, String defaultColor)
private ArrayList<Line3D> extractLines(Cell cell, String defaultColor) throws NeuroMLException
{
return extractLines(cell, 0, 0, 0, defaultColor);
}


private ArrayList<Line3D> extractLines(Cell cell, float offsetX, float offsetY, float offsetZ, String defaultColor)
private ArrayList<Line3D> extractLines(Cell cell, float offsetX, float offsetY, float offsetZ, String defaultColor) throws NeuroMLException
{
ArrayList<Line3D> result = new ArrayList<Line3D>();

Expand Down
Loading