Comments (7)
Your function does work, though it appears to leave a thread hanging so I needed to kill the python script when I used it. I tested it out against a vectorized approach I found here: https://stackoverflow.com/a/54736464.
I subbed in your version of fastremap.unqiue in place of numpy's, and with a test volume of 500 million voxels and 3000 labels, the linked function above uses ~25GB of ram and runs in 55 seconds. The fastremap point_cloud function uses ~60 GB of RAM (borrowing about half of this from virtual memory on my hardware) and runs in 100 seconds.
I agree that this kind of function is definitely useful for my field as well and from looking into it I think others would benefit from a faster implementation. Either way, a dramatic improvement from the simple for loop above.
from connected-components-3d.
If I understand correctly, is it that you'd like to convert the array into a point cloud? If you want to return every voxel as a 3-tuple, while there might be some leeway by playing with the data type, you should expect to use 3x the size of the array at minimum because you'll need 3 integers to represent the position of the label whereas before the position was stored implicitly using a single integer.
from connected-components-3d.
You could think of it as a point cloud, yes where each label location is represented by a 3 tuple. I'm looking to replace this kind of operation, which is shown below in its simplest, least efficient implementation:
connectivity = 6
labels_out = cc3d.connected_components(data, connectivity=connectivity)
labels_idx = []
for i in range(1,np.max(labels_out)+1):
idx = np.argwhere(labels_out == i)
labels_idx.append(idx)
from connected-components-3d.
I ran your example code against 128 MVx of data and it looks like it will take about three hours to run.
This sounds like a good candidate for a new fastremap function. Point clouds are used a lot in my field, it's a little crazy they're so expensive to generate.
from connected-components-3d.
This is a rough implementation, but maybe you'll be able to use it?
https://github.com/seung-lab/fastremap/tree/wms_point_cloud
from connected-components-3d.
It's been a while, but I am releasing fastremap
1.12.0 which will include a point_cloud
function that should be much faster and lower memory than what I previously showed you, maybe even better than the numpy vectorized. The measuring tools on my new arm64 laptop are not reliable in giving memory estimates, so it's difficult for me to make more quantitative statements.
from connected-components-3d.
Closing issue due to inactivity. Please reopen if you want to discuss further!
from connected-components-3d.
Related Issues (20)
- Applying Dust and largest_k dtype output option HOT 2
- dust sugnature HOT 1
- Massive memory Leak HOT 7
- 1D Array of 4 Elements Incorrect HOT 5
- Cannot find reference 'dust' in 'cc3d.py' HOT 2
- Question on comparing individual lesions between two masks based on the cc3d.statistics output. HOT 1
- Additional metrics support HOT 2
- Does cc3d also work with memmory-mapped numpy arrays and array-like data? HOT 14
- cc3d.statistics["bounding_boxes"] are wrong HOT 1
- largest_k fails for transposed arrays HOT 6
- About the lastest_k function HOT 4
- Statistics output HOT 7
- Question on the output of contacts HOT 9
- Periodic Boundary Conditions HOT 4
- Is the output label of largest_k ordered? HOT 2
- Add a better error for type support. HOT 4
- Any way to make this GPU Compatible? HOT 5
- voxel_connectivity_graph and contacts can not be applied in 2D label HOT 5
- Build Equivalence Table Two Z Slices at a Time
- cc3d.dust fails HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from connected-components-3d.