{"action":"opened","issue":{"url":"https://api.github.com/repos/soft-matter/pims/issues/159","labels_url":"https://api.github.com/repos/soft-matter/pims/issues/159/labels{/name}","comments_url":"https://api.github.com/repos/soft-matter/pims/issues/159/comments","events_url":"https://api.github.com/repos/soft-matter/pims/issues/159/events","html_url":"https://github.com/soft-matter/pims/issues/159","id":90808021,"number":159,"title":"ENH: Slicing-aware reader methods","user":{"login":"nkeim","id":2985325,"avatar_url":"https://avatars.githubusercontent.com/u/2985325?v=3","gravatar_id":"","url":"https://api.github.com/users/nkeim","html_url":"https://github.com/nkeim","followers_url":"https://api.github.com/users/nkeim/followers","following_url":"https://api.github.com/users/nkeim/following{/other_user}","gists_url":"https://api.github.com/users/nkeim/gists{/gist_id}","starred_url":"https://api.github.com/users/nkeim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nkeim/subscriptions","organizations_url":"https://api.github.com/users/nkeim/orgs","repos_url":"https://api.github.com/users/nkeim/repos","events_url":"https://api.github.com/users/nkeim/events{/privacy}","received_events_url":"https://api.github.com/users/nkeim/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-06-24T23:46:55Z","updated_at":"2015-06-24T23:46:55Z","closed_at":null,"body":"This is an architectural issue at the intersection of #147, #153, and #158.\r\n\r\n### The problem\r\n\r\nCurrently, pims `SliceableIterable` objects wisely forward unknown method calls to their ancestors, which allows methods to be \"inherited\" from the reader object that opened the file. However, those methods could take frame numbers as their arguments. For example, the Cine and (unmerged) NorpixSeq classes have methods for reading the timestamp of frame *i*. Being able to retrieve a timestamp without reading the entire image can make a large performance difference in some applications. In a similar fashion, these proprietary formats can store other (as yet unsupported) information such as voltages or event markers.\r\n\r\nTherefore, methods like `get_time(frameno)` should be aware that they are being called via a child.\r\n\r\n### A solution\r\n`FramesSequence`-derived objects that want to support this feature provide the context `_use_map`, which would be used within the child `SliceableIterable` as follows (oversimplified for clarity):\r\n\r\n```\r\n# Call get_time() on the parent object\r\nwith self._ancestor.use_map(self.indices):\r\n    self._ancestor.get_time(*args, **kw)\r\n```\r\n\r\nThe reader class would then implement `get_time` as:\r\n\r\n```\r\ndef get_time(self, frameno):\r\n   actual_frameno = self._indexmap(frameno)\r\n   # Return time of actual_frameno...\r\n```\r\n\r\n`use_map()`, `_indexmap()`, etc. would be implemented in the `FramesSequence` base class. `use_map()` could be thread-safe.\r\n\r\nThoughts? I'm open to more elegant solutions, or to the possibility that this is too much of a niche feature!"}}