jni / zarpaint

Paint segmentations directly to on-disk/remote zarr arrays
BSD 3-Clause "New" or "Revised" License
14 stars 8 forks source link

Add plugin for UI #7

Closed jni closed 3 years ago

jni commented 3 years ago

status update: as of napari 0.4.8rc3, with this PR you can do napari --with zarpaint -- path/to/file.tiff and it works for (a) creating/reopening a zarr file and using it as labels, and (b) painting into that file. Chunks are specified as an int tuple that is ast.literal_evald, e.g. (1, 1, 256, 256).

I'll keep pushing a few widgets to this branch, and updating tests. :grimacing:

CC @GenevieveBuckley

jni commented 3 years ago

@tlambert03 I got the dims sorter working :tada: but I have this weird behavior where if I change the values (dims.order, dims.axis_labels) programmatically, the list updates only on hover of the widget. How do I hook up those events to the widget refresh? I couldn't find where in the napari layer list to find that pattern...

If you install the plugin from this branch you can do napari path/to/image.tif --with zarpaint 'Dims Sorter' to test. (Then setting the values in the console.)

tlambert03 commented 3 years ago

I think you might be blocking the events that the Qt view is listening to in your move_indices function:

def move_indices(axes_list, order):
    with axes_list.events.blocker_all():

edit: for reference those events are hooked up here.

however, SelectableEventedList already has move/move_multiple methods that take care of this for you:

try this:


# instead of this
# dims.events.order.connect(
#     lambda event, axes_list=root: move_indices(axes_list, event.value)
# )

# try this:
dims.events.order.connect(lambda event: root.move_multiple(event.value))
jni commented 3 years ago

I should have been clearer: yes I block the events because you don't want to update the order when you're updating the list, but adding a axes_list.events.reordered() at the end didn't help.

however, SelectableEventedList already has move/move_multiple methods that take care of this for you:

Of course it does. 😂 It didn't occur to me that moving all of them to 0 with order would be the same thing as reordering them. 😂 You don't want to know how long I spent debugging this. 😂 😂 😂

Having said that, I'm not sure it does exactly what I need, because the order in the list is not range(ndim), which is what move_multiple(order) assumes?

GenevieveBuckley commented 3 years ago

:tada: