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

change spatial_detection_score binning to be fixed bin size #8

Open
berl opened this issue Nov 22, 2024 · 2 comments · May be fixed by #29
Open

change spatial_detection_score binning to be fixed bin size #8

berl opened this issue Nov 22, 2024 · 2 comments · May be fixed by #29
Assignees

Comments

@berl
Copy link
Collaborator

berl commented Nov 22, 2024

currently uses fixed number of bins for x and y, should be changed to fixed (square) bin size

@shachafl
Copy link
Collaborator

shachafl commented Dec 10, 2024

@berl looking to hear your thought before committing and PR:
I have replaced n_bins with pixel (LMK if a different name is better) where (pixel (int, optional): Pixel size in microns for spatial grouping. Defaults to 100.)
And also made the following addition and substitution of n_bins with nx_bins and ny_bins respectively:

    # determine number of bins on each axis for grouping the data spatially
    nx_bins = np.ceil((s2.x_centroid.max() - s2.x_centroid.min()) / pixel).astype(int)
    ny_bins = np.ceil((s2.y_centroid.max() - s2.y_centroid.min()) / pixel).astype(int)

    s2["xy_bucket"] = list(
        zip(
            pd.cut(s2.x_centroid, nx_bins, labels=list(range(nx_bins))),
            pd.cut(s2.y_centroid, ny_bins, labels=list(range(ny_bins))),
        )
    )

    ...
    bin_image_z_score = np.zeros([nx_bins, ny_bins])
    bin_image_difference = np.zeros([nx_bins, ny_bins])
    bin_image_ratio = np.zeros([nx_bins, ny_bins])
    bin_image_counts = np.zeros([nx_bins, ny_bins])

Also, using n_bins as a parameter for spatial_detection_scores() will return an error in my current code. But I can maintain the old parameter and functionality with an "if-else" statements if you prefer.

@berl
Copy link
Collaborator Author

berl commented Dec 10, 2024

sounds good!

  1. I think bin_size will be less confusing with all the various image pixel sizes and conversions floating around in spatial users' minds
  2. let's drop the n_bins . we can make sure the notebooks are updated

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 a pull request may close this issue.

2 participants