royerlab / napari-dexp Goto Github PK
View Code? Open in Web Editor NEWLicense: BSD 3-Clause "New" or "Revised" License
License: BSD 3-Clause "New" or "Revised" License
Hey, all. Was running tests on all plugins recently and found this one could not be imported after install, due to a missing napari requirement. I was coming here to suggest that you add napari to your install_requires, since this plugin explicitly imports things from napari. But I see that you've already done that. If main is stable, would be good to cut a new release. thanks!
Hi @JoOkuma ,
I observed for some time that when I was attempting to save a labels layer in napari as "test_annotation.tif" to disc, it created a folder called "test_annotation.tif" and stored zarr inside. When I tried to debug this, the following error suggests that napari-dexp is doing this:
|-> Creating Zarr storage: 'C:\structure\data\test_annotation.tif' with read/write mode: 'w-' and store type: 'None'
IndexError Traceback (most recent call last)
[...]
~\miniconda3\envs\bio1\lib\site-packages\napari_plugin_engine\implementation.py in __call__(self=<HookImplementation plugin='napari-dexp' spec='napari_write_labels'>, *args=(r'C:\structure\data\test_annotation.tif', <class 'numpy.ndarray'>
Would it be possible to not write anything in case a file ending such as ".tif" is provided here? another writer plugin would then take over (I guess).
Thanks!
Best,
Robert
Here comes the full error log:
|-> Creating Zarr storage: 'C:\structure\data\test_annotation.tif' with read/write mode: 'w-' and store type: 'None'
|-> Opening as Directory store
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
[... skipping hidden 1 frame]
~\miniconda3\envs\bio1\lib\site-packages\napari_plugin_engine\implementation.py in __call__(self=<HookImplementation plugin='napari-dexp' spec='napari_write_labels'>, *args=(r'C:\structure\data\test_annotation.tif', <class 'numpy.ndarray'> (512, 512) int32, {'blending': 'translucent', 'color': {0: <class 'numpy.ndarray'> (4,) float32, None: <class 'numpy.ndarray'> (4,) float32}, 'data': <class 'numpy.ndarray'> (512, 512) int32, 'metadata': {}, 'multiscale': False, 'name': 'Labels', 'num_colors': 50, 'opacity': 0.7, 'plane': {'enabled': False, 'normal': (1.0, 0.0, 0.0), 'position': (0.0, 0.0, 0.0), 'thickness': 10.0}, 'properties': {}, ...}))
65 def __call__(self, *args):
---> 66 return self.function(*args)
self.function = <function napari_write_labels at 0x0000015E85A8E430>
args = ('C:\\structure\\data\\test_annotation.tif', <class 'numpy.ndarray'> (512, 512) int32, {'name': 'Labels', 'metadata': {}, 'scale': [1.0, 1.0], 'translate': [0.0, 0.0], 'rotate': [[1.0, 0.0], [0.0, 1.0]], 'shear': [0.0], 'opacity': 0.7, 'blending': 'translucent', 'visible': True, 'multiscale': False, 'num_colors': 50, 'properties': {}, 'rendering': 'iso_categorical', 'plane': {'position': (0.0, 0.0, 0.0), 'normal': (1.0, 0.0, 0.0), 'thickness': 10.0, 'enabled': False}, 'seed': 0.5, 'data': <class 'numpy.ndarray'> (512, 512) int32, 'color': {0: <class 'numpy.ndarray'> (4,) float32, None: <class 'numpy.ndarray'> (4,) float32}})
67
~\miniconda3\envs\bio1\lib\site-packages\napari_dexp\_writer.py in napari_write_labels(path=r'C:\structure\data\test_annotation.tif', data=<class 'numpy.ndarray'> (512, 512) int32, meta={'blending': 'translucent', 'color': {0: <class 'numpy.ndarray'> (4,) float32, None: <class 'numpy.ndarray'> (4,) float32}, 'data': <class 'numpy.ndarray'> (512, 512) int32, 'metadata': {}, 'multiscale': False, 'name': 'Labels', 'num_colors': 50, 'opacity': 0.7, 'plane': {'enabled': False, 'normal': (1.0, 0.0, 0.0), 'position': (0.0, 0.0, 0.0), 'thickness': 10.0}, 'properties': {}, ...})
50 def napari_write_labels(path: str, data: Any, meta: Dict) -> str:
---> 51 return writer(path, [(data, meta, 'labels')])
global writer = <function writer at 0x0000015E85A8E310>
path = 'C:\\structure\\data\\test_annotation.tif'
data = <class 'numpy.ndarray'> (512, 512) int32
meta = {'name': 'Labels', 'metadata': {}, 'scale': [1.0, 1.0], 'translate': [0.0, 0.0], 'rotate': [[1.0, 0.0], [0.0, 1.0]], 'shear': [0.0], 'opacity': 0.7, 'blending': 'translucent', 'visible': True, 'multiscale': False, 'num_colors': 50, 'properties': {}, 'rendering': 'iso_categorical', 'plane': {'position': (0.0, 0.0, 0.0), 'normal': (1.0, 0.0, 0.0), 'thickness': 10.0, 'enabled': False}, 'seed': 0.5, 'data': <class 'numpy.ndarray'> (512, 512) int32, 'color': {0: <class 'numpy.ndarray'> (4,) float32, None: <class 'numpy.ndarray'> (4,) float32}}
52
~\miniconda3\envs\bio1\lib\site-packages\napari_dexp\_writer.py in writer(path=r'C:\structure\data\test_annotation.tif', layers_data=[(<class 'numpy.ndarray'> (512, 512) int32, {'blending': 'translucent', 'color': {0: <class 'numpy.ndarray'> (4,) float32, None: <class 'numpy.ndarray'> (4,) float32}, 'data': <class 'numpy.ndarray'> (512, 512) int32, 'metadata': {}, 'multiscale': False, 'name': 'Labels', 'num_colors': 50, 'opacity': 0.7, 'plane': {'enabled': False, 'normal': (1.0, 0.0, 0.0), 'position': (0.0, 0.0, 0.0), 'thickness': 10.0}, 'properties': {}, ...}, 'labels')])
34 for data, meta, ltype in layers_data:
---> 35 dataset.add_channel(meta['name'],
dataset.add_channel = <bound method ZDataset.add_channel of <dexp.datasets.zarr_dataset.ZDataset object at 0x0000015E9FAE6D60>>
meta = {'name': 'Labels', 'metadata': {}, 'scale': [1.0, 1.0], 'translate': [0.0, 0.0], 'rotate': [[1.0, 0.0], [0.0, 1.0]], 'shear': [0.0], 'opacity': 0.7, 'blending': 'translucent', 'visible': True, 'multiscale': False, 'num_colors': 50, 'properties': {}, 'rendering': 'iso_categorical', 'plane': {'position': (0.0, 0.0, 0.0), 'normal': (1.0, 0.0, 0.0), 'thickness': 10.0, 'enabled': False}, 'seed': 0.5, 'data': <class 'numpy.ndarray'> (512, 512) int32, 'color': {0: <class 'numpy.ndarray'> (4,) float32, None: <class 'numpy.ndarray'> (4,) float32}}
global shape = undefined
data.shape = (512, 512)
global dtype = undefined
global np.uint16 = <class 'numpy.uint16'>
ltype = 'labels'
global np.uint32 = <class 'numpy.uint32'>
36 shape=data.shape,
~\miniconda3\envs\bio1\lib\site-packages\dexp\datasets\zarr_dataset.py in add_channel(self=<dexp.datasets.zarr_dataset.ZDataset object>, name='Labels', shape=(512, 512), dtype=<class 'numpy.uint32'>, chunks=None, enable_projections=True, codec='zstd', clevel=3)
339 if chunks is None:
--> 340 chunks = self._default_chunks(shape, dtype)
chunks = None
self._default_chunks = <function ZDataset._default_chunks at 0x0000015E85A85670>
shape = (512, 512)
dtype = <class 'numpy.uint32'>
341
~\miniconda3\envs\bio1\lib\site-packages\dexp\datasets\zarr_dataset.py in _default_chunks(shape=(512, 512), dtype=dtype('uint32'), max_size=2147483647)
166 height = shape[-2]
--> 167 depth = min(max_size // (dtype.itemsize * width * height), shape[-3])
depth = undefined
global min = undefined
max_size = 2147483647
dtype.itemsize = 4
width = 512
height = 512
shape = (512, 512)
168 chunk = (1, depth, height, width)
IndexError: tuple index out of range
The above exception was the direct cause of the following exception:
PluginCallError Traceback (most recent call last)
c:\structure\code\napari\napari\_qt\qt_main_window.py in <lambda>()
573 save_selected_layers.setStatusTip(trans._('Save selected layers'))
574 save_selected_layers.triggered.connect(
--> 575 lambda: self.qt_viewer._save_layers_dialog(selected=True)
global self.qt_viewer._save_layers_dialog = undefined
global selected = undefined
576 )
577
c:\structure\code\napari\napari\_qt\qt_viewer.py in _save_layers_dialog(self=<napari._qt.qt_viewer.QtViewer object>, selected=True)
523 if filename:
524 with warnings.catch_warnings(record=True) as wa:
--> 525 saved = self.viewer.layers.save(filename, selected=selected)
saved = undefined
self.viewer.layers.save = <bound method LayerList.save of [<Labels layer 'Labels' at 0x15e9de21250>]>
filename = 'C:/structure/data/test_annotation.tif'
selected = True
526 error_messages = "\n".join(
527 [str(x.message.args[0]) for x in wa]
c:\structure\code\napari\napari\components\layerlist.py in save(self=[<Labels layer 'Labels' at 0x15e9de21250>], path='C:/structure/data/test_annotation.tif', selected=True, plugin=None)
328 return []
329
--> 330 return save_layers(path, layers, plugin=plugin)
save_layers = <function save_layers at 0x0000015E9FB201F0>
path = 'C:/structure/data/test_annotation.tif'
layers = [<Labels layer 'Labels' at 0x15e9de21250>]
plugin = None
331
332 def _selection_context(self) -> dict:
c:\structure\code\napari\napari\plugins\io.py in save_layers(path='C:/structure/data/test_annotation.tif', layers=[<Labels layer 'Labels'>], plugin=None)
207 )
208 elif len(layers) == 1:
--> 209 _written = _write_single_layer_with_plugins(
_written = undefined
global _write_single_layer_with_plugins = <function _write_single_layer_with_plugins at 0x0000015E9FB20820>
path = 'C:/structure/data/test_annotation.tif'
layers = [<Labels layer 'Labels' at 0x15e9de21250>]
global plugin_name = undefined
plugin = None
210 path, layers[0], plugin_name=plugin
211 )
c:\structure\code\napari\napari\plugins\io.py in _write_single_layer_with_plugins(path='C:/structure/data/test_annotation.tif', layer=<Labels layer 'Labels'>, plugin_name=None)
405
406 # Call the hook_caller
--> 407 return hook_caller(
hook_caller = <HookCaller napari_write_labels>
global _plugin = undefined
plugin_name = None
path = 'C:/structure/data/test_annotation.tif'
global abspath_or_url = <function abspath_or_url at 0x0000015EEF5139D0>
global data = undefined
layer.data = <class 'numpy.ndarray'> (512, 512) int32
global meta = undefined
layer._get_state = <bound method Labels._get_state of <Labels layer 'Labels' at 0x15e9de21250>>
408 _plugin=plugin_name,
409 path=abspath_or_url(path),
~\miniconda3\envs\bio1\lib\site-packages\napari_plugin_engine\hooks.py in __call__(self=<HookCaller napari_write_labels>, _plugin=None, _skip_impls=[], *args=(), **kwargs={'data': <class 'numpy.ndarray'> (512, 512) int32, 'meta': {'blending': 'translucent', 'color': {0: <class 'numpy.ndarray'> (4,) float32, None: <class 'numpy.ndarray'> (4,) float32}, 'data': <class 'numpy.ndarray'> (512, 512) int32, 'metadata': {}, 'multiscale': False, 'name': 'Labels', 'num_colors': 50, 'opacity': 0.7, 'plane': {'enabled': False, 'normal': (1.0, 0.0, 0.0), 'position': (0.0, 0.0, 0.0), 'thickness': 10.0}, 'properties': {}, ...}, 'path': r'C:\structure\data\test_annotation.tif'})
518 return self._call_plugin(_plugin, **kwargs)
519
--> 520 result = self.call_with_result_obj(_skip_impls=_skip_impls, **kwargs)
result = undefined
self.call_with_result_obj = <bound method HookCaller.call_with_result_obj of <HookCaller napari_write_labels>>
_skip_impls = []
kwargs = {'path': 'C:\\structure\\data\\test_annotation.tif', 'data': <class 'numpy.ndarray'> (512, 512) int32, 'meta': {'name': 'Labels', 'metadata': {}, 'scale': [1.0, 1.0], 'translate': [0.0, 0.0], 'rotate': [[1.0, 0.0], [0.0, 1.0]], 'shear': [0.0], 'opacity': 0.7, 'blending': 'translucent', 'visible': True, 'multiscale': False, 'num_colors': 50, 'properties': {}, 'rendering': 'iso_categorical', 'plane': {'position': (0.0, 0.0, 0.0), 'normal': (1.0, 0.0, 0.0), 'thickness': 10.0, 'enabled': False}, 'seed': 0.5, 'data': <class 'numpy.ndarray'> (512, 512) int32, 'color': {0: <class 'numpy.ndarray'> (4,) float32, None: <class 'numpy.ndarray'> (4,) float32}}}
521 return result.result
522
~\miniconda3\envs\bio1\lib\site-packages\napari_plugin_engine\hooks.py in call_with_result_obj(self=<HookCaller napari_write_labels>, _skip_impls=[], **kwargs={'data': <class 'numpy.ndarray'> (512, 512) int32, 'meta': {'blending': 'translucent', 'color': {0: <class 'numpy.ndarray'> (4,) float32, None: <class 'numpy.ndarray'> (4,) float32}, 'data': <class 'numpy.ndarray'> (512, 512) int32, 'metadata': {}, 'multiscale': False, 'name': 'Labels', 'num_colors': 50, 'opacity': 0.7, 'plane': {'enabled': False, 'normal': (1.0, 0.0, 0.0), 'position': (0.0, 0.0, 0.0), 'thickness': 10.0}, 'properties': {}, ...}, 'path': r'C:\structure\data\test_annotation.tif'})
459 self._check_call_kwargs(kwargs)
460 impls = [imp for imp in self.get_hookimpls() if imp not in _skip_impls]
--> 461 return self._hookexec(self, impls, kwargs)
self._hookexec = <bound method PluginManager._hookexec of <napari.plugins._plugin_manager.NapariPluginManager object at 0x0000015EF5FEC4F0>>
self = <HookCaller napari_write_labels>
impls = [<HookImplementation plugin='svg' spec='napari_write_labels' trylast>, <HookImplementation plugin='builtins' spec='napari_write_labels' trylast>, <HookImplementation plugin='napari-dexp' spec='napari_write_labels'>]
kwargs = {'path': 'C:\\structure\\data\\test_annotation.tif', 'data': <class 'numpy.ndarray'> (512, 512) int32, 'meta': {'name': 'Labels', 'metadata': {}, 'scale': [1.0, 1.0], 'translate': [0.0, 0.0], 'rotate': [[1.0, 0.0], [0.0, 1.0]], 'shear': [0.0], 'opacity': 0.7, 'blending': 'translucent', 'visible': True, 'multiscale': False, 'num_colors': 50, 'properties': {}, 'rendering': 'iso_categorical', 'plane': {'position': (0.0, 0.0, 0.0), 'normal': (1.0, 0.0, 0.0), 'thickness': 10.0, 'enabled': False}, 'seed': 0.5, 'data': <class 'numpy.ndarray'> (512, 512) int32, 'color': {0: <class 'numpy.ndarray'> (4,) float32, None: <class 'numpy.ndarray'> (4,) float32}}}
462
463 def __call__(
~\miniconda3\envs\bio1\lib\site-packages\napari_plugin_engine\manager.py in _hookexec(self=<napari.plugins._plugin_manager.NapariPluginManager object>, caller=<HookCaller napari_write_labels>, methods=[<HookImplementation plugin='svg' spec='napari_write_labels' trylast>, <HookImplementation plugin='builtins' spec='napari_write_labels' trylast>, <HookImplementation plugin='napari-dexp' spec='napari_write_labels'>], kwargs={'data': <class 'numpy.ndarray'> (512, 512) int32, 'meta': {'blending': 'translucent', 'color': {0: <class 'numpy.ndarray'> (4,) float32, None: <class 'numpy.ndarray'> (4,) float32}, 'data': <class 'numpy.ndarray'> (512, 512) int32, 'metadata': {}, 'multiscale': False, 'name': 'Labels', 'num_colors': 50, 'opacity': 0.7, 'plane': {'enabled': False, 'normal': (1.0, 0.0, 0.0), 'position': (0.0, 0.0, 0.0), 'thickness': 10.0}, 'properties': {}, ...}, 'path': r'C:\structure\data\test_annotation.tif'})
157 The result object produced by the multicall loop.
158 """
--> 159 return self._inner_hookexec(caller, methods, kwargs)
self._inner_hookexec = <function PluginManager.__init__.<locals>.<lambda> at 0x0000015EF5E08040>
caller = <HookCaller napari_write_labels>
methods = [<HookImplementation plugin='svg' spec='napari_write_labels' trylast>, <HookImplementation plugin='builtins' spec='napari_write_labels' trylast>, <HookImplementation plugin='napari-dexp' spec='napari_write_labels'>]
kwargs = {'path': 'C:\\structure\\data\\test_annotation.tif', 'data': <class 'numpy.ndarray'> (512, 512) int32, 'meta': {'name': 'Labels', 'metadata': {}, 'scale': [1.0, 1.0], 'translate': [0.0, 0.0], 'rotate': [[1.0, 0.0], [0.0, 1.0]], 'shear': [0.0], 'opacity': 0.7, 'blending': 'translucent', 'visible': True, 'multiscale': False, 'num_colors': 50, 'properties': {}, 'rendering': 'iso_categorical', 'plane': {'position': (0.0, 0.0, 0.0), 'normal': (1.0, 0.0, 0.0), 'thickness': 10.0, 'enabled': False}, 'seed': 0.5, 'data': <class 'numpy.ndarray'> (512, 512) int32, 'color': {0: <class 'numpy.ndarray'> (4,) float32, None: <class 'numpy.ndarray'> (4,) float32}}}
160
161 def iter_available(
~\miniconda3\envs\bio1\lib\site-packages\napari_plugin_engine\manager.py in <lambda>(c=<HookCaller napari_write_labels>, m=[<HookImplementation plugin='svg' spec='napari_write_labels' trylast>, <HookImplementation plugin='builtins' spec='napari_write_labels' trylast>, <HookImplementation plugin='napari-dexp' spec='napari_write_labels'>], k={'data': <class 'numpy.ndarray'> (512, 512) int32, 'meta': {'blending': 'translucent', 'color': {0: <class 'numpy.ndarray'> (4,) float32, None: <class 'numpy.ndarray'> (4,) float32}, 'data': <class 'numpy.ndarray'> (512, 512) int32, 'metadata': {}, 'multiscale': False, 'name': 'Labels', 'num_colors': 50, 'opacity': 0.7, 'plane': {'enabled': False, 'normal': (1.0, 0.0, 0.0), 'position': (0.0, 0.0, 0.0), 'thickness': 10.0}, 'properties': {}, ...}, 'path': r'C:\structure\data\test_annotation.tif'})
118 self.trace = _tracing.TagTracer().get("pluginmanage")
119 self.hook = _HookRelay(self)
--> 120 self._inner_hookexec: HookExecFunc = lambda c, m, k: c.multicall(
global self._inner_hookexec = undefined
global HookExecFunc = typing.Callable[[ForwardRef('HookCaller'), typing.List[napari_plugin_engine.implementation.HookImplementation], dict], napari_plugin_engine.callers.HookResult]
c = <HookCaller napari_write_labels>
m = [<HookImplementation plugin='svg' spec='napari_write_labels' trylast>, <HookImplementation plugin='builtins' spec='napari_write_labels' trylast>, <HookImplementation plugin='napari-dexp' spec='napari_write_labels'>]
k = {'path': 'C:\\structure\\data\\test_annotation.tif', 'data': <class 'numpy.ndarray'> (512, 512) int32, 'meta': {'name': 'Labels', 'metadata': {}, 'scale': [1.0, 1.0], 'translate': [0.0, 0.0], 'rotate': [[1.0, 0.0], [0.0, 1.0]], 'shear': [0.0], 'opacity': 0.7, 'blending': 'translucent', 'visible': True, 'multiscale': False, 'num_colors': 50, 'properties': {}, 'rendering': 'iso_categorical', 'plane': {'position': (0.0, 0.0, 0.0), 'normal': (1.0, 0.0, 0.0), 'thickness': 10.0, 'enabled': False}, 'seed': 0.5, 'data': <class 'numpy.ndarray'> (512, 512) int32, 'color': {0: <class 'numpy.ndarray'> (4,) float32, None: <class 'numpy.ndarray'> (4,) float32}}}
c.multicall = <function _multicall at 0x0000015EF5983D30>
global firstresult = undefined
c.is_firstresult = True
121 m, k, firstresult=c.is_firstresult
122 )
~\miniconda3\envs\bio1\lib\site-packages\napari_plugin_engine\callers.py in _multicall(hook_impls=[<HookImplementation plugin='svg' spec='napari_write_labels' trylast>, <HookImplementation plugin='builtins' spec='napari_write_labels' trylast>, <HookImplementation plugin='napari-dexp' spec='napari_write_labels'>], caller_kwargs={'data': <class 'numpy.ndarray'> (512, 512) int32, 'meta': {'blending': 'translucent', 'color': {0: <class 'numpy.ndarray'> (4,) float32, None: <class 'numpy.ndarray'> (4,) float32}, 'data': <class 'numpy.ndarray'> (512, 512) int32, 'metadata': {}, 'multiscale': False, 'name': 'Labels', 'num_colors': 50, 'opacity': 0.7, 'plane': {'enabled': False, 'normal': (1.0, 0.0, 0.0), 'position': (0.0, 0.0, 0.0), 'thickness': 10.0}, 'properties': {}, ...}, 'path': r'C:\structure\data\test_annotation.tif'}, firstresult=True)
209 finally:
210 if firstresult and errors:
--> 211 raise errors[-1]
errors = [PluginCallError("Error in plugin 'napari-dexp', hook 'napari_write_labels': tuple index out of range")]
212
213 outcome = HookResult(
PluginCallError: Error in plugin 'napari-dexp', hook 'napari_write_labels': tuple index out of range
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.