google / neuroglancer

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

Spatial dimensions, xy, is rendering in the 'zy' plane instead of the 'xy' plane when using the zarr format #523

Closed mikejhuang closed 8 months ago

mikejhuang commented 8 months ago

The 'xy' dimensions are being rendered on the 'zy' plane in neuroglancer. Seems that neuroglancer maps the first two spatial dimensions to x, y. However, zarr expects the dimension ordering to be (c, z, y, x). In this case, z, y, x are the three spatial dimensions and z, y becomes the first two dimensions mapped to the 'xy' plane and x, y is mapped to the 'zy' plane.

I configured neuroglancer with the ordering of the zarr.

  "dimensions": {
    "z": [
      0.001,
      "m"
    ],
    "y": [
      0.00002,
      "m"
    ],
    "x": [
      0.00002,
      "m"
    ]
  },

and with each layer

           "outputDimensions": {
            "c^": [
              1,
              ""
            ],
            "z": [
              0.001,
              "m"
            ],
            "y": [
              0.00002,
              "m"
            ],
            "x": [
              0.00002,
              "m"
            ]
          }

Is there a way to configure neuroglancer to recognize this ordering of the dimensions when rendering in the planes?

Here's an example

jbms commented 8 months ago

Neuroglancer by default maps the first 3 global dimensions to be the "display dimensions". You can drag and drop them to reorder them at the top left of the window which will affect the display dimensions. Or you can explicitly override the display dimensions (click on the vertical red/green/blue "z", "y", "x" at left side of the cross-section panel and type in the desired dimension names).

As far as doing this automatically for OME-zarr, there is currently no way to achieve that with Neuroglancer. It can be implemented but will require a mechanism to change how data source dimensions are incorporated into the global dimension list.

mikejhuang commented 8 months ago

Neuroglancer by default maps the first 3 global dimensions to be the "display dimensions". You can drag and drop them to reorder them at the top left of the window which will affect the display dimensions. Or you can explicitly override the display dimensions (click on the vertical red/green/blue "z", "y", "x" at left side of the cross-section panel and type in the desired dimension names).

As far as doing this automatically for OME-zarr, there is currently no way to achieve that with Neuroglancer. It can be implemented but will require a mechanism to change how data source dimensions are incorporated into the global dimension list.

That worked, thanks. As for doing it automatically, the drag and drop reorder changed the dimensions configuration to:

  "dimensions": {
    "x": [
      0.00002,
      "m"
    ],
    "y": [
      0.00002,
      "m"
    ],
    "z": [
      0.001,
      "m"
    ]
  }

So it seems that this ordering can be set this way to do it automatically.

jbms commented 8 months ago

To be clear, you can certainly configure it in the Neuroglancer state, since everything is specified in the Neuroglancer state. What you can't do currently is generate an OME-zarr dataset, with dimensions ordered as c, z, y, x, where just adding the dataset to Neuroglancer interactively will result in the desired x, y, z global dimension order.