remove skimage viewer in tutorials#55
remove skimage viewer in tutorials#55sciunto wants to merge 1 commit intoscikit-image:mainfrom sciunto:cleanup
Conversation
|
Hello @sciunto! Thanks for opening this PR. We checked the lines you've touched for PEP 8 issues, and found:
|
| #from skimage.viewer import ImageViewer | ||
| #from skimage.viewer.widgets import Slider | ||
| #from skimage.viewer.plugins.base import Plugin |
There was a problem hiding this comment.
| #from skimage.viewer import ImageViewer | |
| #from skimage.viewer.widgets import Slider | |
| #from skimage.viewer.plugins.base import Plugin |
There was a problem hiding this comment.
I hesitated to remove being afraid that the logic would be difficult to understand afterwards. No strong feelings through.
| #viewer = ImageViewer(image) | ||
| # | ||
| #plugin = Plugin(image_filter=apply_inverse_filter) | ||
| #plugin += Slider('T', 0, 1, value=0.5, value_type='float', update_on='release') | ||
| #plugin += Slider('a', -0.1, 0.1, value=0, value_type='float', update_on='release') | ||
| #plugin += Slider('b', -0.1, 0.1, value=0, value_type='float', update_on='release') | ||
| #plugin += Slider('K', 0, 100, value=15, value_type='float', update_on='release') | ||
| #plugin += Slider('clip', 0, 1000, value=750, value_type='float', update_on='release') | ||
| #viewer += plugin | ||
| #viewer.show() |
There was a problem hiding this comment.
| #viewer = ImageViewer(image) | |
| # | |
| #plugin = Plugin(image_filter=apply_inverse_filter) | |
| #plugin += Slider('T', 0, 1, value=0.5, value_type='float', update_on='release') | |
| #plugin += Slider('a', -0.1, 0.1, value=0, value_type='float', update_on='release') | |
| #plugin += Slider('b', -0.1, 0.1, value=0, value_type='float', update_on='release') | |
| #plugin += Slider('K', 0, 100, value=15, value_type='float', update_on='release') | |
| #plugin += Slider('clip', 0, 1000, value=750, value_type='float', update_on='release') | |
| #viewer += plugin | |
| #viewer.show() |
|
Am I missing something? This change seems to remove the exploration examples without putting something in its place. Perhaps replace using Napari? Jupyter widgets? |
For It doesn't seem high priority to merge this PR until we are ready to remove the viewer module itself. Ideally we could replace with something based on Napari or Dash as you suggest, but that requires someone familiar with those packages spending the time to do it! @jni is Napari at a state where something like the interactive |
Yes, it would be ~trivial. Here's a relevant example in the magicgui docs. The only thing I don't think we have yet is triggering computation on release instead of on slide. @tlambert03 does it make sense to add such a feature request for magicgui? |
Yeah for sure |
|
added to magicgui in https://github.com/napari/magicgui/pull/248, here's an example that mostly follows the clock deblur example using napari & magicgui: edited to include descriptive text example import numpy as np
from skimage.data import clock
import napari
from magicgui import magicgui, widgets
image = clock()
M, N = image.shape
# Should pad, but doesn't make much difference in this case
MM, NN = 2 * M + 1, 2 * N + 1
# Apply Hann window to prevent ringing
wy = np.hanning(M)[:, None]
wx = np.hanning(N)
f = np.zeros((MM, NN))
f[:M, :N] = wy * wx * image
F = np.fft.fft2(f)
v, u = np.ogrid[:MM, :NN]
v -= (MM - 1) // 2
u -= (NN - 1) // 2
@magicgui(
auto_call=True,
T={"widget_type": "FloatSlider", "max": 1, "tracking": False},
a={"widget_type": "FloatSlider", "min": -0.1, "max": 0.1, "tracking": False},
b={"widget_type": "FloatSlider", "min": -0.1, "max": 0.1, "tracking": False},
K={"widget_type": "FloatSlider", "min": 0.1, "max": 100, "tracking": False},
clip={"widget_type": "FloatSlider", "max": 1000, "tracking": False},
)
def apply_inverse_filter(T=0.5, a=0, b=0, K=15, clip=750) -> "napari.types.ImageData":
uavb = u * a + v * b
H = T * np.sinc(uavb) * np.exp(-1j * np.pi * uavb)
H = np.fft.fftshift(H)
HH = 1.0 / H
HH[np.abs(HH) > K] = K
gg = np.abs(np.fft.ifft2(F * HH))
gg = gg[:M, :N]
gg = np.clip(gg, 0, clip)
gg -= gg.min()
gg /= gg.max()
return gg
viewer = napari.view_image(image)
info = """
<h2>Inverse Filter</h2>
Welcome to the inverse filter tutorial!<br>
Here's a description of some of the<br>
parameters...
<dl>
<dt>T</dt>
<dd>....</dd>
<dt>a</dt>
<dd>....</dd>
</dl>
"""
apply_inverse_filter.insert(0, widgets.Label(value=info))
viewer.window.add_dock_widget(apply_inverse_filter, name='Inverse Filter')
napari.run()(side-notes: setting tracking |
|
Very nice, @tlambert03! It would be good to have a way to point the user's attention to the added widget (otherwise it blends in well with the rest of Napari). And also to add a title to the widget set. But this is a great proof of concept showing that we can go ahead and port our examples over. |
|
@tlambert03 That is perfect; thank you! |

I propose to remove scripts using the skimage viewer.