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

Simple tissue detection for TMA does not work #53

Closed
LieseCharlotte opened this issue Feb 24, 2017 · 11 comments
Closed

Simple tissue detection for TMA does not work #53

LieseCharlotte opened this issue Feb 24, 2017 · 11 comments

Comments

@LieseCharlotte
Copy link

LieseCharlotte commented Feb 24, 2017

When trying to run the simple tissue detection for TMA, as suggested in the manual, it won´t work (the detection lines being either very coarse or not even touching the tissue of the TMA core) no matter how I change the settings. Could this be due to the yellowish background (whitespace) of my slide? How can I change this?

@DavidMHaumann
Copy link

I have the same problem with CZI files.

Pete answered with this - i didnt try to find if my settings were FL instead of brightfield yet, but most of the suggestions i tested already. It did not help. Here the suggestions:

This happens whenever QuPath is unable to detect any cores. There are a few reasons why this may occur:

The Image type is wrong (e.g. set to fluorescence rather than brightfield) - this can be seen after clicking on the Image tab on the left. There is a screenshot here.
The specified TMA core diameter is either too large or too small. QuPath determines the expected TMA grid from 'complete' cores, which have a diameter within a small tolerance of the value set in the dialog box. If no cores fall within this tolerance, the grid cannot be found.
The intensity threshold is either too high or too low (but it is automatically determined from the data, and I don't see any reason in your image why it would be determined wrongly).

If the image type is set correctly, then I would try increasing and decreasing the TMA core diameter to see if this gives any improvements. If not, then there may be some issue happening internally when trying to read from the CZI file - although I have not seen such a problem before. The contents of View → Show log may be helpful to track down the problem.

@Svidro
Copy link

Svidro commented Feb 24, 2017

It could be due to a yellow background as I think the background is taken into account when determining the threshold. On most slides where the background is very white, the "Background" at the bottom of the Image tab on the left should be close to 255,255,255. If you background is not white, this should be different (but still close to 255,255,255), and you can fix that by running Analyze->Preprocessing->Estimate Stain vectors. Make sure you have a large chunk of whitespace (well, background I suppose, in this case!) in the annotation you have selected for the estimation, then when you get the first popup that asks you if you want to accept the Mode value, say "yes." You don't need to continue with the actual stain estimation if you have already run it, just "Okay" out.
That is your best bet as far as taking care of the background, but I have frequently had problems when running lung TMAs or other very low density tissues.
I know you said you have already tried changing the settings, but once you have the background set, you might try a threshold very close to 250, a pixel size near .5um (.233 for .mrxs brightfield), and make sure Expand boundaries and Smooth coordinates are unchecked.

@DavidMHaumann
Copy link

I found the source for the problem with my czi TMAs. Like Pete said, it helped to change the autorecognition of the image type from fluorescence to brightfield.

@petebankhead
Copy link
Member

Adding to the above suggestions, I understand by the manual you mean the section on TMA CD3 analysis.

You can see in the screenshots the kind of settings that were used in that example - in particular, note that the default 'Requested pixel size' is large (20) in the first screenshot showing tissue detection, and the boundary is very coarse and inaccurate for the TMA core. In the second screenshot, this value is low (4), and the boundary is much better. The description is:

For detecting large areas of tissue, e.g. a whole face section, you probably want a large value, e.g. 20 µm. For small regions of tissue, e.g. a TMA core, you probably want a smaller value, e.g. 2-5 µm.

These values depend upon the pixel size information being stored in the image; if you are working with an image where that information is missing (e.g. a JPEG, a PNG) or incorrect then that would cause trouble.

Apart from that, if you could provide any screenshots showing your results then this would help identify what is wrong. If the background is particularly dark and yellow then it could be the problem, because Simple tissue detection works by converting your image to grayscale first, and then applies a threshold to find darker or lighter pixels (this is why it's 'simple'... it doesn't use color information in any smarter way than that). If the background is dark enough, maybe this grayscale image doesn't have good enough contrast for the detection to work. But usually this isn't the case.

If that does turn out that something more sophisticated is needed, then there would be other ways to detect the tissue that can be adapted to your particular images (e.g. with an ImageJ macro). But since these would require considerably more effort, it would be worth it to try to find Simple tissue detection settings that work well enough first.

Finally, depending upon what you want to do you might not need to detect the tissue at all - I often don't. For example, you could simply detect cells within the TMA core directly. This can give you some measurements (e.g. percentages of positive cells, H-scores), but not others (e.g. tissue area, positive cell density).

@Svidro
Copy link

Svidro commented Feb 25, 2017

Ooh, that is good to know! I hadn't realized the tissue detection did not use the colors at all. That nixes the entire first paragraph of my first comment!

And to add on to Peter's last comment, I frequently calculate tissue area in R after the fact, using a sum of the cell areas in each core, or create a second set of cells temporarily with a larger cell expansion if the density is low (large enough that the fake cells fill in most of the tissue space) to get a fairly accurate measure of the tissue area in order to generate a positive cells/mm^2 value.

And if the significant yellowing is the primary culprit, a difference just +/- 1 on the threshold could make a huge difference as long as the background is consistent.

@LieseCharlotte
Copy link
Author

Thank you very much, Svidro, DHaumannHSA and petebankhead for your quick and helpful answers! Very much appreciated! I did not know tissue detection did not use colors! Very interesting!
By "manual" I was referring to the section on TMA CD3 analysis. I followed all these steps precisely (including estimation of stain vectors). The setting is also on Brightfield. The values given for the background/whitespace at the bottom of the Image tab on the left are around 223,215,213 in my case. By playing around with these numbers in my settings I eventually managed to get better results that are ok to work with. Thank you very much everybody once again.

@Svidro
Copy link

Svidro commented Feb 27, 2017

Slightly off QuPath- I don't know what scanner you are using, but if you have access to it, I think most should have a brightfield compensation image adjustment setting (it takes a picture of a blank slide and adjusts). We had some yellowing in ours after some software updates, and that took care of the background.

@LieseCharlotte
Copy link
Author

Thank you Svidro for your advice. I will look into it!

@rgranit
Copy link

rgranit commented Mar 24, 2019

Hey all,

I'm having similar issues to those described here above. TMA dearrayer refuse to detect cores on two images from the project.. seems like the H&E stain is a bit weaker in these slides:
image

I've attempted to change the background colors & stain vectors, but that did not work. Adding rows or columns manually do not work since they are added outside the frame and so I could not relocate them.

Thanks!

@Svidro
Copy link

Svidro commented Mar 24, 2019

I would recommend trying the script here:
#77

@rgranit
Copy link

rgranit commented Mar 25, 2019

Thanks! this indeed solve the issue. I guess it would be nice to have an option to force QuPath to draw the grid even if the cores are not detected in a similar manner to what the script does.

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

No branches or pull requests

5 participants