fish-quant / fq-imjoy

ImJoy plugins to run different smFISH analysis in a user-friendly setting.
https://fq-imjoy.readthedocs.io/en/latest/
MIT License
2 stars 1 forks source link

Program Freezes at "Assign RNAs to cells/nuclei" Step #46

Closed austinlandgraf closed 2 years ago

austinlandgraf commented 2 years ago

Describe the bug When I click the "Assign RNAs to cells" button under "Post-processing," the program continuously loads and never produces any CSV files in the "results_per_fov" file within "spot_detection." The "Assign RNAs to cells" button works when I use the example data but not with our own images. I processed our images using "PreProcess" plugin for z-projections and "SegmentObjects" plugin for cell and nuclei masks. FISH-QUANT successfully generates spot detection files "spots.csv" and "spots_foci.csv" but it keeps freezing when I try to pair these spots with the masks. Spot detection performed on a cy3 image. Nuclei mask generated from DAPI image.

To Reproduce

  1. loaded two images (each with cy3 and dapi channel) **note: images have same names as example data images but they are not the example data;

  2. Spot Detection: selected cy3 for "select channel"

  3. Clicked "Filter Image" using default settings (sigma-xy = 0.75, sigma-z = 1)

  4. Spot detection threshold = 4000. "Apply detection threshold"

  5. Checked "Apply RNA cluster decomposition & detection"

  6. Clicked "Decompose dense regions" using default settings (Spot radius XY = 200, Z = 400)

  7. Clicked "Define Clusters" using default settings (Min nb spots = 4, Max distance (nm) = 300)

  8. Clicked "Launch batch processing" --> image 1 gives 25 spot in CSV; image 2 gives 151 spots in CSV; **note: I run into the same problem when I only click "Analyze current image"

  9. Post-Processing: File identifiers = "__spots_foci.csv" "maskcells.png" "masknuclei.png" Channel identifiers = "cy3" "dapi" "dapi" respectively. **note: I'm using copies of the same mask for the cells and the nuclei. Both masks are identical and based on the same DAPI image; they just have different identifier strings This is because we did not have a good channel for creating clean cell masks. We are only interested in counting #spots per nuclei, but the program seems to not run if the Cells file identifier is left blank. Therefore I filled it with just a replica of the nuclei mask renamed. I tried this approach with the example data and the analysis ran normally.

  10. Clicked "Assign RNAs to cells"; did not check any boxes here; Loading button starts to circle and continues indefinitely.

Logs browser console log.docx plugin log.docx

Screenshots screenshot of Browser console error - this seems to be the main problem.

Screen Shot 2022-03-14 at 5 25 36 PM

Versions: iOS 11.6.2 Chrome Version 99.0.4844.51 FQ plugin: v0.0.16 FQ interface: v0.0.11 big-fish: v0.6.0

Henley13 commented 2 years ago

Hi @austinlandgraf, thanks for raising the issue.

It seems it tries to match 1D coordinates to the cells. Your original image is in 3D, and your "__spots.csv" files have 2D or 3D coordinates, right?

I will try to reproduce your error.

austinlandgraf commented 2 years ago

Hi @Henley13 - thank you for your help! I really appreciate it;
Yes - the original images in "acquisition" are 3D (z-stacks composed of 30 images). The "spots.csv" and the "spots_foci.csv" files also have 3D coordinates (Z, Y, X).

It may be harder to reproduce the error since Assign RNAs function works perfectly with the example data. Would it be helpful if I sent you the images we are trying to analyze?

Henley13 commented 2 years ago

Hello, @austinlandgraf,

I did not reproduce the error yet, but looking at the log (and the code), I might have a temporary fix for you: could you please remove the "foci.csv" files that were saved in your /analysis folder, then rerun the Post-Processing step to assign RNAs to cells ? Also you might need to use "spots.csv" instead of "__spots_foci.csv" as identifier.

You do not detect any foci, so the plugin tries to assign an empty array (explaining the error). Without the "__foci.csv" files it won't try to assign them. If this fix works for you, we would need to update the code of the plugin accordingly.

Henley13 commented 2 years ago

Another comment: if you use a nuclei mask instead of a cell mask, when you will extract the "cells" , you will only keep RNAs detected inside nucleus...

austinlandgraf commented 2 years ago

Hi @Henley13 - thank you for the suggestions. I tried them out and unfortunately it's still not working. I deleted the "foci.csv" files and ran the Assign RNAs function first with the "spots_foci.csv" and second with the "__spots.csv" file. Both of them gave an error, which is different from the earlier error but seems related. I pasted a screenshot of the console log error here. Do you know what might be going on?

Screen Shot 2022-03-24 at 8 25 42 PM
muellerflorian commented 2 years ago

Hello,

as Arthur was pointing out, the problem comes from the fact that no foci were detected. I corrected the code, and it should hopefully work now. I will push the new code in a few minutes. Maybe give it a try and let us know if works now.

austinlandgraf commented 2 years ago

@muellerflorian @Henley13 The update worked! thank you! It works with both the "__spots_foci.csv" and the "__spots.csv" files. I also like the drop-down menu you added for the Spots file identifiers; it's very intuitive. Thank you both very much for your help. There is one other issue I'm encountering related to the "Select smaller region for testing" option under "Spot Detection" - I will make a post about that separately.