google / neuroglancer

WebGL-based viewer for volumetric data
Apache License 2.0
1.08k stars 295 forks source link

Layer limits on Neuroglancer #286

Open manoaman opened 3 years ago

manoaman commented 3 years ago

Hi,

Is there a limit to number of layers loaded simultaneously in Neuroglancer? For example, has there been a use case where 10~20 layers of volumetric or 2D image slices, identical in sizes, are overlayed one another?

Thanks, m

jbms commented 3 years ago

There is no specific limit, but depending on how they are chunked and the resolution/zoom level you may run into browser memory limits if you are attempting to display all of them simultaneously.

If your chunks are 2d , meaning all but 2 dimensions have a size of 1, and appropriately aligned to your cross-section views, you will need much less memory than if you use 3d or higher-d chunks.

You may also find that the layer bar takes up too much space --- that could probably be fixed easily enough. The memory limits will be harder to get around.

manoaman commented 3 years ago

Hi jbms,

Somewhat related to this overlay question, I was assuming that with the current version of the Neuroglancer, I can overlay a segmentation layer and a skeleton layer if they are positioned correctly. In other words, registered correctly. And I was wondering if you could advise me on a visualization which involves nrrd (segmentations) files and swc (skeletons) files which I believe they can be visualized on the Neuroglancer platform. I suppose they can be overlayed once converted into precomputed format. Maybe certain features are already there and I may have overlooked, and I was hoping you could correct me if I'm wrong. Here are questions I was hoping you could advise me if you know.

Questions:

  1. Can the Neuroglancer overlay Skeleton(s) layer(s) on a collection of segmentation mesh objects?

  2. Would it be possible to change the opacity levels of the segmented mesh objects so that the skeleton can be identified inside the mesh?

  3. Converting a swc to a precomputed file format can be done with CloudVolume. However, would it make more sense to prepare tiff or a binary image instead of individual swc files? And then chunk the files into precomputed format?

  4. Is there an open source software which takes a collection of swc files and converts them into a tiff stack or some other formats so that it can later processed from precomputed format? (Maybe an off topic here, sorry.)

  5. Perhaps swc files are not suitable for the visualization with mesh objects. Should I find an approach to convert them into segmentations of a tiff stack or a binary image instead? (Maybe an off topic here, sorry.)

  6. Is there a good public example of an overlay of a segmentation and a skeleton layers?

I'm still researching into swc formats and trying to figure out what data formats are better suited in visualizing on the Neuroglancer platform.

Thank you for your time and advise! -m


swc: http://www.neuronland.org/NLMorphologyConverter/MorphologyFormats/SWC/Spec.html nrrd: https://en.wikipedia.org/wiki/Nrrd#:~:text=Nrrd%20(%22nearly%20raw%20raster%20data,visualization%20and%20image%20processing%20applications.

jbms commented 3 years ago

Yes you can overlay skeletons over segmentation meshes and reduce opacity of meshes so that you can see skeletons inside.

Here is an example

If you want to display skeletons, then converting to precomputed format from swc is probably the simplest thing to do. I don't see how converting to tiff and then presumably volumetric precomputed format would help there.

manoaman commented 3 years ago

Thank you for the example jbms! I will have a look at it.

tischi commented 2 years ago

@jbms

Somewhat related to that:

jbms commented 2 years ago

Neuroglancer can display 2d cross sections of arbitrary nd data sources, including 4d xyzt volumes. You can display 2d and 3d sources overlaid or side by side. There is also experimental 3d volume rendering support.

manoaman commented 2 years ago

Hello @jbms

Does Neuroglancer support showing sections in 3d layout? Currently, I don't see a way to check "Sections" or use a shortcut "s: toggle-show-sections" to make three xyz image planes appear. I was asked about a use case where the user only wants to look at the lower-left of the 4panel layout and view the segmentation on an image in a single large panel. Will the workaround be using either xy-3d, yz-3d, or xz-3d layout?

jbms commented 2 years ago

Normally, when showing cross sections in the 3d view, the cross sections are exactly what is shown in the other cross section panels.

Currently, there isn't a UI option for showing cross sections in the 3d view when the cross section panels aren't shown, but it can be enabled through the JSON state / Python API:

https://github.com/google/neuroglancer/blob/master/python/examples/example_cross_section.py

manoaman commented 2 years ago

I tried adding something like the following segment from the GUI "{}" but the "cross_sections" seems to get ignored and disappears. Could I be doing wrong?

   "layout": "3d",
   "cross_sections":{
      "a":{
         "width":1000,
         "height":1000,
         "position":[
            2914.478759765625,
            3336.535400390625,
            11248.5
         ],
         "orientation":[
            0.6853626370429993,
            0.07270946353673935,
            0.11450875550508499,
            0.7154572606086731
         ],
         "scale":6.491028727518084
      }
   }
jbms commented 2 years ago

It should be:

"layout": {"type": "3d", "crossSections": {"a": {"width": 1000, "height": 1000}}}

https://neuroglancer-demo.appspot.com/#!%7B%22dimensions%22:%7B%22x%22:%5B8e-9%2C%22m%22%5D%2C%22y%22:%5B8e-9%2C%22m%22%5D%2C%22z%22:%5B8e-9%2C%22m%22%5D%7D%2C%22position%22:%5B3132.5%2C3321.5%2C3954.5%5D%2C%22crossSectionScale%22:1%2C%22projectionOrientation%22:%5B0.2876532971858978%2C0.277201384305954%2C0.022550947964191437%2C0.91646409034729%5D%2C%22projectionScale%22:2485.957925324715%2C%22layers%22:%5B%7B%22type%22:%22image%22%2C%22source%22:%22precomputed://gs://neuroglancer-public-data/flyem_fib-25/image%22%2C%22tab%22:%22source%22%2C%22name%22:%22image%22%7D%5D%2C%22selectedLayer%22:%7B%22visible%22:true%2C%22layer%22:%22image%22%7D%2C%22layout%22:%7B%22type%22:%223d%22%2C%22crossSections%22:%7B%22a%22:%7B%7D%7D%7D%7D

If you want to specify position, orientation, or scale, they should be:

"position": {"link": "unlinked", "value": [3000, 3000, 4000]}

In place of "unlinked" you can also specify "relative"

manoaman commented 2 years ago

How do I make yz and xz sections appear also? Do I need to specify other than b or c?

"layout": {"type": "3d", "crossSections": {"a": {"width": 1000, "height": 1000},"b": {"width": 1000, "height": 1000},"c": {"width": 1000, "height": 1000}}}
jbms commented 2 years ago

You need to specify an orientation as well.

manoaman commented 2 years ago

I tried both inside and outside the "crossSections", and both json reverts back to "4panel" layout. Should the orientation specified differently?

  "layout": {
    "type": "3d",
    "crossSections": {
      "a": {
        "position": {
          "link": "unlinked",
          "value": [
            0,
            0,
            0
          ]
        },
        "orientation": [1,0,0,0]        
      },
      "b": {
        "position": {
          "link": "unlinked",
          "value": [
            0,
            0,
            0
          ]
        },
        "orientation": [0,1,0,0]        
      },
      "c": {
        "position": {
          "link": "unlinked",
          "value": [
            0,
            0,
            0
          ]
        }
      },
      "orientation": [0,0,1,0]      
    }
  }
    "layout": {
    "type": "3d",
    "crossSections": {
      "a": {
        "position": {
          "link": "unlinked",
          "value": [
            5848,
            4349,
            7823
          ]
        },
        "orientation": [1,0,0,0]
      }
    }
  }
jbms commented 1 year ago

The orientation works the same as position, so you also need to have nested link and value members.

manoaman commented 1 year ago

Agh, I didn't think about that. Figured it out. Much appreciated @jbms !!

  "layout": {
    "type": "3d",
    "crossSections": {
      "a": {
        "position": {
          "link": "unlinked",
          "value": [0,0,0]
        },
        "orientation": {
          "link": "relative",
          "value": [1,1,0,0]
        }        
      },
      "b": {
        "position": {
          "link": "unlinked",
          "value": [0,0,0]
        },
        "orientation": {
          "link": "relative",
          "value": [0,1,1,0]
        }        
      },
      "c": {
        "position": {
          "link": "unlinked",
          "value": [0,0,0]
        },
        "orientation": {
          "link": "unlinked",
          "value": [1,0,1,0]
        }              
      }
    }
  }
manoaman commented 1 year ago

Could this feature experimental? I see occasionally one cross section (usually "c" in my case), gets disoriented or removed from switching layouts, zoom in/out or navigation on x,y,z from the upper left navigator bars. Not quite sure what's triggering to reset "orientation" for "c" at times.

jbms commented 1 year ago

It is possible there is a bug --- I don't think that feature has been used heavily.

If you can figure out how to reliably reproduce the issue that would help in resolving it.

manoaman commented 1 year ago

My original intention was to position three planes in the center of axis lines. The obvious issue that I see is with the position of the "c" plane, and in some cases showing multiple "c"? planes. Here are the steps I reproduced on the demo site.

  1. Apply the following 3d layout JSON from GUI.
  "layout": {
    "type": "3d",
    "crossSections": {
      "a": {
        "position": {
          "link": "unlinked",
          "value": [0,0,0]
        },
        "orientation": {
          "link": "unlinked",
          "value": [1,1,0,0]
        }        
      },
      "b": {
        "position": {
          "link": "unlinked",
          "value": [0,0,0]
        },
        "orientation": {
          "link": "unlinked",
          "value": [0,1,1,0]
        }        
      },
      "c": {
        "position": {
          "link": "unlinked",
          "value": [0,0,0]
        },
        "orientation": {
          "link": "unlinked",
          "value": [1,0,1,0]
        }              
      }
    }
  }
  1. JSON get updated except "c" position values which displays "c" plane in unexpected position.
Screenshot 2022-11-07 at 9 21 23 AM
  "layout": {
    "type": "3d",
    "crossSections": {
      "a": {
        "position": {
          "link": "unlinked",
          "value": [
            3132.5,
            3321.5,
            3954.5
          ]
        },
        "orientation": {
          "link": "relative",
          "value": [
            0.7071067690849304,
            0.7071067690849304,
            0,
            0
          ]
        }
      },
      "b": {
        "position": {
          "link": "unlinked",
          "value": [
            3132.5,
            3321.5,
            3954.5
          ]
        },
        "orientation": {
          "link": "relative",
          "value": [
            0,
            0.7071067690849304,
            0.7071067690849304,
            0
          ]
        }
      },
      "c": {
        "position": {
          "link": "unlinked",
          "value": [
            0,
            0,
            0
          ]
        },
        "orientation": {
          "link": "unlinked",
          "value": [
            0.7071067690849304,
            0,
            0.7071067690849304,
            0
          ]
        }
      }
    }
  }
  1. Switching to 4d panel layout, zoom out, and toggling 3d panel and 4d panel layout back and forth shows one "c" plane positioned outside from the center, while showing another "c" plane in the center of the axis lines.
Screenshot 2022-11-07 at 9 22 15 AM
{
  "dimensions": {
    "x": [
      8e-9,
      "m"
    ],
    "y": [
      8e-9,
      "m"
    ],
    "z": [
      8e-9,
      "m"
    ]
  },
  "position": [
    3132.5,
    3321.5,
    3954.5
  ],
  "crossSectionScale": 4,
  "projectionOrientation": [
    -0.10855773091316223,
    0.18556760251522064,
    0.11640383303165436,
    0.9696546196937561
  ],
  "projectionScale": 12151.283495145528,
  "layers": [
    {
      "type": "image",
      "source": "precomputed://gs://neuroglancer-public-data/flyem_fib-25/image",
      "tab": "source",
      "name": "image"
    }
  ],
  "selectedLayer": {
    "visible": true,
    "layer": "image"
  },
  "layout": {
    "type": "4panel",
    "crossSections": {
      "a": {
        "position": {
          "link": "unlinked",
          "value": [
            3132.5,
            3321.5,
            3954.5
          ]
        },
        "orientation": {
          "link": "unlinked",
          "value": [
            0.7071067690849304,
            0.7071067690849304,
            0,
            0
          ]
        }
      },
      "b": {
        "position": {
          "link": "unlinked",
          "value": [
            3132.5,
            3321.5,
            3954.5
          ]
        },
        "orientation": {
          "link": "unlinked",
          "value": [
            0,
            0.7071067690849304,
            0.7071067690849304,
            0
          ]
        }
      },
      "c": {
        "position": {
          "link": "unlinked",
          "value": [
            0,
            0,
            0
          ]
        },
        "orientation": {
          "link": "unlinked",
          "value": [
            0.7071067690849304,
            0,
            0.7071067690849304,
            0
          ]
        }
      }
    }
  }
}