-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
WIP: Allow regionprops to reuse objects #4087
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need a test
I might not be totally clear about the intended use-case here, but it seems like if implemented this way then it would be possible to get quite unexpected results unless the user is careful to use the new option in a specific way. Is the intention to have one original labelled image as the 'master' segmentation, and then get the different metrics corresponding to different intensity images, but based on the same original segmentation? If so, I think it would be better to just make sure it is possible to make a copy of a RegionProperties object but with the intensity_image swapped out for the new channel. If the intention is to generate new RegionProperties objects where the supplied slices for the objects don't match the label_image, then I think that could give quite confusing results. But it would be a supported usage. |
@rdgraham, thanks for chiming in! (A long time ago I know! 😅)
Yes, that's the intention!
Well, given our current API, it's a bit tricky, because:
It could be that adding |
Interesting discussion which has come back to life again .. I do have some code where I have exactly this use case; images with several different modalities for which I am measuring various properties. Thus far, I haven't really had a need for functionality like this; I generally just have an object wrapping a regionprops and use the mask directly when I need properties of the different modalities. I often tend not to use the intensity_image because one of the problems that sometimes happens is that you can end up accidentally tying up a lot of memory if the reference in the regionprops is preventing the image data from otherwise being de-referenced when no longer needed. That said, an easier built-in solution would still be a good idea. Adding a channel axis option and stacking all the channels together seems simple at first, but I would discourage this approach as I see at least a couple of problems:
In the guise of my original suggestion for 'making it easy' to change the intensity image, I would suggest adding a new container class for Incidentally, IMHO a container class would also make a much better place for a method that returns a table of properties than the current setup for the recently added |
I see this issue is tagged for v0.18. It looks good to me, but looks like it still needs tests (and a rebase) |
It looks like this could be easy to add a test and complete, but it is mainly a question if this is the API we want. It seems reasonable, but I haven't thought about alternatives enough to have a strong opinion either way. If this is not going to be revisited in the near future, please consider removing the 0.19 milestone. |
Description
If we want to measure regionprops with the same objects over multiple channels, it is wasteful to run
ndimage.find_objects
for each channel. The long term fix would be to add multichannel support, but this is more general anyway and raises fewer API issues.CC @VolkerH
Checklist
./doc/examples
(new features only)./benchmarks
, if your changes aren't covered by anexisting benchmark
For reviewers
later.
__init__.py
.doc/release/release_dev.rst
.@meeseeksdev backport to v0.14.x