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

Add support for ome-ngff-v0.4 #42

Closed
constantinpape opened this issue Nov 25, 2021 · 34 comments
Closed

Add support for ome-ngff-v0.4 #42

constantinpape opened this issue Nov 25, 2021 · 34 comments
Assignees

Comments

@constantinpape
Copy link
Collaborator

See discussions in
ome/ngff#57
and example data at
https://s3.embl.de/i2k-2020/ngff-example-data/v0.4

@constantinpape
Copy link
Collaborator Author

Observation from @KateMoreva the version in the example files is still 0.3, I need to fix this.

@constantinpape
Copy link
Collaborator Author

@K-Meech will look into writing the new version.
For reading we still want to support 0.3; for writing not so important.
We can sort of drop the ome.zarr.xml with this addition.

@constantinpape
Copy link
Collaborator Author

For validating: json validation: ome/ngff#69 (comment)
ome-zarr-py: https://github.com/ome/ome-zarr-py

@constantinpape
Copy link
Collaborator Author

@KateMoreva I checked the version of the example files I shared (https://s3.embl.de/i2k-2020/ngff-example-data/v0.4), but I think they have the correct version:

$ wget https://s3.embl.de/i2k-2020/ngff-example-data/v0.4/cyx.ome.zarr/.zattrs -O cyx-attrs
$ cat cyx-attrs | grep version
            "version": "0.4"

Could you please double check this and describe the issue with the version number more concretely if you still have it?

@K-Meech
Copy link
Contributor

K-Meech commented Nov 26, 2021

@constantinpape Do you also have these files locally somewhere on the group shares?

@KateMoreva
Copy link
Collaborator

@KateMoreva I checked the version of the example files I shared (https://s3.embl.de/i2k-2020/ngff-example-data/v0.4), but I think they have the correct version:

$ wget https://s3.embl.de/i2k-2020/ngff-example-data/v0.4/cyx.ome.zarr/.zattrs -O cyx-attrs
$ cat cyx-attrs | grep version
            "version": "0.4"

Could you please double check this and describe the issue with the version number more concretely if you still have it?

Oh, yes, the example files have v 0.4, I meant the PR file: https://github.com/ome/ngff/pull/57/files#diff-ffe6148e5d9f47acc4337bb319ed4503a810214933e51f5f3e46a227b10e3fcdL241
Sorry for the confusion :(

@constantinpape
Copy link
Collaborator Author

@KateMoreva

Oh, yes, the example files have v 0.4, I meant the PR file: https://github.com/ome/ngff/pull/57/files#diff-ffe6148e5d9f47acc4337bb319ed4503a810214933e51f5f3e46a227b10e3fcdL241

Oh, I see. We are working on some mechanism to bump all the version strings automatically, so that's why it's still at 0.3 there. Just ignore that, but Indeed it can be confusing.

@K-Meech

@constantinpape Do you also have these files locally somewhere on the group shares?

/g/kreshuk/pape/Work/mobie/ngff/ome-ngff-prototypes/single_image/v0.4
Let me know if you don't have access to it, then I can copy it somewhere else.

@KateMoreva
Copy link
Collaborator

/g/kreshuk/pape/Work/mobie/ngff/ome-ngff-prototypes/single_image/v0.4 Let me know if you don't have access to it, then I can copy it somewhere else.

Thank you for this info! It will be useful for file system reading.

@K-Meech
Copy link
Contributor

K-Meech commented Jan 27, 2022

So I'm starting to look into updating the writers for v0.4 ome-zarr. @tischi @constantinpape Do we want to keep the ability to write 0.3? Or just shift everything to 0.4?

@tischi
Copy link
Collaborator

tischi commented Jan 27, 2022

I guess as long as we can still read 0.3, I would be fine with only writing to the latest version (that we can read).

@constantinpape
Copy link
Collaborator Author

So I'm starting to look into updating the writers for v0.4 ome-zarr. @tischi @constantinpape Do we want to keep the ability to write 0.3? Or just shift everything to 0.4?

I agree; it's enough if we write the latest version (i.e. 0.4 now), but we need to keep support for reading older versions.
Just to note: there are still some small changes for 0.4 pending and also reading does not fully work yet. I will continue working on this now and will ping you once there are updates.

@tischi
Copy link
Collaborator

tischi commented Jan 27, 2022

@constantinpape @KateMoreva @K-Meech
Where in our code do we check the OME.Zarr version when reading?
Using the current develop branch I am getting an error reading older zarr versions. The error is here:

        zarrAxes = n5 instanceof N5OmeZarrReader ? ((N5OmeZarrReader) n5).getAxes() :
                n5 instanceof N5S3OmeZarrReader ? ((N5S3OmeZarrReader) n5).getAxes() : ZarrAxes.NOT_SPECIFIED;

        long nC = 1;
        if (attributes.getNumDimensions() > 4) {
            nC = attributes.getDimensions()[C];
        }
        if (zarrAxes.is4DWithChannels()) {
            nC = attributes.getDimensions()[C];
        }

...because zarrAxes is null...

Maybe we cannot read old OME.zarr versions at the moment?

@KateMoreva
Copy link
Collaborator

@constantinpape @KateMoreva @K-Meech Where in our code do we check the OME.Zarr version when reading? Using the current develop branch I am getting an error reading older zarr versions. The error is here:

        zarrAxes = n5 instanceof N5OmeZarrReader ? ((N5OmeZarrReader) n5).getAxes() :
                n5 instanceof N5S3OmeZarrReader ? ((N5S3OmeZarrReader) n5).getAxes() : ZarrAxes.NOT_SPECIFIED;

        long nC = 1;
        if (attributes.getNumDimensions() > 4) {
            nC = attributes.getDimensions()[C];
        }
        if (zarrAxes.is4DWithChannels()) {
            nC = attributes.getDimensions()[C];
        }

...because zarrAxes is null...

Maybe we cannot read old OME.zarr versions at the moment?

We can read v3, I'll fix the older variants now.

@tischi
Copy link
Collaborator

tischi commented Jan 27, 2022

Hm, I I think I am getting the error reading from: "version": "0.3.0"

Examples:

-bash-4.2$ cat ./Sample3_Rafael_LM_crop_5_Trans.ome.zarr/.zattrs 
{
  "multiscales": [
    {
      "axes": [
        "z",
        "y",
        "x"
      ],
      "datasets": [
        {
          "path": "s0"
        },
        {
          "path": "s1"
        },
        {
          "path": "s2"
        },
        {
          "path": "s3"
        },
        {
          "path": "s4"
        },
        {
          "path": "s5"
        },
        {
          "path": "s6"
        }
      ],
      "name": "Sample3_Rafael_LM_crop_5_Trans",
      "type": "Average",
      "version": "0.3.0"
    }
  ]

and

-bash-4.2$ cat ./Sample3_Rafael_LM_crop_5_Trans.ome.zarr/s0/.zarray 
{
  "shape": [
    1,
    1402,
    8984
  ],
  "chunks": [
    1,
    512,
    512
  ],
  "fill_value": 0,
  "dtype": ">u2",
  "filters": [],
  "dimension_separator": "/",
  "zarr_format": 2,
  "compressor": {
    "id": "gzip",
    "level": -1
  },
  "order": "C"
}

Note that I changed now according to mobie/mobie-viewer-fiji#572:

"fill_value": "0",. to "fill_value": 0,

Could that be the issue?

@tischi
Copy link
Collaborator

tischi commented Jan 27, 2022

I think that's wrong?

public class ZArrayAttributes {

protected static final String zarrFormatKey = "zarr_format";
    protected static final String shapeKey = "shape";
    protected static final String chunksKey = "chunks";
    protected static final String dTypeKey = "dtype";
    protected static final String compressorKey = "compressor";
    protected static final String fillValueKey = "fill_value";
    protected static final String orderKey = "order";
    protected static final String filtersKey = "filters";

    private final int zarr_format;
    private final long[] shape;
    private final int[] chunks;
    private final DType dtype;
    private final ZarrCompressor compressor;
    private final String fill_value;   // <----- MUST be something numeric... double?
    private final char order;
    private final List<Filter> filters = new ArrayList<>();

@constantinpape
Copy link
Collaborator Author

@tischi @KateMoreva can we please add tests to mobie-io that check that the old ome.zarr versions can still be read?

@KateMoreva
Copy link
Collaborator

I think the problem was with reading the multiscales attribute.

@KateMoreva
Copy link
Collaborator

@tischi, could you please try again? Note that you need new files from 1.2.1-SNAPSHOT.

@tischi
Copy link
Collaborator

tischi commented Jan 27, 2022

@KateMoreva I did a git pull from develop, but it still is private final String fill_value;
I think this will not work, because it should be a number, right @constantinpape?

@constantinpape
Copy link
Collaborator Author

@KateMoreva I did a git pull from develop, but it still is private final String fill_value;
I think this will not work, because it should be a number, right @constantinpape?

Yeah, fill value should be a number. (That's the short version, ideally it should be a union type.) This seems to be an issue that we inherit from what n5-zarr is doing. I am not sure if it's a good idea to fix it here without looking into this more closely.
@tischi for now I think you shouldn't replace the string in the fill value line; it's most likely unrelated to the issue you are seeing with the boundary chunks and it just came up because we tried to read the data in python. (This should be fixed of course, but I want to know first why this was a string in the first place, it might be some poor attempt to deal with union types and thus necessary. Sorry, this is a bit too complicated to explain here right now, I would need a zoom to explain the underlying issue.)

@KateMoreva
Copy link
Collaborator

@tischi, could you please write the full path to the dataset here? I want to check changes that may fix this problem.

@tischi
Copy link
Collaborator

tischi commented Jan 27, 2022

/g/cba/exchange/kimberly/SXAA03648.ome.zarr

@tischi
Copy link
Collaborator

tischi commented Jan 27, 2022

It works now @KateMoreva!

@KateMoreva
Copy link
Collaborator

@KateMoreva I did a git pull from develop, but it still is private final String fill_value;
I think this will not work, because it should be a number, right @constantinpape?

Yeah, fill value should be a number. (That's the short version, ideally it should be a union type.) This seems to be an issue that we inherit from what n5-zarr is doing. I am not sure if it's a good idea to fix it here without looking into this more closely. @tischi for now I think you shouldn't replace the string in the fill value line; it's most likely unrelated to the issue you are seeing with the boundary chunks and it just came up because we tried to read the data in python. (This should be fixed of course, but I want to know first why this was a string in the first place, it might be some poor attempt to deal with union types and thus necessary. Sorry, this is a bit too complicated to explain here right now, I would need a zoom to explain the underlying issue.)

I opened the PR for a future fix of fill_value #53

@tischi
Copy link
Collaborator

tischi commented Jan 27, 2022

(the bug with the boundary chucks is still there though, see mobie/mobie-viewer-fiji#572).

@constantinpape
Copy link
Collaborator Author

(the bug with the boundary chucks is still there though, see mobie/mobie-viewer-fiji#572).

Yes, as I said already: this bug is almost certainly unrelated to the fill_value. I believe that this is likely a problem when reading the boundary chunks; see my latest comments in mobie/mobie-viewer-fiji#572. (And let's keep the discussion about the boundary chunk issue there).

@constantinpape
Copy link
Collaborator Author

xref #52 (comment)

@constantinpape
Copy link
Collaborator Author

We are making progress!

Reading ome.zarr v0.4 works now, except for multiple images per zarr, see #63.

@K-Meech how is the status with the writer, is this working for ome.zarr v0.4 ("final" version) already?

@K-Meech
Copy link
Contributor

K-Meech commented Feb 14, 2022

@constantinpape - the writers don't support v0.4 yet. I was waiting for the v0.4 readers to be finished first, so it would be easier to test the results from the writers. I'll get on this now! Hopefully I'll have time this week.

@K-Meech
Copy link
Contributor

K-Meech commented Feb 14, 2022

@constantinpape - I'm just having a quick look through the v0.4 example data. I'm a bit unsure of the metadata for the volumes with time. For these, you have one coordinateTransformations underneath the axes, then one for each dataset.

E.g.

"coordinateTransformations": [
                {
                    "scale": [
                        10,
                        1,
                        1,
                        1,
                        1
                    ],
                    "type": "scale"
                }
            ],

and then for the first dataset:

"coordinateTransformations": [
                        {
                            "scale": [
                                1,
                                1,
                                1.0,
                                0.65,
                                0.65
                            ],
                            "type": "scale"
                        }
                    ],
                    "path": "s0"

If I left out the first one, would it be equivalent to put 10 for the time scale in every dataset? Or is it doing something different?

@constantinpape
Copy link
Collaborator Author

If I left out the first one, would it be equivalent to put 10 for the time scale in every dataset? Or is it doing something different?

The "general" coordinateTransformation applies to each scale the same way. So, in this case, instead of having it one could just put the 10 for the time axis to each of the datasets. Does that answer your question?

@K-Meech
Copy link
Contributor

K-Meech commented Feb 14, 2022

Yes -thanks @constantinpape!

@constantinpape
Copy link
Collaborator Author

Reading v0.4 is fully implemented now! Thanks @KateMoreva!

@K-Meech K-Meech mentioned this issue Feb 16, 2022
@constantinpape
Copy link
Collaborator Author

v0.4 is fully supported now (and everything related to this is released!) :)

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

No branches or pull requests

4 participants