Skip to content

set_data()#216

Merged
kushalkolar merged 8 commits into
masterfrom
set_data
Jun 10, 2023
Merged

set_data()#216
kushalkolar merged 8 commits into
masterfrom
set_data

Conversation

@clewis7

@clewis7 clewis7 commented Jun 7, 2023

Copy link
Copy Markdown
Member

#190

add public method to ImageWidget to change the data

Comment thread fastplotlib/widgets/image.py Outdated
Comment thread fastplotlib/widgets/image.py Outdated
Comment thread fastplotlib/widgets/image.py Outdated
Comment thread fastplotlib/widgets/image.py Outdated
Comment thread fastplotlib/widgets/image.py Outdated
@clewis7

clewis7 commented Jun 8, 2023

Copy link
Copy Markdown
Member Author

running into a small issue for setting the data when the ndims of the data increase beyond "txy"

setting the overall data:
self._data[0] = new_data

however, if the dims are higher than 3 and I am trying to update the current displayed image, I get broadcasting errors because the shapes become mismatched
self.plot.graphics[0].data = self._data[0][self.current_index["t"]]

would need to do something like
self.plot.graphics[0].data = self._data[0][self.current_index["t"]]self.current_index["z"] etc.
for whatever dims you are capable of sliding through, but I'm not sure how to make this work if you have an indeterminate amount of dims you could be sliding through

@kushalkolar

Copy link
Copy Markdown
Member

Just do the 0th index for all dims upto the last 2.

Also I just realized we shouldn't directly set the graphic data, if windows functions or something are being used etc. So I would just set the current_index property. But it doesn't do anything if the current index is the same! So you could make a private method that has the logic for the current index setter with a "force" argument to force the update.

@clewis7

clewis7 commented Jun 9, 2023

Copy link
Copy Markdown
Member Author

But it doesn't do anything if the current index is the same!

I do not understand what logic in self.current_index setter prevents the graphic from getting updated even if the index remains the same

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

This to me seems that since the data has changed that the frame returned using the self._current_index values will be different and therefore the data of the current frame will change

It appears to me that regardless of whether the index has changed or not that the data is getting updated...

@clewis7

clewis7 commented Jun 9, 2023

Copy link
Copy Markdown
Member Author

the examples I have to set_data are working locally, I think it is sufficient to just force a call to the current index setter in order to get the graphics to update

@kushalkolar

Copy link
Copy Markdown
Member

Maybe it's true that a simple call to the current_index setter is sufficient to set the image graphic data, haven't seen that code in a while. If it works then it works! :D

@kushalkolar kushalkolar merged commit c53b262 into master Jun 10, 2023
@kushalkolar kushalkolar deleted the set_data branch June 17, 2023 06:20
kushalkolar added a commit that referenced this pull request Jun 21, 2023
* use numpy array instead of tuple for indexing collections

* set_data() (#216)

* set_data()

* fix small logic piece

* requested changes

* refactor reset_vmin_vmax() to work without sliders

* should be functional, need to do some more extensive testing

* removing unneccessary method

* tweaks, not yet tested

* image widget set_data fully works

---------

Co-authored-by: kushalkolar <kushalkolar@gmail.com>

* use numpy array instead of tuple for indexing collections

* update nb

* progresS

---------

Co-authored-by: Caitlin Lewis <69729525+clewis7@users.noreply.github.com>
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.

2 participants