Skip to content

Dataset dimension/axis label renaming #322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 31, 2025
Merged

Dataset dimension/axis label renaming #322

merged 6 commits into from
Mar 31, 2025

Conversation

elevans
Copy link
Member

@elevans elevans commented Mar 27, 2025

This PR address issue #304 by adding support for dimension label renaming on net.imagej.Dataset objects via the to_dataset() method (with dim order hints). Below is a list of what this PR brings:

  • Added dimension label renaming for net.imagej.Dataset
    • This works for both DefaultLinearAxis and EnumeratedAxis type.
  • Updated the Dataset conversion tests to test dim renaming.
  • Added a new section to notebook 06-Working-with-images, 6.11, demonstrating how to use the renaming features.

This commit adds support for dimension renaming with net.imagej.Dataset
objects. The _rename_dataset_dims() function matches the
_rename_xarray_dims() function in that it *only* renames the dimensions
of the input data. It does not transpose the data array or modify the
coordinates/calibration. Users should use transpose and permute with
their respective xarray and dataset objects.

The _rename_dataset_dims() function gets the axis type from new dim
order sequencs and creates a new axis with the old scale and origin
values, preserving the axis coordinates. This implementation only
supports DefaultLinearAxis.
Instead of creating new DefaultLinearAxis or EnumeratedAxis, simply set
the axis type on the existing axes. Both DefaultLinearAxis and
EnumeratedAxis both inherit net.imagej.TypedAxis.
This commit makes updates the dataset to dataset conversion tests with
new and expected dimension label outcomes.
This commit adds a new section to the Working-with-Images notebook
demonstrating how to rename the dimension labels on both Python and Java
images. Note that I added this section as 6.11 and incremented all
following heading numbers by 1.
@elevans elevans requested review from ctrueden and gselzer March 27, 2025 17:54
Copy link
Contributor

@gselzer gselzer left a comment

Choose a reason for hiding this comment

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

Looks great!

Unfortunately, the huge diffs in the images prevented me from diving too deeply into your notebook changes, however I read over the new section 3.11 and it looks good to me!

@elevans elevans merged commit b9a28c5 into main Mar 31, 2025
8 checks passed
@ctrueden ctrueden deleted the dataset-dim-renaming branch May 24, 2025 15:17
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.

2 participants