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

retrieve voxel coords given segment id #649

Open
jakobtroidl opened this issue Jan 21, 2025 · 3 comments
Open

retrieve voxel coords given segment id #649

jakobtroidl opened this issue Jan 21, 2025 · 3 comments
Labels
question What is going on??? :thinking emoji:

Comments

@jakobtroidl
Copy link

jakobtroidl commented Jan 21, 2025

I am looking for a way to generate a list of voxel coordinates for a given segment ID. I want to use those voxel coordinates to sample a point cloud for each neuron. I explicitly do not want to use the vertices of meshes to sample the point cloud but sample from the volume directly.

I found something related to this issue, which recommends using 'cc3d'. My task is significantly related to counting the voxels of a particular segment, so I assume it is possible to get the list of voxel coordinates. Id also be happy already if I could find a way to sparsely sample from all voxel coordinates per segment. Could you help me understand how I could get started here?

@william-silversmith
Copy link
Contributor

william-silversmith commented Jan 21, 2025

Hi Jakob,

Boy do I have the solution for you. I presume you are talking about the watershed volume like in #648

I've been working on creating a giant crackle file that contains the entirety of the fly dataset. The format has natively accelerated functions for computing contour point clouds and voxel counts.

Example (once the file is produced on a big cluster.... that job is pending):

import crackle

arr = crackle.aload("watershed.ckl", allow_mmap=True)
labels = arr.labels() # fast
ptc = arr.point_cloud() # This will take a while... 7045 * tens of seconds per slice? minutes?
cts = arr.voxel_counts() # will take a while 7045 * seconds per slice

The downside is that this is currently single-core and the file being produced is 32x32x40 resolution.

There are other ways to do this using cluster computing of course.

You can see a sample of this for the flywire m783 segmentation here:
https://storage.googleapis.com/flywire_v141_m783/archive/flywire_m141_m783_32x32x40.ckl.lz (35.6GB file, decompresses to 55 GB).

(Note: You can decompress .lz with xz -d or plzip -d.)

@william-silversmith william-silversmith added the question What is going on??? :thinking emoji: label Jan 21, 2025
@william-silversmith
Copy link
Contributor

william-silversmith commented Jan 22, 2025

In my excitement, I neglected that there is a more prosaic way to accomplish most of these goals. Igneous supports computing the voxel count per an object which would give you both the labels and the voxel counts in a method compatible with cluster computing. This will generate an IntMap file that is essentially a searchable serialized dict.

The final summing step will require quite some RAM though.

@jakobtroidl
Copy link
Author

jakobtroidl commented Jan 22, 2025

This is very helpful. I am interested in learning how to use igneous for it since I likely will have to do it for a couple of different volumes.

Igneous supports computing the voxel count per an object which would give you both the labels and the voxel counts in a method compatible with cluster computing. This will generate an IntMap file that is essentially a searchable serialized dict.

The voxel count task would help me get a list of all labels in the volume, but it does not support sampling a sparse point cloud from the segmentation volume per segment, right?

The crackle point cloud looks close to what I want. Is there a way to change the arr.point_cloud() function such that it doesn't give me the contour point cloud but a sparsely sampled (by a given factor) point cloud of all voxels of a given segment ID? Also, could you point me in the right direction on how I can convert NG precomputed segmentations into the crackle format?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question What is going on??? :thinking emoji:
Projects
None yet
Development

No branches or pull requests

2 participants