Skip to content

Commit

Permalink
Merge pull request #120 from NeuroML/development
Browse files Browse the repository at this point in the history
Changes for NeuroML v2.3.1 release
  • Loading branch information
pgleeson authored Aug 20, 2024
2 parents 394dce4 + c527321 commit b43594b
Show file tree
Hide file tree
Showing 19 changed files with 362 additions and 162 deletions.
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.9.1</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.9.1</version>
<version>1.10.1</version>
</dependency>
<dependency>
<groupId>org.lemsml</groupId>
<artifactId>jlems</artifactId>
<version>0.10.8</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
124 changes: 64 additions & 60 deletions src/main/java/org/lemsml/export/dlems/DLemsKeywords.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,79 +2,83 @@

/**
* @author matteocantarelli
*
*
*/
public enum DLemsKeywords
{
DT,
SEED,
REPORT_FILE,
DYNAMICS,
EVENTS,
CONDITION,
DIRECTION,
EFFECT,
NAME,
TYPE,
TITLE,
PARAMETERS,
STATE,
STATE_FUNCTIONS,
T_END,
T_START,
COMMENT,
DUMP_TO_FILE,
OUTPUT_FILE,
SPIKE_FILE,
SPIKE_FILE_FORMAT,
EVENT_SELECTIONS,
EVENT_SELECTION_ID,
SELECT,
EVENT_PORT,
FILE_NAME,
OUTPUT_COLUMNS,
VARIABLE,
QUANTITY,
DISPLAY,
ABSCISSA_AXIS,
MIN, MAX,
ORDINATE_AXIS,
CURVES,
ABSCISSA,
ORDINATE,
POPULATION,
POPULATION_INDEX,
SEGMENT_ID,
SEGMENT_NAME,
FRACTION_ALONG,
COLOUR,
POPULATIONS,
SIZE,
DT,
SEED,
REPORT_FILE,
DYNAMICS,
EVENTS,
CONDITION,
DIRECTION,
EFFECT,
NAME,
TYPE,
TITLE,
PARAMETERS,
STATE,
STATE_FUNCTIONS,
T_END,
T_START,
COMMENT,
DUMP_TO_FILE,
OUTPUT_FILE,
SPIKE_FILE,
SPIKE_FILE_FORMAT,
EVENT_SELECTIONS,
EVENT_SELECTION_ID,
SELECT,
EVENT_PORT,
FILE_NAME,
OUTPUT_COLUMNS,
VARIABLE,
QUANTITY,
DISPLAY,
ABSCISSA_AXIS,
MIN, MAX,
ORDINATE_AXIS,
CURVES,
ABSCISSA,
ORDINATE,
POPULATION,
POPULATION_INDEX,
SEGMENT_ID,
SEGMENT_NAME,
FRACTION_ALONG,
COLOUR,
POPULATIONS,
SIZE,
SYNAPSES,
SYNAPSE,
COMPONENT,
PROJECTIONS,
PRE_POPULATION,
POST_POPULATION,
PROJECTIONS,
PRE_POPULATION,
POST_POPULATION,
CONNECTIONS,
PRE_CELL_ID,
POST_CELL_ID,
WEIGHT,
DELAY,
PRE_CELL_ID,
POST_CELL_ID,
WEIGHT,
DELAY,
INPUTS,


TEMPERATURE,
NEURON_VARIABLE_NAME,
NEURON_MECHANISM_NAME,
NEURON_SECTION_NAME,
NEURON_FRACT_ALONG,
NEURON_VARIABLE_SCALE,

EXPORT_LIBRARY_VERSION;

public String get()
{
return this.toString().toLowerCase();
}
EXPORT_LIBRARY_VERSION,

CVODE,
ABS_TOL,
REL_TOL;

public String get()
{
return this.toString().toLowerCase();
}
}
62 changes: 58 additions & 4 deletions src/main/java/org/lemsml/export/dlems/DLemsWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
import org.lemsml.jlems.core.type.Dimension;
import org.lemsml.jlems.core.type.FinalParam;
import org.lemsml.jlems.core.type.Lems;
import org.lemsml.jlems.core.type.LemsCollection;
import org.lemsml.jlems.core.type.ParamValue;
import org.lemsml.jlems.core.type.Meta;
import org.lemsml.jlems.core.type.Target;
import org.lemsml.jlems.core.type.dynamics.DerivedVariable;
import org.lemsml.jlems.core.type.dynamics.IVisitable;
Expand Down Expand Up @@ -203,6 +205,38 @@ public String getMainScript() throws LEMSException, IOException

g.writeStringField(DLemsKeywords.DT.get(), convertTime(simCpt.getParamValue("step")));

boolean nrn_cvode = false;
/* defaults from NEURON */
String abs_tol = "None";
String rel_tol = "None";
LemsCollection<Meta> metas = simCpt.metas;
for(Meta m : metas)
{
HashMap<String, String> attributes = m.getAttributes();
if (attributes.getOrDefault("for", "").equals("neuron"))
{
if (attributes.getOrDefault("method", "").equals("cvode"))
{
nrn_cvode = true;
abs_tol = attributes.getOrDefault("abs_tolerance", abs_tol);
rel_tol = attributes.getOrDefault("rel_tolerance", rel_tol);
E.info("CVode with abs_tol="+abs_tol+" , rel_tol="+rel_tol+" selected for NEURON simulation");
}
}

}
if (nrn_cvode == true)
{
g.writeStringField(DLemsKeywords.CVODE.get(), "true");
}
else
{
g.writeStringField(DLemsKeywords.CVODE.get(), "false");
}
/* set them to something even if not provided by user */
g.writeStringField(DLemsKeywords.ABS_TOL.get(), abs_tol);
g.writeStringField(DLemsKeywords.REL_TOL.get(), rel_tol);

int seed = DEFAULT_SEED;
if (simCpt.hasStringValue("seed"))
seed = Integer.parseInt(simCpt.getStringValue("seed"));
Expand Down Expand Up @@ -639,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 @@ -860,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 @@ -899,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
Loading

0 comments on commit b43594b

Please sign in to comment.