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

Import spots from labels #47

Closed
wants to merge 23 commits into from
Closed

Conversation

stefanhahmann
Copy link
Collaborator

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.

@stefanhahmann stefanhahmann requested a review from maarzt October 9, 2023 13:52
@stefanhahmann
Copy link
Collaborator Author

@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.

@stefanhahmann stefanhahmann self-assigned this Oct 9, 2023
@stefanhahmann stefanhahmann force-pushed the import_spots_from_labels branch 4 times, most recently from 09e6ea0 to 7891a3a Compare October 10, 2023 10:36
@stefanhahmann stefanhahmann force-pushed the import_spots_from_labels branch 11 times, most recently from e3de381 to 7930b0c Compare November 15, 2023 12:10
@stefanhahmann stefanhahmann force-pushed the import_spots_from_labels branch 2 times, most recently from 9ec867d to ff6d7cb Compare November 23, 2023 16:42
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

80.0% 80.0% Coverage
0.0% 0.0% Duplication

@stefanhahmann stefanhahmann force-pushed the import_spots_from_labels branch from 2c35790 to f824baa Compare February 23, 2024 15:46
stefanhahmann and others added 8 commits February 29, 2024 12:39
…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.
@stefanhahmann stefanhahmann force-pushed the import_spots_from_labels branch from b1a9cde to 4a926fd Compare February 29, 2024 11:40
Copy link

@stefanhahmann
Copy link
Collaborator Author

Closed in favor of #79

@stefanhahmann stefanhahmann deleted the import_spots_from_labels branch March 20, 2024 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants