Skip to content

Commit

Permalink
allow manual setting of filer dimensionality
Browse files Browse the repository at this point in the history
  • Loading branch information
brisvag committed Feb 23, 2024
1 parent 8d046c3 commit bc31f4b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/blik/widgets/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
3 changes: 2 additions & 1 deletion src/blik/widgets/power_spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit bc31f4b

Please sign in to comment.