Skip to content

Add support for different file formats to spec #49

Closed

Description

@constantinpape

Given that the ome.zarr format is progressing (ome/ngff#46) and that we may eventually want to support OpenOrganelle data (cc @bogovicj), I think we should add support for data formats that don't have a bdv.xml representation to the spec.

Currently, we store the data location in the spec like this:

"imageDataLocations": {
  "fileSystem": "bdv-file-for-local-data.xml",
  "s3store": "bdv-file-for-s3-data.xml"}

Here, we assume that the values are (relative) file paths that point to a bdv.xml file that in turn contains either the path to a local n5/hdf5 file or the address for the s3 storage.

However, for ome.zarr we don't need an xml file, because all relevant metadata is stored in the zarr attributes. In addition, for data that is stored on s3 (or some other object store), we also don't need to have any corresponding file in the project, but instead need to store the address.

So I would propose to add a new field fileFormat to support this. Initially we would support bdv.xml and we can probably add ome.zarr very soon.

For example:

"fileFormat": "bdv.xml",
"imageDataLocations": {
  "fileSystem": "bdv-file-for-local-data.xml",
  "s3store": "bdv-file-for-s3-data.xml"}
"fileFormat": "ome.zarr",
"imageDataLocations": {
  "fileSystem": "some-relative-path.ome.zarr",
  "s3store": "https://s3.embl.de/some-bucket/some-name.ome.zarr"}

or (eventually) for OpenOrganelle:

"fileFormat": "openOrganelle",
"imageDataLocations": {
  "s3Store": "s3://janelia-cosem/jrc_macrophage-2/jrc_macrophage-2.n5"}

Activity

  1. tischi commented on Jun 1, 2021

    @tischi
    Contributor

    Sounds good!

    To be more flexible what about something like this?

    "imageDataStorage":
      [ "store1": { "format": "bdv xml/h5", "storage": "fileSystem", "relativePath": "some-relative-path.xml" },
        "store2": { "format": "ome.zarr", "storage": "s3Store, "relativePath": "some-relative-path.ome.zarr" } ],
    
  2. constantinpape commented on Jun 1, 2021

    @constantinpape
    ContributorAuthor

    To be more flexible what about something like this?

    "imageDataStorage":
      [ "store1": { "format": "bdv xml/h5", "storage": "fileSystem", "relativePath": "some-relative-path.xml" },
        "store2": { "format": "ome.zarr", "storage": "s3Store, "relativePath": "some-relative-path.ome.zarr" } ],
    

    Makes sense, I will update the spec later and create an example project with it.

  3. constantinpape commented on Jun 1, 2021

    @constantinpape
    ContributorAuthor

    @tischi I had another look at your proposal and it's not valid json.
    I would suggest the following now:

    "imageData": {
    "<NAME>": {"format": "bdv.xml", "storage": "fileSystem", "relativePath": "..xml"},
    "<NAME>": {"format": "ome.zarr", "storage": "s3", "https://s3...."}

    i.e. imageData is a map with different names that map to the storage description for that name.

    The question is a bit how we deal with these names then. I think we should not restrict them, but then we somehow need to list the available storage options in MoBIE. So do we need another field in "project.json" for this, so that you know this when initialising the viewer without going through all sources?

  4. tischi commented on Jun 2, 2021

    @tischi
    Contributor

    Good question...

    In the code it looks like this:

    final String relativeImagePath = source.imageDataLocations.get( settings.values.getImageDataStorageModality().toString() );
    

    Which, I think we discussed before, could be make more general:

    final String relativeImagePath = source.imageData.get( settings.values.getImageDataStore() ).relativePath;
    

    Where source.imageData is the Map that you propose and settings.values.getImageDataStore() is the key to be used for opening the specific instance (getImageDataStorageModality() used to be an enum with only two options: fileSystem and s3).

    The question now is where does the user specify which of the image data stores (keys) they want to use.

    I don't know if we have to add this to the project.json, because one can figure out all the options also when parsing the specific dataset.json.

    Frankly, I don't know exactly, maybe we need to discuss in person.

  5. constantinpape commented on Jun 2, 2021

    @constantinpape
    ContributorAuthor

    The question now is where does the user specify which of the image data stores (keys) they want to use.

    I don't know if we have to add this to the project.json, because one can figure out all the options also when parsing the specific dataset.json.

    Frankly, I don't know exactly, maybe we need to discuss in person

    I proposed to put it in the project.json, because it is the first entry point for the MoBIE viewer. But if you would rather have it in the dataset.json that's also fine with me.

    But I see that this changes the logic of opening MoBIE projects a bit, because now we don't know a priori which data sources are available, but need to parse some meta-data for it, so the user cannot select this anymore without loading some metadata.

    Maybe we can find 5 minutes in the meeting later to discuss this.

  6. tischi commented on Jun 2, 2021

    @tischi
    Contributor

    I proposed to put it in the project.json, because it is the first entry point for the MoBIE viewer. But if you would rather have it in the dataset.json that's also fine with me.

    It's good to have it in the projection.json, but then we have to maintain the same information in two places, which is not ideal...

  7. constantinpape commented on Jun 2, 2021

    @constantinpape
    ContributorAuthor

    Alternatively, we could also keep the current logic of using "storage" as key and only allowing a fixed set of keys (currently "fileSystem" and "s3Store"). Then the only change would be that this maps to a map with the format and the source (= either relative path or address, we can still discuss how to actually encode this):

    "imageData":{
      "fileSystem": {"format": "bdv.xml", "source": "some/file.xml"},
      "s3Store": {"format": "ome.zarr", "source": "https://s3.something.com"}
    }

    Then we don't need to duplicate the information and know beforehand what options are available (for now "fileSystem" or "s3Store").
    The downside is that we don't allow for providing the data via different s3 stores, which would be possible in the other approach.

  8. tischi commented on Jun 2, 2021

    @tischi
    Contributor

    I still find the whole logic a bit suboptimal:

        "056F63395C_lynEGFP_seg": {
          
          
                  "segmentation": {
          
                    "imageDataLocations": {
          
                      "fileSystem": "images/local/membrane-056F63395C_lynEGFP_seg.xml",
                      "s3store": "images/remote/membrane-056F63395C_lynEGFP_seg.xml"
                    },
                    "tableDataLocation": "tables/membrane-056F63395C_lynEGFP_seg"
          
          
                  }
    

    Maybe we should also unify what we do for images and tables in terms of specifying the storage location and filetype.

  9. constantinpape commented on Jun 2, 2021

    @constantinpape
    ContributorAuthor

    New idea:

    "imageData": {
      "fileSystem": {"format": "bdv.xml", "source": "..."},
      "s3Store": {"..."}
    },
    "tableData": {
      "fileSystem": {"...."},
      "s3Store": {"..."},
      "github": {"..."}
    }
  10. constantinpape commented on Jun 2, 2021

    @constantinpape
    ContributorAuthor

    Ok, to summarise the changes discussed with @tischi:

    "imageData": {
      "fileSystem": {"format": "bdv.n5", "source": "images/my_image_fs.xml"},
      "gitHub": {"format": "bdv.n5.s3","source": "images/my_image_gh.xml"},
      "s3Store": {"format": "bdv.n5.s3", "source": "https://s3.com/my_image.xml"}
    },
    "tableData": {
      "fileSystem": {"format": "tsv", "source": "tables/some_tables",
      "gitHub": {"format": "tsv", "source": "tables/some_tables"},
      "s3Store": {"format": "tsv", "sorce": "https://s3com/tables/some_tables"}
    }

    This means: for "fileSystem" and "gitHub", the "source" is relative to the project directory / repository (which is derived from the entrypoint that the user provides, i.e. either the github repo or the path on the filesystem). For "s3Store", the "source" points to the s3 address. Note that the key only specifies where the 'image entry point' is located, which is different from the actual image data in the case of bdv.xml (it will be the same for ome.zarr though).
    For example: {"gitHub":{ "format": "bdv.n5.s3", "source": "images/my_image_gh.xml"}} means that the xml is read from github and the xml contains the information to load the actual image data from s3.
    For now, we support the formats "bdv.hdf5", "bdv.n5", "bdv.n5.s3". (Support for open organelle and ome zarr formats should come soon.)

    The case for tables is very similar and for now we support the format "tsv". In the future, we may support other formats like databases, see #23. For the current format, "source" always provides the location of the top directory that contains all the table files.

    @tischi I will create a branch with an example for this and let you know once it's there.

    Edit: changed "github" to "gitHub".

  11. tischi commented on Jun 2, 2021

    @tischi
    Contributor

    I think it should be gitHub.

    image

  12. constantinpape commented on Jun 2, 2021

    @constantinpape
    ContributorAuthor
  13. tischi commented on Jun 3, 2021

    @tischi
    Contributor

    Thanks!
    Copying here a part of it.

            "imageData": {
              "fileSystem": {
                "format": "bdv.n5",
                "source": "images/local/lm-cells.xml"
              },
              "gitHub": {
                "format": "bdv.n5.s3",
                "source": "images/remote/lm-cells.xml"
              }
            },
            "tableData": {
              "fileSystem": {
                "format": "tsv",
                "source": "tables/lm-cells"
              },
              "github": {
                "format": "tsv",
                "source": "tables/lm-cells"
              }
            }
          }
    

    Somehow I am still confused as to whether we are getting it right...

    1. Also for s3 one could in fact imagine to copy the whole project to a different bucket / institute, and then it would be nice if one would not have to change the JSONs. Thus I wonder whether also the S3 could be relative?
    2. Given above point, everything could be relative and then, currently for the tables, the entries all would identical, blowing up the dataset.json maybe unnecessarily.
    3. n5 and zarr in principle don't care whether they are on a file system or in an object store, that's why maybe we do not need to specify this in the dataset.json in terms of a different "format". The reader could figure out automatically whether it needs to read from S3.
    4. It is confusing now that one can "read an image from gitHub"

    Maybe we could rethink this again, forgetting for now that we currently need two different xml, assuming that images are stored as ZARR. And then, maybe just in the java code do something special to navigate to the correct xml, but not explicitly specify both locations in the dataset.json?!

  14. tischi commented on Jun 3, 2021

    @tischi
    Contributor

    And then, maybe just in the java code do something special to navigate to the correct xml, but not explicitly specify both locations in the dataset.json?!

    We could have just two xml next to each other, one ending on .s3.xml. Or we keep the subfolders as we have them, but do not mention them in the dataset.json, but add the subfolder in the Java code, as needed. It would be nice to rename the subfolders to "fileSystem" and "s3" (but I see that this is too much work for the data in object stores).

  15. constantinpape commented on Jun 4, 2021

    @constantinpape
    ContributorAuthor
    1. Also for s3 one could in fact imagine to copy the whole project to a different bucket / institute, and then it would be nice if one would not have to change the JSONs. Thus I wonder whether also the S3 could be relative?
    

    This will not work for the following case: read project data from github and access the image data on s3:
    In that case we need absolute paths, because the image data locations are not relative to the project root.

    3\. n5 and zarr in principle don't care whether they are on a file system or in an object store, that's why maybe we do not need to specify this in the dataset.json in terms of a different "format". The reader could figure out automatically whether it needs to read from S3.
    

    I don't really mind either way, but I like right now that the file format names are the same as used in the bdv xml file,
    where we have both bdv.n5 and bdv.n5.s3. For the ome.zarr use case we don't need to introduce it, becuase having the image data on github there also doesn't make sense.

    4\. It is confusing now that one can "read an image from gitHub"
    

    But this is the most consistent solution. It specifies where the image data entry point is located.
    I don't think it matters so much that it's a bit confusing on the surface. For a normal user this is never visible and for advanced users we can properly document this.

    We could have just two xml next to each other, one ending on .s3.xml. Or we keep the subfolders as we have them, but do not mention them in the dataset.json, but add the subfolder in the Java code, as needed. It would be nice to rename the subfolders to "fileSystem" and "s3" (but I see that this is too much work for the data in object stores).

    I don't like introducing implicit assumption on the folder structure in the spec again.

  16. 25 remaining items

  17. tischi commented on Jun 7, 2021

    @tischi
    Contributor

    I think your current proposal would work.

    I understand like this:

    • Loading images from github requires providing an image data root path.
    • Depending on the root path the ImageLoader or the S3ImageLoader will be used, from the xml on github

    Right?

    If we stick to this logic, we could in fact switch to ZARR without needing the voxel size, because we could make an xml with a ZARR image loader, containing the voxel size.

    If we now decide to read the xml from GitHub, in terms of Java code, it would be easier for me and stay consistent with the current logic of how the xml work, to, as also proposed at some point, have two xml next to each other (one ending on .s3.xml).

  18. tischi commented on Jun 7, 2021

    @tischi
    Contributor

    I am thinking now we could in fact also more or less leave it as it was, maybe just cleaning up the xmls, in a sense that we do not have two folders "local" and "remote", but just save them next to each other, with different endings. And then also keep the paths in the s3.xml absolute as we had them, which fixes all sorts of issues.

    And the Java code would just pick the correct xml, based on some user choice.

    And if we, for now, also use xml to open the ome.zarr we don't need anything, is it? In fact, I just saw that I seem to have the code for opening ome.zarr via xml already, which as mentioned above would also fix the voxel size issue.

    And, since we do not urgently need it, we postpone supporting relative s3 paths to a later edition?

  19. constantinpape commented on Jun 7, 2021

    @constantinpape
    ContributorAuthor
    {
      "imageData": {
         "bdv.n5": {"relativePath": "..."},
         "bdv.n5.s3": {"relativePath": "..."},
         "openOrganelle": {"s3Address": "..."}
      }
    }
    
  20. constantinpape commented on Jun 7, 2021

    @constantinpape
    ContributorAuthor
    {
       "tableData": {"tsv": {"relativePath": "..."}}
    }
    
  21. constantinpape commented on Jun 7, 2021

    @constantinpape
    ContributorAuthor
    project.json: "imageDataFormats": [...].
    
  22. tischi commented on Jun 7, 2021

    @tischi
    Contributor

    Cool, dann koennen wir auch bvd.ome.zarr (with xml) und ome.zarr (without xml) haben 🥳 , which allows us to use the xml for the voxel size as a temporary solution in a relatively clean way.

  23. constantinpape commented on Jun 7, 2021

    @constantinpape
    ContributorAuthor

    @tischi project with new data spec is there:
    github: https://github.com/mobie/arabidopsis-root-lm-datasets/tree/new-data-spec3
    filesystem: /g/kreshuk/pape/Work/mobie/arabidopsis-root-lm-datasets

  24. tischi commented on Jul 21, 2021

    @tischi
    Contributor

    I could not find the other issue, so I am posting here.

    Does that look good for the auto-detection of the storage?

    if ( settings.values.getImageDataFormat() == null )
    		{
    			final List< ImageDataFormat > imageDataFormats = project.getImageDataFormats();
    			if ( projectLocation.startsWith( "http" ) )
    			{
    				if ( imageDataFormats.contains( ImageDataFormat.BdvN5S3 ) )
    					settings = settings.imageDataFormat( ImageDataFormat.BdvN5S3 );
    				else if ( imageDataFormats.contains( ImageDataFormat.OmeZarrS3 ) )
    					settings = settings.imageDataFormat( ImageDataFormat.OmeZarrS3 );
    				else
    					throw new UnsupportedOperationException( "Could not find an S3 storage of the images." );
    			} 
    			else
    			{
    				if ( imageDataFormats.contains( ImageDataFormat.BdvN5 ) )
    					settings = settings.imageDataFormat( ImageDataFormat.BdvN5 );
    				else if ( imageDataFormats.contains( ImageDataFormat.OmeZarr ) )
    					settings = settings.imageDataFormat( ImageDataFormat.OmeZarr );
    				else
    					throw new UnsupportedOperationException( "Could not find a file system storage of the images." );
    			}
    		}
    
  25. constantinpape commented on Jul 21, 2021

    @constantinpape
    ContributorAuthor

    @tischi overall looks good, but the if is missing two formats: BdvOmeZarrS3 and OpenOrganelleS3.
    The else is missing BdvOmeZarr and BdvHdf5 (we still support hdf5 for local files, at least in the spec; if you want we could also remove it).

  26. tischi commented on Jul 22, 2021

    @tischi
    Contributor
  27. constantinpape commented on Jul 22, 2021

    @constantinpape
    ContributorAuthor

    @tischi
    I would suggest this small cosmetic change: mobie/mobie-viewer-fiji#367.
    Also, could you make a new MoBIE-beta release with these changes so that I can test the new data formats in the release?

  28. tischi commented on Jul 22, 2021

    @tischi
    Contributor

    done
    done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions