ImageView: make .nframes() to use .axis['t'] instead of .shape[0]#2623
ImageView: make .nframes() to use .axis['t'] instead of .shape[0]#2623j9ac9k merged 1 commit intopyqtgraph:masterfrom
Conversation
This is fixing the behviour of ImageView for 3 dimentional images, where stacking or time is not in 0 index of array shape. as nframes is being called by other methods which are enbled only if axes t is recognised, there is no need to check for if axes['t] is None (then frame should be 1); alternatively, would not it be better to remove this method and use where needed `self.tVals.shape[0]` ? From performance point of view that would be better, but seeing the checking `if self.image is None:` probably there is the reason for cases where would be 0 frames. Thus I had added at the end `return 1` and so `nframes()` should cover all possible cases also then called externally.
|
@outofculture @campagnola you two work with these more than I do, comments? |
|
thanks for the PR @sem-geologist the diff LGTM, but this is a part of the library I don't work with much myself so hopefully one of the other maintainers will chime in here. |
|
I mentioned initially the performance concern; actually I see no noticeable performance hit (internally |
|
I think I've given folks ample opportunity, thanks for the explanation @sem-geologist this LGTM. |
|
cool, thanks. I saw it made into newest version and is ready in 0.13.2. I can now get rid of subclass in my new project which uses |
BUG-FIX:
This is fixing the behavior of ImageView for 3 dimensional images, where stacking of images or time frames are not at commonly expected 0'th index of arrays shape. Using hard-coded image.shape[0] causes the progress of play stop at such index if image.shape[0] is smaller than the shape at index set for axis t.
Alternatively, would not it be better to remove this method and use where needed
self.tVals.shape[0]? From performance point of view that would be probably better, but seeing the checkingif self.image is None:probably there is an external reason for cases where would be 0 frames (in the end this method is public and could be called externally). Thus I had added at the end the additional case returning1when there is single frame and sonframes()should cover all possible cases also then called externally.Minimal Code to reproduce the BUG:
.play()or keyboard keys will go as far as 16 slice, becausenframes()returnsimage.shape[0]which is 16.also
will print 16, and there is only 1 frame.
This bug-fix makes the first example to play to the end, and second example to correctly return
1as number of frames