Skip to content
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

xarray.DataArray imagej metadata and improved axis/scale logic #247

Draft
wants to merge 41 commits into
base: main
Choose a base branch
from

Commits on Apr 14, 2023

  1. Configuration menu
    Copy the full SHA
    728619c View commit details
    Browse the repository at this point in the history
  2. Add _create_image_metadata function

    This function creates a metadata dictionary
    meant to be stored in a newly created xarray.DataArray's
    global attributes. The initial metadata created stores
    scale type of the axis (linear, enumerated or none).
    elevans committed Apr 14, 2023
    Configuration menu
    Copy the full SHA
    53d23ea View commit details
    Browse the repository at this point in the history
  3. Update _assign_axes to use "imagej" metadata

    This commit changes how the linear and enumerated axes
    are assigned. We now look for the "imagej" key in the
    xarray's global attributes. If the key is present we look for
    dim + "_axis_scale" to assign linear or enumerated axes.
    elevans committed Apr 14, 2023
    Configuration menu
    Copy the full SHA
    d5375dc View commit details
    Browse the repository at this point in the history
  4. Add metadata for all CalibratedAxis types

    Although the only calibrated axes used by nearly everyone are
    DefaultLinearAxis and EnumeratedAxis, I added metadata support
    for all CalibratedAxis types (e.g. PolynomialAxis etc...) just to
    be thorough. This metadata will be used for matching the Calibrated
    Axis type when going back to ImageJ/Java land.
    elevans committed Apr 14, 2023
    Configuration menu
    Copy the full SHA
    9adf026 View commit details
    Browse the repository at this point in the history
  5. Refactor dims._assign_axes()

    This commit refactors dims._assign_axes() to use
    imagej specific metadata attached to a given
    xarray.DataArray. If the "imagej" attribute is present
    in the xarray's global attributes then information
    like scale, origin and the type of CalibratedAxis
    (e.g. DefaultLinearAxis, EnumeratedAxis, etc...) can be used
    to assign the correct calibrated axis per given dimension
    during the net.imagej.Dataset conversion process. If the
    desired calibrated axis is not available or the axis is
    unknown then we fall back to a DefaultLinearAxis and attempt
    to get scale/origin data from the coordinates.
    elevans committed Apr 14, 2023
    Configuration menu
    Copy the full SHA
    ed8f794 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    719fe25 View commit details
    Browse the repository at this point in the history
  7. Check for "Hello" key in attributes

    The new "imagej" metadata attribute may not
    always be present (depending on the origin of
    the xarray). Checking for all attributes makes this
    kind of hard, so lets just check for the key we put in!
    elevans committed Apr 14, 2023
    Configuration menu
    Copy the full SHA
    1c0f385 View commit details
    Browse the repository at this point in the history
  8. Add case for singleton coordinates array

    If a singleton dimension is detected, assign a scale/slope
    of 1.
    elevans committed Apr 14, 2023
    Configuration menu
    Copy the full SHA
    ab2238c View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    8cf19e5 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    8ed5fa4 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    d58d255 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    fac7f33 View commit details
    Browse the repository at this point in the history
  13. Add metadata submodule

    This commit adds a new metadata submodule to handle
    all image related metadata functions (e.g. creating/updating the
    xarray.DataArray metadata attribute). All metadata related
    functions should exist in this submodule.
    elevans committed Apr 14, 2023
    Configuration menu
    Copy the full SHA
    0f175dd View commit details
    Browse the repository at this point in the history
  14. Use one-liner to fetch dict key

    Gabe suggested using a nice one-liner to get
    the CalibratedAxis from the dict instead of
    the if/else statement.
    elevans committed Apr 14, 2023
    Configuration menu
    Copy the full SHA
    61a814c View commit details
    Browse the repository at this point in the history
  15. Refactor metadata module to be more pythonic

    The axis submodule has also been streamlined to drop
    the CalibratedAxis dict and instead uses a list of Strings.
    This avoids Java import errors if a user imports the axis submodule
    before initializing ImageJ.
    elevans committed Apr 14, 2023
    Configuration menu
    Copy the full SHA
    56ca272 View commit details
    Browse the repository at this point in the history

