seung-lab / cloud-volume

Read and write Neuroglancer datasets programmatically.
https://twitter.com/thundercloudvol
BSD 3-Clause "New" or "Revised" License
135 stars 47 forks source link

save meshes in sharded neuroglancer precomputed #584

Open fb0l opened 1 year ago

fb0l commented 1 year ago

Hi everyone, I have a local dataset in neuroglancer precomputed format (sharded) which also contains meshes. Following the tutorial, I'm loading the meshes and I'm applying some transformations to them. After the transformations have been applied, I'd like to save the updated meshes back as sharded neuroglancer precomputed format, ideally into a new output folder.

Is this possible with cloud-volume? Do you have experience with this use-case and know how to continue?

Thanks!

william-silversmith commented 1 year ago

Hi fb0l,

Producing a shard is kind of convoluted, but if you do the updates in batches, you could try following the code here and replacing the original shard filename:

https://github.com/seung-lab/igneous/blob/master/igneous/tasks/mesh/multires.py#L356-L358

You can also generate an unsharded volume and convert it to sharded using igneous mesh xfer and then delete the original.

Let me know if you need additional help!

william-silversmith commented 1 year ago

I forgot to mention, you might find it beneficial to use disassemble_shard

https://github.com/seung-lab/cloud-volume/blob/fb3a8c3364a30e82a38fe7607e7602405c873799/cloudvolume/datasource/precomputed/sharding.py#L520

You'll need to use logic in this file in order to read the multi-lod format:

https://github.com/seung-lab/cloud-volume/blob/fb3a8c3364a30e82a38fe7607e7602405c873799/cloudvolume/datasource/precomputed/mesh/multilod.py#L18