Skip to content

Commit

Permalink
ensure thickness is only added if needeed
Browse files Browse the repository at this point in the history
  • Loading branch information
brisvag committed Nov 30, 2023
1 parent ba48197 commit 7c69ed3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ dependencies = [
"einops",
"morphosamplers>=0.0.10",
"pydantic<2", # migration will take a while for napari
"packaging",
]

# extras
Expand Down
10 changes: 7 additions & 3 deletions src/blik/reader.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import warnings
from importlib.metadata import version
from pathlib import Path
from uuid import uuid1

Expand All @@ -7,10 +8,13 @@
import pandas as pd
from cryotypes.image import ImageProtocol
from cryotypes.poseset import PoseSetProtocol
from packaging.version import parse as parse_version
from scipy.spatial.transform import Rotation

from .utils import generate_vectors, invert_xyz

NAPARI_050 = parse_version(version("napari")) >= parse_version("0.5.0a")


def get_reader(path):
return read_layers
Expand Down Expand Up @@ -38,9 +42,9 @@ def _construct_positions_layer(
"shading": "spherical",
"antialiasing": 0,
"metadata": {"experiment_id": exp_id, "p_id": p_id, "source": source},
"projection_mode": "all",
"out_of_slice_display": True,
**pt_kwargs,
**({"projection_mode": "all"} if NAPARI_050 else {}),
},
"points",
)
Expand All @@ -65,8 +69,8 @@ def _construct_orientations_layer(coords, features, scale, exp_id, p_id, source)
"scale": [scale] * 3,
"metadata": {"experiment_id": exp_id, "p_id": p_id, "source": source},
"vector_style": "arrow",
"projection_mode": "all",
"out_of_slice_display": True,
**({"projection_mode": "all"} if NAPARI_050 else {}),
},
"vectors",
)
Expand Down Expand Up @@ -154,7 +158,7 @@ def read_image(image):
"depiction": "plane",
"blending": "translucent",
"plane": {"thickness": 5},
"projection_mode": "mean",
**({"projection_mode": "mean"} if NAPARI_050 else {}),
},
"image",
)
Expand Down
5 changes: 4 additions & 1 deletion src/blik/widgets/main_widget.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

from importlib.metadata import version
from typing import List

import napari
Expand All @@ -10,6 +11,7 @@
from napari.layers import Image, Labels, Points, Shapes, Vectors
from napari.utils._magicgui import find_viewer_ancestor
from napari.utils.notifications import show_info
from packaging.version import parse as parse_version
from scipy.spatial.transform import Rotation

from ..reader import construct_particle_layer_tuples
Expand Down Expand Up @@ -242,7 +244,8 @@ def __init__(self, *args, **kwargs):
self.append(exp)
self.append(new)
self.append(add_to_exp)
self.append(slice_thickness_A)
if parse_version(version("napari")) >= parse_version("0.5.0a"):
self.append(slice_thickness_A)

def append(self, item):
super().append(item)
Expand Down

0 comments on commit 7c69ed3

Please sign in to comment.