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

Writing Neuroglancer Precomputed data with png compression not working correctly #196

Open
LarsKoeppel opened this issue Sep 6, 2024 · 0 comments

Comments

@LarsKoeppel
Copy link

Hi,

i generated 2 versions of a dataset with tensorstore. And a 3erd version of the same data with cloud-volume.

The first version uses jpg compression and can be opened normaly:
jpg version

The second version uses png compression and the image is not fully loaded(border chunks missing):
png version

The 3rd version was created using cloud-volume(loads normaly):
cloud-volume

Neuroglancer is not able to show the chunks that overlap the border of the image from the png version made with tensorstore.
I verified that all chunks are loaded and that the naming of the cunks is identical. I also check this in the Firefox and Edge browser - same result.

I used this config for tensorstore to create this dataset. Did i miss something in the config?

tensorstore::Open({{"driver", "neuroglancer_precomputed"},
                                       {"kvstore", {
                                            {"driver", "file"},
                                            {"path", <path>}
                                        }},
                                       {"multiscale_metadata", {
                                            {"data_type", "uint8}, 
                                            {"num_channels", 1},
                                            {"type", "image"},
                                        }},
                                       {"scale_metadata", {
                                            {"resolution", {resolution[0], resolution[1], resolution[2]}},
                                            {"encoding", "png"},
                                            {"png_level", 6},
                                            {"chunk_size", {chunkSize[0], chunkSize[1], chunkSize[2]}},
                                            {"size", {sizeX, sizeY, sizeZ}},
                                        }},
                                       {"scale_index", index},
                                      },
                                      context,
                                      tensorstore::OpenMode::create,
                                      tensorstore::RecheckCached{false},
                                      tensorstore::ReadWriteMode::write).value();

I used this code to generate the cloud volume version. So the data is stored in the chunks but not in a format that neuroglancer can read.

>>> from cloudvolume import CloudVolume
>>> import tensorstore as ts
>>> dataset = ts.open(
...             {
...                 "driver": "neuroglancer_precomputed",
...                 "kvstore": {
...                     "driver": "file",
...                     "path": <path>,
...                 },
...             }
...         ).result()
>>> data = dataset[:,:,0].read().result()
>>> volume_path = 'file://<output_path>'
>>> info = CloudVolume.create_new_info(
...     num_channels=1,                    # number of channels
...     layer_type='image',                 # 'image' for image data
...     data_type='uint8',                  # data type of your NumPy array
...     encoding='png',                     # use PNG compression
...     resolution=[1, 1, 1],              # in nanometers
...     voxel_offset=[0, 0, 0],             # where the data starts
...     chunk_size=[1024, 1024, 1],             # size of each chunk in voxels
...     volume_size=data.shape,           # volume size in voxels
... )
>>> vol = CloudVolume(volume_path, info=info)
>>> vol.commit_info()  # write the metadata to disk
>>> vol[:,:,0] = data

I am happy to help with more information.

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

1 participant