From c2f1276fbb535c63ba654008707e1234a9f79d9f Mon Sep 17 00:00:00 2001 From: Padraig Gleeson Date: Fri, 22 Sep 2023 17:40:22 +0100 Subject: [PATCH 01/23] To v1.10.0 --- pom.xml | 6 +++--- src/main/java/org/neuroml/export/utils/Utils.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index bb9a7c3cf..c38acde79 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.neuroml.export org.neuroml.export bundle - 1.9.1 + 1.10.0 org.neuroml.export http://maven.apache.org @@ -18,12 +18,12 @@ org.neuroml.model org.neuroml.model - 1.9.1 + 1.10.0 org.lemsml jlems - 0.10.8 + 0.11.0 org.apache.velocity diff --git a/src/main/java/org/neuroml/export/utils/Utils.java b/src/main/java/org/neuroml/export/utils/Utils.java index 29f14ece4..b1d26dbb6 100644 --- a/src/main/java/org/neuroml/export/utils/Utils.java +++ b/src/main/java/org/neuroml/export/utils/Utils.java @@ -42,7 +42,7 @@ public class Utils private static Lems lemsWithNML2CompTypes; - public static String ORG_NEUROML_EXPORT_VERSION = "1.9.1"; + public static String ORG_NEUROML_EXPORT_VERSION = "1.10.0"; public static final String ARCH_I686 = "i686"; public static final String ARCH_I386 = "i386"; From b8713b4c8493941a94dc3f998d351bcbbcdcf3f3 Mon Sep 17 00:00:00 2001 From: "Ankur Sinha (Ankur Sinha Gmail)" Date: Wed, 20 Dec 2023 15:09:49 +0000 Subject: [PATCH 02/23] feat(nrnwriter): also handle ChannelDensityNonUniformNernst --- src/main/java/org/neuroml/export/neuron/NeuronWriter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/neuroml/export/neuron/NeuronWriter.java b/src/main/java/org/neuroml/export/neuron/NeuronWriter.java index 17f5c541d..08c846388 100644 --- a/src/main/java/org/neuroml/export/neuron/NeuronWriter.java +++ b/src/main/java/org/neuroml/export/neuron/NeuronWriter.java @@ -2128,7 +2128,7 @@ public IntracellularProperties convertCellWithMorphology(Component cellComponent writeModFile(channelDensity.getRefHM().get("ionChannel"), option); } - else if (channelDensity.getTypeName().equals("channelDensityNernst")){ + else if (channelDensity.getTypeName().equals("channelDensityNernst") || channelDensity.getTypeName().equals("channelDensityNonUniformNernst") ){ ChannelConductanceOption option = ChannelConductanceOption.USE_NERNST; writeModFile(channelDensity.getRefHM().get("ionChannel"), option); } From 2f2e2a75d7fa0df4f78355356a44f5b2661c9d7c Mon Sep 17 00:00:00 2001 From: pgleeson Date: Mon, 12 Feb 2024 18:13:25 +0000 Subject: [PATCH 03/23] Add functionality to save file outputs of sed-ml --- .../org/lemsml/export/sedml/SEDMLWriter.java | 60 ++++++++++++++----- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/lemsml/export/sedml/SEDMLWriter.java b/src/main/java/org/lemsml/export/sedml/SEDMLWriter.java index 92899dd80..1129c4f05 100644 --- a/src/main/java/org/lemsml/export/sedml/SEDMLWriter.java +++ b/src/main/java/org/lemsml/export/sedml/SEDMLWriter.java @@ -37,6 +37,9 @@ public class SEDMLWriter extends AXMLWriter private String inputFileName = ""; private Format modelFormat; + private final String DISPLAY_PREFIX = "DISPLAY__"; + private final String OUTPUT_PREFIX = "OUTPUT__"; + public SEDMLWriter(Lems lems, File outputFolder, String outputFileName, String inputFileName, Format modelFormat) throws ModelFeatureSupportException, NeuroMLException, LEMSException { super(lems, Format.SEDML, outputFolder, outputFileName); @@ -143,26 +146,30 @@ else if(modelFormat == Format.CELLML) endElement(main, "math"); endElement(main, "dataGenerator"); - for(Component dispComp : simCpt.getAllChildren()) + for(Component dispOrOutputComp : simCpt.getAllChildren()) { - if(dispComp.getTypeName().equals("Display")) + if(dispOrOutputComp.getTypeName().equals("Display") || dispOrOutputComp.getTypeName().equals("OutputFile")) { - String dispId = dispComp.getID().replace(" ","_"); + String id = dispOrOutputComp.getID().replace(" ","_"); - for(Component lineComp : dispComp.getAllChildren()) + for(Component lineOrColumnComp : dispOrOutputComp.getAllChildren()) { - if(lineComp.getTypeName().equals("Line")) + if(lineOrColumnComp.getTypeName().equals("Line") || lineOrColumnComp.getTypeName().equals("OutputColumn")) { - // trace=StateMonitor(hhpop,'v',record=[0]) - - String quantity = lineComp.getStringValue("quantity"); + String quantity = lineOrColumnComp.getStringValue("quantity"); LEMSQuantityPath lqp = new LEMSQuantityPath(quantity); String pop = lqp.getPopulation(); String num = lqp.getPopulationIndex() + ""; String segid = lqp.getSegmentId()==0 ? "" : ("_"+lqp.getSegmentId()); String var = lqp.getVariable(); - String genId = dispId + "_" + lineComp.getID().replace(" ","_"); + String prefix = DISPLAY_PREFIX; + if (lineOrColumnComp.getTypeName().equals("OutputColumn")) + { + prefix = OUTPUT_PREFIX; + } + + String genId = prefix + id + "_" + lineOrColumnComp.getID().replace(" ","_"); String varFull = pop + "_" + num+segid + "_" + var; startElement(main, "dataGenerator", "id=" + genId, "name=" + genId); @@ -200,16 +207,41 @@ else if(modelFormat == Format.CELLML) startElement(main, "listOfOutputs"); - for(Component dispComp : simCpt.getAllChildren()) + for(Component dispOrOutputComp : simCpt.getAllChildren()) { - if(dispComp.getTypeName().equals("Display")) + if(dispOrOutputComp.getTypeName().equals("OutputFile")) + { + String reportName = dispOrOutputComp.getStringValue("fileName").replace(".dat",""); + String ofId = dispOrOutputComp.getID().replace(" ","_"); + + startElement(main, "report", "id=" + reportName); + startElement(main, "listOfDataSets"); + + startEndElement(main, "dataSet", "id=time", "name=time", "dataReference=time"); + + for(Component ocComp : dispOrOutputComp.getAllChildren()) + { + if(ocComp.getTypeName().equals("OutputColumn")) + { + // + String ocid = ocComp.getID().replace(" ","_"); + + String genId = OUTPUT_PREFIX + ofId + "_" + ocid; + startEndElement(main, "dataSet", "id=" + ocid, "name=" + genId, "dataReference=" + genId); + } + } + endElement(main, "listOfDataSets"); + + endElement(main, "report"); + } + if(dispOrOutputComp.getTypeName().equals("Display")) { - String dispId = dispComp.getID().replace(" ","_"); + String dispId = dispOrOutputComp.getID().replace(" ","_"); startElement(main, "plot2D", "id=" + dispId); startElement(main, "listOfCurves"); - for(Component lineComp : dispComp.getAllChildren()) + for(Component lineComp : dispOrOutputComp.getAllChildren()) { if(lineComp.getTypeName().equals("Line")) { @@ -221,7 +253,7 @@ else if(modelFormat == Format.CELLML) String lcid = lineComp.getID().replace(" ","_"); - String genId = dispId + "_" + lcid; + String genId = DISPLAY_PREFIX + dispId + "_" + lcid; // String varFull = pop+"_"+num+"_"+var; // startEndElement(main, "curve", "id=curve_" + lcid, "logX=false", "logY=false", "xDataReference=time", "yDataReference=" + genId); From f6ad0c817e39fca998481257084aa8596d7e9334 Mon Sep 17 00:00:00 2001 From: pgleeson Date: Mon, 12 Feb 2024 18:36:45 +0000 Subject: [PATCH 04/23] Generates valid sed-ml --- src/main/java/org/lemsml/export/sedml/SEDMLWriter.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/lemsml/export/sedml/SEDMLWriter.java b/src/main/java/org/lemsml/export/sedml/SEDMLWriter.java index 1129c4f05..bcff31e2a 100644 --- a/src/main/java/org/lemsml/export/sedml/SEDMLWriter.java +++ b/src/main/java/org/lemsml/export/sedml/SEDMLWriter.java @@ -28,7 +28,7 @@ public class SEDMLWriter extends AXMLWriter { public static final int SEDML_LEVEL = 1; - public static final int SEDML_VERSION = 2; + public static final int SEDML_VERSION = 3; public static final String PREF_SEDML_SCHEMA = "https://raw.githubusercontent.com/SED-ML/sed-ml/master/schema/level"+SEDML_LEVEL+"/version"+SEDML_VERSION+"/sed-ml-L"+SEDML_LEVEL+"-V"+SEDML_VERSION+".xsd"; public static final String GLOBAL_TIME_SBML = "t"; @@ -217,7 +217,7 @@ else if(modelFormat == Format.CELLML) startElement(main, "report", "id=" + reportName); startElement(main, "listOfDataSets"); - startEndElement(main, "dataSet", "id=time", "name=time", "dataReference=time"); + startEndElement(main, "dataSet", "id=time", "name=time", "dataReference=time", "label=time"); for(Component ocComp : dispOrOutputComp.getAllChildren()) { @@ -227,7 +227,7 @@ else if(modelFormat == Format.CELLML) String ocid = ocComp.getID().replace(" ","_"); String genId = OUTPUT_PREFIX + ofId + "_" + ocid; - startEndElement(main, "dataSet", "id=" + ocid, "name=" + genId, "dataReference=" + genId); + startEndElement(main, "dataSet", "id=" + ocid, "name=" + genId, "dataReference=" + genId, "label=" + genId); } } endElement(main, "listOfDataSets"); From fe6009b6fd6b2b17b06977afa6a651c7a6891374 Mon Sep 17 00:00:00 2001 From: "Ankur Sinha (Ankur Sinha Gmail)" Date: Thu, 15 Feb 2024 12:25:45 +0000 Subject: [PATCH 05/23] feat(dlems-keywords): add cvode related keywords --- .../lemsml/export/dlems/DLemsKeywords.java | 124 +++++++++--------- 1 file changed, 64 insertions(+), 60 deletions(-) diff --git a/src/main/java/org/lemsml/export/dlems/DLemsKeywords.java b/src/main/java/org/lemsml/export/dlems/DLemsKeywords.java index c92442f3d..2423c2322 100644 --- a/src/main/java/org/lemsml/export/dlems/DLemsKeywords.java +++ b/src/main/java/org/lemsml/export/dlems/DLemsKeywords.java @@ -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(); + } } From 2aa6950a38239dceb0289567306f74b2e155224b Mon Sep 17 00:00:00 2001 From: "Ankur Sinha (Ankur Sinha Gmail)" Date: Thu, 15 Feb 2024 12:27:19 +0000 Subject: [PATCH 06/23] feat(netpyne-template): update to include cvode bits --- src/main/resources/netpyne/run.vm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/resources/netpyne/run.vm b/src/main/resources/netpyne/run.vm index 8ed746ee5..17db9f044 100644 --- a/src/main/resources/netpyne/run.vm +++ b/src/main/resources/netpyne/run.vm @@ -14,7 +14,7 @@ import datetime class NetPyNESimulation(): - def __init__(self, tstop=$t_end, dt=$dt, seed=123456789, save_json=False): + def __init__(self, tstop=$t_end, dt=$dt, seed=123456789, save_json=False, abs_tol=None): self.setup_start = time.time() #if ($report_file) @@ -47,6 +47,13 @@ class NetPyNESimulation(): self.simConfig.duration = self.simConfig.tstop = tstop # Duration of the simulation, in ms self.simConfig.dt = dt # Internal integration timestep to use + # cvode + if abs_tol is not None: + self.simConfig.cvode_active = True + self.simConfig.cvode_atol = $abs_tol + else: + self.simConfig.cvode_active = False + # Seeds for randomizers (connectivity, input stimulation and cell locations) # Note: locations and connections should be fully specified by the structure of the NeuroML, # so seeds for conn & loc shouldn't affect networks structure/behaviour @@ -231,7 +238,7 @@ if __name__ == '__main__': save_json = '-json' in sys.argv no_run = '-norun' in sys.argv - ns = NetPyNESimulation(tstop=$t_end, dt=$dt, seed=$seed, save_json=save_json) + ns = NetPyNESimulation(tstop=$t_end, dt=$dt, seed=$seed, save_json=save_json, abs_tol=$abs_tol) if not no_run: ns.run() From d5b2eb94be914fbbc044301fa8e5e189b4c97bc4 Mon Sep 17 00:00:00 2001 From: "Ankur Sinha (Ankur Sinha Gmail)" Date: Thu, 15 Feb 2024 12:36:05 +0000 Subject: [PATCH 07/23] feat(dlems-writer): add bits for handling cvode in NEURON --- .../org/lemsml/export/dlems/DLemsWriter.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/main/java/org/lemsml/export/dlems/DLemsWriter.java b/src/main/java/org/lemsml/export/dlems/DLemsWriter.java index ebe295720..944aa7d05 100644 --- a/src/main/java/org/lemsml/export/dlems/DLemsWriter.java +++ b/src/main/java/org/lemsml/export/dlems/DLemsWriter.java @@ -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; @@ -203,6 +205,34 @@ 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 metas = simCpt.metas; + for(Meta m : metas) + { + HashMap 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"); + 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")); From dacf1f3fadf1672d7a1a29c4ecab0f7b2d051052 Mon Sep 17 00:00:00 2001 From: "Ankur Sinha (Ankur Sinha Gmail)" Date: Thu, 15 Feb 2024 15:47:36 +0000 Subject: [PATCH 08/23] fix(netpyne): improve logic for cvode in generated script --- src/main/java/org/lemsml/export/dlems/DLemsWriter.java | 10 +++++++--- src/main/resources/netpyne/run.vm | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/lemsml/export/dlems/DLemsWriter.java b/src/main/java/org/lemsml/export/dlems/DLemsWriter.java index 944aa7d05..237c8688a 100644 --- a/src/main/java/org/lemsml/export/dlems/DLemsWriter.java +++ b/src/main/java/org/lemsml/export/dlems/DLemsWriter.java @@ -228,10 +228,14 @@ public String getMainScript() throws LEMSException, IOException if (nrn_cvode == true) { g.writeStringField(DLemsKeywords.CVODE.get(), "true"); - g.writeStringField(DLemsKeywords.ABS_TOL.get(), abs_tol); - g.writeStringField(DLemsKeywords.REL_TOL.get(), rel_tol); - } + 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")) diff --git a/src/main/resources/netpyne/run.vm b/src/main/resources/netpyne/run.vm index 17db9f044..e03992872 100644 --- a/src/main/resources/netpyne/run.vm +++ b/src/main/resources/netpyne/run.vm @@ -50,7 +50,7 @@ class NetPyNESimulation(): # cvode if abs_tol is not None: self.simConfig.cvode_active = True - self.simConfig.cvode_atol = $abs_tol + self.simConfig.cvode_atol = abs_tol else: self.simConfig.cvode_active = False From 1e3948d0656c364b53131367df2f77aded18dfdf Mon Sep 17 00:00:00 2001 From: "Ankur Sinha (Ankur Sinha Gmail)" Date: Thu, 18 Apr 2024 10:39:27 +0100 Subject: [PATCH 09/23] fix(sedml): sanitise report id in sedml export fixes #114 --- src/main/java/org/lemsml/export/sedml/SEDMLWriter.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/lemsml/export/sedml/SEDMLWriter.java b/src/main/java/org/lemsml/export/sedml/SEDMLWriter.java index bcff31e2a..15df02271 100644 --- a/src/main/java/org/lemsml/export/sedml/SEDMLWriter.java +++ b/src/main/java/org/lemsml/export/sedml/SEDMLWriter.java @@ -212,9 +212,10 @@ else if(modelFormat == Format.CELLML) if(dispOrOutputComp.getTypeName().equals("OutputFile")) { String reportName = dispOrOutputComp.getStringValue("fileName").replace(".dat",""); + String reportId = reportName.replaceAll("[\\W]", "_"); String ofId = dispOrOutputComp.getID().replace(" ","_"); - startElement(main, "report", "id=" + reportName); + startElement(main, "report", "id=" + reportId); startElement(main, "listOfDataSets"); startEndElement(main, "dataSet", "id=time", "name=time", "dataReference=time", "label=time"); From d5aaa32f7b26832bfbc014757b15c52ce1a626cf Mon Sep 17 00:00:00 2001 From: "Ankur Sinha (Ankur Sinha Gmail)" Date: Thu, 18 Apr 2024 14:26:55 +0100 Subject: [PATCH 10/23] fix(sedml): make variable ids unique for data generators Otherwise biosimulations errors; ``` Multiple objects have the following ids:\n - hhpop_0_bioPhys1_membraneProperties_KConductances_KConductance_n_q\n - hhpop_0_bioPhys1_membraneProperties_NaConductances_NaConductance_h_q\n - hhpop_0_bioPhys1_membraneProperties_NaConductances_NaConductance_m_q\n - hhpop_0_v\n - time"" ``` --- src/main/java/org/lemsml/export/sedml/SEDMLWriter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/lemsml/export/sedml/SEDMLWriter.java b/src/main/java/org/lemsml/export/sedml/SEDMLWriter.java index 15df02271..3e02943ba 100644 --- a/src/main/java/org/lemsml/export/sedml/SEDMLWriter.java +++ b/src/main/java/org/lemsml/export/sedml/SEDMLWriter.java @@ -170,7 +170,7 @@ else if(modelFormat == Format.CELLML) } String genId = prefix + id + "_" + lineOrColumnComp.getID().replace(" ","_"); - String varFull = pop + "_" + num+segid + "_" + var; + String varFull = genId + "_" + pop + "_" + num+segid + "_" + var; startElement(main, "dataGenerator", "id=" + genId, "name=" + genId); startElement(main, "listOfVariables"); From f8a601fcbf0800672b091d148119e3126d3e867b Mon Sep 17 00:00:00 2001 From: "Ankur Sinha (Ankur Sinha Gmail)" Date: Thu, 18 Apr 2024 14:34:45 +0100 Subject: [PATCH 11/23] fix(sedml): also make data set ids in reports unique Otherwise biosimulations errs with: ``` Multiple objects have the following ids:\n - time ``` --- src/main/java/org/lemsml/export/sedml/SEDMLWriter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/lemsml/export/sedml/SEDMLWriter.java b/src/main/java/org/lemsml/export/sedml/SEDMLWriter.java index 3e02943ba..722552e1a 100644 --- a/src/main/java/org/lemsml/export/sedml/SEDMLWriter.java +++ b/src/main/java/org/lemsml/export/sedml/SEDMLWriter.java @@ -225,7 +225,7 @@ else if(modelFormat == Format.CELLML) if(ocComp.getTypeName().equals("OutputColumn")) { // - String ocid = ocComp.getID().replace(" ","_"); + String ocid = reportId + "_" + ocComp.getID().replace(" ","_"); String genId = OUTPUT_PREFIX + ofId + "_" + ocid; startEndElement(main, "dataSet", "id=" + ocid, "name=" + genId, "dataReference=" + genId, "label=" + genId); From ce395cf9857c8b1387a411c5caa4974e089b43d7 Mon Sep 17 00:00:00 2001 From: "Ankur Sinha (Ankur Sinha Gmail)" Date: Thu, 18 Apr 2024 14:39:07 +0100 Subject: [PATCH 12/23] fix(sedml): also make time id unique --- src/main/java/org/lemsml/export/sedml/SEDMLWriter.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/lemsml/export/sedml/SEDMLWriter.java b/src/main/java/org/lemsml/export/sedml/SEDMLWriter.java index 722552e1a..4e0c1c8d0 100644 --- a/src/main/java/org/lemsml/export/sedml/SEDMLWriter.java +++ b/src/main/java/org/lemsml/export/sedml/SEDMLWriter.java @@ -218,17 +218,17 @@ else if(modelFormat == Format.CELLML) startElement(main, "report", "id=" + reportId); startElement(main, "listOfDataSets"); - startEndElement(main, "dataSet", "id=time", "name=time", "dataReference=time", "label=time"); + startEndElement(main, "dataSet", "id=" + reportId + "_time", "name=time", "dataReference=time", "label=time"); for(Component ocComp : dispOrOutputComp.getAllChildren()) { if(ocComp.getTypeName().equals("OutputColumn")) { // - String ocid = reportId + "_" + ocComp.getID().replace(" ","_"); + String ocid = ocComp.getID().replace(" ","_"); String genId = OUTPUT_PREFIX + ofId + "_" + ocid; - startEndElement(main, "dataSet", "id=" + ocid, "name=" + genId, "dataReference=" + genId, "label=" + genId); + startEndElement(main, "dataSet", "id=" + reportId + "_" + ocid, "name=" + genId, "dataReference=" + genId, "label=" + genId); } } endElement(main, "listOfDataSets"); From e6ef4de485da2cf92ebee54cb6e2025d57ae7452 Mon Sep 17 00:00:00 2001 From: pgleeson Date: Wed, 1 May 2024 11:38:16 +0100 Subject: [PATCH 13/23] Test on java 21 --- .github/workflows/ci.yml | 13 +++++++++---- .github/workflows/docs.yml | 14 +++++++------- pom.xml | 4 ++-- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a1b56b05d..e980149b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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-latest, windows-latest] + 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' diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 2d1c5f0d4..380031c48 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -13,18 +13,18 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: nelonoel/branch-name@v1.0.1 - 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 @@ -34,14 +34,14 @@ 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 @@ -49,14 +49,14 @@ jobs: - 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 diff --git a/pom.xml b/pom.xml index c38acde79..8df75dd3a 100644 --- a/pom.xml +++ b/pom.xml @@ -91,8 +91,8 @@ maven-compiler-plugin 3.0 - 1.7 - 1.7 + 1.8 + 1.8 From 2d0159a697e185ecd735bd5eb19468db0294f0c6 Mon Sep 17 00:00:00 2001 From: pgleeson Date: Wed, 1 May 2024 11:42:22 +0100 Subject: [PATCH 14/23] Just test on macos-12 for now... --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e980149b8..ef4d9210e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: fail-fast: false matrix: java: [ '8', '11', '16', '17', '19', '21' ] - runs-on: [ubuntu-latest, macos-latest, windows-latest] + runs-on: [ubuntu-latest, macos-12, windows-latest] # Note macos-12, not latest/14, due to hdf5 install issue exclude: - runs-on: macos-latest java: "8" @@ -36,7 +36,7 @@ jobs: - name: Install and test (non Win) env: main_repo_branch: ${GITHUB_REF_NAME} - if: ${{ matrix.runs-on != 'windows-2019' }} + if: ${{ matrix.runs-on != 'windows-latest' }} run: | export main_repo_branch=${{env.main_repo_branch}} if [[ ${main_repo_branch} != "master" && ${main_repo_branch} != "development" && ${main_repo_branch} != "experimental" && ${main_repo_branch} != *"osb"* ]]; then main_repo_branch=development ; fi @@ -72,7 +72,7 @@ jobs: mvn dependency:tree - name: Install and test (Win) - if: ${{ matrix.runs-on == 'windows-2019' }} + if: ${{ matrix.runs-on == 'windows-latest' }} run: | # Install org.neuroml.model.injectingplugin From faf1311f84a8fc3bc0b9c204e3c8ca127ab2eefd Mon Sep 17 00:00:00 2001 From: pgleeson Date: Wed, 1 May 2024 11:49:37 +0100 Subject: [PATCH 15/23] Back to windows-2019 --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef4d9210e..922ab123b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: fail-fast: false matrix: java: [ '8', '11', '16', '17', '19', '21' ] - runs-on: [ubuntu-latest, macos-12, windows-latest] # Note macos-12, not latest/14, due to hdf5 install issue + 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" @@ -36,7 +36,7 @@ jobs: - name: Install and test (non Win) env: main_repo_branch: ${GITHUB_REF_NAME} - if: ${{ matrix.runs-on != 'windows-latest' }} + if: ${{ matrix.runs-on != 'windows-2019' }} run: | export main_repo_branch=${{env.main_repo_branch}} if [[ ${main_repo_branch} != "master" && ${main_repo_branch} != "development" && ${main_repo_branch} != "experimental" && ${main_repo_branch} != *"osb"* ]]; then main_repo_branch=development ; fi @@ -72,7 +72,7 @@ jobs: mvn dependency:tree - name: Install and test (Win) - if: ${{ matrix.runs-on == 'windows-latest' }} + if: ${{ matrix.runs-on == 'windows-2019' }} run: | # Install org.neuroml.model.injectingplugin From 528e08ab08e10b18fdbf4c068659bc0ad3920b27 Mon Sep 17 00:00:00 2001 From: pgleeson Date: Fri, 31 May 2024 10:26:56 +0100 Subject: [PATCH 16/23] Fixes to Neuron and Netpyne to handle case where cell has external morphology/biophysicalProperties --- .../org/lemsml/export/dlems/DLemsWriter.java | 28 ++++++++-- .../neuroml/export/info/InfoTreeCreator.java | 2 +- .../neuroml/export/netpyne/NetPyNEWriter.java | 5 ++ .../neuroml/export/neuron/NamingHelper.java | 3 +- .../neuroml/export/neuron/NeuronWriter.java | 26 ++++++---- .../org/neuroml/export/svg/Network3D.java | 9 ++-- .../org/neuroml/export/svg/SVGWriter.java | 38 ++++++++------ .../java/org/neuroml/export/utils/Utils.java | 39 ++++++++++++-- .../export/utils/support/ModelFeature.java | 51 ++++++++++--------- .../export/neuron/JsonSerializerTest.java | 2 +- 10 files changed, 141 insertions(+), 62 deletions(-) diff --git a/src/main/java/org/lemsml/export/dlems/DLemsWriter.java b/src/main/java/org/lemsml/export/dlems/DLemsWriter.java index 237c8688a..270da55bb 100644 --- a/src/main/java/org/lemsml/export/dlems/DLemsWriter.java +++ b/src/main/java/org/lemsml/export/dlems/DLemsWriter.java @@ -673,8 +673,21 @@ private void writeDLemsForComponent(JsonGenerator g, Component comp, HashMap standalones = Utils.convertLemsComponentToNeuroML(component); + LinkedHashMap standalones = Utils.convertLemsComponentToNeuroML(component, true, null); for(Standalone element : standalones.values()) { diff --git a/src/main/java/org/neuroml/export/netpyne/NetPyNEWriter.java b/src/main/java/org/neuroml/export/netpyne/NetPyNEWriter.java index 04b8aea0e..2df4ee025 100644 --- a/src/main/java/org/neuroml/export/netpyne/NetPyNEWriter.java +++ b/src/main/java/org/neuroml/export/netpyne/NetPyNEWriter.java @@ -472,6 +472,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) { diff --git a/src/main/java/org/neuroml/export/neuron/NamingHelper.java b/src/main/java/org/neuroml/export/neuron/NamingHelper.java index a51024d23..87df3170a 100644 --- a/src/main/java/org/neuroml/export/neuron/NamingHelper.java +++ b/src/main/java/org/neuroml/export/neuron/NamingHelper.java @@ -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; /** * @@ -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(); diff --git a/src/main/java/org/neuroml/export/neuron/NeuronWriter.java b/src/main/java/org/neuroml/export/neuron/NeuronWriter.java index 08c846388..d1bad3df2 100644 --- a/src/main/java/org/neuroml/export/neuron/NeuronWriter.java +++ b/src/main/java/org/neuroml/export/neuron/NeuronWriter.java @@ -2071,7 +2071,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; @@ -2105,7 +2105,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"); } @@ -3936,8 +3940,8 @@ public static void main(String[] args) throws Exception ArrayList lemsFiles = new ArrayList(); - 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")); @@ -3947,14 +3951,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")); @@ -3976,7 +3980,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")); @@ -3995,7 +4003,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")); diff --git a/src/main/java/org/neuroml/export/svg/Network3D.java b/src/main/java/org/neuroml/export/svg/Network3D.java index 2cfa0ba79..59561063f 100644 --- a/src/main/java/org/neuroml/export/svg/Network3D.java +++ b/src/main/java/org/neuroml/export/svg/Network3D.java @@ -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 { @@ -19,13 +20,13 @@ public Network3D(String comment) lines = new ArrayList(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)); } @@ -201,13 +202,13 @@ private Network3D rotate(double degreesAroundZ, double degreesAroundY) } - private ArrayList extractLines(Cell cell, String defaultColor) + private ArrayList extractLines(Cell cell, String defaultColor) throws NeuroMLException { return extractLines(cell, 0, 0, 0, defaultColor); } - private ArrayList extractLines(Cell cell, float offsetX, float offsetY, float offsetZ, String defaultColor) + private ArrayList extractLines(Cell cell, float offsetX, float offsetY, float offsetZ, String defaultColor) throws NeuroMLException { ArrayList result = new ArrayList(); diff --git a/src/main/java/org/neuroml/export/svg/SVGWriter.java b/src/main/java/org/neuroml/export/svg/SVGWriter.java index 7733ead43..de92ffe5e 100644 --- a/src/main/java/org/neuroml/export/svg/SVGWriter.java +++ b/src/main/java/org/neuroml/export/svg/SVGWriter.java @@ -82,21 +82,27 @@ public String getMainScript() throws GenerationException { StringBuilder core = new StringBuilder(); - Rectangle bounds = render(core, false); - StringBuilder result = new StringBuilder(); - //Add header - result.append("\n"); - //addComment(result, "Total bounds: "+bounds.toString()); - startElement(result, "svg", "xmlns=" + SVG_NAMESPACE, - "version=" + SVG_VERSION, - "width="+bounds.width, - "height="+bounds.height, - "viewBox=0 0 "+bounds.width+" "+bounds.height); - - result.append(core.toString()); - - endElement(result, "svg"); + try { + + Rectangle bounds = render(core, false); + + //Add header + result.append("\n"); + //addComment(result, "Total bounds: "+bounds.toString()); + startElement(result, "svg", "xmlns=" + SVG_NAMESPACE, + "version=" + SVG_VERSION, + "width="+bounds.width, + "height="+bounds.height, + "viewBox=0 0 "+bounds.width+" "+bounds.height); + + result.append(core.toString()); + + endElement(result, "svg"); + } + catch (NeuroMLException ne) { + throw new GenerationException("Problem generating SVG", ne); + } return result.toString(); } @@ -107,7 +113,7 @@ public List getAllBasedOnCell(NeuroMLDocument nmlDocument) { return cells; } - public Rectangle render(StringBuilder result, boolean png) { + public Rectangle render(StringBuilder result, boolean png) throws NeuroMLException { if (nmlDocument.getNetwork().isEmpty()) { @@ -185,7 +191,7 @@ public Rectangle render(StringBuilder result, boolean png) { } } - public void convertToPng(File pngFile) { + public void convertToPng(File pngFile) throws NeuroMLException { // One quick run to get bounds... Rectangle bounds = render(new StringBuilder(), false); diff --git a/src/main/java/org/neuroml/export/utils/Utils.java b/src/main/java/org/neuroml/export/utils/Utils.java index b1d26dbb6..726510814 100644 --- a/src/main/java/org/neuroml/export/utils/Utils.java +++ b/src/main/java/org/neuroml/export/utils/Utils.java @@ -30,6 +30,8 @@ import org.neuroml.export.utils.support.SupportLevelInfo; import org.neuroml.model.Cell; import org.neuroml.model.Cell2CaPools; +import org.neuroml.model.Morphology; +import org.neuroml.model.BiophysicalProperties; import org.neuroml.model.NeuroMLDocument; import org.neuroml.model.Standalone; import org.neuroml.model.util.NeuroML2Validator; @@ -401,11 +403,42 @@ public static NeuroMLDocument convertLemsComponentToNeuroMLDocument(Component co return nmlDocument; } - public static LinkedHashMap convertLemsComponentToNeuroML(Component comp) throws LEMSException, NeuroMLException + public static LinkedHashMap convertLemsComponentToNeuroML(Component comp, boolean fixExternalMorphsBiophys, Lems lems) throws LEMSException, NeuroMLException { NeuroMLDocument nmlDocument = convertLemsComponentToNeuroMLDocument(comp); LinkedHashMap els = NeuroMLConverter.getAllStandaloneElements(nmlDocument); + + if (fixExternalMorphsBiophys) + { + for (Map.Entry entry : els.entrySet()) + { + String id = entry.getKey(); + Standalone e = entry.getValue(); + if (e instanceof Cell) { + Cell cell = (Cell)e; + + if (cell.getMorphologyAttr() != null) + { + Component morphComp = lems.getComponent(cell.getMorphologyAttr()); + NeuroMLDocument nmlDocumentMorph = convertLemsComponentToNeuroMLDocument(morphComp); + Morphology m = nmlDocumentMorph.getMorphology().get(0); + cell.setMorphology(m); + cell.setMorphologyAttr(null); + els.put(id, cell); + } + if (cell.getBiophysicalPropertiesAttr() != null) + { + Component bpComp = lems.getComponent(cell.getBiophysicalPropertiesAttr()); + NeuroMLDocument nmlDocumentBp = convertLemsComponentToNeuroMLDocument(bpComp); + BiophysicalProperties bp = nmlDocumentBp.getBiophysicalProperties().get(0); + cell.setBiophysicalProperties(bp); + cell.setBiophysicalPropertiesAttr(null); + els.put(id, cell); + } + } + } + } return els; } @@ -423,9 +456,9 @@ public static Component convertNeuroMLToComponent(Standalone nmlElement) throws } } - public static Cell getCellFromComponent(Component comp) throws LEMSException, NeuroMLException + public static Cell getCellFromComponent(Component comp, Lems lems) throws LEMSException, NeuroMLException { - LinkedHashMap els = Utils.convertLemsComponentToNeuroML(comp); + LinkedHashMap els = Utils.convertLemsComponentToNeuroML(comp, true, lems); Cell cell = (Cell) els.values().iterator().next(); if (cell == null) { diff --git a/src/main/java/org/neuroml/export/utils/support/ModelFeature.java b/src/main/java/org/neuroml/export/utils/support/ModelFeature.java index 6063290cf..a15cab5b8 100644 --- a/src/main/java/org/neuroml/export/utils/support/ModelFeature.java +++ b/src/main/java/org/neuroml/export/utils/support/ModelFeature.java @@ -106,7 +106,7 @@ private static void analyseSingleComponent(Component component, ArrayList 1) @@ -116,29 +116,34 @@ private static void analyseSingleComponent(Component component, ArrayList Date: Tue, 4 Jun 2024 15:40:02 +0100 Subject: [PATCH 17/23] Added check EXT_MORPH_BIOPHYS_CELL_MODEL, just passing on Neuron & Netne --- src/main/java/org/neuroml/export/eden/EDENWriter.java | 1 + .../org/neuroml/export/netpyne/NetPyNEWriter.java | 1 + .../java/org/neuroml/export/neuron/NeuronWriter.java | 1 + src/main/java/org/neuroml/export/utils/Utils.java | 10 +++++++++- .../neuroml/export/utils/support/ModelFeature.java | 11 +++++++++++ .../export/utils/support/SupportLevelInfo.java | 4 +++- 6 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/neuroml/export/eden/EDENWriter.java b/src/main/java/org/neuroml/export/eden/EDENWriter.java index e94b9260c..a812a2c2d 100644 --- a/src/main/java/org/neuroml/export/eden/EDENWriter.java +++ b/src/main/java/org/neuroml/export/eden/EDENWriter.java @@ -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.NONE); 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); diff --git a/src/main/java/org/neuroml/export/netpyne/NetPyNEWriter.java b/src/main/java/org/neuroml/export/netpyne/NetPyNEWriter.java index 2df4ee025..931a63310 100644 --- a/src/main/java/org/neuroml/export/netpyne/NetPyNEWriter.java +++ b/src/main/java/org/neuroml/export/netpyne/NetPyNEWriter.java @@ -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); diff --git a/src/main/java/org/neuroml/export/neuron/NeuronWriter.java b/src/main/java/org/neuroml/export/neuron/NeuronWriter.java index d1bad3df2..8d1d509a9 100644 --- a/src/main/java/org/neuroml/export/neuron/NeuronWriter.java +++ b/src/main/java/org/neuroml/export/neuron/NeuronWriter.java @@ -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); diff --git a/src/main/java/org/neuroml/export/utils/Utils.java b/src/main/java/org/neuroml/export/utils/Utils.java index 726510814..93dd9ea76 100644 --- a/src/main/java/org/neuroml/export/utils/Utils.java +++ b/src/main/java/org/neuroml/export/utils/Utils.java @@ -556,7 +556,15 @@ public Sim importFile(File simFile) throws LEMSException { if(run) { SupportLevelInfo sli = SupportLevelInfo.getSupportLevelInfo(); - sli.checkConversionSupported(Format.LEMS, sim.getLems()); + try + { + sli.checkConversionSupported(Format.LEMS, sim.getLems()); + } + catch (ModelFeatureSupportException mfse) + { + E.info(mfse.getMessage()); + System.exit(-1); + } sim.run(); IOUtil.saveReportAndTimesFile(sim, lemsFile); E.info("Finished reading, building, running and displaying LEMS model"); diff --git a/src/main/java/org/neuroml/export/utils/support/ModelFeature.java b/src/main/java/org/neuroml/export/utils/support/ModelFeature.java index a15cab5b8..cb34f7ff7 100644 --- a/src/main/java/org/neuroml/export/utils/support/ModelFeature.java +++ b/src/main/java/org/neuroml/export/utils/support/ModelFeature.java @@ -37,6 +37,7 @@ public enum ModelFeature NETWORK_WITH_ANALOG_CONNS_MODEL("Network model with analog/continuously communicating connections between cells"), ABSTRACT_CELL_MODEL("Model with abstract (non conductance based) cell(s)"), COND_BASED_CELL_MODEL("Model with conductance based cell(s)"), + EXT_MORPH_BIOPHYS_CELL_MODEL("Model with conductance based cell(s) with morphology and/or biophysicalProperties outside cell element"), MULTICOMPARTMENTAL_CELL_MODEL("Model with multicompartmental cell(s)"), CHANNEL_POPULATIONS_CELL_MODEL("Model with channel populations"), CHANNEL_DENSITY_ON_SEGMENT("Model with channel density specified per segment (aot segmentGroup)"), @@ -106,7 +107,17 @@ private static void analyseSingleComponent(Component component, ArrayList 1) diff --git a/src/main/java/org/neuroml/export/utils/support/SupportLevelInfo.java b/src/main/java/org/neuroml/export/utils/support/SupportLevelInfo.java index 78ad709ed..6849028b9 100644 --- a/src/main/java/org/neuroml/export/utils/support/SupportLevelInfo.java +++ b/src/main/java/org/neuroml/export/utils/support/SupportLevelInfo.java @@ -41,6 +41,7 @@ private SupportLevelInfo() /* Add info on formats supported in jLEMS */ addSupportInfo(Format.LEMS, ModelFeature.ABSTRACT_CELL_MODEL, SupportLevelInfo.Level.HIGH); addSupportInfo(Format.LEMS, ModelFeature.COND_BASED_CELL_MODEL, SupportLevelInfo.Level.HIGH); + addSupportInfo(Format.LEMS, ModelFeature.EXT_MORPH_BIOPHYS_CELL_MODEL, SupportLevelInfo.Level.NONE); addSupportInfo(Format.LEMS, ModelFeature.SINGLE_COMP_MODEL, SupportLevelInfo.Level.HIGH); addSupportInfo(Format.LEMS, ModelFeature.NETWORK_MODEL, SupportLevelInfo.Level.HIGH); addSupportInfo(Format.LEMS, ModelFeature.MULTI_CELL_MODEL, SupportLevelInfo.Level.HIGH); @@ -135,11 +136,12 @@ public void checkConversionSupported(Format format, Lems lems) throws ModelFeatu if(!supp.equals(SUPPORTED)) { passed = false; - report.append("Feature not supported in " + format + ": " + mf + "\n " + myInstance.isSupported(format, mf) + "\n"); + report.append("Feature is not supported in " + format + ": " + mf + "\n " + myInstance.isSupported(format, mf) + "\n"); } } if(!passed) { + report.insert(0, "Error! Some features of the model are not supported by that simulator.\n\n"); report.append("\nInfo on supported features:\n" + myInstance); throw new ModelFeatureSupportException(report.toString()); } From c4d3ae993e33a0dd92c6117fb67e11998fefbfe6 Mon Sep 17 00:00:00 2001 From: pgleeson Date: Tue, 11 Jun 2024 10:38:54 +0100 Subject: [PATCH 18/23] Eden supports external morphology/bioPhys --- src/main/java/org/neuroml/export/eden/EDENWriter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/neuroml/export/eden/EDENWriter.java b/src/main/java/org/neuroml/export/eden/EDENWriter.java index a812a2c2d..427e3aace 100644 --- a/src/main/java/org/neuroml/export/eden/EDENWriter.java +++ b/src/main/java/org/neuroml/export/eden/EDENWriter.java @@ -71,7 +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.NONE); + 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); From 7f7590e407ca8e8bfd81d6fd8675f365558b6b04 Mon Sep 17 00:00:00 2001 From: Padraig Gleeson Date: Tue, 11 Jun 2024 12:01:34 +0100 Subject: [PATCH 19/23] To v1.10.1 --- pom.xml | 6 +++--- src/main/java/org/neuroml/export/utils/Utils.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 8df75dd3a..4664358ef 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.neuroml.export org.neuroml.export bundle - 1.10.0 + 1.10.1 org.neuroml.export http://maven.apache.org @@ -18,12 +18,12 @@ org.neuroml.model org.neuroml.model - 1.10.0 + 1.10.1 org.lemsml jlems - 0.11.0 + 0.11.1 org.apache.velocity diff --git a/src/main/java/org/neuroml/export/utils/Utils.java b/src/main/java/org/neuroml/export/utils/Utils.java index 93dd9ea76..96b88c52c 100644 --- a/src/main/java/org/neuroml/export/utils/Utils.java +++ b/src/main/java/org/neuroml/export/utils/Utils.java @@ -44,7 +44,7 @@ public class Utils private static Lems lemsWithNML2CompTypes; - public static String ORG_NEUROML_EXPORT_VERSION = "1.10.0"; + public static String ORG_NEUROML_EXPORT_VERSION = "1.10.1"; public static final String ARCH_I686 = "i686"; public static final String ARCH_I386 = "i386"; From 11aabc96f27dcab9bb9b29a0a04fab49a249113e Mon Sep 17 00:00:00 2001 From: Padraig Gleeson Date: Tue, 11 Jun 2024 12:18:08 +0100 Subject: [PATCH 20/23] Bump year in docs --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4664358ef..96bf28ef9 100644 --- a/pom.xml +++ b/pom.xml @@ -49,7 +49,7 @@ <br /> <br /> - Copyright NeuroML Contributors 2023 + Copyright NeuroML Contributors 2024 From e6981bfbee7c5f21728890a845423e6c7e0df7ae Mon Sep 17 00:00:00 2001 From: pgleeson Date: Thu, 13 Jun 2024 13:22:43 +0100 Subject: [PATCH 21/23] Check if cell is CELL_2CA_POOLS_COMP_TYPE --- .../export/utils/support/ModelFeature.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/neuroml/export/utils/support/ModelFeature.java b/src/main/java/org/neuroml/export/utils/support/ModelFeature.java index cb34f7ff7..98a07c6c8 100644 --- a/src/main/java/org/neuroml/export/utils/support/ModelFeature.java +++ b/src/main/java/org/neuroml/export/utils/support/ModelFeature.java @@ -107,13 +107,16 @@ private static void analyseSingleComponent(Component component, ArrayList Date: Thu, 4 Jul 2024 19:10:34 +0100 Subject: [PATCH 22/23] Add location of neuron when pip installed on Binder --- src/main/java/org/neuroml/export/neuron/ProcessManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/neuroml/export/neuron/ProcessManager.java b/src/main/java/org/neuroml/export/neuron/ProcessManager.java index 645a55c81..220ea5695 100644 --- a/src/main/java/org/neuroml/export/neuron/ProcessManager.java +++ b/src/main/java/org/neuroml/export/neuron/ProcessManager.java @@ -83,6 +83,7 @@ else if (Utils.isLinuxBasedPlatform()) options.add("/usr"); options.add("/usr/local"); options.add("/usr/local/nrn/x86_64"); + options.add("/srv/conda/envs/notebook/"); // location of neuron when pip installed on Binder... } for (String option : options) From ae0ef92e10e17307230deca7cbd9a0b17e865c1e Mon Sep 17 00:00:00 2001 From: pgleeson Date: Wed, 31 Jul 2024 11:28:34 +0100 Subject: [PATCH 23/23] Add more info on namespaces in SED-ML export --- .../java/org/lemsml/export/sedml/SEDMLWriter.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/lemsml/export/sedml/SEDMLWriter.java b/src/main/java/org/lemsml/export/sedml/SEDMLWriter.java index 4e0c1c8d0..0a6a347aa 100644 --- a/src/main/java/org/lemsml/export/sedml/SEDMLWriter.java +++ b/src/main/java/org/lemsml/export/sedml/SEDMLWriter.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.Arrays; import org.lemsml.export.base.AXMLWriter; import org.lemsml.jlems.core.logging.E; @@ -67,9 +68,18 @@ public String getMainScript() throws ContentError StringBuilder main = new StringBuilder(); main.append("\n"); - String[] attrs = new String[] { "xmlns=http://sed-ml.org/sed-ml/level"+SEDML_LEVEL+"/version"+SEDML_VERSION, "level="+SEDML_LEVEL, "version="+SEDML_VERSION+"", "xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance", + String[] attrs = new String[] { "xmlns=http://sed-ml.org/sed-ml/level"+SEDML_LEVEL+"/version"+SEDML_VERSION, + "level="+SEDML_LEVEL, + "version="+SEDML_VERSION+"", + "xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance", "xsi:schemaLocation=http://sed-ml.org/sed-ml/level"+SEDML_LEVEL+"/version"+SEDML_VERSION+" " + PREF_SEDML_SCHEMA }; + if(modelFormat == Format.SBML) + { + attrs = Arrays.copyOf(attrs, attrs.length + 1); + attrs[attrs.length-1] = "xmlns:sbml=http://www.sbml.org/sbml/level2/version2"; + } + startElement(main, "sedML", attrs); startElement(main, "notes"); startElement(main, "p", "xmlns=http://www.w3.org/1999/xhtml");