Skip to content

Commit

Permalink
Merge pull request #101 from NeuroML/feat/99-treat-all-normal
Browse files Browse the repository at this point in the history
Feat/99 treat all normal - test in experimental branch
  • Loading branch information
pgleeson committed May 26, 2023
2 parents 179d6dd + 8a36b63 commit b5bf3d6
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 72 deletions.
2 changes: 1 addition & 1 deletion 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.0</version>
<version>1.9.1</version>
<name>org.neuroml.export</name>
<url>http://maven.apache.org</url>

Expand Down
145 changes: 75 additions & 70 deletions src/main/java/org/neuroml/export/neuron/JSONCellSerializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -297,92 +297,97 @@ else if(fract == 0 && segsPar.get(0) == parentId)
g.writeEndArray();

g.writeArrayFieldStart("groups");
boolean foundAll = false;
/* Convert all segment groups.
* Note that the "nrn_all" segment group/section list id is reserved.
* We use it to keep a list of all segments/sections
*/
for(SegmentGroup grp : morph.getSegmentGroup())
{
if(!grp.getId().equals("all")) // I'll calculate this here...
/* Ask the user not to use nrn_all as a segment group id */
if(grp.getId().equals("nrn_all"))
{
if(!(foundNeuroLexFlags && CellUtils.isUnbranchedNonOverlapping(grp)))
{
g.writeStartObject();
g.writeStringField("name", grp.getId());
throw new NeuroMLException("A segment group named \"nrn_all\" was found. Please use another id for the segment group. The \"nrn_all\" group is reserved");
}
if(!(foundNeuroLexFlags && CellUtils.isUnbranchedNonOverlapping(grp)))
{
g.writeStartObject();
g.writeStringField("name", grp.getId());

if(!grp.getMember().isEmpty())
if(!grp.getMember().isEmpty())
{
g.writeArrayFieldStart("segments");
for(Member m : grp.getMember())
{
g.writeString(idsVsNames.get(m.getSegment()));
}
g.writeEndArray();
}
if(!grp.getInclude().isEmpty())
{
g.writeArrayFieldStart("groups");
for(org.neuroml.model.Include inc : grp.getInclude())
{
boolean isSection = CellUtils.isUnbranchedNonOverlapping(namesVsSegmentGroups.get(inc.getSegmentGroup()));
if(!isSection)
{
g.writeArrayFieldStart("segments");
for(Member m : grp.getMember())
{
g.writeString(idsVsNames.get(m.getSegment()));
}
g.writeEndArray();
g.writeString(inc.getSegmentGroup());
}
if(!grp.getInclude().isEmpty())
}
g.writeEndArray();
g.writeArrayFieldStart("sections");
for(org.neuroml.model.Include inc : grp.getInclude())
{
boolean isSection = CellUtils.isUnbranchedNonOverlapping(namesVsSegmentGroups.get(inc.getSegmentGroup()));
if(isSection)
{
g.writeArrayFieldStart("groups");
for(org.neuroml.model.Include inc : grp.getInclude())
{
boolean isSection = CellUtils.isUnbranchedNonOverlapping(namesVsSegmentGroups.get(inc.getSegmentGroup()));
if(!isSection)
{
g.writeString(inc.getSegmentGroup());
}
}
g.writeEndArray();
g.writeArrayFieldStart("sections");
for(org.neuroml.model.Include inc : grp.getInclude())
{
boolean isSection = CellUtils.isUnbranchedNonOverlapping(namesVsSegmentGroups.get(inc.getSegmentGroup()));
if(isSection)
{
g.writeString(inc.getSegmentGroup());
}
}
g.writeEndArray();
g.writeString(inc.getSegmentGroup());
}
}
g.writeEndArray();
}
// System.out.println("+++ " +grp.getInhomogeneousParameter());
// System.out.println("-- " +ChannelDensity.class.getSimpleName());
if(!grp.getInhomogeneousParameter().isEmpty())
{
g.writeArrayFieldStart("inhomogeneousParameters");
for(InhomogeneousParameter ih : grp.getInhomogeneousParameter())
{
g.writeStartObject();
g.writeStringField("id", ih.getId());
g.writeStringField("variable", ih.getVariable());
inhomogeneousParametersVsVariables.put(ih.getId(), ih.getVariable());
g.writeStringField("metric", ih.getMetric().value());
if(ih.getProximal() != null)
{
g.writeStringField("proximalTranslationStart", ih.getProximal().getTranslationStart() + "");
}
// System.out.println("+++ " +grp.getInhomogeneousParameter());
// System.out.println("-- " +ChannelDensity.class.getSimpleName());
if(!grp.getInhomogeneousParameter().isEmpty())
if(ih.getDistal() != null)
{
g.writeArrayFieldStart("inhomogeneousParameters");
for(InhomogeneousParameter ih : grp.getInhomogeneousParameter())
{
g.writeStartObject();
g.writeStringField("id", ih.getId());
g.writeStringField("variable", ih.getVariable());
inhomogeneousParametersVsVariables.put(ih.getId(), ih.getVariable());
g.writeStringField("metric", ih.getMetric().value());
if(ih.getProximal() != null)
{
g.writeStringField("proximalTranslationStart", ih.getProximal().getTranslationStart() + "");
}
if(ih.getDistal() != null)
{
g.writeStringField("distalNormalizationEnd", ih.getDistal().getNormalizationEnd() + "");
}
g.writeEndObject();
}
g.writeEndArray();
g.writeStringField("distalNormalizationEnd", ih.getDistal().getNormalizationEnd() + "");
}

g.writeEndObject();
g.writeEndObject();
}
g.writeEndArray();
}

g.writeEndObject();
}
}
if(!foundAll)
{
g.writeStartObject();
g.writeStringField("name", "all");
g.writeArrayFieldStart("sections");
for(Segment seg : morph.getSegment())
{
String name = nh.getNrnSectionName(seg);
g.writeString(name);
}
g.writeEndArray();
g.writeEndObject();

/* Create the nrn_all section list that contains all sections */
g.writeStartObject();
g.writeStringField("name", "nrn_all");
g.writeArrayFieldStart("sections");
for(Segment seg : morph.getSegment())
{
String name = nh.getNrnSectionName(seg);
g.writeString(name);
}
g.writeEndArray();
g.writeEndObject();

/* groups */
g.writeEndArray();

IntracellularProperties ip = null;
MembraneProperties mp = null;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/neuroml/export/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class Utils

private static Lems lemsWithNML2CompTypes;

public static String ORG_NEUROML_EXPORT_VERSION = "1.9.0";
public static String ORG_NEUROML_EXPORT_VERSION = "1.9.1";

public static final String ARCH_I686 = "i686";
public static final String ARCH_I386 = "i386";
Expand Down

0 comments on commit b5bf3d6

Please sign in to comment.