Skip to content

Z downsampling#36

Merged
dannda merged 11 commits intodevfrom
z-downsampling
Dec 11, 2025
Merged

Z downsampling#36
dannda merged 11 commits intodevfrom
z-downsampling

Conversation

@AlexSurtees
Copy link
Collaborator

@AlexSurtees AlexSurtees commented Dec 10, 2025

Description

Recalculate Z-index for images which are downscaled in z-index

Fixes # (issue)
Closes #16

Type of change

  • 🐛 Bug fix (non-breaking change that resolves an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • ⚡ Optimisation (non-breaking improvement to performance or efficiency)
  • 🧩 Documentation (adds or improves documentation)
  • 🧱 Maintenance (refactor, dependency update, CI/CD, etc.)
  • 🔥 Breaking change (fix or feature that causes existing functionality to change)

Checklist

  • All tests pass (eg. npm test)
  • Pre-commit hooks run successfully (eg. pre-commit run --all-files)
  • Documentation updated (if required)

@netlify
Copy link

netlify bot commented Dec 10, 2025

Deploy Preview for biongff-vizarr ready!

Name Link
🔨 Latest commit f2ad48f
🔍 Latest deploy log https://app.netlify.com/projects/biongff-vizarr/deploys/693adcc8ddc269000856fbfe
😎 Deploy Preview https://deploy-preview-36--biongff-vizarr.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Dec 10, 2025

Deploy Preview for z-downsampling ready!

Name Link
🔨 Latest commit f2ad48f
🔍 Latest deploy log https://app.netlify.com/projects/z-downsampling/deploys/693adcc884f82a0008ebb32a
😎 Deploy Preview https://deploy-preview-36--z-downsampling.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@AlexSurtees AlexSurtees assigned dannda and unassigned dannda Dec 10, 2025
@will-moore
Copy link
Collaborator

https://deploy-preview-36--z-downsampling.netlify.app/?source=https://s3.janelia.org/cellmap/jrc_ut21-1413-003/jrc_ut21-1413-003.zarr/recon-1/em/fibsem-uint8/ is working nicely as before (great to have the netlify deploy 👍 )

Also tested a couple of other images and all looks good.
A 2nd opinion on the code changes would be nice - thx.

Copy link
Collaborator

@dannda dannda left a comment

Choose a reason for hiding this comment

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

works great, thank you!

was wondering if it is any worth having originalSizeZ also as a readonly property to simplify. Adding it to the ZarrPixelSourceOptions as optional, and providing it in loadOmeMultiscales like

  const loader = data.map(
    (arr, i) =>
      new ZarrPixelSource(arr, {
        labels: axis_labels,
        tileSize,
        originalSizeZ: data[0].shape[axis_labels.indexOf("z")], // Set originalSizeZ for all ZarrPixelSource arrays so they can adjust for Z downsampling
        ...(i === 0 ? { meta: { physicalSizes } } : {}),
      }),
  );

to avoid the additional loop to set it

also ensuring the recalculation is performed only when necessary

recalculateZSelection(z: number, zIndex: number): number {
    if (this.originalSizeZ && this.originalSizeZ !== this.shape[zIndex]) {
      return Math.floor((z * this.shape[zIndex]) / this.originalSizeZ);
    }
    return z;
  }

as multiscales will have originalSizeZ but without meaning they've been downsampled (or maybe originalSizeZ should only be defined when it's actually downsampled?)

@AlexSurtees
Copy link
Collaborator Author

Thanks @dannda, I have made those changes and added some missing documentation.

@dannda dannda merged commit a2c459d into dev Dec 11, 2025
9 checks passed
@dannda dannda deleted the z-downsampling branch December 11, 2025 17:30
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.

3 participants

Comments