{
  "id": 338525,
  "title": "An overview: Stain Normalization (Style Transfer) Techniques",
  "url": "/competitions/hubmap-organ-segmentation/discussion/338525",
  "author_name": "",
  "post_date": "2022-07-20T19:06:10.023979Z",
  "votes": 40,
  "comment_count": 4,
  "views": 0,
  "content": "<p>We might have noticed that there are not only texture differences but also color differences due to different stain protocols in the train and test set. So, I wanted to create this post to have an overview of varying normalization techniques for histopathological images.</p>\n<p>I created this notebook: <a href=\"https://www.kaggle.com/code/nghihuynh/stain-normalization-staingan-stainnet\" target=\"_blank\">Stain Normalization techniques: StainGAN, StainNet</a> to illustrate the following techniques:</p>\n<hr>\n<p>Here is a recap of the <a href=\"https://www.kaggle.com/competitions/hubmap-organ-segmentation/data\" target=\"_blank\">data description</a>:</p>\n<ul>\n<li>Train set: only contains public HPA data</li>\n<li>Public test set: contains private HPA and HuBMAP data</li>\n<li>Private test set: contains only HuBMAP data</li>\n</ul>\n<p><strong>HPA</strong> samples: stained with 3,3'-diaminobenzidine (<strong>DAB</strong>) + hematoxylin (<strong>H</strong>)<br>\n<strong>HuBMAP</strong> samples: stained with hematoxylin and eosin (<strong>H&amp;E</strong>)<br>\n-&gt; <a href=\"https://www.kaggle.com/competitions/hubmap-organ-segmentation/discussion/333704\" target=\"_blank\">reference from Darien Schettler discussion on Understanding the Different Tissue Stains </a></p>\n<p>There are many histological image normalization methods developed explicitly for H&amp;E staining. However, only a few studies investigated DAB+H staining. </p>\n<p>There are 3 groups of <strong>conventional stain normalization methods</strong> [<a href=\"https://www.ece.ualberta.ca/~xingyu/resources/J_TBME2015.pdf\" target=\"_blank\"><em>reference: Complete normalization</em></a>]<br>\n1) Histogram matching<br>\n2) Color transfer<br>\n3) Spectral matching<br>\nHowever, the limitation in these conventional methods is that histological information is hardly preserved after normalization.</p>\n<p>Here are a few common stain normalization techniques developed by Reinhard, Macenko, and Vahadane. [<a href=\"https://iopscience.iop.org/article/10.1088/1742-6596/1362/1/012108/pdf\" target=\"_blank\"><em>reference: A review of stain removal</em></a>]</p>\n<ul>\n<li><strong>Reinhard</strong>: based on color transfer between a standard image and color varied image using mean and variance of both the images. Then. alter the source image to the target image</li>\n<li><strong>Macenko</strong>: find particular stain vectors for each image based on the colors that are present in the image</li>\n<li><strong>Vahadane:</strong> decompose the image into stain density map that are sparse and non-negative. Then, the stain density maps are combined on the basis of stain color of a pathologist preferred target image. Thus, altering only its color and preserving the structure.</li>\n</ul>\n<p>And of course, they have <strong>deep-learning-based methods</strong> primarily applying generative adversarial networks (GANs) as well.<br>\nSome previous works:</p>\n<ul>\n<li><strong>StainGAN:</strong> based on CycleGAN to transfer the stain style. Limitation: complex and might have a risk of introducing some artifacts [<a href=\"https://arxiv.org/abs/1703.10593\" target=\"_blank\"><em>reference: Cycle-consistent adversial networks</em></a>]</li>\n<li><strong>StainNet:</strong> uses StainGAN as the teacher network, to learn the color mapping by distillation learning. [<a href=\"https://www.frontiersin.org/articles/10.3389/fmed.2021.746307/full\" target=\"_blank\"><em>reference: StainNet-a fast and robust network</em></a>] </li>\n</ul>\n<hr>\n<p>To sum up, we can try out these conventional and deep learning-based normalization techniques as the preprocessing step for this competition. We might want to compare the performances of those techniques with a baseline model to understand which method might work better. </p>\n<hr>\n<p>Let me know if anything is missing or if I need to make any corrections. 😊</p>",
  "messages": [
    {
      "id": "1864156",
      "postDate": "07/20/2022 19:06:10",
      "content": "<p>We might have noticed that there are not only texture differences but also color differences due to different stain protocols in the train and test set. So, I wanted to create this post to have an overview of varying normalization techniques for histopathological images.</p>\n<p>I created this notebook: <a href=\"https://www.kaggle.com/code/nghihuynh/stain-normalization-staingan-stainnet\" target=\"_blank\">Stain Normalization techniques: StainGAN, StainNet</a> to illustrate the following techniques:</p>\n<hr>\n<p>Here is a recap of the <a href=\"https://www.kaggle.com/competitions/hubmap-organ-segmentation/data\" target=\"_blank\">data description</a>:</p>\n<ul>\n<li>Train set: only contains public HPA data</li>\n<li>Public test set: contains private HPA and HuBMAP data</li>\n<li>Private test set: contains only HuBMAP data</li>\n</ul>\n<p><strong>HPA</strong> samples: stained with 3,3'-diaminobenzidine (<strong>DAB</strong>) + hematoxylin (<strong>H</strong>)<br>\n<strong>HuBMAP</strong> samples: stained with hematoxylin and eosin (<strong>H&amp;E</strong>)<br>\n-&gt; <a href=\"https://www.kaggle.com/competitions/hubmap-organ-segmentation/discussion/333704\" target=\"_blank\">reference from Darien Schettler discussion on Understanding the Different Tissue Stains </a></p>\n<p>There are many histological image normalization methods developed explicitly for H&amp;E staining. However, only a few studies investigated DAB+H staining. </p>\n<p>There are 3 groups of <strong>conventional stain normalization methods</strong> [<a href=\"https://www.ece.ualberta.ca/~xingyu/resources/J_TBME2015.pdf\" target=\"_blank\"><em>reference: Complete normalization</em></a>]<br>\n1) Histogram matching<br>\n2) Color transfer<br>\n3) Spectral matching<br>\nHowever, the limitation in these conventional methods is that histological information is hardly preserved after normalization.</p>\n<p>Here are a few common stain normalization techniques developed by Reinhard, Macenko, and Vahadane. [<a href=\"https://iopscience.iop.org/article/10.1088/1742-6596/1362/1/012108/pdf\" target=\"_blank\"><em>reference: A review of stain removal</em></a>]</p>\n<ul>\n<li><strong>Reinhard</strong>: based on color transfer between a standard image and color varied image using mean and variance of both the images. Then. alter the source image to the target image</li>\n<li><strong>Macenko</strong>: find particular stain vectors for each image based on the colors that are present in the image</li>\n<li><strong>Vahadane:</strong> decompose the image into stain density map that are sparse and non-negative. Then, the stain density maps are combined on the basis of stain color of a pathologist preferred target image. Thus, altering only its color and preserving the structure.</li>\n</ul>\n<p>And of course, they have <strong>deep-learning-based methods</strong> primarily applying generative adversarial networks (GANs) as well.<br>\nSome previous works:</p>\n<ul>\n<li><strong>StainGAN:</strong> based on CycleGAN to transfer the stain style. Limitation: complex and might have a risk of introducing some artifacts [<a href=\"https://arxiv.org/abs/1703.10593\" target=\"_blank\"><em>reference: Cycle-consistent adversial networks</em></a>]</li>\n<li><strong>StainNet:</strong> uses StainGAN as the teacher network, to learn the color mapping by distillation learning. [<a href=\"https://www.frontiersin.org/articles/10.3389/fmed.2021.746307/full\" target=\"_blank\"><em>reference: StainNet-a fast and robust network</em></a>] </li>\n</ul>\n<hr>\n<p>To sum up, we can try out these conventional and deep learning-based normalization techniques as the preprocessing step for this competition. We might want to compare the performances of those techniques with a baseline model to understand which method might work better. </p>\n<hr>\n<p>Let me know if anything is missing or if I need to make any corrections. 😊</p>",
      "rawMarkdown": "We might have noticed that there are not only texture differences but also color differences due to different stain protocols in the train and test set. So, I wanted to create this post to have an overview of varying normalization techniques for histopathological images.\n\nI created this notebook: [Stain Normalization techniques: StainGAN, StainNet](https://www.kaggle.com/code/nghihuynh/stain-normalization-staingan-stainnet) to illustrate the following techniques:\n\n---\n\nHere is a recap of the [data description](https://www.kaggle.com/competitions/hubmap-organ-segmentation/data):\n+ Train set: only contains public HPA data\n+ Public test set: contains private HPA and HuBMAP data\n+ Private test set: contains only HuBMAP data\n\n**HPA** samples: stained with 3,3'-diaminobenzidine (**DAB**) + hematoxylin (**H**)\n**HuBMAP** samples: stained with hematoxylin and eosin (**H&E**)\n-> [reference from Darien Schettler discussion on Understanding the Different Tissue Stains ](https://www.kaggle.com/competitions/hubmap-organ-segmentation/discussion/333704)\n\nThere are many histological image normalization methods developed explicitly for H&E staining. However, only a few studies investigated DAB+H staining. \n\nThere are 3 groups of **conventional stain normalization methods** [[*reference: Complete normalization*](https://www.ece.ualberta.ca/~xingyu/resources/J_TBME2015.pdf)]\n1) Histogram matching\n2) Color transfer\n3) Spectral matching\nHowever, the limitation in these conventional methods is that histological information is hardly preserved after normalization.\n\nHere are a few common stain normalization techniques developed by Reinhard, Macenko, and Vahadane. [[*reference: A review of stain removal*](https://iopscience.iop.org/article/10.1088/1742-6596/1362/1/012108/pdf)]\n+ **Reinhard**: based on color transfer between a standard image and color varied image using mean and variance of both the images. Then. alter the source image to the target image\n+ **Macenko**: find particular stain vectors for each image based on the colors that are present in the image\n+ **Vahadane:** decompose the image into stain density map that are sparse and non-negative. Then, the stain density maps are combined on the basis of stain color of a pathologist preferred target image. Thus, altering only its color and preserving the structure.\n\nAnd of course, they have **deep-learning-based methods** primarily applying generative adversarial networks (GANs) as well.\nSome previous works:\n+ **StainGAN:** based on CycleGAN to transfer the stain style. Limitation: complex and might have a risk of introducing some artifacts [[*reference: Cycle-consistent adversial networks*](https://arxiv.org/abs/1703.10593)]\n+ **StainNet:** uses StainGAN as the teacher network, to learn the color mapping by distillation learning. [[*reference: StainNet-a fast and robust network*](https://www.frontiersin.org/articles/10.3389/fmed.2021.746307/full)] \n\n---\n\nTo sum up, we can try out these conventional and deep learning-based normalization techniques as the preprocessing step for this competition. We might want to compare the performances of those techniques with a baseline model to understand which method might work better. \n\n---\n\nLet me know if anything is missing or if I need to make any corrections. 😊",
      "votes": null
    },
    {
      "id": "1868353",
      "postDate": "07/23/2022 23:35:37",
      "content": "<p>Great post!                                 </p>",
      "rawMarkdown": "Great post!",
      "votes": null
    },
    {
      "id": "1870414",
      "postDate": "07/25/2022 14:31:11",
      "content": "<p>Thanks Devastator!</p>",
      "rawMarkdown": "Thanks Devastator!",
      "votes": null
    },
    {
      "id": "1870689",
      "postDate": "07/25/2022 18:15:48",
      "content": "<p><strong>Important note:</strong> <br>\nEven though <strong><em>stain normalization</em></strong> has some proven benefits for training our models, experts in this field recommend that it's <strong><em>not always useful.</em></strong> Since we want to build a model being robust to color, it's <strong><em>better</em></strong> to do <strong><em>color augmentation</em></strong> instead of normalizing them. However, you can still use it as long as it's reasonable.</p>",
      "rawMarkdown": "**Important note:** \nEven though ***stain normalization*** has some proven benefits for training our models, experts in this field recommend that it's ***not always useful.*** Since we want to build a model being robust to color, it's ***better*** to do ***color augmentation*** instead of normalizing them. However, you can still use it as long as it's reasonable.",
      "votes": null
    },
    {
      "id": "1935423",
      "postDate": "09/12/2022 05:27:22",
      "content": "<p>Nice post.</p>",
      "rawMarkdown": "Nice post.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1868353,
      "author_name": "thedevastator",
      "author_url": "",
      "post_date": "07/23/2022 23:35:37",
      "content": "<p>Great post!                                 </p>",
      "votes": null,
      "replies": [
        {
          "id": 1870414,
          "author_name": "nghihuynh",
          "author_url": "",
          "post_date": "07/25/2022 14:31:11",
          "content": "<p>Thanks Devastator!</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1870689,
      "author_name": "nghihuynh",
      "author_url": "",
      "post_date": "07/25/2022 18:15:48",
      "content": "<p><strong>Important note:</strong> <br>\nEven though <strong><em>stain normalization</em></strong> has some proven benefits for training our models, experts in this field recommend that it's <strong><em>not always useful.</em></strong> Since we want to build a model being robust to color, it's <strong><em>better</em></strong> to do <strong><em>color augmentation</em></strong> instead of normalizing them. However, you can still use it as long as it's reasonable.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1935423,
      "author_name": "diakoo",
      "author_url": "",
      "post_date": "09/12/2022 05:27:22",
      "content": "<p>Nice post.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1864156": "We might have noticed that there are not only texture differences but also color differences due to different stain protocols in the train and test set. So, I wanted to create this post to have an overview of varying normalization techniques for histopathological images.\n\nI created this notebook: [Stain Normalization techniques: StainGAN, StainNet](https://www.kaggle.com/code/nghihuynh/stain-normalization-staingan-stainnet) to illustrate the following techniques:\n\n---\n\nHere is a recap of the [data description](https://www.kaggle.com/competitions/hubmap-organ-segmentation/data):\n+ Train set: only contains public HPA data\n+ Public test set: contains private HPA and HuBMAP data\n+ Private test set: contains only HuBMAP data\n\n**HPA** samples: stained with 3,3'-diaminobenzidine (**DAB**) + hematoxylin (**H**)\n**HuBMAP** samples: stained with hematoxylin and eosin (**H&E**)\n-> [reference from Darien Schettler discussion on Understanding the Different Tissue Stains ](https://www.kaggle.com/competitions/hubmap-organ-segmentation/discussion/333704)\n\nThere are many histological image normalization methods developed explicitly for H&E staining. However, only a few studies investigated DAB+H staining. \n\nThere are 3 groups of **conventional stain normalization methods** [[*reference: Complete normalization*](https://www.ece.ualberta.ca/~xingyu/resources/J_TBME2015.pdf)]\n1) Histogram matching\n2) Color transfer\n3) Spectral matching\nHowever, the limitation in these conventional methods is that histological information is hardly preserved after normalization.\n\nHere are a few common stain normalization techniques developed by Reinhard, Macenko, and Vahadane. [[*reference: A review of stain removal*](https://iopscience.iop.org/article/10.1088/1742-6596/1362/1/012108/pdf)]\n+ **Reinhard**: based on color transfer between a standard image and color varied image using mean and variance of both the images. Then. alter the source image to the target image\n+ **Macenko**: find particular stain vectors for each image based on the colors that are present in the image\n+ **Vahadane:** decompose the image into stain density map that are sparse and non-negative. Then, the stain density maps are combined on the basis of stain color of a pathologist preferred target image. Thus, altering only its color and preserving the structure.\n\nAnd of course, they have **deep-learning-based methods** primarily applying generative adversarial networks (GANs) as well.\nSome previous works:\n+ **StainGAN:** based on CycleGAN to transfer the stain style. Limitation: complex and might have a risk of introducing some artifacts [[*reference: Cycle-consistent adversial networks*](https://arxiv.org/abs/1703.10593)]\n+ **StainNet:** uses StainGAN as the teacher network, to learn the color mapping by distillation learning. [[*reference: StainNet-a fast and robust network*](https://www.frontiersin.org/articles/10.3389/fmed.2021.746307/full)] \n\n---\n\nTo sum up, we can try out these conventional and deep learning-based normalization techniques as the preprocessing step for this competition. We might want to compare the performances of those techniques with a baseline model to understand which method might work better. \n\n---\n\nLet me know if anything is missing or if I need to make any corrections. 😊",
    "1868353": "Great post!",
    "1870414": "Thanks Devastator!",
    "1870689": "**Important note:** \nEven though ***stain normalization*** has some proven benefits for training our models, experts in this field recommend that it's ***not always useful.*** Since we want to build a model being robust to color, it's ***better*** to do ***color augmentation*** instead of normalizing them. However, you can still use it as long as it's reasonable.",
    "1935423": "Nice post."
  },
  "source": "meta"
}