Skip to content

Conversation

@allison-truhlar
Copy link
Collaborator

Clickup id: 86acggp4k

This PR adds support for detecting all available Zarr metadata versions in a Zarr directory and displaying this information in the Zarr metadata table. In addition, a version suffix is added to Neuroglancer links to specify what version metadata to use. In cases where both v2 and v3 metadata are available, the Neuroglancer source is set to zarr3.

Example dual Zarr path for testing: /groups/liconn/liconn/data_internal/dual_metadata_test/20250903_FlyID08-01_2ndGel_10%_0.8%_1hr_Atto488_40XW_003_dual.zarr

Key changes

  • src/queries/zarrQueries.ts: Added detectZarrVersions() function to identify available versions from file list
  • src/hooks/useZarrMetadata.ts: sets effective Zarr version (defaults to zarr3 when both version 2 and 3 metadata are available) and generates version-specific Neuroglancer URLs. Also fixed a bug introduced in the migration to Tanstack query where the layer variable wasn't set to the default "image" in cases where a thumbnail wasn't available.
  • src/omezarr-helper.ts: Updated getNeuroglancerSource() to accept version parameter and generate appropriate source URL (|zarr2: or |zarr3:)
  • src/components/ui/BrowsePage/ZarrMetadataTable.tsx: Display available versions in metadata table

Tests

  • Component test: ZarrMetadataTable tests for version display behavior. This also required adding MSW handlers for multiple Zarr version scenarios and a mock helper to bypass the omezarr-helper.ts module
  • Unit tests: Version detection logic and Neuroglancer source URL generation

- during the refactor, this was incorrectly changed such that if thumbnailSrc didn't exist, layer was set to null. This resulted in Neuroglancer state being generated without a layer type and the user needing to manually select a image in the neuroglancer interface
Copy link
Contributor

@mkitti mkitti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me. I will see if I can test it later.

Copy link
Member

@krokicki krokicki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I just made a few code structure suggestions.

* Detects which Zarr versions are supported by checking for version-specific marker files.
* @returns Array of supported versions: ['v2'], ['v3'], or ['v2', 'v3']
*/
export function detectZarrVersions(fileNames: string[]): ('v2' | 'v3')[] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice. Can it also replace uses of isZarrDirectory, which looks like it now duplicates a subset of this logic?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made this change in commits 4c8e7f3 and 56f4094

const availableVersions = detectZarrVersions(fileNames);

// Default to Zarr v3 when available
if (availableVersions.includes('v3') && zarrJsonFile) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These if/else blocks are now duplicating the logic that checks for each file. I would refactor this slightly so that we first check the availableVersions, and if v3 is available only then get the zarr.json file. In the else block we can deal with the v2 uses cases in the same way.

It's always better to cover all if/else conditions when possible, that makes the code easier to follow and it's less likely to have hidden bugs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made this change in commit 2e5d6e6

@allison-truhlar allison-truhlar merged commit 97b110d into main Nov 20, 2025
7 checks passed
@allison-truhlar allison-truhlar deleted the simplified-dual-zarrs branch November 20, 2025 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants