-
Notifications
You must be signed in to change notification settings - Fork 1
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
Import spots from labels #47
Conversation
@maarzt this PR is the result of a collaboration of @Noam-Dori and myself. It adds the functionality to Mastodon to convert a series of label images to spots at different timepoints. This may be handy if a good segmentation had already been produced outside of Mastodon. We were inspired by some code you provided: https://github.com/mastodon-sc/mastodon-ellipsoid-fitting/tree/compute-ellipsoid-for-segmentation I would be interested in your opinion before merging it. It is not urgent though. |
09e6ea0
to
7891a3a
Compare
e3de381
to
7930b0c
Compare
9ec867d
to
ff6d7cb
Compare
Kudos, SonarCloud Quality Gate passed! |
2c35790
to
f824baa
Compare
…mmation (might need more robust fix later), anisotropic dimensions, finding minimum and max pixel value to account for unsigned conversions,and fixed a bug in the covariance math. also, added support for testing, configuration of the sigma parameter, and directly reading integer images rather than cast them to double.
…ucing BigInteger. We have no way to avoid this as we needed a 128bit integer to truly solve the problem.
…tically trivial example that can easily be tested.
…nnel to convert labels into ellipsoids (using the raw image instead of the label image) A warning is thus printed if lots of labels are detected (i.e. more than 10_000)
…porter.labelimage * These respective plugin is importing instead of exporting
…lImageView via the CommandService
b1a9cde
to
4a926fd
Compare
Quality Gate passedIssues Measures |
Closed in favor of #79 |
This PR adds a plugin to convert label images to (spot) ellipsoids.
Notes from https://github.com/Noam-Dori who contributed to this:
To accomplish the targeted functionality, the plugin runs twice through each image read.
Once to determine maximum/minimum values for array initialization, and once to do summation for covariance & mean. It might be possible to reduce this to 1 run either by finding the min/max stored in the metadata of the image (this is a common and very useful property so it might exist in there), or by changing from an array model to a Hashmap model (at the expense of memory).
One note I saw in the comments was about the inclusion of 5 in the covariance calculation. This is not for the covariance calculation, but rather for drawing the ellipsoid. It seems mastodon draws the ellipsoid at 1σ, which only includes ~46% of the target ellipsoid. This is unsurprising but not what we are looking for. Therefore I set it to draw the ellipsoid at 2.2σ, which when squared yields the 5 in the calculation. Since this is an empirical choice I also included it as a parameter in the plugin dialog.
Finally, a short discussion on summation, since it brought many bugs to the surface. Naturally, calculating covariance requires summation over the squares of the pixel coordinates. This can get very big with dealing with large images, and with large labels. These values got so big that the longs overflew many times. This was only resolved by changing the 1D sums into long integers, and the 2D sums into variable bit depth integers (since 128 bit integers don't exist in Java). Maybe reading integers forces out some unknown factor? Regardless, this is something to look out for.