Skip to content

Commit 93253ce

Browse files
committed
fix(morph-plot): handle files with single point cell types
If a file contains the definition of a point cell type, for example, `IafTauRefCell`, we should still be able to plot the file, even if its only a single circle/sphere. Until now, we only handled files if they had multi-compartmental `Cell` or `Morphology` instances, and the plotter would crash for files that had other point cell types.
1 parent 0f2793c commit 93253ce

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

pyneuroml/plot/PlotMorphology.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ def plot_2D(
483483
radius = pop_id_vs_radii[pop_id] if pop_id in pop_id_vs_radii else 10
484484
color = pop_id_vs_color[pop_id] if pop_id in pop_id_vs_color else None
485485

486-
if cell is None:
486+
if cell is None or not isinstance(cell, Cell):
487487
plot_2D_point_cells(
488488
offset=pos,
489489
plane2d=plane2d,

pyneuroml/plot/PlotMorphologyVispy.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,9 @@ def plot_interactive_3D(
607607
# other networks
608608
else:
609609
plottable_nml_model = nml_model
610+
611+
logger.debug(plottable_nml_model.info(show_contents=True))
612+
610613
# what did we get?
611614
else:
612615
raise ValueError(f"Could not process argument: {nml_model}")
@@ -671,7 +674,7 @@ def plot_interactive_3D(
671674
else:
672675
cell = list(pop_id_vs_cell.values())[0]
673676

674-
if cell is not None:
677+
if cell is not None and isinstance(cell, Cell):
675678
view_min, view_max = get_cell_bound_box(cell)
676679
else:
677680
logger.debug("Got a point cell")
@@ -790,7 +793,8 @@ def plot_interactive_3D(
790793
except AttributeError:
791794
logging.debug(f"Plotting a point cell at {pos}")
792795

793-
if cell is None:
796+
# a point cell component type
797+
if cell is None or not isinstance(cell, Cell):
794798
meshdata.append(
795799
(
796800
f"{radius:.1f}",

pyneuroml/utils/__init__.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,12 @@ def extract_position_info(
9797
cell_elements = []
9898
popElements = []
9999

100-
cell_elements.extend(nml_model.cells)
101-
cell_elements.extend(nml_model.cell2_ca_poolses)
100+
members = nml_model.info(show_contents=True, return_format="dict")
101+
102+
for member, mdict in members.items():
103+
if "cell" in mdict["type"].lower():
104+
cell_elements.extend(mdict["members"])
105+
# cell_elements.extend(nml_model.cell2_ca_poolses)
102106

103107
# if there are no cells, look at morphologies
104108
if len(cell_elements) == 0:
@@ -715,7 +719,6 @@ def get_model_file_list(
715719
lems_def_dir = get_model_file_list(inc, filelist, rootdir, lems_def_dir)
716720

717721
elif rootfile.endswith(".sedml"):
718-
719722
try:
720723
import libsedml
721724
except ModuleNotFoundError:

pyneuroml/utils/plot.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -351,15 +351,14 @@ def load_minimal_morphplottable__model(
351351
model_members = list(vars(nml_model).keys())
352352
required_members = [
353353
"id",
354-
"cells",
355354
"morphology",
356355
"cell2_ca_poolses",
357356
"networks",
358357
"populations",
359358
"includes",
360359
]
361360
for m in model_members:
362-
if m not in required_members:
361+
if m not in required_members and "cells" not in m:
363362
setattr(nml_model, m, None)
364363
logger.debug(f"Dropped {m}")
365364

0 commit comments

Comments
 (0)