Commits on Apr 17, 2023

  1. Configuration menu
    Copy the full SHA
    8af2bdc View commit details
    Browse the repository at this point in the history

Commits on Apr 25, 2023

  1. Configuration menu
    Copy the full SHA
    6cd7eb8 View commit details
    Browse the repository at this point in the history
  2. Improve docstring for axis functions

    The docstring wasn't clear about what kind of string to send
    to and from the calibrated axis helper functions.
    elevans committed Apr 25, 2023
    Configuration menu
    Copy the full SHA
    1956351 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    615ee25 View commit details
    Browse the repository at this point in the history

Commits on May 18, 2023

  1. Remove axis submodule and axis to str methods

    The axis data are stored in the scifio.metadata.image
    map under the "axes" key. Converting this to a string
    is unecessary.
    elevans committed May 18, 2023
    Configuration menu
    Copy the full SHA
    88f5040 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    bcfa002 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    ccee1b3 View commit details
    Browse the repository at this point in the history
  4. Use the metadata module for image metadata

    This commit uses the metadata module to create the
    metadata for both xarray and java images. Images
    can now be transferred back and forth between Java
    and Python without loosing the metadata.
    elevans committed May 18, 2023
    Configuration menu
    Copy the full SHA
    80ed95a View commit details
    Browse the repository at this point in the history
  5. Apply Black formatting

    I missed this one :(.
    elevans committed May 18, 2023
    Configuration menu
    Copy the full SHA
    28ab749 View commit details
    Browse the repository at this point in the history
  6. Add array module for xarray accessors

    This module contains the xarray accessors that
    extend the xarray.DataArrays with additional methods.
    This module must be imported before the accessors are found.
    No other code is needed to attach these accessors.
    elevans committed May 18, 2023
    Configuration menu
    Copy the full SHA
    73c5734 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    b88e513 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    205cff9 View commit details
    Browse the repository at this point in the history
  9. Add tree method to MetadataAccessor

    Once the metadata has been set call the tree()
    method to print a dict tree.
    elevans committed May 18, 2023
    Configuration menu
    Copy the full SHA
    097c907 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    94db806 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    e281221 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    f2aef68 View commit details
    Browse the repository at this point in the history

Commits on May 22, 2023

  1. Store the metadata dict in the xarray global attr

    This preserves the metadata dict between slices.
    elevans committed May 22, 2023
    Configuration menu
    Copy the full SHA
    4c5bba6 View commit details
    Browse the repository at this point in the history
  2. Add _update method to MetadataAccessor

    The _update() method runs any time the MetadataAccerssor is accessed.
    This allows us to update the metadata base by checking the state
    of the backing xarray.DataArray. So for example if dimensions change
    order or are dropped the "scifio.metadata.image" (if present) metadata
    should reflect these changes where appropriate.
    elevans committed May 22, 2023
    Configuration menu
    Copy the full SHA
    93d6ba9 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    30c4fa3 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    b8f3b6c View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    58f19b1 View commit details
    Browse the repository at this point in the history
  6. Fix metadata axes sorting

    The axes were still in ImageJ order. They now match and check
    against the dimension order of the parent xarray.DataArray.
    
    Note that the metadata must be updated manually after creation
    to update the order from Java to Python.
    elevans committed May 22, 2023
    Configuration menu
    Copy the full SHA
    3beccd9 View commit details
    Browse the repository at this point in the history
  7. Remove duplicate comment

    elevans committed May 22, 2023
    Configuration menu
    Copy the full SHA
    d0b208b View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    12da19e View commit details
    Browse the repository at this point in the history
  9. Use MetadataAccessor to assign dataset axes

    Use the MetadataAccessor class of the xarray to assign
    the correct axes. Fallback to a DefaultLinearAxis if the metadata
    is not available.
    elevans committed May 22, 2023
    Configuration menu
    Copy the full SHA
    5b611c4 View commit details
    Browse the repository at this point in the history
  10. Remove metadata module

    This is no longer in needed.
    elevans committed May 22, 2023
    Configuration menu
    Copy the full SHA
    0b1ab8b View commit details
    Browse the repository at this point in the history