← 返回首页
Refactor imwidget by apasarkar · Pull Request #459 · fastplotlib/fastplotlib · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

Refactor imwidget#459

Merged
kushalkolar merged 32 commits into
fastplotlib:iw_refactorfrom
apasarkar:refactor_imwidget
Apr 12, 2024
Merged

Refactor imwidget#459
kushalkolar merged 32 commits into
fastplotlib:iw_refactorfrom
apasarkar:refactor_imwidget

Conversation

apasarkar commented Mar 29, 2024
edited by kushalkolar
Loading

Copy link
Copy Markdown
Collaborator

Closes #284

apasarkar marked this pull request as draft March 29, 2024 14:25
…e the function was only being applied to the first array
…e graphic now occurs outside of the for loop for running the window functions which is more efficient
… Z dimensions, also removes logic saying that window_funcs can be ints, they now have to be dictionaries or None
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
6 hidden conversations Load more…
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
Comment thread fastplotlib/widgets/image.py Show resolved Hide resolved
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
Comment thread fastplotlib/widgets/image.py Show resolved Hide resolved

kushalkolar commented Apr 1, 2024
edited
Loading

Copy link
Copy Markdown
Member

I think we can use the a[np.newaxis] method as you mentioned, it returns views of the array which makes sense: a[np.newaxis, np.newaxis].ctypes.data == a.ctypes.data

Currently ImageWidget uses the lowest "t" and/or "z" dimension sizes to set the max bounds "_dims_max_bounds" for the ImageWidget and the sliders. If we instead set _dims_max_bounds based on the largest sizes in each dimension by modifying this bit:

# get max bound for all data arrays for all dimensions
self._dims_max_bounds: Dict[str, int] = {k: np.inf for k in self.slider_dims}
for _dim in list(self._dims_max_bounds.keys()):
for array, order in zip(self.data, self.dims_order):
self._dims_max_bounds[_dim] = min(
self._dims_max_bounds[_dim], array.shape[order.index(_dim)]
)

and then in @current_index.setter

for i, (ig, data) in enumerate(zip(self.managed_graphics, self.data)):
frame = self._process_indices(data, self._current_index)
frame = self._process_frame_apply(frame, i)
ig.data = frame

when iterating through each individual data array, we do something like this to prevent out of bounds indices for the data arrays which have fewer "t" or "z" items (ex. corr images) than the other data arrays (ex. movies).

current_index = dict() for k in self._current_index: dim_ix = dict(reversed(ALLOWED_SLIDER_DIMS))[k] current_index[k] = min(self._current_index[k], data.shape[dim_ix])

It'll be generally useful anytime the shapes are very different. Might want to raise a warning in the constructor and set_data() to just let the user know that the array shapes are different and to expect this type of behavior (ex. sliding through data using the "t" slider will only change the graphic data if data exists at that position along that dimension, else it is ignored and the other data arrays are updated).

kushalkolar mentioned this pull request Apr 7, 2024
7 tasks
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
Comment thread fastplotlib/widgets/image.py Show resolved Hide resolved
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
2 hidden conversations Load more…
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
…num to n for readability, makes rgb init parameter a list of boolean values
…array so it can be applied in a modular fashion to each individual array
…ing the max length logic to reflect the mixed types and also adding explicit property for histogram_widget
9 hidden items Load more…
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
Comment thread fastplotlib/widgets/image.py Show resolved Hide resolved
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
6 hidden conversations Load more…
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved

Copy link
Copy Markdown
Collaborator Author

@kushalkolar It seems the tests for pre-existing cells in image_widget_test.ipynb are failing. The rgba_to_rgb function seems to complain that the input has 2 indices but 3 indices are indexed etc. Let me know what you think, maybe we need to update the rgba_to_rgb function?

Once we have that fixed, I can re-run to generate + update new screenshots.

kushalkolar marked this pull request as ready for review April 11, 2024 04:29

Copy link
Copy Markdown
Member

I've made this a full PR from the draft so the CI will run on GitHub actions, we can check the result tomorrow.

Comment thread fastplotlib/widgets/image.py Outdated Show resolved Hide resolved
kushalkolar changed the base branch from main to iw_refactor April 12, 2024 04:28
kushalkolar merged commit 55e8b4e into fastplotlib:iw_refactor Apr 12, 2024
kushalkolar mentioned this pull request Apr 12, 2024
kushalkolar added a commit that referenced this pull request Apr 12, 2024
* fefactor imwidget, restrict to tzxy, txy, xy, added RGB(A) support (#459) * add new iw test screenshots * update api docs --------- Co-authored-by: Amol Pasarkar <amolpasarkar@gmail.com>
kushalkolar added a commit that referenced this pull request Apr 12, 2024
* figure refactor seems to work * update nbs w.r.t. new figure * update test util * black * remove lingering uses of gridplot * update API doc generation * update contributing * typo Co-authored-by: Caitlin Lewis <69729525+clewis7@users.noreply.github.com> * Iw refactor (#482) * fefactor imwidget, restrict to tzxy, txy, xy, added RGB(A) support (#459) * add new iw test screenshots * update api docs --------- Co-authored-by: Amol Pasarkar <amolpasarkar@gmail.com> * figure refactor seems to work * update nbs w.r.t. new figure * update test util * black * remove lingering uses of gridplot * update API doc generation * update contributing * typos * update iw with FIgure * update api docs * black * update quickstart * update iw examples * update iw type annotations * default cmap iw * remove gp docs * update readme * forgot to delete more api docs * I need to run nbs before committing them * more docs --------- Co-authored-by: Caitlin Lewis <69729525+clewis7@users.noreply.github.com> Co-authored-by: Amol Pasarkar <amolpasarkar@gmail.com>
apasarkar deleted the refactor_imwidget branch July 15, 2024 18:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

Refactor ImageWidget

2 participants

Footer

© 2026 GitHub, Inc.