Skip to content

Commit

Permalink
fix orientation getting messed up, move to arrow rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
brisvag committed Nov 9, 2023
1 parent cdaeda6 commit 0d6078f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/blik/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ def _construct_orientations_layer(coords, features, scale, exp_id, p_id, source)
{
"name": f"{exp_id} - particle orientations",
"edge_color": vec_color,
"length": 150 / np.array(scale),
"length": 100 / np.array(scale),
"edge_width": 10 / np.array(scale),
"scale": [scale] * 3,
"metadata": {"experiment_id": exp_id, "p_id": p_id, "source": source},
"vector_style": "arrow",
# "projection_mode": "all", # only available in napari 0.5.0
"out_of_slice_display": True,
},
Expand Down Expand Up @@ -102,8 +104,9 @@ def construct_particle_layer_tuples(
)
ori = _construct_orientations_layer(coords, features, scale, exp_id, p_id, source)

# invert order for convenience (latest added layer is selected)
return [ori, pos]
# ori should be last, or the auto-update feedback loop messes up the orientations
# when existing layers are updated from a new run
return [pos, ori]


def read_particles(particles):
Expand Down
6 changes: 2 additions & 4 deletions src/blik/widgets/picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,13 @@ def surface_particles(
pos = np.concatenate(pos)
features = pd.DataFrame({"orientation": np.asarray(Rotation.concatenate(ori))})

vec_layer_tuple, pos_layer_tuple = construct_particle_layer_tuples(
return construct_particle_layer_tuples(
coords=invert_xyz(pos),
features=features,
scale=surface.scale[0],
exp_id=exp_id,
face_color_cycle=colors,
)
return [vec_layer_tuple, pos_layer_tuple]


@magicgui(
Expand Down Expand Up @@ -280,13 +279,12 @@ def filament_particles(

features = pd.DataFrame({"orientation": np.asarray(Rotation.concatenate(ori))})

vec_layer_tuple, pos_layer_tuple = construct_particle_layer_tuples(
return construct_particle_layer_tuples(
coords=invert_xyz(pos),
features=features,
scale=filament.scale[0],
exp_id=exp_id,
)
return [vec_layer_tuple, pos_layer_tuple]


@magicgui(
Expand Down

0 comments on commit 0d6078f

Please sign in to comment.