-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image block layer #1827
Image block layer #1827
Conversation
Since I may not have time to work on this for a few weeks, I'd rather land it without any of the TODOs other than the cleanup and squashing so that it doesn't rot. The only thing I'd like to wait on, then, is the next |
Great! I try to go through the changes later today. Since the TODOs are still useful changes, we should probably move them to two or three new issues. |
django/applications/catmaid/static/js/layers/pixi-image-block-layer.js
Outdated
Show resolved
Hide resolved
django/applications/catmaid/static/js/layers/pixi-image-block-layer.js
Outdated
Show resolved
Hide resolved
let texture = baseTex._glTextures[renderer.CONTEXT_UID]; | ||
let newTex = false; | ||
let width = slice.shape[1]; | ||
let height = slice.shape[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose, shape[1]
is width and shape[0]
and height because of the transpose(1, 0)
call in line 193?
Thanks Andrew! I read through the changes and everything looks good, LGTM! The block changes are well structured and provide a reasonable interface for the stack viewer's tiling perspective. Also, With respect to WebGL2, I think we should also test for availability initially and show the "Modern browser" message if unavailable. It might be nice to be able to use WebGL2 features in other parts of CATMAID and rely on it being there. As far as I understand, Safari doesn't support WebGL2, but I believe there are only a few people using Safari for CATMAID and I think their user experience with CATMAID is likely better with Chromium or Firefox anyway. Alternatively, we can provide WebGL1 as fallback when constructing the Pixi layer. It's good that there are checks for BigInt and dynamic imports. Unfortunately, FireFox doesn't seem to be close to BigInt support yet. Also nice to see all the tile source related things being brought together into the |
This is necessary for stores that need to take action on eviction, e.g., to write mutated values to a backend.
Construct an explicit WebGL2 context and pass it to Pixi. This is necessary to use WebGL2 features elsewhere, e.g., integer textures and sized textures. Pixi seems to work correctly when using this WebGL2 context.
Fix a bug where navigating to the next section would end up returning to the same section because of epsilon and flooring.
Add a tile source type for N5 files served directly over HTTP. Note that this tile source is experimental and the URL format is subject to breaking changes. Since this is the first image block source type, add an abstract base class to the frontend for those types. For loading N5, use n5-wasm at tag 0.1.0. n5-wasm is built release, packaged with wasm-bindgen, then updated to use browser-builting WASM module loading with: https://github.com/FreeMasen/wasm-chrome-hack then edited to use appropriate CATMAID paths. Also includes numjs 0.16.0.
Add a prototype stack layer for displaying image block sources via Pixi.
Allow stacks that have image block sources to be viewed from any orientation by wrapping the stack in the front end. The image block layer permutes dimensions of the loaded blocks appropriate to the orientation, which allows for all views of the stack to use the same cache.
Throw an error if either dynamic import or BigInt are not supported by the browser. Move the dynamic import inside an evaluated string so that it does not prevent Firefox loading the file.
Handle the case at stack boundaries where a block may have fewer Z slices than the block size.
Use this modified time as the state identifier for now. Mtime has the following drawbacks: - Only millisecond resolution in javascript - Not content-verifiable And these advantages: - Free (from request headers) - Standards compliant for other features like cache invalidation
This also converts existing layers' returns to Promises.
This prevents conflict with the event source clear method.
Use new method in N5-wasm to consume rather than copy the data vector, which greatly reduces GC and improves performance when browsing these stacks.
This can occur when the layer is rendered before the image block source has fully loaded.
This matches the behavior of other stack layers.
Fix a case where in particular timing conditions with the image block layer, smooth scrolling would not draw section changes because the microtask queue was not empty, but section changes where slightly slower than the max FPS interval. This one-line change courtesy 5 hours of debugging.
1c13ea9
to
0d5f22f
Compare
Build failure looks like a Travis/sauce/pypy problem, not relevant. |
🎉 |
Forgot to do the WebGL2 check/fallback. Will create an issue. |
Fantastic to see this functionality in CATMAID! I'd be eager to test this on a small scale sample (<1GB) and provide feedback if that's useful. Is there some brief documentation on how to set up the N5/Data Layout and the CATMAID stack? Are uint32 and/or uint64 label stacks also supported? |
It's still considered a prototype feature, some details will change, and a lot of functionality is still limited to the console, so there's not much documentation yet. Basic steps are:
There's no UI for this yet, but once you create an N5 stack you can open it in arbitrary orthviews. For example, if you have a deep link URL with a parameter like
See this table for what's been tested. All will supported eventually, but each requires solving a few issues, mostly around shader generality and javascript numeric issues. There's a known bug with blocks at the stack boundary that I fixed previously but must've been lost to rebasing. |
Great, I'll try that and report back. |
|
Note to self that it looks that this may work in Firefox >= 65 since |
The problem with the downsample factors field seems to be that Django is no longer calling I've wasted too much time on this today, but will fix it at some point. |
|
Yeah, the documentation for Re: 2. If your dimensions are still such that your "natural" XYZ axes are 210, having a stack with an ZY orientation and 210 slicing dims doesn't make much sense to me -- it's not going to change any of the performance issues with the transpose slicing, and the project space is even more permuted from the "natural" axes. Note also that the reorientation of the "_zy" suffixes in the URL is applied on top of the stack-project orientation. |
Also in those screenshots it looks like the resolution in the stack's Z is squashed (while in neuroglancer it looks correct). Is it set wrong in the stack properties, or could this be a bug with the anisotropic rendering? |
I confirmed now that my conversion of my numpy array with shape [712,712,336] to n5 using a) transpose first and then save with z5py, and b) using n5gest on an image series of 712x712 files matches. So, the following are my two stack configurations for a XY and a XZ stack: Am I missing a suffix? Re: anisotropy: see stack config above. I do not have any additional attributes in the n5 file. It is squashed in CATMAID, but not in NG. |
If you create an explicit XZ stack like that (as opposed to the implicit reoriented stacks created by the "_xz" URL suffixes), you need to manually permute the properties. So the dimension should be [712, 336, 712] and the resolution should be [10, 25, 10]. Otherwise they look fine -- I didn't realize you had already fixed your z5py transposed stack. Getting rid of this manual duplication/permutation tedium is the point of the front-end reorientation. I'll add UI to make that easier to use soon. |
With permuting the dim/res, it works now as expected, including the anisotropy, great! Re the compression parameter: Would be good if they can generate their documentation themselves. Right now, I don't know how to find out what is available. Btw, with the github.com/seung-lab/compressedseg method, I get quite good compression ratios. Two more question regarding n5gest:
|
|
Almost forgot: related to label import/downsampling, you should also be aware of Philipp's great paintera-conversion-helper. The |
For reorientable stacks, add buttons to the layer controls to open reoriented stack views. Correctly generate deep link URLs for stack viewers whose primary stacks are reoriented. Post-polish on #1827.
This UI has always been cumbersome, but recently broke entirely for custom factors do to Django changes. Fix this and simplify the interaction between field and widget here. This is deceptively difficult because: - MultiValueField and MultiWidget assume list (and *sometimes* tuple) types are already decompressed. Downsample factors are a list of Integer3D, and have to be so elsewhere for use as an ArrayField. - SimpleArrayField also makes assumptions about coupling with its default widget. - The SimpleArrayFields used are of Integer3DFormField, which is another MultiValueField/MultiWidget of list type. See discussion in #1827.
You probably saw this already, but Neuroglancer now supports N5 natively. Although with some specific expectations for the file layout. @aschampion Could be nice to revisit the synchronized navigation between CATMAID and Neuroglancer you implemented at some point. Is this code in some branch? |
The is the second block of changes from #1801 following #1816.
The main new functionality of this branch is the direct rendering of volumetric image data to stack viewers via an
ImageBlockLayer
. Currently this only supports N5 volumes. Such image block layers are backed by a cache. Mutations of this cache dynamically trigger redrawing of image block layers via the event system. The cache also has hook events for eviction of mutated blocks, for write-back behavior.Changes also include:
Remaining backlog: