{
  "id": 175041,
  "title": "Issues reading dicom series for patient ID00052637202186188008618",
  "url": "/competitions/osic-pulmonary-fibrosis-progression/discussion/175041",
  "author_name": "",
  "post_date": "2020-08-16T22:01:04.356699800Z",
  "votes": 4,
  "comment_count": 6,
  "views": 0,
  "content": "<p>Has anyone else had issues reading the dicom series for patient <code>ID00052637202186188008618</code> ?</p>\n<p>When visualising the axial slice with instance number \"4\" (slice with index number 3 when you load in the individual axial slices and sort by Instance number) I seem to get a different image each time I load the dicom.</p>\n<p>Here are 2 examples of what this slice looks like after loading the CT scan twice:</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F5561832%2F3faa5691195c4c7e4576f132865eaa01%2Fexmples.png?generation=1597615536455991&amp;alt=media\" alt=\"\"></p>\n<p>I was experiencing this issue with pydicom, and couldnt seem to see an issue with my code:</p>\n<pre><code>def load_slices(path: str) -&gt; List[pydicom.dataset.FileDataset]:\n    path = os.path.join(path, '*')\n    fnames = glob.glob(path, recursive=False)\n    slices = [pydicom.dcmread(fname) for fname in fnames]\n    return sorted(slices, key=operator.attrgetter('InstanceNumber'))\n\ndef load_scan(path: str) -&gt; np.ndarray:\n    slices = load_slices(path)\n    scan = np.stack([s.pixel_array for s in slices])\n\n    return scan\n</code></pre>\n<p>So I also tired to use simpleitk, in case there was an issue with pydicom, to load the image and it would throw an exception when trying to load the image.</p>\n<p>The code for loading the images is adapted from: <a href=\"https://www.programmersought.com/article/3279964614/\" target=\"_blank\">https://www.programmersought.com/article/3279964614/</a></p>\n<pre><code>reader = sitk.ImageSeriesReader()\ndicom_names = reader.GetGDCMSeriesFileNames(PATH_TO_CASE)\nreader.SetFileNames(dicom_names)\nimage = reader.Execute()\nimage_array = sitk.GetArrayFromImage(image) # z, y, x\n</code></pre>\n<p><code>image = reader.Execute()</code> throws:</p>\n<pre><code>RuntimeError: Exception thrown in SimpleITK ImageSeriesReader_Execute: /opt/miniconda3/envs/bld/conda-bld/simpleitk_1573598722828/work/build/ITK/Modules/IO/GDCM/src/itkGDCMImageIO.cxx:233:\nitk::ERROR: GDCMImageIO(0x55b83b305970): Failed to get the buffer!\n</code></pre>\n<p>I am wondering if dicom files for this CT scan are corrupt?</p>",
  "messages": [
    {
      "id": "972841",
      "postDate": "08/16/2020 22:01:04",
      "content": "<p>Has anyone else had issues reading the dicom series for patient <code>ID00052637202186188008618</code> ?</p>\n<p>When visualising the axial slice with instance number \"4\" (slice with index number 3 when you load in the individual axial slices and sort by Instance number) I seem to get a different image each time I load the dicom.</p>\n<p>Here are 2 examples of what this slice looks like after loading the CT scan twice:</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F5561832%2F3faa5691195c4c7e4576f132865eaa01%2Fexmples.png?generation=1597615536455991&amp;alt=media\" alt=\"\"></p>\n<p>I was experiencing this issue with pydicom, and couldnt seem to see an issue with my code:</p>\n<pre><code>def load_slices(path: str) -&gt; List[pydicom.dataset.FileDataset]:\n    path = os.path.join(path, '*')\n    fnames = glob.glob(path, recursive=False)\n    slices = [pydicom.dcmread(fname) for fname in fnames]\n    return sorted(slices, key=operator.attrgetter('InstanceNumber'))\n\ndef load_scan(path: str) -&gt; np.ndarray:\n    slices = load_slices(path)\n    scan = np.stack([s.pixel_array for s in slices])\n\n    return scan\n</code></pre>\n<p>So I also tired to use simpleitk, in case there was an issue with pydicom, to load the image and it would throw an exception when trying to load the image.</p>\n<p>The code for loading the images is adapted from: <a href=\"https://www.programmersought.com/article/3279964614/\" target=\"_blank\">https://www.programmersought.com/article/3279964614/</a></p>\n<pre><code>reader = sitk.ImageSeriesReader()\ndicom_names = reader.GetGDCMSeriesFileNames(PATH_TO_CASE)\nreader.SetFileNames(dicom_names)\nimage = reader.Execute()\nimage_array = sitk.GetArrayFromImage(image) # z, y, x\n</code></pre>\n<p><code>image = reader.Execute()</code> throws:</p>\n<pre><code>RuntimeError: Exception thrown in SimpleITK ImageSeriesReader_Execute: /opt/miniconda3/envs/bld/conda-bld/simpleitk_1573598722828/work/build/ITK/Modules/IO/GDCM/src/itkGDCMImageIO.cxx:233:\nitk::ERROR: GDCMImageIO(0x55b83b305970): Failed to get the buffer!\n</code></pre>\n<p>I am wondering if dicom files for this CT scan are corrupt?</p>",
      "rawMarkdown": "Has anyone else had issues reading the dicom series for patient `ID00052637202186188008618` ?\n\nWhen visualising the axial slice with instance number \"4\" (slice with index number 3 when you load in the individual axial slices and sort by Instance number) I seem to get a different image each time I load the dicom.\n\nHere are 2 examples of what this slice looks like after loading the CT scan twice:\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F5561832%2F3faa5691195c4c7e4576f132865eaa01%2Fexmples.png?generation=1597615536455991&alt=media)\n\nI was experiencing this issue with pydicom, and couldnt seem to see an issue with my code:\n\n\n```\ndef load_slices(path: str) -> List[pydicom.dataset.FileDataset]:\n    path = os.path.join(path, '*')\n    fnames = glob.glob(path, recursive=False)\n    slices = [pydicom.dcmread(fname) for fname in fnames]\n    return sorted(slices, key=operator.attrgetter('InstanceNumber'))\n\ndef load_scan(path: str) -> np.ndarray:\n    slices = load_slices(path)\n    scan = np.stack([s.pixel_array for s in slices])\n\n    return scan\n```\n\nSo I also tired to use simpleitk, in case there was an issue with pydicom, to load the image and it would throw an exception when trying to load the image.\n\nThe code for loading the images is adapted from: https://www.programmersought.com/article/3279964614/\n\n```\nreader = sitk.ImageSeriesReader()\ndicom_names = reader.GetGDCMSeriesFileNames(PATH_TO_CASE)\nreader.SetFileNames(dicom_names)\nimage = reader.Execute()\nimage_array = sitk.GetArrayFromImage(image) # z, y, x\n```\n`image = reader.Execute()` throws:\n\n```\nRuntimeError: Exception thrown in SimpleITK ImageSeriesReader_Execute: /opt/miniconda3/envs/bld/conda-bld/simpleitk_1573598722828/work/build/ITK/Modules/IO/GDCM/src/itkGDCMImageIO.cxx:233:\nitk::ERROR: GDCMImageIO(0x55b83b305970): Failed to get the buffer!\n```\n\nI am wondering if dicom files for this CT scan are corrupt?",
      "votes": null
    },
    {
      "id": "974019",
      "postDate": "08/17/2020 17:03:59",
      "content": "<p>Just tried to load the pixel array for that slice and wasn't able to (python wanted GDCM installed). You and your code should probably just ignore it; I don't think there are many of these errors.</p>",
      "rawMarkdown": "Just tried to load the pixel array for that slice and wasn't able to (python wanted GDCM installed). You and your code should probably just ignore it; I don't think there are many of these errors.",
      "votes": null
    },
    {
      "id": "974068",
      "postDate": "08/17/2020 17:49:37",
      "content": "<p>This slice seems to be problematic, however, the other slices within the same patient work. We decided to keep this patient rather than dropping the whole patient from the dataset.</p>",
      "rawMarkdown": "This slice seems to be problematic, however, the other slices within the same patient work. We decided to keep this patient rather than dropping the whole patient from the dataset.",
      "votes": null
    },
    {
      "id": "974305",
      "postDate": "08/17/2020 21:26:58",
      "content": "<p>I've tried to attach the image in question. I loaded it in the K-PACS viewer. Initially it was slightly off in Window/Level, but I was able to manually fix it.</p>\n<p>It doesn't show any lung tissue, so probably of limited importance. It is slightly corrupted, if you compare the view of the table under the patient, it has horizontal lines that don't belong and a shift of pixels. You could just duplicate an adjacent image and probably would not make any difference.</p>",
      "rawMarkdown": "I've tried to attach the image in question. I loaded it in the K-PACS viewer. Initially it was slightly off in Window/Level, but I was able to manually fix it.\n\nIt doesn't show any lung tissue, so probably of limited importance. It is slightly corrupted, if you compare the view of the table under the patient, it has horizontal lines that don't belong and a shift of pixels. You could just duplicate an adjacent image and probably would not make any difference.",
      "votes": null
    },
    {
      "id": "974316",
      "postDate": "08/17/2020 22:03:30",
      "content": "<p>Hi Ahmed, Thanks for the reply. I'm in the same team as the OP. Can we assume that corrupted slices won't appear in the test set or will we have to detect whether a slice is corrupt in code?</p>",
      "rawMarkdown": "Hi Ahmed, Thanks for the reply. I'm in the same team as the OP. Can we assume that corrupted slices won't appear in the test set or will we have to detect whether a slice is corrupt in code?",
      "votes": null
    },
    {
      "id": "974359",
      "postDate": "08/17/2020 23:42:31",
      "content": "<p>Per the administrators:</p>\n<p>We verified that patients in the test set are readable and include all needed tags, as explained in other posts in the discussion.</p>",
      "rawMarkdown": "Per the administrators:\n\nWe verified that patients in the test set are readable and include all needed tags, as explained in other posts in the discussion.",
      "votes": null
    },
    {
      "id": "974406",
      "postDate": "08/18/2020 00:13:19",
      "content": "<p>Great, thanks!</p>",
      "rawMarkdown": "Great, thanks!",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 974019,
      "author_name": "samlin20",
      "author_url": "",
      "post_date": "08/17/2020 17:03:59",
      "content": "<p>Just tried to load the pixel array for that slice and wasn't able to (python wanted GDCM installed). You and your code should probably just ignore it; I don't think there are many of these errors.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 974068,
      "author_name": "ahmedhshahin",
      "author_url": "",
      "post_date": "08/17/2020 17:49:37",
      "content": "<p>This slice seems to be problematic, however, the other slices within the same patient work. We decided to keep this patient rather than dropping the whole patient from the dataset.</p>",
      "votes": null,
      "replies": [
        {
          "id": 974316,
          "author_name": "baon6052",
          "author_url": "",
          "post_date": "08/17/2020 22:03:30",
          "content": "<p>Hi Ahmed, Thanks for the reply. I'm in the same team as the OP. Can we assume that corrupted slices won't appear in the test set or will we have to detect whether a slice is corrupt in code?</p>",
          "votes": null,
          "replies": [
            {
              "id": 974359,
              "author_name": "richardepstein",
              "author_url": "",
              "post_date": "08/17/2020 23:42:31",
              "content": "<p>Per the administrators:</p>\n<p>We verified that patients in the test set are readable and include all needed tags, as explained in other posts in the discussion.</p>",
              "votes": null,
              "replies": []
            },
            {
              "id": 974406,
              "author_name": "baon6052",
              "author_url": "",
              "post_date": "08/18/2020 00:13:19",
              "content": "<p>Great, thanks!</p>",
              "votes": null,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 974305,
      "author_name": "richardepstein",
      "author_url": "",
      "post_date": "08/17/2020 21:26:58",
      "content": "<p>I've tried to attach the image in question. I loaded it in the K-PACS viewer. Initially it was slightly off in Window/Level, but I was able to manually fix it.</p>\n<p>It doesn't show any lung tissue, so probably of limited importance. It is slightly corrupted, if you compare the view of the table under the patient, it has horizontal lines that don't belong and a shift of pixels. You could just duplicate an adjacent image and probably would not make any difference.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "972841": "Has anyone else had issues reading the dicom series for patient `ID00052637202186188008618` ?\n\nWhen visualising the axial slice with instance number \"4\" (slice with index number 3 when you load in the individual axial slices and sort by Instance number) I seem to get a different image each time I load the dicom.\n\nHere are 2 examples of what this slice looks like after loading the CT scan twice:\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F5561832%2F3faa5691195c4c7e4576f132865eaa01%2Fexmples.png?generation=1597615536455991&alt=media)\n\nI was experiencing this issue with pydicom, and couldnt seem to see an issue with my code:\n\n\n```\ndef load_slices(path: str) -> List[pydicom.dataset.FileDataset]:\n    path = os.path.join(path, '*')\n    fnames = glob.glob(path, recursive=False)\n    slices = [pydicom.dcmread(fname) for fname in fnames]\n    return sorted(slices, key=operator.attrgetter('InstanceNumber'))\n\ndef load_scan(path: str) -> np.ndarray:\n    slices = load_slices(path)\n    scan = np.stack([s.pixel_array for s in slices])\n\n    return scan\n```\n\nSo I also tired to use simpleitk, in case there was an issue with pydicom, to load the image and it would throw an exception when trying to load the image.\n\nThe code for loading the images is adapted from: https://www.programmersought.com/article/3279964614/\n\n```\nreader = sitk.ImageSeriesReader()\ndicom_names = reader.GetGDCMSeriesFileNames(PATH_TO_CASE)\nreader.SetFileNames(dicom_names)\nimage = reader.Execute()\nimage_array = sitk.GetArrayFromImage(image) # z, y, x\n```\n`image = reader.Execute()` throws:\n\n```\nRuntimeError: Exception thrown in SimpleITK ImageSeriesReader_Execute: /opt/miniconda3/envs/bld/conda-bld/simpleitk_1573598722828/work/build/ITK/Modules/IO/GDCM/src/itkGDCMImageIO.cxx:233:\nitk::ERROR: GDCMImageIO(0x55b83b305970): Failed to get the buffer!\n```\n\nI am wondering if dicom files for this CT scan are corrupt?",
    "974019": "Just tried to load the pixel array for that slice and wasn't able to (python wanted GDCM installed). You and your code should probably just ignore it; I don't think there are many of these errors.",
    "974068": "This slice seems to be problematic, however, the other slices within the same patient work. We decided to keep this patient rather than dropping the whole patient from the dataset.",
    "974305": "I've tried to attach the image in question. I loaded it in the K-PACS viewer. Initially it was slightly off in Window/Level, but I was able to manually fix it.\n\nIt doesn't show any lung tissue, so probably of limited importance. It is slightly corrupted, if you compare the view of the table under the patient, it has horizontal lines that don't belong and a shift of pixels. You could just duplicate an adjacent image and probably would not make any difference.",
    "974316": "Hi Ahmed, Thanks for the reply. I'm in the same team as the OP. Can we assume that corrupted slices won't appear in the test set or will we have to detect whether a slice is corrupt in code?",
    "974359": "Per the administrators:\n\nWe verified that patients in the test set are readable and include all needed tags, as explained in other posts in the discussion.",
    "974406": "Great, thanks!"
  },
  "source": "meta"
}