Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cache the current frame for fast access
When working with large data on a slow filesystem, simply reading the current displayed image gets to be really slow. This happens when checking the intensity of different coordinates for instance (via mouseover events). To improve performance, we can store the currently displayed frame and simply access it if the user has not selected a different frame. We accomplish this here by storing the frame number (time) and the current frame. These are both initialized to be `None` so that they will fail any checks to see if the frame can be reused on the first call. Within `get_image`, checks are added to see if the requested (or default) frame number (time) are the same. If not, the new frame is loaded and the time updated. By only updating the time after, this ensures that some raised exception doesn't create an incorrectly determined cached image. In either case the frame just now or already loaded, is returned.
- Loading branch information