Skip to content

Commit

Permalink
Some leftover issues (#151)
Browse files Browse the repository at this point in the history
* fix default vectors

* fix reader for orientations

* more fixed
  • Loading branch information
brisvag authored Sep 11, 2023
1 parent b73be4c commit fa3c860
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/blik/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def _construct_positions_layer(coords, features, scale, exp_id, p_id, source):
if len(features)
else pd.DataFrame()
)
feat_defaults["orientation"] = Rotation.identity()
feat_defaults["orientation"] = np.array(Rotation.identity(), dtype=object)
return (
coords,
{
Expand Down Expand Up @@ -82,7 +82,7 @@ def construct_particle_layer_tuples(

if "orientation" not in features.columns:
features["orientation"] = np.array(
[] if coords is None else Rotation.identity(len(coords))
[] if coords is None else Rotation.identity(len(coords)), dtype=object
)

# divide by scale top keep constant size. TODO: remove after vispy 0.12 which fixes this
Expand Down Expand Up @@ -114,7 +114,7 @@ def read_particles(particles):
shift_cols = ["shift_z", "shift_y", "shift_x"]
features[shift_cols] = shifts
if particles.orientation is not None:
features["orientation"] = np.asarray(particles.orientation)
features["orientation"] = np.asarray(particles.orientation, dtype=object)

return construct_particle_layer_tuples(
coords, features, px_size, particles.experiment_id, particles.source
Expand Down
4 changes: 4 additions & 0 deletions src/blik/widgets/main_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ def _connect_points_to_vectors(p, v):
"""connect a particle points layer to a vectors layer to keep them in sync."""

def _update_vectors():
if np.any(pd.isnull(p.features["orientation"])):
obj = p.features["orientation"].astype(object)
obj[pd.isnull(obj)] = Rotation.identity()
p.features["orientation"] = obj
vec_data, vec_color = generate_vectors(p.data[...], p.features["orientation"])
v.data = vec_data
v.edge_color = vec_color
Expand Down

0 comments on commit fa3c860

Please sign in to comment.