Skip to content

separate array logic and graphic logic in ImageWidget #868

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

kushalkolar
Copy link
Member

@kushalkolar kushalkolar commented Jun 29, 2025

This should help de-spaghettify ImageWidget.

This should also make it possible for ImageWidget to use the upcoming ImageVolumeGraphic

@kushalkolar
Copy link
Member Author

kushalkolar commented Jul 6, 2025

If we add the following properties we can make things way more arbitrary:

dim_names: dict that maps numerical dim index to a dimension name, ex: {0: "t", 1: "z"}. Only need to name scrollable dims.

index: dict that maps dim name to current index, ex: {"t": 123, "z": 5}

image_dims: tuple[int, int] | tuple[int, int, int] numerical dim indices that define the image displayed in the ImageGraphic or ImageVolumeGraphic.

Also, for window_funcs, if a window func is provided for only one dim then it should apply the window only along that dim. If window_funcs are defined for multiple dimensions, then apply the window for all provided dims. Can also have a way to define the order, ex. do "t" first and "z" etc.

Histogram calculation can also be done within this widget anytime the window funcs or frame_apply funcs are changed. We can then just allow force-setting the HistogramLUTGraph.

@kushalkolar
Copy link
Member Author

kushalkolar commented Aug 3, 2025

Make a few ready-made subclasses of ImageWidgetArray, for example IWA_Dask, IWA_Lazy etc.

In ImageWidget.__init__(), parse each data array in the list use the appropriate IWA type based on the data array type.

IW also has a new kwarg iwa_types which can explicitly define the IWA type which corresponds to the data array.

Make the window functions more flexible. Allow options kwargs that include the full data array, i.e. IWA.data, and the current index. Useful for things like computing a window function and then using that on the original data or current frame. Example, use a rolling filter on the current window, use this to subtract from the original frame.

@kushalkolar
Copy link
Member Author

new kwarg on ImageWidget, "adaptive_histogram", List[bool] | bool which creates an event handler for current_index so that any time the slider is moved or the index is changed it sets the histogram based on the current frame/volume.

@kushalkolar
Copy link
Member Author

If the data doesn't change when moving through dims, example: if there's a simple 2D image amongst multiple txy videos, then would be good to handle this efficiently so that Texture doesn't isn't uploaded when it doesn't change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant