fastplotlib / fastplotlib

Next-gen fast plotting library running on WGPU using the pygfx rendering engine
https://fastplotlib.readthedocs.io/
Apache License 2.0
341 stars 33 forks source link

error with creating ImageWidget #476

Closed XuAn-universe closed 1 month ago

XuAn-universe commented 1 month ago

I got this error while testing cnmfe workshop demo. Any solutions?

iw = ImageWidget(data=data_orig, cmap="gray") iw.show()


TypeError Traceback (most recent call last) Cell In[8], line 1 ----> 1 iw = ImageWidget(data=data_orig, 2 cmap="gray") 3 iw.show()

File C:\ProgramData\anaconda3\envs\mescore\lib\site-packages\fastplotlib\widgets\image.py:561, in ImageWidget.init(self, data, dims_order, slider_dims, window_funcs, frame_apply, grid_shape, names, grid_plot_kwargs, histogram_widget, kwargs) 557 # update the default kwargs with any user-specified kwargs 558 # user specified kwargs will overwrite the defaults 559 grid_plot_kwargs_default.update(grid_plot_kwargs) --> 561 self._gridplot: GridPlot = GridPlot(shape=grid_shape, grid_plot_kwargs_default) 563 for data_ix, (d, subplot) in enumerate(zip(self.data, self.gridplot)): 564 if self._names is not None:

File C:\ProgramData\anaconda3\envs\mescore\lib\site-packages\fastplotlib\layouts_gridplot.py:93, in GridPlot.init(self, shape, cameras, controller_types, controller_ids, canvas, renderer, size, names) 90 else: 91 self.names = None ---> 93 canvas, renderer = make_canvas_and_renderer(canvas, renderer) 95 if isinstance(cameras, str): 96 # create the array representing the views for each subplot in the grid 97 cameras = np.array([cameras] self.shape[0] self.shape[1]).reshape( 98 self.shape 99 )

File C:\ProgramData\anaconda3\envs\mescore\lib\site-packages\fastplotlib\layouts_utils.py:70, in make_canvas_and_renderer(canvas, renderer) 68 if canvas is None: 69 Canvas = auto_determine_canvas() ---> 70 canvas = Canvas(max_fps=60) 72 elif isinstance(canvas, str): 73 if canvas not in CANVAS_OPTIONS:

TypeError: 'bool' object is not callable

kushalkolar commented 1 month ago

Hi, thanks for posting! You'll either need to downgrade pygfx to v0.1.17 or install fastplotlib directly from main.

On Thu, Apr 4, 2024, 10:45 Xu An @.***> wrote:

I got this error while testing cnmfe workshop demo. Any solutions?

iw = ImageWidget(data=data_orig, cmap="gray") iw.show()

TypeError Traceback (most recent call last) Cell In[8], line 1 ----> 1 iw = ImageWidget(data=data_orig, 2 cmap="gray") 3 iw.show()

File C:\ProgramData\anaconda3\envs\mescore\lib\site-packages\fastplotlib\widgets\image.py:561, in ImageWidget.init(self, data, dims_order, slider_dims, window_funcs, frame_apply, grid_shape, names, grid_plot_kwargs, histogram_widget, kwargs) 557 # update the default kwargs with any user-specified kwargs 558 # user specified kwargs will overwrite the defaults 559 grid_plot_kwargs_default.update(grid_plot_kwargs) --> 561 self._gridplot: GridPlot = GridPlot(shape=grid_shape, grid_plot_kwargs_default) 563 for data_ix, (d, subplot) in enumerate(zip(self.data, self.gridplot)): 564 if self._names is not None:

File C:\ProgramData\anaconda3\envs\mescore\lib\site-packages\fastplotlib\layouts_gridplot.py:93, in GridPlot.init(self, shape, cameras, controller_types, controller_ids, canvas, renderer, size, names) 90 else: 91 self.names = None ---> 93 canvas, renderer = make_canvas_and_renderer(canvas, renderer) 95 if isinstance(cameras, str): 96 # create the array representing the views for each subplot in the grid 97 cameras = np.array([cameras] self.shape[0] self.shape[1]).reshape( 98 self.shape 99 )

File C:\ProgramData\anaconda3\envs\mescore\lib\site-packages\fastplotlib\layouts_utils.py:70, in make_canvas_and_renderer(canvas, renderer) 68 if canvas is None: 69 Canvas = auto_determine_canvas() ---> 70 canvas = Canvas(max_fps=60) 72 elif isinstance(canvas, str): 73 if canvas not in CANVAS_OPTIONS:

TypeError: 'bool' object is not callable

— Reply to this email directly, view it on GitHub https://github.com/fastplotlib/fastplotlib/issues/476, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACHXXRATR3W6YUAFAFPIWSLY3VRPDAVCNFSM6AAAAABFXNWHASVHI2DSMVQWIX3LMV43ASLTON2WKOZSGIZDKNZRG43DGMY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

XuAn-universe commented 1 month ago

install fastplotlib directly from main solves the above problem. But I got an error here: iw.plot.canvas.close()


AttributeError Traceback (most recent call last) Cell In[9], line 1 ----> 1 iw.plot.canvas.close()

AttributeError: 'ImageWidget' object has no attribute 'plot'

When I tested the fastplotlib example, this error came up:

create a Plot instance

plot = Plot()

get a grayscale image

data = iio.imread("imageio:camera.png")

plot the image data

image_graphic = plot.add_image(data=data, name="sample-image")

show the plot

plot.show(sidecar=True)


ZeroDivisionError Traceback (most recent call last) Cell In[6], line 2 1 # create a Plot instance ----> 2 plot = Plot() 4 # get a grayscale image 5 data = iio.imread("imageio:camera.png")

File H:\fastplotlib\fastplotlib\layouts_plot.py:48, in Plot.init(self, canvas, renderer, camera, controller, size, kwargs) 12 def init( 13 self, 14 canvas: Union[str, WgpuCanvasBase] = None, (...) 19 kwargs, 20 ): 21 """ 22 Simple Plot object. 23 (...) 46 47 """ ---> 48 super().init( 49 parent=None, 50 position=(0, 0), 51 parent_dims=(1, 1), 52 canvas=canvas, 53 renderer=renderer, 54 camera=camera, 55 controller=controller, 56 **kwargs, 57 ) 58 RecordMixin.init(self) 59 Frame.init(self)

File H:\fastplotlib\fastplotlib\layouts_subplot.py:73, in Subplot.init(self, parent, position, parent_dims, camera, controller, canvas, renderer, name) 31 """ 32 General plot object that composes a Gridplot. Each Gridplot instance will have [n rows, n columns] 33 of subplots. (...) 68 69 """ 71 super(GraphicMethodsMixin, self).init() ---> 73 canvas, renderer = make_canvas_and_renderer(canvas, renderer) 75 if position is None: 76 position = (0, 0)

File H:\fastplotlib\fastplotlib\layouts_utils.py:30, in make_canvas_and_renderer(canvas, renderer) 24 raise TypeError( 25 f"canvas option must either be a valid WgpuCanvas implementation, a pygfx Texture" 26 f" or a str with the wgpu gui backend name." 27 ) 29 if renderer is None: ---> 30 renderer = WgpuRenderer(canvas) 31 elif not isinstance(renderer, Renderer): 32 raise TypeError( 33 f"renderer option must be a pygfx.Renderer instance such as pygfx.WgpuRenderer" 34 )

File C:\ProgramData\anaconda3\envs\mescore\lib\site-packages\pygfx\renderers\wgpu_renderer.py:136, in WgpuRenderer.init(self, target, pixel_ratio, pixel_filter, show_fps, blend_mode, sort_objects, enable_events, gamma_correction, *args, **kwargs) 132 raise TypeError( 133 f"Render target must be a Canvas or Texture, not a {target.class.name}" 134 ) 135 self._target = target --> 136 self.pixel_ratio = pixel_ratio 137 self.pixel_filter = pixel_filter 139 # Make sure we have a shared object (the first renderer creates the instance)

File C:\ProgramData\anaconda3\envs\mescore\lib\site-packages\pygfx\renderers\wgpu_renderer.py:234, in WgpuRenderer.pixel_ratio(self, value) 232 target_lsize = self.logical_size 233 # Determine target ratio --> 234 target_ratio = target_psize[0] / target_lsize[0] 235 # Use 2 on non-hidpi displays. On hidpi displays follow target. 236 self._pixel_ratio = float(target_ratio) if target_ratio > 1 else 2.0

ZeroDivisionError: division by zero

XuAn-universe commented 1 month ago

I have fastplotlib 0.1.0a16, pygfx 0.1.18, and wgpu 0.15.1 installed.

kushalkolar commented 1 month ago

This doesn't look like a notebook from the fastplotlib repo since that api is older, where's the notebook from?

On Thu, Apr 4, 2024, 14:13 Xu An @.***> wrote:

I have fastplotlib 0.1.0a16, pygfx 0.1.18, and wgpu 0.15.1 installed.

— Reply to this email directly, view it on GitHub https://github.com/fastplotlib/fastplotlib/issues/476#issuecomment-2037878054, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACHXXRDQ7AW3B6FU5PJR5KTY3WJ4NAVCNFSM6AAAAABFXNWHASVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZXHA3TQMBVGQ . You are receiving this because you commented.Message ID: @.***>

XuAn-universe commented 1 month ago

It came with mesmerize-core pachage here: https://github.com/nel-lab/mesmerize-core

kushalkolar commented 1 month ago

It looks like you have older notebooks, please use the latest from that repo and post any issues over there :)

On Thu, Apr 4, 2024, 14:51 Xu An @.***> wrote:

It came with mesmerize-core pachage here: https://github.com/nel-lab/mesmerize-core

— Reply to this email directly, view it on GitHub https://github.com/fastplotlib/fastplotlib/issues/476#issuecomment-2037970637, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACHXXRGIHQSYYZ2NVQDY2ODY3WOK7AVCNFSM6AAAAABFXNWHASVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZXHE3TANRTG4 . You are receiving this because you commented.Message ID: @.***>

kushalkolar commented 1 month ago

also see https://github.com/nel-lab/mesmerize-core/issues/295#issuecomment-2041434703