manuel-munoz-aguirre / PyHIST

A pipeline to segment tissue from the background in histological images
GNU General Public License v3.0
56 stars 13 forks source link

Parameter recommendations for immunohistochemical stained WSI #21

Closed gabemarx closed 3 years ago

gabemarx commented 3 years ago

Hello, I am working with WSI of human hippocampal tissue stained with AT8 IHC to detect neurofibrillary tangles. The ICH creates a dark brown stain for positive tissue while the negative tissue is quite light. When running Pyhist on cases with a great deal of positive stain, I am unable to get segmentation of the negatively stained tissue. I have played with combinations of mask downsampling, minimum segment size, and k-const which occasionally increase the covered area but I haven't found the right set of parameters to fully encompass the tissue with tiles. I was wondering if you had any recommendations for approaches to parameters for cases where there is a large contrast within the tissue. Happy to provide any code or output image.

Thank you Gabe

manuel-munoz-aguirre commented 3 years ago

Hi. This seems to be a problem in detecting the background correctly. Is there a lot of stained tissue on the edges of the WSI? PyHIST relies on the borders of the WSI to determine the background. A few things you could try: 1) Change the percentage of the border detection: --percentage-bc 1 2) Use a small fraction of the image corners to detect the background: --corners 1111 --borders 0000 --percentage-bc 1 3) Use another segmentation method: --method "otsu" or --method "adaptive".

If these suggestions don't work, could you share an example of an input image so we can look into it? Thanks!

gabemarx commented 3 years ago

Hello,

Appreciate the response. Tried the above recommendations unfortunately to no avail. Attached is an example of the output for --corners 1111 --borders 0000 --percentage-bc 1.

tilecrossed_42040

What would be the best way to share the input? It is a 390 mb svs image.

manuel-munoz-aguirre commented 3 years ago

Seems that the issue is rather on the amount of tissue content for thresholding to decide if keeping the tile or not, since the tissue is correctly-centered. Maybe you could try: --method "otsu" --content-threshold 0.01 with varying values of content threshold (0.01 - 0.5) to see if this fixes it. If not, you can drop the file in this folder and I'll take a look: https://drive.google.com/drive/folders/1uBN2DY-JckpDhmkNAdVNSczOdX9ov9Nd

Thanks!

gabemarx commented 3 years ago

Hello,

Sorry for the delayed response. I played around with various content thresholds (as you recommended from 0.01 to 0.5) with the otsu algorithm and it was not successful. Attached is an example of the tilecrossed image when the content threshold was set to 0.001. It is still has insufficient coverage of the tissue. tilecrossed_42040

I will upload the slide to the drive.

I appreciate your help and assistance.

-Gabe

vntasis commented 3 years ago

Hi,

As you can see the graph method works pretty good.

tilecrossed_42040 I have used the following parameters: pyhist --method graph --mask-downsample 8 --output-downsample 2 --tilecross-downsample 32 --content-threshold 0.2 --save-tilecrossed-image --corners 1111 --borders 0000 --percentage-bc 1 --k-const 1000 --minimum_segmentsize 1000 --output images/ images/42040.tiff

The important part that solves the problem is related to the --mask-downsample parameter. PyHIST berfore segmenting the image, scales down the input. The default value for this downsampling factor is 16, which makes the whole process more efficient, because the segmentation runs in a much smaller version of the image. But sometimes it is too 'lossy', and we loose clear separation between the tissue and the background, like in this case. So, if we reduce that to a value of 8, we see an accurate separation.

gabemarx commented 3 years ago

Incredible! Thank you so much.