From bc31f4bc1b4a001bc553900c9bc3d0b921949b4b Mon Sep 17 00:00:00 2001 From: Lorenzo Gaifas Date: Fri, 23 Feb 2024 16:55:10 +0100 Subject: [PATCH] allow manual setting of filer dimensionality --- src/blik/widgets/filter.py | 7 +++++-- src/blik/widgets/power_spectrum.py | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/blik/widgets/filter.py b/src/blik/widgets/filter.py index af479f9..9e90f00 100644 --- a/src/blik/widgets/filter.py +++ b/src/blik/widgets/filter.py @@ -16,9 +16,12 @@ high={"widget_type": "FloatSlider", "min": 0, "max": 0.5}, ) def bandpass_filter( - image: "napari.layers.Image", low: float = 0.1, high: float = 0.4 + image: "napari.layers.Image", + low: float = 0.1, + high: float = 0.4, + is_2D_data: bool = False, ) -> "napari.types.LayerDataTuple": - channel_axis = 0 if image.metadata["stack"] else None + channel_axis = 0 if is_2D_data else None high_pass = butterworth( np.asarray(image.data), low, high_pass=True, channel_axis=channel_axis ) diff --git a/src/blik/widgets/power_spectrum.py b/src/blik/widgets/power_spectrum.py index 5698d1f..edf1baf 100644 --- a/src/blik/widgets/power_spectrum.py +++ b/src/blik/widgets/power_spectrum.py @@ -15,13 +15,14 @@ ) def power_spectrum( image: "napari.layers.Image", + is_2D_data: bool = False, ) -> "napari.types.LayerDataTuple": """ Power spectrum (log scale) of the image. First centers in real space on the origin to remove shift effects. """ - axes = (1, 2) if image.metadata["stack"] else None + axes = (-2, -1) if is_2D_data else None raw = da.compute(image.data)[0] power_spectrum = np.abs( fftshift(fftn(ifftshift(raw, axes=axes), axes=axes), axes=axes)