Skip to content

smFISH decoding #82

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

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

Conversation

mspend
Copy link
Contributor

@mspend mspend commented May 21, 2025

modified display_results method in PixelDecoder to display all bits in napari.

Context:
The decode_one_tile method in PixelDecoding opens multiple images in Napari - "pixels," "decoded," "magnitude," and "distance." The image in Napari labeled "pixels" represents the pre-decoding intensities of spots in 1 bit, whereas the "decoded" image that opens represents all bits, summarized using a grayscale gradient. (Black is zero, or bit 1. White is 15, or bit 16). I modified the display_results function in Pixel decoder to open up all 16 bits of pre-decoding spot intensities, so now you can toggle between the pre-decoded and decoded spots for all bits.

@mspend
Copy link
Contributor Author

mspend commented May 21, 2025

This is what it should look like:

Napari window

@dpshepherd
Copy link
Contributor

Do you want to expose the smFISH magnitude thresholds as parameters so that you can set them programatically?

@dpshepherd
Copy link
Contributor

Once you have run this on your smFISH data, let me know and we can look at results. If that all looks good, I'll ask Max to simulate some smFISH data using his code and I can write new tests to cover the smFISH case.

Eventually I'll put the tests so they run on github, but I've had some issues with the GPU in that context so I run them locally before we add features.

@mspend
Copy link
Contributor Author

mspend commented May 28, 2025

I tested it on our smFISH data and the code itself is working, but we'll need to adjust the thresholds. With a magnitude threshold of [0.75,1.75] and a distance threshold of 1.0, we got very few decoded spots (see screenshot).

Napari shows most values for magnitude fall between -1 and 0. I'm not sure how we got negative values, as I thought we took the absolute value of the L2 norm.

image

@dpshepherd
Copy link
Contributor

If the L2-norm is zero, then when we scale the normalized pixels by the L2-norm (magnitude), we get infinity.

in _normalize_pixel_traces(), we check for this:

https://github.com/mspend/merfish3d-analysis/blob/3650936ddd408b03f9ff962146950c47d082f962/src/merfish3danalysis/PixelDecoder.py#L736-L739

and set any pixels where the normalized value is inf to -1.

@dpshepherd
Copy link
Contributor

dpshepherd commented May 28, 2025

If the thresholds aren't working, the normalization may not be right. The math I worked out only works if the data is properly normalized between [0,1].

Hopefully viewing the magnitude and distance images, with only one round of your normalized smFISH data active, will help narrow down what is going on.

@mspend mspend changed the title Display one tile of decoded smFISH results in Napari smFISH decoding Jun 2, 2025
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