Skip to content

Commit

Permalink
feat(vispy): allow marking segments as spheres
Browse files Browse the repository at this point in the history
Looks nicer than a large flat cylinder in most cases.
  • Loading branch information
sanjayankur31 committed Aug 13, 2024
1 parent 4aa207d commit ca56010
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pyneuroml/plot/PlotMorphologyVispy.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,8 @@ def plot_interactive_3D(
- marker_color: color of the marker
- marker_size: [diameter 1, diameter 2] (in case of sphere, the first value
is used)
- marker_type: "sphere" (otherwise the default shape of the segment is
used, which could either be a sphere or a cylinder)
E.g.:
Expand All @@ -419,7 +421,8 @@ def plot_interactive_3D(
"cell_color": "red",
"seg id1": {
"marker_color": "blue",
"marker_size": [0.1, 0.1]
"marker_size": [0.1, 0.1],
"marker_type": "sphere"
}
}
}
Expand Down Expand Up @@ -939,6 +942,8 @@ def plot_3D_cell_morphology(
- marker_color: color of the marker
- marker_size: [diameter 1, diameter 2] (in case of sphere, the first value
is used)
- marker_type: "sphere" (otherwise the default shape of the segment is
used, which could either be a sphere or a cylinder)
:type highlight_spec: dict
:param upright: bool only applicable for single cells: Makes cells "upright"
Expand Down Expand Up @@ -1029,6 +1034,7 @@ def plot_3D_cell_morphology(
segment_spec = {
"marker_size": None,
"marker_color": None,
"marker_type": None,
}
try:
segment_spec.update(highlight_spec[str(seg.id)])
Expand All @@ -1050,6 +1056,14 @@ def plot_3D_cell_morphology(
r1 = round(float(segment_spec["marker_size"][0]) / 2, mesh_precision)
r2 = round(float(segment_spec["marker_size"][1]) / 2, mesh_precision)

if (
segment_spec["marker_type"] is not None
and segment_spec["marker_type"].lower() == "sphere"
):
logger.debug("Changing marker type to sphere")
r1 = r2 = round(float(segment_spec["marker_size"][0]) / 2, mesh_precision)
length = 0.0

key = (
f"{r1:.{abs(mesh_precision)}f}",
f"{r2:.{abs(mesh_precision)}f}",
Expand Down

0 comments on commit ca56010

Please sign in to comment.