{
  "id": 242741,
  "title": "A notebook on manually applying a VOI LUT",
  "url": "/competitions/siim-covid19-detection/discussion/242741",
  "author_name": "",
  "post_date": "2021-05-30T13:48:59.165480Z",
  "votes": 3,
  "comment_count": 18,
  "views": 0,
  "content": "<p>After talking with a couple people about VOI LUTs, I realize there seems to be some confusion on the subject. I thought I'd write up a notebook to explain how VOI LUTs can be manually created and applied.</p>\n<p>This is a brief explanation and application of 'windowing' as it is done inside DICOM image viewers.</p>\n<p><a href=\"https://www.kaggle.com/davidbroberts/manual-dicom-voi-lut\" target=\"_blank\">https://www.kaggle.com/davidbroberts/manual-dicom-voi-lut</a></p>",
  "messages": [
    {
      "id": "1328749",
      "postDate": "05/30/2021 13:48:59",
      "content": "<p>After talking with a couple people about VOI LUTs, I realize there seems to be some confusion on the subject. I thought I'd write up a notebook to explain how VOI LUTs can be manually created and applied.</p>\n<p>This is a brief explanation and application of 'windowing' as it is done inside DICOM image viewers.</p>\n<p><a href=\"https://www.kaggle.com/davidbroberts/manual-dicom-voi-lut\" target=\"_blank\">https://www.kaggle.com/davidbroberts/manual-dicom-voi-lut</a></p>",
      "rawMarkdown": "After talking with a couple people about VOI LUTs, I realize there seems to be some confusion on the subject. I thought I'd write up a notebook to explain how VOI LUTs can be manually created and applied.\n\nThis is a brief explanation and application of 'windowing' as it is done inside DICOM image viewers.\n\nhttps://www.kaggle.com/davidbroberts/manual-dicom-voi-lut",
      "votes": null
    },
    {
      "id": "1329805",
      "postDate": "05/31/2021 11:44:25",
      "content": "<p>So you are saying we have more than 8-bit data in DICOM? Is there a reason to use 8-bit image format then?</p>",
      "rawMarkdown": "So you are saying we have more than 8-bit data in DICOM? Is there a reason to use 8-bit image format then?",
      "votes": null
    },
    {
      "id": "1329892",
      "postDate": "05/31/2021 12:59:45",
      "content": "<p>Yes, most uncompressed DICOM x-ray images are larger than 8 bit. </p>\n<p>A 12 bit image can have up to 4906 values, a 16 bit image can have 65,536 but consumer grade display adapters (and monitors) can only display 8 bits of grayscale (256 'colors').</p>\n<p>Radiologists generally use special displays that can show more shades of gray than the ones we use at home. Ideally, it could show all possible color values .. but there is some science behind what shades of color the human eye can distinguish between, that says we really only need about 10 or 12 bits.</p>\n<p>The reason to use 8 bit formats was originally bandwidth/network related. JPG compression offers a decent trade-off between file size and diagnostic quality. Generally speaking, an x-ray that is properly exposed <em>can</em> offer adequate diagnostic information with only 8 bits, but not always.</p>\n<p>Likewise, there are some JPG compression algorithms that are Lossless. That is, they can compress more than 8+ bits down to 8 without losing any detail.</p>",
      "rawMarkdown": "Yes, most uncompressed DICOM x-ray images are larger than 8 bit. \n\nA 12 bit image can have up to 4906 values, a 16 bit image can have 65,536 but consumer grade display adapters (and monitors) can only display 8 bits of grayscale (256 'colors').\n\nRadiologists generally use special displays that can show more shades of gray than the ones we use at home. Ideally, it could show all possible color values .. but there is some science behind what shades of color the human eye can distinguish between, that says we really only need about 10 or 12 bits.\n\nThe reason to use 8 bit formats was originally bandwidth/network related. JPG compression offers a decent trade-off between file size and diagnostic quality. Generally speaking, an x-ray that is properly exposed *can* offer adequate diagnostic information with only 8 bits, but not always.\n\nLikewise, there are some JPG compression algorithms that are Lossless. That is, they can compress more than 8+ bits down to 8 without losing any detail.",
      "votes": null
    },
    {
      "id": "1329994",
      "postDate": "05/31/2021 14:14:36",
      "content": "<p>Still, what's the reason to use JPG or PNG at all if the data will be loaded into neural network with floats?</p>",
      "rawMarkdown": "Still, what's the reason to use JPG or PNG at all if the data will be loaded into neural network with floats?",
      "votes": null
    },
    {
      "id": "1330088",
      "postDate": "05/31/2021 15:29:07",
      "content": "<p>I do not know that answer. I posted the same question myself.</p>\n<p><a href=\"https://www.kaggle.com/c/siim-covid19-detection/discussion/240882#1318031\" target=\"_blank\">https://www.kaggle.com/c/siim-covid19-detection/discussion/240882#1318031</a></p>",
      "rawMarkdown": "I do not know that answer. I posted the same question myself.\n\nhttps://www.kaggle.com/c/siim-covid19-detection/discussion/240882#1318031",
      "votes": null
    },
    {
      "id": "1330382",
      "postDate": "05/31/2021 18:28:43",
      "content": "<p>But, my guess is that most CNN models that can be used for transfer learning are built on 8 bit images. It seems the majority of the top level architectures in competitions like this favor transfer learning as well.</p>\n<p>Since medical image datasets are hard to come by, and it would require a large set to build a model from scratch .. I suspect most people opt for the 8 bit solution.</p>",
      "rawMarkdown": "But, my guess is that most CNN models that can be used for transfer learning are built on 8 bit images. It seems the majority of the top level architectures in competitions like this favor transfer learning as well.\n\nSince medical image datasets are hard to come by, and it would require a large set to build a model from scratch .. I suspect most people opt for the 8 bit solution.",
      "votes": null
    },
    {
      "id": "1330498",
      "postDate": "05/31/2021 21:36:44",
      "content": "<p>there is no practical difference between using raw 12bits and 12 bits converted to 8bits. Talking from my personal experience :)</p>",
      "rawMarkdown": "there is no practical difference between using raw 12bits and 12 bits converted to 8bits. Talking from my personal experience :)",
      "votes": null
    },
    {
      "id": "1330501",
      "postDate": "05/31/2021 21:47:58",
      "content": "<p>You must look at DICOM metadata to see if VOI LUT function should be interpreted as linear or not - which is actually quite messy (if you looked at pydicom internals… its a headache)</p>\n<p>There is quite a lot X-ray devices producing non-linear pixels - more often its non-linear than linear!</p>",
      "rawMarkdown": "You must look at DICOM metadata to see if VOI LUT function should be interpreted as linear or not - which is actually quite messy (if you looked at pydicom internals... its a headache)\n\nThere is quite a lot X-ray devices producing non-linear pixels - more often its non-linear than linear!",
      "votes": null
    },
    {
      "id": "1330529",
      "postDate": "05/31/2021 23:42:36",
      "content": "<p>CNN models are not \"build on 8 bit images\", Neural Networks use floats not 8 bits</p>",
      "rawMarkdown": "CNN models are not \"build on 8 bit images\", Neural Networks use floats not 8 bits",
      "votes": null
    },
    {
      "id": "1330541",
      "postDate": "06/01/2021 00:10:34",
      "content": "<p>They are if 8 bit JPGs are used as input. </p>\n<p>My thought process is this .. If you export all the images into JPG using a single VOI LUT that simply maps the Level to 127 and the Width to 255 on a properly exposed image, the lungs may be demonstrated well, but the mediastinum might not. Or the costophrenic angles might be obscured by breast tissue and need a lower level to be adequately interpreted.</p>\n<p>If you attempt to adjust the Level darker to 'see through' the thicker anatomy better,  there is a big difference in the result from an 8 bit versus a 10-12 bit image.</p>\n<p>Doesn't it make sense to feed a NN raw (normalized) pixel values instead of scaled pixels? Or, at least export multiple 8 bit copies with various VOI LUTs applied?</p>\n<p>Thank you all for your replies!</p>",
      "rawMarkdown": "They are if 8 bit JPGs are used as input. \n\nMy thought process is this .. If you export all the images into JPG using a single VOI LUT that simply maps the Level to 127 and the Width to 255 on a properly exposed image, the lungs may be demonstrated well, but the mediastinum might not. Or the costophrenic angles might be obscured by breast tissue and need a lower level to be adequately interpreted.\n\nIf you attempt to adjust the Level darker to 'see through' the thicker anatomy better,  there is a big difference in the result from an 8 bit versus a 10-12 bit image.\n\nDoesn't it make sense to feed a NN raw (normalized) pixel values instead of scaled pixels? Or, at least export multiple 8 bit copies with various VOI LUTs applied?\n\nThank you all for your replies!",
      "votes": null
    },
    {
      "id": "1330578",
      "postDate": "06/01/2021 01:04:02",
      "content": "<p>I made a quick notebook on using raw pixel data as input for a couple CNNs. </p>\n<p>Unless I am missing something, I fail to see why it wouldn't be beneficial to do this way.</p>\n<p><a href=\"https://www.kaggle.com/davidbroberts/dicom-full-range-pixels-as-cnn-input\" target=\"_blank\">https://www.kaggle.com/davidbroberts/dicom-full-range-pixels-as-cnn-input</a></p>\n<p>I posted this question about image depth a couple weeks ago here -&gt; <a href=\"https://www.kaggle.com/c/siim-covid19-detection/discussion/240882\" target=\"_blank\">https://www.kaggle.com/c/siim-covid19-detection/discussion/240882</a></p>",
      "rawMarkdown": "I made a quick notebook on using raw pixel data as input for a couple CNNs. \n\nUnless I am missing something, I fail to see why it wouldn't be beneficial to do this way.\n\nhttps://www.kaggle.com/davidbroberts/dicom-full-range-pixels-as-cnn-input\n\nI posted this question about image depth a couple weeks ago here -> https://www.kaggle.com/c/siim-covid19-detection/discussion/240882",
      "votes": null
    },
    {
      "id": "1330589",
      "postDate": "06/01/2021 01:46:16",
      "content": "<p>Yes, a lot of newer DX systems use sigmoid VOI LUTs, but a lot of non-proprietary image viewers do not support them. They commonly fall back to using linear LUTs which still produce acceptable results. Also, embedded VOI LUT aren't adjustable.</p>\n<p>Ignoring a VOI LUT sequence is not a sin :)</p>",
      "rawMarkdown": "Yes, a lot of newer DX systems use sigmoid VOI LUTs, but a lot of non-proprietary image viewers do not support them. They commonly fall back to using linear LUTs which still produce acceptable results. Also, embedded VOI LUT aren't adjustable.\n\nIgnoring a VOI LUT sequence is not a sin :)",
      "votes": null
    },
    {
      "id": "1331738",
      "postDate": "06/01/2021 17:16:09",
      "content": "<p>You are raising very good questions here! I have found that CLAHE normalization on top of default VOI LUT transformation is a very nice way to deal with the fact that you can get better view with manually adjusted WW/WC. Please also have in mind that neural networks see the images differently than humans, and different WW/WC may be insignificant for NN to do all the pattern matching :)</p>",
      "rawMarkdown": "You are raising very good questions here! I have found that CLAHE normalization on top of default VOI LUT transformation is a very nice way to deal with the fact that you can get better view with manually adjusted WW/WC. Please also have in mind that neural networks see the images differently than humans, and different WW/WC may be insignificant for NN to do all the pattern matching :)",
      "votes": null
    },
    {
      "id": "1331774",
      "postDate": "06/01/2021 17:54:42",
      "content": "<p>Thanks for the feedback <a href=\"https://www.kaggle.com/raddar\" target=\"_blank\">@raddar</a>! I will research CLAHE normalization.</p>\n<p>My thought is that edge detection and pattern matching <em>should be</em> more reliant on the supplied WW/WC than a human would be since a human can make adjustments to better visualize pathology that is so sensitive to WW/WC like pneumonia is.</p>\n<p>If a radiologist needs to adjust the contrast slightly to better separate soft tissue from denser soft tissue in a standard normalized image, it stands to reason that a CNN using the same image would have a harder time detecting edges and patterns, unless the image was leveled appropriately. </p>\n<p>Things like rib suppression could also be achieved by using various Levels and Centers and some masking, but would be difficult without it.</p>",
      "rawMarkdown": "Thanks for the feedback @raddar! I will research CLAHE normalization.\n\nMy thought is that edge detection and pattern matching *should be* more reliant on the supplied WW/WC than a human would be since a human can make adjustments to better visualize pathology that is so sensitive to WW/WC like pneumonia is.\n\nIf a radiologist needs to adjust the contrast slightly to better separate soft tissue from denser soft tissue in a standard normalized image, it stands to reason that a CNN using the same image would have a harder time detecting edges and patterns, unless the image was leveled appropriately. \n\nThings like rib suppression could also be achieved by using various Levels and Centers and some masking, but would be difficult without it.",
      "votes": null
    },
    {
      "id": "1331932",
      "postDate": "06/01/2021 20:10:02",
      "content": "<p>I would think this way - WW/WC operation is equivalent to clipping of top/bottom pixel values and stretching to full 8bit range. If you provide raw input to a neural network - it should be more than capable of defining its own optimal clipping parameters. That's why I am not too worried about feeding correct VOI LUT to models.</p>\n<p>Edit: of course, you have to worry about all the images to have same WW/WC logic - which is hard as images come from different X-ray vendors. CLAHE solves this partially. I also found CLAHE models to generalize better on unseen devices.</p>\n<p>Double edit: feeding raw pixel values is not a good idea - you need to have VOI LUT transformed pixels (preferably device default WW/WC), as there is a mix of linear and non-linear images:)</p>",
      "rawMarkdown": "I would think this way - WW/WC operation is equivalent to clipping of top/bottom pixel values and stretching to full 8bit range. If you provide raw input to a neural network - it should be more than capable of defining its own optimal clipping parameters. That's why I am not too worried about feeding correct VOI LUT to models.\n\nEdit: of course, you have to worry about all the images to have same WW/WC logic - which is hard as images come from different X-ray vendors. CLAHE solves this partially. I also found CLAHE models to generalize better on unseen devices.\n\nDouble edit: feeding raw pixel values is not a good idea - you need to have VOI LUT transformed pixels (preferably device default WW/WC), as there is a mix of linear and non-linear images:)",
      "votes": null
    },
    {
      "id": "1332089",
      "postDate": "06/01/2021 22:36:34",
      "content": "<p>As far as I can tell, there aren't any images in this dataset with VOI LUT sequences or VOI LUT Functions that specify anything other than linear conversion.</p>\n<p>I wrote up a notebook to check. Of 5936 images in the train set, none of them have VOI LUT tags.</p>\n<p>This one also counts the non Explicit VR Little Endian transfer syntaxes.</p>\n<p><a href=\"https://www.kaggle.com/davidbroberts/covid19-images-check-for-voi-lut\" target=\"_blank\">https://www.kaggle.com/davidbroberts/covid19-images-check-for-voi-lut</a></p>",
      "rawMarkdown": "As far as I can tell, there aren't any images in this dataset with VOI LUT sequences or VOI LUT Functions that specify anything other than linear conversion.\n\nI wrote up a notebook to check. Of 5936 images in the train set, none of them have VOI LUT tags.\n\nThis one also counts the non Explicit VR Little Endian transfer syntaxes.\n\nhttps://www.kaggle.com/davidbroberts/covid19-images-check-for-voi-lut",
      "votes": null
    },
    {
      "id": "1335312",
      "postDate": "06/04/2021 06:33:08",
      "content": "<p><a href=\"https://www.kaggle.com/davidbroberts\" target=\"_blank\">@davidbroberts</a>  could help understand this term VOILUT..<br>\nAlso if you use Fastai method  df .from _dicom that exports all meta data as dataframe ,one can see easily VOILUT attribute for X ray. Is that info enough ?</p>",
      "rawMarkdown": "davidbroberts  could help understand this term VOILUT..\nAlso if you use Fastai method  df .from _dicom that exports all meta data as dataframe ,one can see easily VOILUT attribute for X ray. Is that info enough ?",
      "votes": null
    },
    {
      "id": "1335399",
      "postDate": "06/04/2021 07:31:09",
      "content": "<p>you could think this way - the X-ray devices produces images which are not \"human-friendly\". VOILUT is a transformation which makes it \"human-friendly\"</p>",
      "rawMarkdown": "you could think this way - the X-ray devices produces images which are not \"human-friendly\". VOILUT is a transformation which makes it \"human-friendly\"",
      "votes": null
    },
    {
      "id": "1335734",
      "postDate": "06/04/2021 12:04:22",
      "content": "<p>I like to think of VOI LUts as binning and normalization. If the range of pixel values is too high, bin them  and crunch them down to a reasonable range. In the case of images, the range is 0-255.</p>\n<p>VOI LUTs can come in several fashions .. I.E. embedded as a sequence in the DICOM file, in an external file, or just as a descriptor that specifies they type of algebra used on the Window Width and Center values to create the LUT.</p>\n<p>You can read more about it in the DICOM Part3 standard here -&gt; <a href=\"http://dicom.nema.org/medical/Dicom/2018d/output/chtml/part03/sect_C.11.2.html\" target=\"_blank\">http://dicom.nema.org/medical/Dicom/2018d/output/chtml/part03/sect_C.11.2.html</a></p>",
      "rawMarkdown": "I like to think of VOI LUts as binning and normalization. If the range of pixel values is too high, bin them  and crunch them down to a reasonable range. In the case of images, the range is 0-255.\n\nVOI LUTs can come in several fashions .. I.E. embedded as a sequence in the DICOM file, in an external file, or just as a descriptor that specifies they type of algebra used on the Window Width and Center values to create the LUT.\n\nYou can read more about it in the DICOM Part3 standard here -> http://dicom.nema.org/medical/Dicom/2018d/output/chtml/part03/sect_C.11.2.html",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1329805,
      "author_name": "jacekpoplawski",
      "author_url": "",
      "post_date": "05/31/2021 11:44:25",
      "content": "<p>So you are saying we have more than 8-bit data in DICOM? Is there a reason to use 8-bit image format then?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1329892,
      "author_name": "davidbroberts",
      "author_url": "",
      "post_date": "05/31/2021 12:59:45",
      "content": "<p>Yes, most uncompressed DICOM x-ray images are larger than 8 bit. </p>\n<p>A 12 bit image can have up to 4906 values, a 16 bit image can have 65,536 but consumer grade display adapters (and monitors) can only display 8 bits of grayscale (256 'colors').</p>\n<p>Radiologists generally use special displays that can show more shades of gray than the ones we use at home. Ideally, it could show all possible color values .. but there is some science behind what shades of color the human eye can distinguish between, that says we really only need about 10 or 12 bits.</p>\n<p>The reason to use 8 bit formats was originally bandwidth/network related. JPG compression offers a decent trade-off between file size and diagnostic quality. Generally speaking, an x-ray that is properly exposed <em>can</em> offer adequate diagnostic information with only 8 bits, but not always.</p>\n<p>Likewise, there are some JPG compression algorithms that are Lossless. That is, they can compress more than 8+ bits down to 8 without losing any detail.</p>",
      "votes": null,
      "replies": [
        {
          "id": 1329994,
          "author_name": "jacekpoplawski",
          "author_url": "",
          "post_date": "05/31/2021 14:14:36",
          "content": "<p>Still, what's the reason to use JPG or PNG at all if the data will be loaded into neural network with floats?</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1330088,
          "author_name": "davidbroberts",
          "author_url": "",
          "post_date": "05/31/2021 15:29:07",
          "content": "<p>I do not know that answer. I posted the same question myself.</p>\n<p><a href=\"https://www.kaggle.com/c/siim-covid19-detection/discussion/240882#1318031\" target=\"_blank\">https://www.kaggle.com/c/siim-covid19-detection/discussion/240882#1318031</a></p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1330382,
          "author_name": "davidbroberts",
          "author_url": "",
          "post_date": "05/31/2021 18:28:43",
          "content": "<p>But, my guess is that most CNN models that can be used for transfer learning are built on 8 bit images. It seems the majority of the top level architectures in competitions like this favor transfer learning as well.</p>\n<p>Since medical image datasets are hard to come by, and it would require a large set to build a model from scratch .. I suspect most people opt for the 8 bit solution.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1330498,
          "author_name": "raddar",
          "author_url": "",
          "post_date": "05/31/2021 21:36:44",
          "content": "<p>there is no practical difference between using raw 12bits and 12 bits converted to 8bits. Talking from my personal experience :)</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1330529,
          "author_name": "jacekpoplawski",
          "author_url": "",
          "post_date": "05/31/2021 23:42:36",
          "content": "<p>CNN models are not \"build on 8 bit images\", Neural Networks use floats not 8 bits</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1330541,
          "author_name": "davidbroberts",
          "author_url": "",
          "post_date": "06/01/2021 00:10:34",
          "content": "<p>They are if 8 bit JPGs are used as input. </p>\n<p>My thought process is this .. If you export all the images into JPG using a single VOI LUT that simply maps the Level to 127 and the Width to 255 on a properly exposed image, the lungs may be demonstrated well, but the mediastinum might not. Or the costophrenic angles might be obscured by breast tissue and need a lower level to be adequately interpreted.</p>\n<p>If you attempt to adjust the Level darker to 'see through' the thicker anatomy better,  there is a big difference in the result from an 8 bit versus a 10-12 bit image.</p>\n<p>Doesn't it make sense to feed a NN raw (normalized) pixel values instead of scaled pixels? Or, at least export multiple 8 bit copies with various VOI LUTs applied?</p>\n<p>Thank you all for your replies!</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1330578,
          "author_name": "davidbroberts",
          "author_url": "",
          "post_date": "06/01/2021 01:04:02",
          "content": "<p>I made a quick notebook on using raw pixel data as input for a couple CNNs. </p>\n<p>Unless I am missing something, I fail to see why it wouldn't be beneficial to do this way.</p>\n<p><a href=\"https://www.kaggle.com/davidbroberts/dicom-full-range-pixels-as-cnn-input\" target=\"_blank\">https://www.kaggle.com/davidbroberts/dicom-full-range-pixels-as-cnn-input</a></p>\n<p>I posted this question about image depth a couple weeks ago here -&gt; <a href=\"https://www.kaggle.com/c/siim-covid19-detection/discussion/240882\" target=\"_blank\">https://www.kaggle.com/c/siim-covid19-detection/discussion/240882</a></p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1331738,
          "author_name": "raddar",
          "author_url": "",
          "post_date": "06/01/2021 17:16:09",
          "content": "<p>You are raising very good questions here! I have found that CLAHE normalization on top of default VOI LUT transformation is a very nice way to deal with the fact that you can get better view with manually adjusted WW/WC. Please also have in mind that neural networks see the images differently than humans, and different WW/WC may be insignificant for NN to do all the pattern matching :)</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1331774,
          "author_name": "davidbroberts",
          "author_url": "",
          "post_date": "06/01/2021 17:54:42",
          "content": "<p>Thanks for the feedback <a href=\"https://www.kaggle.com/raddar\" target=\"_blank\">@raddar</a>! I will research CLAHE normalization.</p>\n<p>My thought is that edge detection and pattern matching <em>should be</em> more reliant on the supplied WW/WC than a human would be since a human can make adjustments to better visualize pathology that is so sensitive to WW/WC like pneumonia is.</p>\n<p>If a radiologist needs to adjust the contrast slightly to better separate soft tissue from denser soft tissue in a standard normalized image, it stands to reason that a CNN using the same image would have a harder time detecting edges and patterns, unless the image was leveled appropriately. </p>\n<p>Things like rib suppression could also be achieved by using various Levels and Centers and some masking, but would be difficult without it.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1331932,
          "author_name": "raddar",
          "author_url": "",
          "post_date": "06/01/2021 20:10:02",
          "content": "<p>I would think this way - WW/WC operation is equivalent to clipping of top/bottom pixel values and stretching to full 8bit range. If you provide raw input to a neural network - it should be more than capable of defining its own optimal clipping parameters. That's why I am not too worried about feeding correct VOI LUT to models.</p>\n<p>Edit: of course, you have to worry about all the images to have same WW/WC logic - which is hard as images come from different X-ray vendors. CLAHE solves this partially. I also found CLAHE models to generalize better on unseen devices.</p>\n<p>Double edit: feeding raw pixel values is not a good idea - you need to have VOI LUT transformed pixels (preferably device default WW/WC), as there is a mix of linear and non-linear images:)</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1332089,
          "author_name": "davidbroberts",
          "author_url": "",
          "post_date": "06/01/2021 22:36:34",
          "content": "<p>As far as I can tell, there aren't any images in this dataset with VOI LUT sequences or VOI LUT Functions that specify anything other than linear conversion.</p>\n<p>I wrote up a notebook to check. Of 5936 images in the train set, none of them have VOI LUT tags.</p>\n<p>This one also counts the non Explicit VR Little Endian transfer syntaxes.</p>\n<p><a href=\"https://www.kaggle.com/davidbroberts/covid19-images-check-for-voi-lut\" target=\"_blank\">https://www.kaggle.com/davidbroberts/covid19-images-check-for-voi-lut</a></p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1335312,
          "author_name": "jaideepvalani",
          "author_url": "",
          "post_date": "06/04/2021 06:33:08",
          "content": "<p><a href=\"https://www.kaggle.com/davidbroberts\" target=\"_blank\">@davidbroberts</a>  could help understand this term VOILUT..<br>\nAlso if you use Fastai method  df .from _dicom that exports all meta data as dataframe ,one can see easily VOILUT attribute for X ray. Is that info enough ?</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1335399,
          "author_name": "raddar",
          "author_url": "",
          "post_date": "06/04/2021 07:31:09",
          "content": "<p>you could think this way - the X-ray devices produces images which are not \"human-friendly\". VOILUT is a transformation which makes it \"human-friendly\"</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1335734,
          "author_name": "davidbroberts",
          "author_url": "",
          "post_date": "06/04/2021 12:04:22",
          "content": "<p>I like to think of VOI LUts as binning and normalization. If the range of pixel values is too high, bin them  and crunch them down to a reasonable range. In the case of images, the range is 0-255.</p>\n<p>VOI LUTs can come in several fashions .. I.E. embedded as a sequence in the DICOM file, in an external file, or just as a descriptor that specifies they type of algebra used on the Window Width and Center values to create the LUT.</p>\n<p>You can read more about it in the DICOM Part3 standard here -&gt; <a href=\"http://dicom.nema.org/medical/Dicom/2018d/output/chtml/part03/sect_C.11.2.html\" target=\"_blank\">http://dicom.nema.org/medical/Dicom/2018d/output/chtml/part03/sect_C.11.2.html</a></p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1330501,
      "author_name": "raddar",
      "author_url": "",
      "post_date": "05/31/2021 21:47:58",
      "content": "<p>You must look at DICOM metadata to see if VOI LUT function should be interpreted as linear or not - which is actually quite messy (if you looked at pydicom internals… its a headache)</p>\n<p>There is quite a lot X-ray devices producing non-linear pixels - more often its non-linear than linear!</p>",
      "votes": null,
      "replies": [
        {
          "id": 1330589,
          "author_name": "davidbroberts",
          "author_url": "",
          "post_date": "06/01/2021 01:46:16",
          "content": "<p>Yes, a lot of newer DX systems use sigmoid VOI LUTs, but a lot of non-proprietary image viewers do not support them. They commonly fall back to using linear LUTs which still produce acceptable results. Also, embedded VOI LUT aren't adjustable.</p>\n<p>Ignoring a VOI LUT sequence is not a sin :)</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1328749": "After talking with a couple people about VOI LUTs, I realize there seems to be some confusion on the subject. I thought I'd write up a notebook to explain how VOI LUTs can be manually created and applied.\n\nThis is a brief explanation and application of 'windowing' as it is done inside DICOM image viewers.\n\nhttps://www.kaggle.com/davidbroberts/manual-dicom-voi-lut",
    "1329805": "So you are saying we have more than 8-bit data in DICOM? Is there a reason to use 8-bit image format then?",
    "1329892": "Yes, most uncompressed DICOM x-ray images are larger than 8 bit. \n\nA 12 bit image can have up to 4906 values, a 16 bit image can have 65,536 but consumer grade display adapters (and monitors) can only display 8 bits of grayscale (256 'colors').\n\nRadiologists generally use special displays that can show more shades of gray than the ones we use at home. Ideally, it could show all possible color values .. but there is some science behind what shades of color the human eye can distinguish between, that says we really only need about 10 or 12 bits.\n\nThe reason to use 8 bit formats was originally bandwidth/network related. JPG compression offers a decent trade-off between file size and diagnostic quality. Generally speaking, an x-ray that is properly exposed *can* offer adequate diagnostic information with only 8 bits, but not always.\n\nLikewise, there are some JPG compression algorithms that are Lossless. That is, they can compress more than 8+ bits down to 8 without losing any detail.",
    "1329994": "Still, what's the reason to use JPG or PNG at all if the data will be loaded into neural network with floats?",
    "1330088": "I do not know that answer. I posted the same question myself.\n\nhttps://www.kaggle.com/c/siim-covid19-detection/discussion/240882#1318031",
    "1330382": "But, my guess is that most CNN models that can be used for transfer learning are built on 8 bit images. It seems the majority of the top level architectures in competitions like this favor transfer learning as well.\n\nSince medical image datasets are hard to come by, and it would require a large set to build a model from scratch .. I suspect most people opt for the 8 bit solution.",
    "1330498": "there is no practical difference between using raw 12bits and 12 bits converted to 8bits. Talking from my personal experience :)",
    "1330501": "You must look at DICOM metadata to see if VOI LUT function should be interpreted as linear or not - which is actually quite messy (if you looked at pydicom internals... its a headache)\n\nThere is quite a lot X-ray devices producing non-linear pixels - more often its non-linear than linear!",
    "1330529": "CNN models are not \"build on 8 bit images\", Neural Networks use floats not 8 bits",
    "1330541": "They are if 8 bit JPGs are used as input. \n\nMy thought process is this .. If you export all the images into JPG using a single VOI LUT that simply maps the Level to 127 and the Width to 255 on a properly exposed image, the lungs may be demonstrated well, but the mediastinum might not. Or the costophrenic angles might be obscured by breast tissue and need a lower level to be adequately interpreted.\n\nIf you attempt to adjust the Level darker to 'see through' the thicker anatomy better,  there is a big difference in the result from an 8 bit versus a 10-12 bit image.\n\nDoesn't it make sense to feed a NN raw (normalized) pixel values instead of scaled pixels? Or, at least export multiple 8 bit copies with various VOI LUTs applied?\n\nThank you all for your replies!",
    "1330578": "I made a quick notebook on using raw pixel data as input for a couple CNNs. \n\nUnless I am missing something, I fail to see why it wouldn't be beneficial to do this way.\n\nhttps://www.kaggle.com/davidbroberts/dicom-full-range-pixels-as-cnn-input\n\nI posted this question about image depth a couple weeks ago here -> https://www.kaggle.com/c/siim-covid19-detection/discussion/240882",
    "1330589": "Yes, a lot of newer DX systems use sigmoid VOI LUTs, but a lot of non-proprietary image viewers do not support them. They commonly fall back to using linear LUTs which still produce acceptable results. Also, embedded VOI LUT aren't adjustable.\n\nIgnoring a VOI LUT sequence is not a sin :)",
    "1331738": "You are raising very good questions here! I have found that CLAHE normalization on top of default VOI LUT transformation is a very nice way to deal with the fact that you can get better view with manually adjusted WW/WC. Please also have in mind that neural networks see the images differently than humans, and different WW/WC may be insignificant for NN to do all the pattern matching :)",
    "1331774": "Thanks for the feedback @raddar! I will research CLAHE normalization.\n\nMy thought is that edge detection and pattern matching *should be* more reliant on the supplied WW/WC than a human would be since a human can make adjustments to better visualize pathology that is so sensitive to WW/WC like pneumonia is.\n\nIf a radiologist needs to adjust the contrast slightly to better separate soft tissue from denser soft tissue in a standard normalized image, it stands to reason that a CNN using the same image would have a harder time detecting edges and patterns, unless the image was leveled appropriately. \n\nThings like rib suppression could also be achieved by using various Levels and Centers and some masking, but would be difficult without it.",
    "1331932": "I would think this way - WW/WC operation is equivalent to clipping of top/bottom pixel values and stretching to full 8bit range. If you provide raw input to a neural network - it should be more than capable of defining its own optimal clipping parameters. That's why I am not too worried about feeding correct VOI LUT to models.\n\nEdit: of course, you have to worry about all the images to have same WW/WC logic - which is hard as images come from different X-ray vendors. CLAHE solves this partially. I also found CLAHE models to generalize better on unseen devices.\n\nDouble edit: feeding raw pixel values is not a good idea - you need to have VOI LUT transformed pixels (preferably device default WW/WC), as there is a mix of linear and non-linear images:)",
    "1332089": "As far as I can tell, there aren't any images in this dataset with VOI LUT sequences or VOI LUT Functions that specify anything other than linear conversion.\n\nI wrote up a notebook to check. Of 5936 images in the train set, none of them have VOI LUT tags.\n\nThis one also counts the non Explicit VR Little Endian transfer syntaxes.\n\nhttps://www.kaggle.com/davidbroberts/covid19-images-check-for-voi-lut",
    "1335312": "davidbroberts  could help understand this term VOILUT..\nAlso if you use Fastai method  df .from _dicom that exports all meta data as dataframe ,one can see easily VOILUT attribute for X ray. Is that info enough ?",
    "1335399": "you could think this way - the X-ray devices produces images which are not \"human-friendly\". VOILUT is a transformation which makes it \"human-friendly\"",
    "1335734": "I like to think of VOI LUts as binning and normalization. If the range of pixel values is too high, bin them  and crunch them down to a reasonable range. In the case of images, the range is 0-255.\n\nVOI LUTs can come in several fashions .. I.E. embedded as a sequence in the DICOM file, in an external file, or just as a descriptor that specifies they type of algebra used on the Window Width and Center values to create the LUT.\n\nYou can read more about it in the DICOM Part3 standard here -> http://dicom.nema.org/medical/Dicom/2018d/output/chtml/part03/sect_C.11.2.html"
  },
  "source": "meta"
}