PreibischLab / RS-FISH

Tool for precise, interactive, fast and scalable FISH spot detection
GNU General Public License v2.0
45 stars 14 forks source link

ROI Map (too many ROIs selected) #5

Open StephanTir opened 3 years ago

StephanTir commented 3 years ago

Dear RS-FISH team,

thanks a lot for this great tool! I have an issue that is rather indirectly related to the RS-FISH plugin but which might be of interest for the people who are using it:

I have a relatively large image (9230 x 7688) with ~ 360,000 FISH spots. Spot detection with RS-FISH works nicely but I have a problem with creating a labeled mask from ROIs. I usually use the LOCI "ROI Map" command which works fine for smaller images with less spots, but for the above described case I get the following Error when I try to run "ROI Map" after running RS-FISH:

There are too many ROIs selected

Do you have an alternative or workaround for this problem?

Thanks a lot in advance!

Best

Stephan

Too_many_ROIs

StephanPreibisch commented 3 years ago

Hi @StephanTir ... first of all thanks! So if I understand this right this is a problem of the ROI manager not scaling to these numbers? Can you at least save the points to disc?

StephanTir commented 3 years ago

I think so, or at least the LOCI/ROI Map command can't handle the numbers. But I also tried other plugins that can generate a labeled image from ROIs and this also didn't work. For example the BIOP plugin actually generates a labelled image but displays only ~1/6 of all the ROIs.

But yes, saving the ROIs to disk works (although it takes some time) and also reloading of ROIs works.

Fritze commented 3 years ago

This is most likely not directly related to RS-FISH but due to the the LOCI/ROI Map command not being able to create images based on more than ~65k ROI's as this is the upper limit of 16bit (probably also the reason why the BIOP plugin creates only 1/6 of all ROIs [60k * 6 = 360k]).

This ImageJ macro (see also this post by @imagejan) should do the same job and create a 32bit image with all spots, each spot with a different intensity value based on its position in the ROI manager:

newImage("Labeling", "32-bit black", getWidth(), getHeight(), 1);

for (index = 0; index < roiManager("count"); index++) {
    roiManager("select", index);
    setColor(index+1);
    fill();
}
StephanTir commented 3 years ago

That works! Thanks a lot!

StephanPreibisch commented 3 years ago

Thanks so much @Fritze! @StephanTir can we make this somehow easier for you? What do you ideally want to do after detection?

StephanTir commented 3 years ago

For me the solution that @Fritze suggested is totally fine.

In general, I use RS-FISH for the analysis of multiplexed RNA-FISH (RNAScope) data (12-24 plex). After spot detection I want to 1) visualize the overlay of detected spots of a set of marker genes (e.g. in napari). By the way, therefore it would be great if the spot size would be adjustable after detection. 2) quantify transcripts/spots per nucleus/cell for downstream analysis/clustering. I currently do this in KNIME.

Fritze commented 3 years ago

I think for both, visualizing overlays and counting transcripts per nucleus/cell, it would be great to develop a RS-FISH node in KNIME. This would allow users to go from raw images to a transcripts per cell matrix in one reproducible workflow. From what I understand, it should be rather straightforward using the ImageJ2/ImgLib2 integration in KNIME. I am happy to give it a try but I might need a quick intro on how to set up things in maven etc..

StephanPreibisch commented 3 years ago

The command-line tool (https://github.com/PreibischLab/RS-FISH/blob/master/src/main/java/cmd/RadialSymmetry.java), or Spark command-line tool (https://github.com/PreibischLab/RS-FISH-Spark/blob/main/src/main/java/net/preibisch/rsfish/spark/SparkRSFISH.java) that additionally distributes the task into small blocks, both nicely encapsulate the functionality. Using this it should be trivial to incorporate into a KNIME node. Or @dietzc? :)

imagejan commented 3 years ago

@Fritze wrote:

it should be rather straightforward using the ImageJ2/ImgLib2 integration in KNIME. I am happy to give it a try but I might need a quick intro on how to set up things in maven etc..

In case it helps, there are many IJ2 plugin examples that auto-generate a KNIME node here:

https://github.com/fmi-faim/fmi-ij2-plugins/tree/master/src/main/java/ch/fmi

You can also start from https://github.com/imagej/example-imagej-command in general. The important thing for node auto-generation in KNIME is that:

If you want to benefit from a KNIME update site with automated deployment already established, I'll be happy to accept pull requests adding new plugins to https://github.com/fmi-faim/fmi-ij2-plugins, otherwise I'm sure @stelfrich, @gab1one and others at KNIME will help you setting up your own update site.

I suggest continuing the discussing at https://forum.image.sc if you want to pursue this route.