Comments (7)
Hi William,
cc3d.statistics
returns the lists voxel_counts
, bounding_boxes
and centroids
. Does index 0 in each of the list correspond to component 1 (label 1) and so on or is it unordered? Maybe it would be better to return a list of dicts each with the entries label
, voxel_counts
, bounding_boxes
and centroids
? This would be similar to skimage.measure.regionprops
and is in my opinion more intuitive. Also, it would make it easier to return more stats without getting too messy.
Best,
Karol
from connected-components-3d.
Hi Karol,
Thanks for writing in! The index into the list is the label ID (e.g. arr[label]
for each of the properties). Index 0 is the background. This is similar to scipy.measure.find_objects
except that in scipy, the first index corresponds to label 1, so you need to do arr[label-1]
to get the right index. There was some discussion of this here: #94 I figured it would be more intuitive to not require any offset (and I was getting the statistics for label 0 anyway in one pass).
Array of objects vs object containing arrays is always debatable. I tend to favor object of arrays because then you can operate on the entire array efficiently. This is also the format used to actually perform the calculation internally for that reason (which is why the function is fast).
There might come a point when e.g. some labels might have calculated properties that others do not. I'll reconsider the interface as more properties are proposed. If there's a situation where you need statistics to be a drop-in replacement for regionprops, let me know and we can discuss some more. Maybe I could add in a compatibility function that translates the interface.
Will
from connected-components-3d.
Hi Will,
thanks for the quick reply!
Thanks for writing in! The index into the list is the label ID (e.g. arr[label] for each of the properties). Index 0 is the background. This is similar to scipy.measure.find_objects except that in scipy, the first index corresponds to label 1, so you need to do arr[label-1] to get the right index. There was some discussion of this here: #94 I figured it would be more intuitive to not require any offset (and I was getting the statistics for label 0 anyway in one pass).
Ah, I didn't assume that the background was also treated as a component. Thanks for the clarification!
Array of objects vs object containing arrays is always debatable. I tend to favor object of arrays because then you can operate on the entire array efficiently. This is also the format used to actually perform the calculation internally for that reason (which is why the function is fast).
Yes, you are right. It probably comes down to preference. I am team object-containing-array ;) but the current representation is fine as well with only three stats.
There might come a point when e.g. some labels might have calculated properties that others do not. I'll reconsider the interface as more properties are proposed. If there's a situation where you need statistics to be a drop-in replacement for regionprops, let me know and we can discuss some more. Maybe I could add in a compatibility function that translates the interface.
At the moment, I only need the bounding boxes so the current output is absolutly sufficient. But thanks for the proposition!
Best,
Karol
from connected-components-3d.
Anytime! You can always let me know if you have any questions or feedback about cc3d. Good luck on your project!
from connected-components-3d.
Thanks! Another question: Does the number of components, returned in connected_components
when using the return_N
parameter, also include the background component?
from connected-components-3d.
No, it only counts foreground labels.
from connected-components-3d.
Thanks!
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 Remove Dust Function HOT 2
- cc3d.statistics['bounding_boxes'] is contains floats instead of int as slice positions HOT 2
- 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.