diff --git a/caseExamples/NeuroML2/Case1_new_morphOnly.cell.nml b/caseExamples/NeuroML2/Case1_new_morphOnly.cell.nml new file mode 100644 index 0000000..a17d7be --- /dev/null +++ b/caseExamples/NeuroML2/Case1_new_morphOnly.cell.nml @@ -0,0 +1,98 @@ + + + + Neuronal morphology exported in NeuroML v2.3.1 from CVapp (NeuroMorpho.org version) + Original file: Case1_new.swc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/caseExamples/NeuroML2/Case1_orig_morphOnly.cell.nml b/caseExamples/NeuroML2/Case1_orig_morphOnly.cell.nml new file mode 100644 index 0000000..1a90fc5 --- /dev/null +++ b/caseExamples/NeuroML2/Case1_orig_morphOnly.cell.nml @@ -0,0 +1,90 @@ + + + + Neuronal morphology exported in NeuroML v2.3.1 from CVapp (NeuroMorpho.org version) + Original file: Case1_orig.swc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/caseExamples/NeuroML2/Case2_new_morphOnly.cell.nml b/caseExamples/NeuroML2/Case2_new_morphOnly.cell.nml new file mode 100644 index 0000000..bad8e7c --- /dev/null +++ b/caseExamples/NeuroML2/Case2_new_morphOnly.cell.nml @@ -0,0 +1,87 @@ + + + + Neuronal morphology exported in NeuroML v2.3.1 from CVapp (NeuroMorpho.org version) + Original file: Case2_new.swc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/caseExamples/NeuroML2/Case2_orig_morphOnly.cell.nml b/caseExamples/NeuroML2/Case2_orig_morphOnly.cell.nml new file mode 100644 index 0000000..297d6be --- /dev/null +++ b/caseExamples/NeuroML2/Case2_orig_morphOnly.cell.nml @@ -0,0 +1,87 @@ + + + + Neuronal morphology exported in NeuroML v2.3.1 from CVapp (NeuroMorpho.org version) + Original file: Case2_orig.swc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/caseExamples/NeuroML2/Case3_new_morphOnly.cell.nml b/caseExamples/NeuroML2/Case3_new_morphOnly.cell.nml new file mode 100644 index 0000000..aff644d --- /dev/null +++ b/caseExamples/NeuroML2/Case3_new_morphOnly.cell.nml @@ -0,0 +1,76 @@ + + + + Neuronal morphology exported in NeuroML v2.3.1 from CVapp (NeuroMorpho.org version) + Original file: Case3_new.swc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/caseExamples/NeuroML2/Case3_orig_morphOnly.cell.nml b/caseExamples/NeuroML2/Case3_orig_morphOnly.cell.nml new file mode 100644 index 0000000..1af37e2 --- /dev/null +++ b/caseExamples/NeuroML2/Case3_orig_morphOnly.cell.nml @@ -0,0 +1,148 @@ + + + + Neuronal morphology exported in NeuroML v2.3.1 from CVapp (NeuroMorpho.org version) + Original file: Case3_orig.swc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/caseExamples/NeuroML2/Case4_new_morphOnly.cell.nml b/caseExamples/NeuroML2/Case4_new_morphOnly.cell.nml new file mode 100644 index 0000000..49211af --- /dev/null +++ b/caseExamples/NeuroML2/Case4_new_morphOnly.cell.nml @@ -0,0 +1,108 @@ + + + + Neuronal morphology exported in NeuroML v2.3.1 from CVapp (NeuroMorpho.org version) + Original file: Case4_new.swc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/caseExamples/NeuroML2/Case4_orig_morphOnly.cell.nml b/caseExamples/NeuroML2/Case4_orig_morphOnly.cell.nml new file mode 100644 index 0000000..5cc1172 --- /dev/null +++ b/caseExamples/NeuroML2/Case4_orig_morphOnly.cell.nml @@ -0,0 +1,108 @@ + + + + Neuronal morphology exported in NeuroML v2.3.1 from CVapp (NeuroMorpho.org version) + Original file: Case4_orig.swc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/caseExamples/NeuroML2/Case5_new_morphOnly.cell.nml b/caseExamples/NeuroML2/Case5_new_morphOnly.cell.nml new file mode 100644 index 0000000..a622111 --- /dev/null +++ b/caseExamples/NeuroML2/Case5_new_morphOnly.cell.nml @@ -0,0 +1,102 @@ + + + + Neuronal morphology exported in NeuroML v2.3.1 from CVapp (NeuroMorpho.org version) + Original file: Case5_new.swc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/caseExamples/NeuroML2/Case5_orig_morphOnly.cell.nml b/caseExamples/NeuroML2/Case5_orig_morphOnly.cell.nml new file mode 100644 index 0000000..5c0ccd8 --- /dev/null +++ b/caseExamples/NeuroML2/Case5_orig_morphOnly.cell.nml @@ -0,0 +1,99 @@ + + + + Neuronal morphology exported in NeuroML v2.3.1 from CVapp (NeuroMorpho.org version) + Original file: Case5_orig.swc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/cvapp/main.java b/src/cvapp/main.java index 9d53d88..f05e98d 100644 --- a/src/cvapp/main.java +++ b/src/cvapp/main.java @@ -324,13 +324,18 @@ private static void doTests(neuronEditorFrame nef, String fileName, String nmlEx if (Character.isDigit(nml2FileName.charAt(0))) { nml2FileName = "Cell_"+nml2FileName; } - File nml2File = new File(nmlExportDir, nml2FileName); - nep.writeStringToFile(nep.getCell().writeNeuroML_v2(), nml2File.getAbsolutePath()); + File nml2File = new File(nmlExportDir, nml2FileName); + nep.writeStringToFile(nep.getCell().writeNeuroML_v2(), nml2File.getAbsolutePath()); System.out.println("Saved NeuroML representation of the file to: "+nml2File.getAbsolutePath()+": "+nml2File.exists()); - validateXMLWithURL(nml2File, LATEST_NEUROML_V2_SCHEMA); + + nml2FileName = nml2FileName.replace(".cell","_morphOnly.cell"); + File nml2FileMorph = new File(nmlExportDir, nml2FileName); + nep.writeStringToFile(nep.getCell().writeNeuroML_v2_morphologyOnly(), nml2FileMorph.getAbsolutePath()); + System.out.println("Saved NeuroML representation of the file to: "+nml2FileMorph.getAbsolutePath()+": "+nml2FileMorph.exists()); + validateXMLWithURL(nml2FileMorph, LATEST_NEUROML_V2_SCHEMA); } diff --git a/src/cvapp/neulucData.java b/src/cvapp/neulucData.java index c366a52..89f630c 100644 --- a/src/cvapp/neulucData.java +++ b/src/cvapp/neulucData.java @@ -661,7 +661,7 @@ public String writeNeuroML_v1_8_1() { // above also sets maxType to the maximal nlcode; neuromlWriter nw = new neuromlWriter(points, sectionTypes, sourceFileName); - return nw.nmlString(neuromlWriter.NeuroMLVersion.NEUROML_VERSION_1_8_1); + return nw.nmlString(neuromlWriter.NeuroMLVersion.NEUROML_VERSION_1_8_1, false); } public String writeNeuroML_v2() { @@ -670,7 +670,15 @@ public String writeNeuroML_v2() { // above also sets maxType to the maximal nlcode; neuromlWriter nw = new neuromlWriter(points, sectionTypes, sourceFileName); - return nw.nmlString(neuromlWriter.NeuroMLVersion.NEUROML_VERSION_2_3_1); + return nw.nmlString(neuromlWriter.NeuroMLVersion.NEUROML_VERSION_2_3_1, false); + } + public String writeNeuroML_v2_morphologyOnly() { + unwrite(); + // rootpoint = maxRadiusPoint(); + // above also sets maxType to the maximal nlcode; + + neuromlWriter nw = new neuromlWriter(points, sectionTypes, sourceFileName); + return nw.nmlString(neuromlWriter.NeuroMLVersion.NEUROML_VERSION_2_3_1, true); } public String GENESISwriteHR() { diff --git a/src/cvapp/neuromlWriter.java b/src/cvapp/neuromlWriter.java index ef93247..a512e08 100644 --- a/src/cvapp/neuromlWriter.java +++ b/src/cvapp/neuromlWriter.java @@ -123,9 +123,13 @@ public boolean isVersion1() form.setGroupingUsed(false); } - public String nmlString(NeuroMLVersion version) { + public String nmlString(NeuroMLVersion version, boolean morphologyOnly) { if (points.size() < 2 || sectionTypes.length < 2 || !sectionTypes[1].equals("soma")) { - System.out.println("error: null data or section types in hocWrite"); + System.out.println("Error: null data or section types in hocWrite"); + return ""; + } + if (version.isVersion1() && morphologyOnly) { + System.out.println("Error: morphologyOnly option only supported by version 2"); return ""; } @@ -209,10 +213,13 @@ public String nmlString(NeuroMLVersion version) { INDENT+"length_units=\"micrometer\">\n\n"); } else if (version.isVersion2()) { + String nmlId = cellName; + if (morphologyOnly) + nmlId += "_morphology"; sbf.append("\n\n"); + INDENT+"id=\""+nmlId+"\">\n\n"); } String metaPrefix=""; @@ -222,7 +229,7 @@ public String nmlString(NeuroMLVersion version) { sbf.append(INDENT+INDENT+"\n"); metaPrefix = "meta:"; - } else if (version.isVersion2()){ + } else if (version.isVersion2() && !morphologyOnly){ sbf.append(INDENT+"\n"); } @@ -277,9 +284,12 @@ public String nmlString(NeuroMLVersion version) { { sbf.append(INDENT+INDENT+INDENT+"\n\n"); - sbf.append(INDENT+"\n\n"); + if (!morphologyOnly) + { + sbf.append(INDENT+"\n\n"); - sbf.append(INDENT+"\n"); + sbf.append(INDENT+"\n"); + } } sbf.append("\n"); diff --git a/src/cvapp/neuronEditorPanel.java b/src/cvapp/neuronEditorPanel.java index 9b450de..dde8331 100644 --- a/src/cvapp/neuronEditorPanel.java +++ b/src/cvapp/neuronEditorPanel.java @@ -76,7 +76,8 @@ class neuronEditorPanel extends JPanel implements ActionListener, ItemListener { protected final static String SAVE_GENESIS = "GENESIS"; protected final static String SAVE_NEUROML_v1 = "NeuroML v1.8.1"; protected final static String SAVE_NEUROML_v2alpha = "NeuroML v2alpha"; - protected final static String SAVE_NEUROML_v2 = "NeuroML v2"; + protected final static String SAVE_NEUROML_v2_cell = "NeuroML v2 "; + protected final static String SAVE_NEUROML_v2_morphOnly = "NeuroML v2 "; protected final static String CENTER = "Center"; @@ -577,14 +578,24 @@ public void processNameEvent(String sarg) { } else { System.out.println("file writing not allowed "); } - } else if (sarg.startsWith(neuronEditorPanel.SAVE_NEUROML_v2)) { + } else if (sarg.startsWith(neuronEditorPanel.SAVE_NEUROML_v2_cell)) { if (canWriteFiles) { File f = fileString.getFileToSave(this, fdir, "Select NeuroML file"); if (f != null) { blockingMessageOn("formatting as NeuroML"); writeStringToFile(cell.writeNeuroML_v2(), f.getAbsolutePath()); } + } else { + System.out.println("file writing not allowed "); + } + } else if (sarg.startsWith(neuronEditorPanel.SAVE_NEUROML_v2_morphOnly)) { + if (canWriteFiles) { + File f = fileString.getFileToSave(this, fdir, "Select NeuroML file"); + if (f != null) { + blockingMessageOn("formatting as NeuroML"); + writeStringToFile(cell.writeNeuroML_v2_morphologyOnly(), f.getAbsolutePath()); + } } else { System.out.println("file writing not allowed "); } @@ -702,7 +713,8 @@ class ModifiedOptionBar extends JPanel implements ItemListener, ActionListener { options.addItem(neuronEditorPanel.SAVE_NEURON); options.addItem(neuronEditorPanel.SAVE_GENESIS); options.addItem(neuronEditorPanel.SAVE_NEUROML_v1); - options.addItem(neuronEditorPanel.SAVE_NEUROML_v2); + options.addItem(neuronEditorPanel.SAVE_NEUROML_v2_cell); + options.addItem(neuronEditorPanel.SAVE_NEUROML_v2_morphOnly); add(saveLabel); add(options); @@ -761,8 +773,10 @@ public void actionPerformed(ActionEvent e) { neupan.processNameEvent("save as Genesis - hierarchical"); } else if (sarg.equals(neuronEditorPanel.SAVE_NEUROML_v1)) { neupan.processNameEvent(neuronEditorPanel.SAVE_NEUROML_v1); - } else if (sarg.equals(neuronEditorPanel.SAVE_NEUROML_v2)) { - neupan.processNameEvent(neuronEditorPanel.SAVE_NEUROML_v2); + } else if (sarg.equals(neuronEditorPanel.SAVE_NEUROML_v2_cell)) { + neupan.processNameEvent(neuronEditorPanel.SAVE_NEUROML_v2_cell); + } else if (sarg.equals(neuronEditorPanel.SAVE_NEUROML_v2_morphOnly)) { + neupan.processNameEvent(neuronEditorPanel.SAVE_NEUROML_v2_morphOnly); } else if (sarg.equals("Center")) { neupan.neucan.find(); } else {