{
  "id": 523859,
  "title": "Figure out sagittal image direction",
  "url": "/competitions/rsna-2024-lumbar-spine-degenerative-classification/discussion/523859",
  "author_name": "",
  "post_date": "2024-08-03T06:27:30.535738300Z",
  "votes": 19,
  "comment_count": 2,
  "views": 0,
  "content": "<h1>Figure out sagittal image direction</h1>\n<p>As discussed in this <a href=\"https://www.kaggle.com/competitions/rsna-2024-lumbar-spine-degenerative-classification/discussion/521997\" target=\"_blank\">page</a>, the direction of MRI scans in this dataset is not ordered for the saggital images, meaning for some images lower instance number means left, whereas for some other lower instances number means right. </p>\n<p>This can be inferred from the label coordinates, as their keypoints represent left or right of the patient (see fig1). As a result, model cannot learn the direction of the 3d image and cannot differentiate between left and right degeneration diagnoses. </p>\n<p>This can be solved using the Image Position (Patient) information in the dicom metadata. As stated in <a href=\"https://blog.redbrickai.com/blog-posts/introduction-to-dicom-coordinate\" target=\"_blank\">this webpage</a> about dicom images (see fig2).</p>\n<blockquote>\n  <p>The positive X direction is towards the left of the patient.</p>\n  <p>The positive Y direction is towards the back of the patient (anterior to posterior).</p>\n  <p>The positive Z direction is towards top of the patient (inferior to superior).</p>\n</blockquote>\n<p>We know that the x coordinate in the Image Position (Patient) describes the relative direction of the scan to the patient. The higher it is, the more left it is to the actual patient. Vice versa. Therefore, we can take the first and last dicom from the folder, get the difference between the x Image Position coordinate of the two, and infer whether the series is from left to right, or right to left, in the patient's perspective. Once we get this information, we can simply flip the dicom series number for those that has unmatching orientation. See result in fig3.</p>\n<h1>Notebook, dataset</h1>\n<p>See more details in notebook: <a href=\"https://www.kaggle.com/code/llleeeoooh/how-to-figure-out-sagittal-image-direction\" target=\"_blank\">notebook</a></p>\n<p>Use dataset which contains information of the direction of the image: <a href=\"https://www.kaggle.com/datasets/llleeeoooh/annotated-train-series-descriptions\" target=\"_blank\">dataset</a></p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F15806223%2F7d6acf350009e93c273ddc7e2bdff53c%2F1.png?generation=1722666242730970&amp;alt=media\" alt=\"fig1\"></p>\n<p><img src=\"https://cdn.prod.website-files.com/642ff723b80bac51fafabacb/6432e06f637d39358edb9b2c_1*s1N_h0tyT2DPGjH8R5G7wg.png\" alt=\"fig2\"></p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F15806223%2F14c4803bedb9157693de1ed2b7bdd199%2F2.png?generation=1722666277389608&amp;alt=media\" alt=\"fig3\"></p>",
  "messages": [
    {
      "id": "2945194",
      "postDate": "08/03/2024 06:27:30",
      "content": "<h1>Figure out sagittal image direction</h1>\n<p>As discussed in this <a href=\"https://www.kaggle.com/competitions/rsna-2024-lumbar-spine-degenerative-classification/discussion/521997\" target=\"_blank\">page</a>, the direction of MRI scans in this dataset is not ordered for the saggital images, meaning for some images lower instance number means left, whereas for some other lower instances number means right. </p>\n<p>This can be inferred from the label coordinates, as their keypoints represent left or right of the patient (see fig1). As a result, model cannot learn the direction of the 3d image and cannot differentiate between left and right degeneration diagnoses. </p>\n<p>This can be solved using the Image Position (Patient) information in the dicom metadata. As stated in <a href=\"https://blog.redbrickai.com/blog-posts/introduction-to-dicom-coordinate\" target=\"_blank\">this webpage</a> about dicom images (see fig2).</p>\n<blockquote>\n  <p>The positive X direction is towards the left of the patient.</p>\n  <p>The positive Y direction is towards the back of the patient (anterior to posterior).</p>\n  <p>The positive Z direction is towards top of the patient (inferior to superior).</p>\n</blockquote>\n<p>We know that the x coordinate in the Image Position (Patient) describes the relative direction of the scan to the patient. The higher it is, the more left it is to the actual patient. Vice versa. Therefore, we can take the first and last dicom from the folder, get the difference between the x Image Position coordinate of the two, and infer whether the series is from left to right, or right to left, in the patient's perspective. Once we get this information, we can simply flip the dicom series number for those that has unmatching orientation. See result in fig3.</p>\n<h1>Notebook, dataset</h1>\n<p>See more details in notebook: <a href=\"https://www.kaggle.com/code/llleeeoooh/how-to-figure-out-sagittal-image-direction\" target=\"_blank\">notebook</a></p>\n<p>Use dataset which contains information of the direction of the image: <a href=\"https://www.kaggle.com/datasets/llleeeoooh/annotated-train-series-descriptions\" target=\"_blank\">dataset</a></p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F15806223%2F7d6acf350009e93c273ddc7e2bdff53c%2F1.png?generation=1722666242730970&amp;alt=media\" alt=\"fig1\"></p>\n<p><img src=\"https://cdn.prod.website-files.com/642ff723b80bac51fafabacb/6432e06f637d39358edb9b2c_1*s1N_h0tyT2DPGjH8R5G7wg.png\" alt=\"fig2\"></p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F15806223%2F14c4803bedb9157693de1ed2b7bdd199%2F2.png?generation=1722666277389608&amp;alt=media\" alt=\"fig3\"></p>",
      "rawMarkdown": "# Figure out sagittal image direction\n\nAs discussed in this [page](https://www.kaggle.com/competitions/rsna-2024-lumbar-spine-degenerative-classification/discussion/521997), the direction of MRI scans in this dataset is not ordered for the saggital images, meaning for some images lower instance number means left, whereas for some other lower instances number means right. \n\nThis can be inferred from the label coordinates, as their keypoints represent left or right of the patient (see fig1). As a result, model cannot learn the direction of the 3d image and cannot differentiate between left and right degeneration diagnoses. \n\nThis can be solved using the Image Position (Patient) information in the dicom metadata. As stated in [this webpage](https://blog.redbrickai.com/blog-posts/introduction-to-dicom-coordinate) about dicom images (see fig2).\n\n> The positive X direction is towards the left of the patient.\n\n> The positive Y direction is towards the back of the patient (anterior to posterior).\n\n> The positive Z direction is towards top of the patient (inferior to superior).\n\nWe know that the x coordinate in the Image Position (Patient) describes the relative direction of the scan to the patient. The higher it is, the more left it is to the actual patient. Vice versa. Therefore, we can take the first and last dicom from the folder, get the difference between the x Image Position coordinate of the two, and infer whether the series is from left to right, or right to left, in the patient's perspective. Once we get this information, we can simply flip the dicom series number for those that has unmatching orientation. See result in fig3.\n\n# Notebook, dataset\n\nSee more details in notebook: [notebook](https://www.kaggle.com/code/llleeeoooh/how-to-figure-out-sagittal-image-direction)\n\nUse dataset which contains information of the direction of the image: [dataset](https://www.kaggle.com/datasets/llleeeoooh/annotated-train-series-descriptions)\n\n![fig1](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F15806223%2F7d6acf350009e93c273ddc7e2bdff53c%2F1.png?generation=1722666242730970&alt=media)\n\n![fig2](https://cdn.prod.website-files.com/642ff723b80bac51fafabacb/6432e06f637d39358edb9b2c_1*s1N_h0tyT2DPGjH8R5G7wg.png)\n\n![fig3](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F15806223%2F14c4803bedb9157693de1ed2b7bdd199%2F2.png?generation=1722666277389608&alt=media)",
      "votes": null
    },
    {
      "id": "2956474",
      "postDate": "08/12/2024 06:17:57",
      "content": "<p>Thanks for sharing your experience.</p>",
      "rawMarkdown": "Thanks for sharing your experience.",
      "votes": null
    },
    {
      "id": "2959691",
      "postDate": "08/15/2024 07:27:02",
      "content": "<p>Thank you for your valuable insights. It has helped me greatly to get started. Consistent scan direction should significantly enhance a model's learning.</p>",
      "rawMarkdown": "Thank you for your valuable insights. It has helped me greatly to get started. Consistent scan direction should significantly enhance a model's learning.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2956474,
      "author_name": "sinyoungra",
      "author_url": "",
      "post_date": "08/12/2024 06:17:57",
      "content": "<p>Thanks for sharing your experience.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 2959691,
      "author_name": "suhailchand",
      "author_url": "",
      "post_date": "08/15/2024 07:27:02",
      "content": "<p>Thank you for your valuable insights. It has helped me greatly to get started. Consistent scan direction should significantly enhance a model's learning.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "2945194": "# Figure out sagittal image direction\n\nAs discussed in this [page](https://www.kaggle.com/competitions/rsna-2024-lumbar-spine-degenerative-classification/discussion/521997), the direction of MRI scans in this dataset is not ordered for the saggital images, meaning for some images lower instance number means left, whereas for some other lower instances number means right. \n\nThis can be inferred from the label coordinates, as their keypoints represent left or right of the patient (see fig1). As a result, model cannot learn the direction of the 3d image and cannot differentiate between left and right degeneration diagnoses. \n\nThis can be solved using the Image Position (Patient) information in the dicom metadata. As stated in [this webpage](https://blog.redbrickai.com/blog-posts/introduction-to-dicom-coordinate) about dicom images (see fig2).\n\n> The positive X direction is towards the left of the patient.\n\n> The positive Y direction is towards the back of the patient (anterior to posterior).\n\n> The positive Z direction is towards top of the patient (inferior to superior).\n\nWe know that the x coordinate in the Image Position (Patient) describes the relative direction of the scan to the patient. The higher it is, the more left it is to the actual patient. Vice versa. Therefore, we can take the first and last dicom from the folder, get the difference between the x Image Position coordinate of the two, and infer whether the series is from left to right, or right to left, in the patient's perspective. Once we get this information, we can simply flip the dicom series number for those that has unmatching orientation. See result in fig3.\n\n# Notebook, dataset\n\nSee more details in notebook: [notebook](https://www.kaggle.com/code/llleeeoooh/how-to-figure-out-sagittal-image-direction)\n\nUse dataset which contains information of the direction of the image: [dataset](https://www.kaggle.com/datasets/llleeeoooh/annotated-train-series-descriptions)\n\n![fig1](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F15806223%2F7d6acf350009e93c273ddc7e2bdff53c%2F1.png?generation=1722666242730970&alt=media)\n\n![fig2](https://cdn.prod.website-files.com/642ff723b80bac51fafabacb/6432e06f637d39358edb9b2c_1*s1N_h0tyT2DPGjH8R5G7wg.png)\n\n![fig3](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F15806223%2F14c4803bedb9157693de1ed2b7bdd199%2F2.png?generation=1722666277389608&alt=media)",
    "2956474": "Thanks for sharing your experience.",
    "2959691": "Thank you for your valuable insights. It has helped me greatly to get started. Consistent scan direction should significantly enhance a model's learning."
  },
  "source": "meta"
}