saalfeldlab / paintera

GNU General Public License v2.0
95 stars 17 forks source link

A valid N5 container is a directory that contains a file attributes.json with a key "n5". #457

Closed Lauenburg closed 1 year ago

Lauenburg commented 2 years ago

Issue When I try to load my data I always get the following error message: A valid N5 container is a directory that contains a file attributes.json with a key "n5".

My attribute.json:

{  "blockSize": [
        256,
        32,
        128
    ],
    "compression": {
        "blocksize": 0,
        "clevel": 5,
        "cname": "lz4",
        "shuffle": 1,
        "type": "blosc"
    },
    "dataType": "uint16",
    "dimensions": [
        2048,
        255,
        2048
    ]
}

I can not find any further information on the error message. I tried adding n5:0 to the JSON but it does not help. Is the JSON/N5 format not compatible?

What I did I installed Paintera using Conda on MacOs. I converted an h5 dataset to n5 using the python library zarr. I started Paintera by simply running paintera and tried loading my data by clicking on File>Open>Raw/Label Source. In the new dialog, I entered the path to the n5 container into the field N5 Container and a random name into the field Specify Source name (required).

cmhulbert commented 2 years ago

I can test better later whether I would expect this to work if you just add the n5 key like you suggested, but if you are trying to load the directory that directly contains this attributes.json, I can at least suggest something that should get this working.

Typically the datasets I have worked with consist of a top level directory as the n5 container (for example, let's call it container.n5) which is just a directory with an attributes.json containing the n5 key and a version number, such as:

{"n5":"2.5.0"}

Then, that top level directory would contain that attributes.json and it would also contain a second directory with your data (e.g. data). The data directory would then contain the attributes.json as you listed above.

So the overall directory structure would look like:

container.n5
│   attributes.json         <--- this contains the n5 version tag
└───data
     │   attributes.json    <--- this is the file you posted above
     │   .... (actual data) 

Then, when in Paintera, select the container.n5 in the Browse Folders drop down to the right of the N5 Container text field, and it should populate the Dataset drop down with the dataset it detects (in this case, it would be called data )

Let me know if that clarifies things, or if that doesn't work. In the mean time, I can see what I would expect if you just added the "n5" version tag to your data json.

Lauenburg commented 2 years ago

@cmhulbert, thank you! I am now able to load my data.

I try to use your tool to create a visualization for a paper. Same as the picture on the right (source: https://github.com/stardist/stardist) image

I converted a large numpy ndarray instance mask to n5 and visualize it by following the information above. However, when setting thresholding the data I am only able to set a monochrome color. How can I make Paintera assign different colors for each instance?

axtimwalde commented 2 years ago
  1. Your N5 container is a bit special in that it contains only one dataset at the root path "/". This is possible but not typical if e.g. you want to make your data multi-scale. Check https://github.com/saalfeldlab/paintera-conversion-helper for tools to make multi-scale label sets from single scale label sources (like yours).
  2. You most likely imported the dataset as a raw dataset, this is meant for background, microscopy images or alike. You will have to import it as a label dataset, then the various integers in the volume are interpreted as object instances.
GenevieveBuckley commented 1 year ago

I cannot get this trick to work.

I've tried using the zarr library to write out an .n5 directory, and then like you suggest shifting all the data into a subdirectory and adding a new .attributes.json file containing only the contents {"n5": "2.5.0"}

container.n5
│   attributes.json         <--- this contains the n5 version tag
└───data
     │   attributes.json    <--- this is the file you posted above
     │   .... (actual data) 

I've tried for both uint32 and uint16 label data.

I can get this to display in paintera as a raw dataset, but not as the label dataset it actually is. It seems like it's trying to load something, but the sources list stays empty. There's no data/labels visible on the main canvases, either.

The one thing that does change is that there is now a little grey rectangle in each corner that looks like it's trying to give you a minature map of where you are in the full volume (which doesn't make a lot of sense in the circumstances, but still)

cmhulbert commented 1 year ago

@Lauenburg let me know if Stephan's comment solved this issue for and if so feel free to close it.

@GenevieveBuckley we talked a bit outside of here too; let me know if you are still having issues. If you are, probably best to create a new issue, so this one can specifically track @Lauenburg's original issue

Lauenburg commented 1 year ago

@cmhulbert I could not solve my issue back then and the deadline was approaching too fast. I, therefore, ended up using different software for the visualization. Sorry! But thank you so much for your help either way.