Skip to content

Commit

Permalink
fix(morphplot): handle cases of docs containing only morphologies
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjayankur31 committed Aug 20, 2024
1 parent e16c31c commit 89f19ff
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
18 changes: 15 additions & 3 deletions pyneuroml/plot/PlotMorphology.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
24 changes: 18 additions & 6 deletions pyneuroml/plot/PlotMorphologyVispy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit 89f19ff

Please sign in to comment.