Segmentation artifacts and guidelines for tiger-example-algorithm

Segmentation artifacts and guidelines for tiger-example-algorithm  

  By: mart.vanrijthoven on March 31, 2022, 10:13 a.m.

Dear Participants,

As mentioned in the major update, we have noticed that submissions results for the segmentation task include artifacts. In this post, I want to give you some additional info on how you might can deal with these artifacts, particularly some guidelines if you use the tiger-algorithm example as a skeleton.

Before I get to the details, I want to clarify that I use "approximately 0.5um/px" in the text below. What I mean by this is the slide spacing close to 0.5. Because slides can have a bit lower resolution, for example. 0.4987 or a slightly higher resolution, for example, 0.5123.

Due to the size of a whole slide image (WSI) at full resolution, inference on a WSI is often made via a sliding-window approach. We already implemented a basic loop in the tiger-algorithm-example.

However, based on your settings, preprocessing steps, type of model, and postprocessing steps, you might want or need to change the basic version of this loop. Below, I give some insight into how you can deal with specific settings.

The use of lower magnification/spacing.

The basic loop in the tiger-algorithm example loops over the slide at approximately 0.5um/px. This setting corresponds the level 0 in the images and is configured here. If your model, for example, processes patches at a spacing of approximately 2.0um/px, you will need to adjust the level setting and adjust the loop to make it consistent with the spacing you are processing. If you use a different spacing, you should retrieve the exact spacing present in the WSI and the shape of the slide at that particular spacing and loop according to that shape. Furthermore, the evaluation expects your model predictions at the lowest spacing of the slide =~0.5um/px. Therefore you also have to upsample your model's predictions if you work with a different spacing.

The use of "valid padding"

Another example where you probably want to change the basic loop somehow is when you use 'valid padding' or 'same padding' in your models. If you use 'valid padding,' your model output will be smaller than the input. Hence in the basic loop, you will have to extract a larger patch, and you might even have to do some extra cropping to make your output prediction consistent with your defined writing tile size. Furthermore, valid padding might also profit from additional cropping of the predictions to avoid artifacts at the borders due to stitching. One strategy is to crop the predictions to a shape that is divisible by 2**depths (i.e., the number of pooling layers in your model) such that pooling is aligned over the full WSI.

The use of "same padding"

If you use "same padding," your input and output will be the same. However, your model padded the input with artificial pixels, which often results in artifacts at the border, which might not be visible in the patch itself, but become quite evident in the full WSI prediction due to the stitching by the sliding window loop. One way to solve this is by modifying the basic loop to extract patches in an overlapping fashion. Whereafter you have to crop the borders of your prediction. So, for example, if you use a patch size of 1024, you can slide with 512 overlaps and center crop your model's prediction patch to 512. In this setting, you will have to set the writing tile size to 512. If you use a different size, you must change the writing tile size accordingly. Other, more sophisticated techniques like predicting multiple overlaps and combining the softmax values with a gaussian are also possible. Which strategy you will use is up to you, but one way or another, you will need to address the artifacts, and this most likely involves a change in the basic loop.

As the last point, I would like to mention that you can or need to change the writing tile size. You can change it to any multiplier of 16. But the most efficient way is if you would use a writing tile size 512 or 1024. Depending on your model settings, you might have to do additional stitching or cropping.

To conclude, if you use the tiger-algorithm example, you might need to change something in the basic loop based on your preprocessing steps, model configuration, and postprocessing steps. What exactly is specific to your method. Please check your predictions at full WSI. If you have any problems or questions, please don't hesitate to ask them here in the forum. We are happy to help you, and we can try to solve all the issues, together.

Best wishes, Mart, on behalf of the TIGER organization team

Re: Segmentation artifacts and guidelines for tiger-example-algorithm  

  By: mart.vanrijthoven on April 2, 2022, 8:43 a.m.

Hi All,

As you probably know, we have provided the tiger-algorithm example, which you can use as a skeleton to build your inference pipeline. We have also released the code for the baseline method that Cyril de Kock created. As you may have noticed, the baseline method is not using the tiger-algorithm example as a skeleton. The reason for this is that both codes were developed simultaneously. The baseline method is using HookNet for the segmentation task in this challenge. We have now also provided an implementation of HookNet in the tiger-algorithm example, which results in the same segmentation maps as the baseline code. We hope that this can give you some additional ideas on how you can adjust the basic loop in the tiger algorithm example for a particular model. HookNet uses 'valid padding' and also requires two inputs. Your model might be different and could be using 'same padding .'As mentioned in the post above, you might want to adjust the basic loop, extract overlapping tiles, and center crop to avoid border artifacts. These are just some ideas. The actual implementation that works for your model depends on the type of model and settings.

You can find the implementation for HookNet here. Please note that we have removed the detection and computation of a TILS score part in this processing.py file for clarity.

I hope this can help you to avoid artifacts in your segmentation masks. Please let us know if you still have issues.

Best wishes, Mart

Re: Segmentation artifacts and guidelines for tiger-example-algorithm  

  By: mart.vanrijthoven on May 2, 2022, 8:21 a.m.

Dear All,

In some result we have noticed some interpolation erros in prediction masks.
If you need to upscale you masks please dont use linear interplation and use nearest interpolation instead.

Best wishes, Mart