Code Monkey home page Code Monkey logo

Comments (8)

jbms avatar jbms commented on May 30, 2024

The extra single quote (to make it a local dimension) is added here:

I didn't anticipate that someone would include the special neuroglancer dimension indicators as part of the OME axis names, but I suppose it would make sense to not append a single quote if the dimension name already ends in ' or ^.

from neuroglancer.

danielsf avatar danielsf commented on May 30, 2024

My goal was to be able to programmatically create a URL that "just worked" (i.e. users could open the URL and see the RGB image without having to do any work to flag the channel axis as a channel axis). If there is another way to do that without changing the neuroglancer code, I'm open to it. Adding the ^ to the channel axis name was what I came up with after googling my problem. Granted, I was in a "fast-and-dirty-prototype" state of mind when doing this, so I might have missed something.

from neuroglancer.

danielsf avatar danielsf commented on May 30, 2024

Why is a ' appended to the name of the channel axis. Shouldn't it be a ^? Base on my reading of this

https://github.com/google/neuroglancer/blob/master/src/neuroglancer/coordinate_transform.ts#L636-L638

it seems like channel dimensions are supposed to end with ^ (though I admit there may be something I am not understanding).

As an operational demonstration of my difficulty, this shader code

#uicontrol invlerp normalized(range=[0, 255], channel=2)
void main() {
  emitGrayscale(normalized());
}

doesn't work if the channel name ends with ', but does work if I manually hack the channel name to end with ^.

from neuroglancer.

jbms avatar jbms commented on May 30, 2024

If it ends with ', then it is treated as a "local dimension", meaning the layer tab shows a selector for that dimension, and the shader will only have access to the single selected position. However, you can duplicate the layer (probably with a different shader), select a different position for that dimension in the duplicate, and then blend them together.

If it ends with ^, then it is treated as a "channel dimension", which means the shader can access multiple/all positions along that dimension. Neuroglancer currently does not support channel dimensions that are chunked, i.e. where the chunk size along that dimension is not equal to the total extent of that dimension.

In your example where you are using the invlerp control to select just a single channel, you could accomplish the same thing by making it a local dimension rather than a channel dimension. The only case where a channel dimension is needed is if you need a single shader to access more than one channel.

from neuroglancer.

jbms avatar jbms commented on May 30, 2024

It is indeed a bit arbitrary whether Neuroglancer makes OME-zarr "channel" dimensions into local dimensions or channel dimensions by default. I decided to make them local dimensions by default because of the limitation on chunking. Changing the name as you have done is in fact the intended mechanism to make it into a channel dimension if that is desired.

from neuroglancer.

danielsf avatar danielsf commented on May 30, 2024

In trying to be as minimally illustrative as possible, I was too simple in my example. My end goal is to have a single shader access all three channels so that I can display an RGB image (and possibly also adjust their relative intensities). Something like

#uicontrol invlerp normalized_r(range=[0, 255.0], channel=0)
#uicontrol invlerp normalized_g(range=[0, 255.0], channel=1)
#uicontrol invlerp normalized_b(range=[0, 255.0], channel=2)

void main() {
  float r = normalized_r();
  float g = normalized_g();
  float b = normalized_b();
  emitRGB(vec3(r,g,b));
}

Again: this works if the channel dimension is named c^, but not if it is named c', which is what the neuroglancer code seems to produce by default.

I admit that changing the one character in the name of the channel dimension is not that difficult, but I am trying to produce a tool that will "just work" for a non-technical user, and I'd rather not ask them to fix the column name unless I absolutely have to.

Is there a way to get shader RGB shader code to work with the current convention?

from neuroglancer.

jbms avatar jbms commented on May 30, 2024

You could also accomplish this by having a separate layer for each channel (using c') and enable additive blending mode.

By "produce a tool", can you clarify what you mean? Is your tool generating a Neuroglancer URL/state for the user, that includes this RGB shader? In that case your tool could just rename the dimension as part of the Neuroglancer state.

from neuroglancer.

danielsf avatar danielsf commented on May 30, 2024

Yes. By "produce a tool" I mean "write a script that creates a URL with all the configs necessary to visualize our data."

I did not realize I could rename the dimension in the JSON config. Thank you. I am now unblocked.

from neuroglancer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.