Skip to content

fix(morph-plot): handle files with single point cell types #441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyneuroml/plot/PlotMorphology.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def plot_2D(
radius = pop_id_vs_radii[pop_id] if pop_id in pop_id_vs_radii else 10
color = pop_id_vs_color[pop_id] if pop_id in pop_id_vs_color else None

if cell is None:
if cell is None or not isinstance(cell, Cell):
plot_2D_point_cells(
offset=pos,
plane2d=plane2d,
Expand Down
8 changes: 6 additions & 2 deletions pyneuroml/plot/PlotMorphologyVispy.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,9 @@ def plot_interactive_3D(
# other networks
else:
plottable_nml_model = nml_model

logger.debug(plottable_nml_model.info(show_contents=True))

# what did we get?
else:
raise ValueError(f"Could not process argument: {nml_model}")
Expand Down Expand Up @@ -671,7 +674,7 @@ def plot_interactive_3D(
else:
cell = list(pop_id_vs_cell.values())[0]

if cell is not None:
if cell is not None and isinstance(cell, Cell):
view_min, view_max = get_cell_bound_box(cell)
else:
logger.debug("Got a point cell")
Expand Down Expand Up @@ -790,7 +793,8 @@ def plot_interactive_3D(
except AttributeError:
logging.debug(f"Plotting a point cell at {pos}")

if cell is None:
# a point cell component type
if cell is None or not isinstance(cell, Cell):
meshdata.append(
(
f"{radius:.1f}",
Expand Down
12 changes: 9 additions & 3 deletions pyneuroml/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,15 @@ def extract_position_info(
cell_elements = []
popElements = []

cell_elements.extend(nml_model.cells)
cell_elements.extend(nml_model.cell2_ca_poolses)
members = nml_model.info(show_contents=True, return_format="dict")

for member, mdict in members.items():
if "cell" in mdict["type"].lower():
try:
cell_elements.extend(mdict["members"])
except TypeError:
pass
# cell_elements.extend(nml_model.cell2_ca_poolses)

# if there are no cells, look at morphologies
if len(cell_elements) == 0:
Expand Down Expand Up @@ -715,7 +722,6 @@ def get_model_file_list(
lems_def_dir = get_model_file_list(inc, filelist, rootdir, lems_def_dir)

elif rootfile.endswith(".sedml"):

try:
import libsedml
except ModuleNotFoundError:
Expand Down
3 changes: 1 addition & 2 deletions pyneuroml/utils/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,15 +351,14 @@ def load_minimal_morphplottable__model(
model_members = list(vars(nml_model).keys())
required_members = [
"id",
"cells",
"morphology",
"cell2_ca_poolses",
"networks",
"populations",
"includes",
]
for m in model_members:
if m not in required_members:
if m not in required_members and "cells" not in m:
setattr(nml_model, m, None)
logger.debug(f"Dropped {m}")

Expand Down
Loading