From 61611e3b1e76abbcbcdebface38e28a9dfcc450f Mon Sep 17 00:00:00 2001 From: Lorenzo Gaifas Date: Fri, 12 Jul 2024 17:14:45 +0200 Subject: [PATCH] Temp fix for napari bug, add test to catch it (#177) * add test that fails :( * disable axis labels for now due to napari bug --- src/blik/reader.py | 10 +++++----- src/blik/widgets/main_widget.py | 8 ++++---- tests/test_reader.py | 6 ++++++ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/blik/reader.py b/src/blik/reader.py index db33501..ca45bed 100644 --- a/src/blik/reader.py +++ b/src/blik/reader.py @@ -42,7 +42,7 @@ def _construct_positions_layer( "metadata": {"experiment_id": exp_id, "p_id": p_id, "source": source}, "out_of_slice_display": True, "projection_mode": "all", - "axis_labels": ('z', 'y', 'x'), + # "axis_labels": ('z', 'y', 'x'), "units": 'angstrom', **pt_kwargs, }, @@ -71,7 +71,7 @@ def _construct_orientations_layer( "vector_style": "arrow", "out_of_slice_display": True, "projection_mode": "all", - "axis_labels": ('z', 'y', 'x'), + # "axis_labels": ('z', 'y', 'x'), "units": 'angstrom', }, "vectors", @@ -179,7 +179,7 @@ def read_image(image): "blending": "translucent", "plane": {"thickness": 5}, "projection_mode": "mean", - "axis_labels": ('z', 'y', 'x'), + # "axis_labels": ('z', 'y', 'x'), "units": 'angstrom', }, "image", @@ -212,7 +212,7 @@ def read_surface_picks(path): "edge_color": "surface_id", "shape_type": "path", "ndim": 3, - "axis_labels": ('z', 'y', 'x'), + # "axis_labels": ('z', 'y', 'x'), "units": 'angstrom', }, "shapes", @@ -236,7 +236,7 @@ def read_surface(path): "scale": scale, # TODO: needs to exposed in napari # colormap=colormap - "axis_labels": ('z', 'y', 'x'), + # "axis_labels": ('z', 'y', 'x'), "units": 'angstrom', }, "surface", diff --git a/src/blik/widgets/main_widget.py b/src/blik/widgets/main_widget.py index b33ea66..c920584 100644 --- a/src/blik/widgets/main_widget.py +++ b/src/blik/widgets/main_widget.py @@ -79,7 +79,7 @@ def _attach_callbacks_to_viewer(wdg): # pixels are 1 A. We put 0.1nm cause it's more readable with multiples viewer.scale_bar.unit = "0.1nm" viewer.scale_bar.visible = True - viewer.dims.axis_labels = ['z', 'y', 'x'] + # viewer.dims.axis_labels = ['z', 'y', 'x'] def _connect_layers(viewer, e): @@ -175,7 +175,7 @@ def new( np.zeros(lay.data.shape, dtype=np.int32), name=f"{exp_id} - segmentation", scale=lay.scale, - axis_labels=('z', 'y', 'x'), + # axis_labels=('z', 'y', 'x'), units='angstrom', metadata={ "experiment_id": exp_id, @@ -207,7 +207,7 @@ def new( edge_color_cycle=np.random.rand(30, 3), edge_color="surface_id", ndim=3, - axis_labels=('z', 'y', 'x'), + # axis_labels=('z', 'y', 'x'), units='angstrom', ) @@ -222,7 +222,7 @@ def new( metadata={"experiment_id": exp_id}, face_color_cycle=np.random.rand(30, 3), ndim=3, - axis_labels=('z', 'y', 'x'), + # axis_labels=('z', 'y', 'x'), units='angstrom', ) diff --git a/tests/test_reader.py b/tests/test_reader.py index 5c78fbf..310c52d 100644 --- a/tests/test_reader.py +++ b/tests/test_reader.py @@ -28,3 +28,9 @@ def test_construct_empty_layers(): assert pts[2] == "points" vec = layer_data_list[1] assert vec[2] == "vectors" + + +def test_napari_read(star_file, mrc_file, make_napari_viewer): + v = make_napari_viewer() + v.open(star_file, plugin='blik') + v.open(mrc_file, plugin='blik')