diff --git a/pyneuroml/plot/PlotMorphology.py b/pyneuroml/plot/PlotMorphology.py index d28faae4..51cdab30 100644 --- a/pyneuroml/plot/PlotMorphology.py +++ b/pyneuroml/plot/PlotMorphology.py @@ -355,10 +355,22 @@ def plot_2D( logger.debug(f"plottable cell model is: {plottable_nml_model.cells[0]}") if title is None: title = f"{plottable_nml_model.cells[0].id}" + # if it's a document, figure out if it's a cell or morphology elif isinstance(nml_model, NeuroMLDocument): - plottable_nml_model = fix_external_morphs_biophys_in_cell( - nml_model, overwrite=False - ) + logger.debug("Received document, checking for cells/morphologies") + if len(nml_model.cells) > 0: + logger.debug("Received document with cells") + plottable_nml_model = fix_external_morphs_biophys_in_cell( + nml_model, overwrite=False + ) + elif len(nml_model.morphology) > 0: + logger.debug("Received document with morphologies, adding to dummy cells") + plottable_nml_model = NeuroMLDocument(id="newdoc") + for m in nml_model.morphology: + plottable_nml_model.add(Cell, id=m.id, morphology=m, validate=False) + logger.debug(f"plottable cell model is: {plottable_nml_model.cells[0]}") + # use title from original model document + title = nml_model.id if title is None: title = f"{plottable_nml_model.id}" diff --git a/pyneuroml/plot/PlotMorphologyVispy.py b/pyneuroml/plot/PlotMorphologyVispy.py index 090ca4a7..9bb92870 100644 --- a/pyneuroml/plot/PlotMorphologyVispy.py +++ b/pyneuroml/plot/PlotMorphologyVispy.py @@ -528,21 +528,33 @@ def plot_interactive_3D( if title is None: title = f"{plottable_nml_model.cells[0].id}" - # if it's only a cell, add it to an empty cell in a document + # if it's only a morphology, add it to an empty cell in a document elif isinstance(nml_model, Morphology): logger.debug("Received morph, adding to a dummy cell") plottable_nml_model = NeuroMLDocument(id="newdoc") - nml_cell = plottable_nml_model.add( + plottable_nml_model.add( Cell, id=nml_model.id, morphology=nml_model, validate=False ) - plottable_nml_model.add(nml_cell) logger.debug(f"plottable cell model is: {plottable_nml_model.cells[0]}") if title is None: title = f"{plottable_nml_model.cells[0].id}" + + # if it's a document, figure out if it's a cell or morphology elif isinstance(nml_model, NeuroMLDocument): - plottable_nml_model = fix_external_morphs_biophys_in_cell( - nml_model, overwrite=False - ) + logger.debug("Received document, checking for cells/morphologies") + if len(nml_model.cells) > 0: + logger.debug("Received document with cells") + plottable_nml_model = fix_external_morphs_biophys_in_cell( + nml_model, overwrite=False + ) + elif len(nml_model.morphology) > 0: + logger.debug("Received document with morphologies, adding to dummy cells") + plottable_nml_model = NeuroMLDocument(id="newdoc") + for m in nml_model.morphology: + plottable_nml_model.add(Cell, id=m.id, morphology=m, validate=False) + logger.debug(f"plottable cell model is: {plottable_nml_model.cells[0]}") + # use title from original model document + title = nml_model.id if title is None: title = f"{plottable_nml_model.id}"