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

High intensity background detection discarding #50

Open
alfonsecard opened this issue Apr 12, 2022 · 3 comments
Open

High intensity background detection discarding #50

alfonsecard opened this issue Apr 12, 2022 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@alfonsecard
Copy link

Hi, I'm having some problems adapting the parameters of the detection in images with high background interference. I work with plant tissue, so the autofluorescence is sometimes really high. When I run your software in MATLAB I had been able to discard those dots coming from the high-intensity background, by setting a maximum threshold in the Sigma-XY criteria. Now I'm trying with your ImJoy version and I see that I can just adjust the minimum threshold for intensity. Is there any possibility to adapt this to improve the detection precision?

The settings I'm using are:
"settings": {
"filter": {
"method": "LoG",
"sigma": [
1,
0.75,
0.75
]
},
"detection": {
"method": "localmax",
"mind_dist": [
2,
2
],
"threshold": 122

And this is the output that I'm obtaining:
image

If I analyze the same outline with similar criteria in MATLAB and adjust the sigmaXY maximum threshold I obtain a good detection. Here I show you the results for the cell marked with a red square above

image
image

Do you have any suggestions on how could I adjust better this criteria in Imjoy?

Thanks in advance

@muellerflorian
Copy link
Member

Hello,

currently ImJoy permits no thresholding beyond the adjustment of the initial intensity value.

In ImJoy we use our Python library big-fish to perform the actual analysis. This library provides the possibility to fit spots with a Gaussian function (@Henley13 ) and then extract values such as their fitted size (akin to the Matlab version).

We would then need to add some more functionality to the plugin to

  1. Fit the spots
  2. Set thresholds for the fitting parameters with an interactive plot akin to Matlab.

implementing this will take a bit of time, but we can start working on this relatively soon.

best
F

@muellerflorian muellerflorian self-assigned this Apr 14, 2022
@muellerflorian muellerflorian added the enhancement New feature or request label Apr 14, 2022
@muellerflorian
Copy link
Member

@Henley13 . We currently provide the function detection.fit_subpixel to perform a Gaussian fit on a provided list of spots. However, this function "only" returns the subpixel coordinates for each spot and not the other fitting parameters.

maybe we could add a parameter to create a conditional output where we return the other fitting parameters as well (amplitude, background, sigmas)?

or do you think it's better to simply loop over the spots and apply modelize_spot directly?

@Henley13
Copy link
Member

For now I think the latter option is best. Function bigfish.detection.modelize_spot was implemented for that purpose. You should also use bigfish.detection.get_spot_volume or bigfish.detection.get_spot_surface.

Something like that:

import bigfish.detection as detection

# inputs requested
# image = ... (2 or 3 dimensions)
# spot_coordinate = ... (zyx or yx coordinates)
# voxel_size = ... (in nanometer)
# radius_nm = ... (in nanometer)
# ndim = ... (2 or 3)

# get spot spot radius in pixel
radius_px = detection.get_object_radius_pixel(
        voxel_size_nm=voxel_size,
        object_radius_nm=spot_radius,
        ndim=ndim)
radius_px = [np.sqrt(ndim) * r for r in radius_px]
radius_px = tuple(radius_px)

# extract spot image
image_spot, _ = detection.get_spot_volume(
        image=image,
        spot_z=spot_coordinate[0],
        spot_y=spot_coordinate[1],
        spot_x=spot_coordinate[2],
        radius_z=radius_px[0],
        radius_yx=radius_px[-1])

# fit gaussian
parameters = detection.modelize_spot(
        reference_spot=image_spot,
        voxel_size=voxel_size,
        spot_radius=radius_nm,
        return_coord=True)

You will need big-fish>=0.6.2 to use detection.get_spot_volume and detection.get_spot_surface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants