{
  "id": 177619,
  "title": "Converting dicoms to 3D volumes",
  "url": "/competitions/osic-pulmonary-fibrosis-progression/discussion/177619",
  "author_name": "",
  "post_date": "2020-08-26T16:35:01.578622300Z",
  "votes": 3,
  "comment_count": 4,
  "views": 0,
  "content": "<p>I'm struggling to convert the 2D dicoms to 3D arrays. I followed this notebook but I'm finding issues:<br>\n<a href=\"https://www.kaggle.com/allunia/pulmonary-fibrosis-dicom-preprocessing\" target=\"_blank\">https://www.kaggle.com/allunia/pulmonary-fibrosis-dicom-preprocessing</a></p>\n<p>For example, see the image below for subject ID00355637202295106567614. The scan seems to be squashed in the z axis. There are 37 slices, so the shape before resampling is(37, 512, 512).<br>\nApparently the slice thickness is 1, and the  pixel spacing is 0.679688, i.e. [1.0, 0.679688, 0.679688]. Therefore the shape after resampling becomes (37, 348, 348), but this is still squashed in the z axis.</p>\n<p>Is the slice thickness wrong??</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4791839%2Fb3192382344b4935a5743d7b339780f3%2FScreenshot%20from%202020-08-26%2017-27-27.png?generation=1598459892612918&amp;alt=media\" alt=\"\"></p>",
  "messages": [
    {
      "id": "986632",
      "postDate": "08/26/2020 16:35:01",
      "content": "<p>I'm struggling to convert the 2D dicoms to 3D arrays. I followed this notebook but I'm finding issues:<br>\n<a href=\"https://www.kaggle.com/allunia/pulmonary-fibrosis-dicom-preprocessing\" target=\"_blank\">https://www.kaggle.com/allunia/pulmonary-fibrosis-dicom-preprocessing</a></p>\n<p>For example, see the image below for subject ID00355637202295106567614. The scan seems to be squashed in the z axis. There are 37 slices, so the shape before resampling is(37, 512, 512).<br>\nApparently the slice thickness is 1, and the  pixel spacing is 0.679688, i.e. [1.0, 0.679688, 0.679688]. Therefore the shape after resampling becomes (37, 348, 348), but this is still squashed in the z axis.</p>\n<p>Is the slice thickness wrong??</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4791839%2Fb3192382344b4935a5743d7b339780f3%2FScreenshot%20from%202020-08-26%2017-27-27.png?generation=1598459892612918&amp;alt=media\" alt=\"\"></p>",
      "rawMarkdown": "I'm struggling to convert the 2D dicoms to 3D arrays. I followed this notebook but I'm finding issues:\nhttps://www.kaggle.com/allunia/pulmonary-fibrosis-dicom-preprocessing\n\nFor example, see the image below for subject ID00355637202295106567614. The scan seems to be squashed in the z axis. There are 37 slices, so the shape before resampling is(37, 512, 512).\nApparently the slice thickness is 1, and the  pixel spacing is 0.679688, i.e. [1.0, 0.679688, 0.679688]. Therefore the shape after resampling becomes (37, 348, 348), but this is still squashed in the z axis.\n\nIs the slice thickness wrong??\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4791839%2Fb3192382344b4935a5743d7b339780f3%2FScreenshot%20from%202020-08-26%2017-27-27.png?generation=1598459892612918&alt=media)",
      "votes": null
    },
    {
      "id": "986673",
      "postDate": "08/26/2020 17:15:11",
      "content": "<p>Slice thickness is different than slice spacing. I'm guessing your example is 1 mm slices taken every 10 mm. This is like takes a loaf of sliced bread and only taking every tenth slice. Many of the studies take every slice, but it is not unusual to have slices with skips in between.</p>",
      "rawMarkdown": "Slice thickness is different than slice spacing. I'm guessing your example is 1 mm slices taken every 10 mm. This is like takes a loaf of sliced bread and only taking every tenth slice. Many of the studies take every slice, but it is not unusual to have slices with skips in between.",
      "votes": null
    },
    {
      "id": "987407",
      "postDate": "08/27/2020 08:24:26",
      "content": "<p>Okay, so I can use the difference between the SliceLocation of adjacent scans, or the difference in ImagePositionPatient[2] to get the slice spacing. However, some patients don't have this information, for example patient ID00128637202219474716089 doesn't have this information. So what to do? I wonder if it is better to just resample everything to a uniform cube, 128x128x128 for instance.</p>",
      "rawMarkdown": "Okay, so I can use the difference between the SliceLocation of adjacent scans, or the difference in ImagePositionPatient[2] to get the slice spacing. However, some patients don't have this information, for example patient ID00128637202219474716089 doesn't have this information. So what to do? I wonder if it is better to just resample everything to a uniform cube, 128x128x128 for instance.",
      "votes": null
    },
    {
      "id": "987740",
      "postDate": "08/27/2020 13:36:59",
      "content": "<p>I tried doing something similar and this is what I did.<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1887174%2F434cb4a45e2eff9ed40cb13d06871ec9%2Ffsafsed.png?generation=1598535294840985&amp;alt=media\" alt=\"\"><br>\nI think it's hacky but I read all files for a patient into a 8 * 256 * 256 array and used a 3D convolution on it. Could not really get good validation score for the first try. </p>",
      "rawMarkdown": "I tried doing something similar and this is what I did.\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1887174%2F434cb4a45e2eff9ed40cb13d06871ec9%2Ffsafsed.png?generation=1598535294840985&alt=media)\nI think it's hacky but I read all files for a patient into a 8 * 256 * 256 array and used a 3D convolution on it. Could not really get good validation score for the first try.",
      "votes": null
    },
    {
      "id": "988801",
      "postDate": "08/28/2020 09:40:15",
      "content": "<p><a href=\"https://www.kaggle.com/richardoshaw\" target=\"_blank\">@richardoshaw</a>  <br>\nwhat is pixel spacing..<br>\n\"Apparently the slice thickness is 1, and the pixel spacing is 0.679688, i.e. [1.0, 0.679688, 0.679688]. Therefore the shape after resampling becomes (37, 348, 348), but this is still squashed in the z axis.\"</p>\n<p>what is purpose of resampling here.. how is pixel spacing used ?</p>",
      "rawMarkdown": "richardoshaw  \nwhat is pixel spacing..\n\"Apparently the slice thickness is 1, and the pixel spacing is 0.679688, i.e. [1.0, 0.679688, 0.679688]. Therefore the shape after resampling becomes (37, 348, 348), but this is still squashed in the z axis.\"\n\nwhat is purpose of resampling here.. how is pixel spacing used ?",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 986673,
      "author_name": "richardepstein",
      "author_url": "",
      "post_date": "08/26/2020 17:15:11",
      "content": "<p>Slice thickness is different than slice spacing. I'm guessing your example is 1 mm slices taken every 10 mm. This is like takes a loaf of sliced bread and only taking every tenth slice. Many of the studies take every slice, but it is not unusual to have slices with skips in between.</p>",
      "votes": null,
      "replies": [
        {
          "id": 987407,
          "author_name": "richardoshaw",
          "author_url": "",
          "post_date": "08/27/2020 08:24:26",
          "content": "<p>Okay, so I can use the difference between the SliceLocation of adjacent scans, or the difference in ImagePositionPatient[2] to get the slice spacing. However, some patients don't have this information, for example patient ID00128637202219474716089 doesn't have this information. So what to do? I wonder if it is better to just resample everything to a uniform cube, 128x128x128 for instance.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 987740,
      "author_name": "jonykarki",
      "author_url": "",
      "post_date": "08/27/2020 13:36:59",
      "content": "<p>I tried doing something similar and this is what I did.<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1887174%2F434cb4a45e2eff9ed40cb13d06871ec9%2Ffsafsed.png?generation=1598535294840985&amp;alt=media\" alt=\"\"><br>\nI think it's hacky but I read all files for a patient into a 8 * 256 * 256 array and used a 3D convolution on it. Could not really get good validation score for the first try. </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 988801,
      "author_name": "jaideepvalani",
      "author_url": "",
      "post_date": "08/28/2020 09:40:15",
      "content": "<p><a href=\"https://www.kaggle.com/richardoshaw\" target=\"_blank\">@richardoshaw</a>  <br>\nwhat is pixel spacing..<br>\n\"Apparently the slice thickness is 1, and the pixel spacing is 0.679688, i.e. [1.0, 0.679688, 0.679688]. Therefore the shape after resampling becomes (37, 348, 348), but this is still squashed in the z axis.\"</p>\n<p>what is purpose of resampling here.. how is pixel spacing used ?</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "986632": "I'm struggling to convert the 2D dicoms to 3D arrays. I followed this notebook but I'm finding issues:\nhttps://www.kaggle.com/allunia/pulmonary-fibrosis-dicom-preprocessing\n\nFor example, see the image below for subject ID00355637202295106567614. The scan seems to be squashed in the z axis. There are 37 slices, so the shape before resampling is(37, 512, 512).\nApparently the slice thickness is 1, and the  pixel spacing is 0.679688, i.e. [1.0, 0.679688, 0.679688]. Therefore the shape after resampling becomes (37, 348, 348), but this is still squashed in the z axis.\n\nIs the slice thickness wrong??\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4791839%2Fb3192382344b4935a5743d7b339780f3%2FScreenshot%20from%202020-08-26%2017-27-27.png?generation=1598459892612918&alt=media)",
    "986673": "Slice thickness is different than slice spacing. I'm guessing your example is 1 mm slices taken every 10 mm. This is like takes a loaf of sliced bread and only taking every tenth slice. Many of the studies take every slice, but it is not unusual to have slices with skips in between.",
    "987407": "Okay, so I can use the difference between the SliceLocation of adjacent scans, or the difference in ImagePositionPatient[2] to get the slice spacing. However, some patients don't have this information, for example patient ID00128637202219474716089 doesn't have this information. So what to do? I wonder if it is better to just resample everything to a uniform cube, 128x128x128 for instance.",
    "987740": "I tried doing something similar and this is what I did.\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1887174%2F434cb4a45e2eff9ed40cb13d06871ec9%2Ffsafsed.png?generation=1598535294840985&alt=media)\nI think it's hacky but I read all files for a patient into a 8 * 256 * 256 array and used a 3D convolution on it. Could not really get good validation score for the first try.",
    "988801": "richardoshaw  \nwhat is pixel spacing..\n\"Apparently the slice thickness is 1, and the pixel spacing is 0.679688, i.e. [1.0, 0.679688, 0.679688]. Therefore the shape after resampling becomes (37, 348, 348), but this is still squashed in the z axis.\"\n\nwhat is purpose of resampling here.. how is pixel spacing used ?"
  },
  "source": "meta"
}