-
-
Notifications
You must be signed in to change notification settings - Fork 374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove skimage viewer in tutorials #55
base: main
Are you sure you want to change the base?
Conversation
Hello @sciunto! Thanks for opening this PR. We checked the lines you've touched for PEP 8 issues, and found:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent, thank you @sciunto
#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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#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.