Add delayed Z-dimension scaling option for 3D image multiscales #955
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a new
delay_z_scalingparameter toImage3DModel.parse()that enables delayed scaling along the Z dimension for 3D images. This is particularly useful for 3D image visualization where preserving Z resolution longer is beneficial.Problem
When creating multiscale representations of 3D images, the default behavior scales all dimensions (X, Y, Z) uniformly. For certain use cases, especially 3D rendering and visualization, it's desirable to preserve Z resolution longer by scaling only X and Y dimensions initially.
Solution
Added a new optional parameter
delay_z_scaling: bool = FalsetoImage3DModel.parse()that:min(X_size, Y_size) < original_Z_sizeExample Usage
Resulting Multiscale Structure
For the example data
[12, 194, 3181, 4045](C, Z, Y, X):[12, 194, 3181, 4045](original)[12, 194, Y/2, X/2](only X,Y scaled, Z preserved)[12, Z/2, Y/2, X/2](all dimensions scaled)Z scaling begins when
min(X,Y) = 99 < original_Z = 194.Implementation Details
parse()method inImage3DModelclass_compute_delayed_z_scale_factors()helper method with the scaling algorithmscale_factorsis provided alongsidedelay_z_scaling=TrueTesting
Added tests that verify:
delay_z_scaling=FalseFixes #954.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.