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

2d radius calculation in blob detection (blob.py) is incorrect #2022

Closed
shachafl opened this issue Oct 7, 2024 · 0 comments · Fixed by #2023
Closed

2d radius calculation in blob detection (blob.py) is incorrect #2022

shachafl opened this issue Oct 7, 2024 · 0 comments · Fixed by #2023
Assignees
Labels
bug An issue with an existing feature

Comments

@shachafl
Copy link
Collaborator

shachafl commented Oct 7, 2024

Description

The radius calculated for blobs in 2d and 3d based on pixels should be different, but instead, it uses the same formula (probably a copy+paste error by the author).
This can be easily corrected by changing the 2d case from np.sqrt(3) to np.sqrt(2).
See Notes of https://scikit-image.org/docs/stable/api/skimage.feature.html#skimage.feature.blob_log

Relevant Code

starfish/starfish/core/spots/FindSpots/blob.py

def image_to_spots(
    ...
    # measure intensities
        data_image = np.asarray(data_image)
        if self.is_volume:
            z_inds = fitted_blobs_array[:, 0].astype(int)
            y_inds = fitted_blobs_array[:, 1].astype(int)
            x_inds = fitted_blobs_array[:, 2].astype(int)
            radius = np.round(fitted_blobs_array[:, 3] * np.sqrt(3))
            intensities = data_image[tuple([z_inds, y_inds, x_inds])]
        else:
            z_inds = np.asarray([0 for x in range(len(fitted_blobs_array))])
            y_inds = fitted_blobs_array[:, 0].astype(int)
            x_inds = fitted_blobs_array[:, 1].astype(int)
            radius = np.round(fitted_blobs_array[:, 2] * np.sqrt(3))
            intensities = data_image[tuple([y_inds, x_inds])]
    ...
@shachafl shachafl added the bug An issue with an existing feature label Oct 7, 2024
@shachafl shachafl self-assigned this Oct 7, 2024
@shachafl shachafl linked a pull request Oct 8, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue with an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant