DeepLabCut / napari-deeplabcut

a napari plugin for labeling and refining keypoint data within DeepLabCut projects
GNU Lesser General Public License v3.0
52 stars 22 forks source link

Fix copy-paste functionality w/ napari 0.4.18 #83

Closed jeylau closed 1 year ago

deprecated-napari-hub-preview-bot[bot] commented 1 year ago

Preview page for your plugin is ready here: https://preview.napari-hub.org/DeepLabCut/napari-deeplabcut/83 Created: 2023-07-19T07:53:31.265579

n-poulsen commented 1 year ago

Which copy-paste functionality do I need to test with this (in which context)?

jeylau commented 1 year ago

Selecting some points in an image, copying them (with Ctrl+C) and pasting them onto an other image (with Ctrl+V). It broke with napari==0.4.18 but should now work.

n-poulsen commented 1 year ago

I'm still getting an error with this implementation and the following setup:

napari: 0.4.18
Platform: macOS-13.3.1-arm64-arm-64bit
System: MacOS 13.3.1
Python: 3.10.12 (main, Jul  5 2023, 15:02:25) [Clang 14.0.6 ]
Qt: 6.3.1
PySide6: 
NumPy: 1.23.5
SciPy: 1.10.1
Dask: 2023.4.0
VisPy: 0.12.2
magicgui: 0.7.2
superqt: unknown
in-n-out: 0.1.7
app-model: 0.2.0
npe2: 0.7.2

OpenGL:
  - GL version:  2.1 Metal - 83.1
  - MAX_TEXTURE_SIZE: 16384

Screens:
  - screen 1: resolution 1470x956, scale 2.0
  - screen 2: resolution 2560x1440, scale 1.0

Settings path:
  - /napari/upa_84ffcbcf74a467a4b2c47af3c3eded2cf816f4de/settings.yaml
Plugins:
  - napari: 0.4.18 (77 contributions)
  - napari-console: 0.0.8 (0 contributions)
  - napari-deeplabcut: 0.1.3.dev31+g2d5116a (16 contributions)
  - napari-svg: 0.1.10 (2 contributions)

Stack trace:

File napari-deeplabcut/src/napari_deeplabcut/_widgets.py:157, in _paste_data(self=<Points layer 'CollectedData_ma'>, store=<napari_deeplabcut.keypoints.KeypointStore object>)
    155 self._clipboard["indices"] = indices_
    156 if text_ is not None:
--> 157     new_text = {k: v[unannotated] for k, v in text_.items()}
        unannotated = [True]
        text_ = {'string': <class 'numpy.ndarray'> (1,) <U21, 'color': <class 'numpy.ndarray'> (4,) float32}
    158     self._clipboard["text"] = new_text
    160 npoints = len(self._view_data)

File napari-deeplabcut/src/napari_deeplabcut/_widgets.py:157, in <dictcomp>(.0=<dict_itemiterator object>)
    155 self._clipboard["indices"] = indices_
    156 if text_ is not None:
--> 157     new_text = {k: v[unannotated] for k, v in text_.items()}
        unannotated = [True]
        k = 'color'
        v = <class 'numpy.ndarray'> (4,) float32
        k, v = ('color', <class 'numpy.ndarray'> (4,) float32)
    158     self._clipboard["text"] = new_text
    160 npoints = len(self._view_data)

IndexError: boolean index did not match indexed array along dimension 0; dimension is 4 but corresponding boolean dimension is 1