{
  "id": 346981,
  "title": "issue with nifti volumes orientation ",
  "url": "/competitions/rsna-2022-cervical-spine-fracture-detection/discussion/346981",
  "author_name": "Abdmar",
  "post_date": "2022-08-22T11:26:14.157000",
  "votes": 3,
  "comment_count": 2,
  "views": 0,
  "content": "<p>All the segmentations related NIFTI files show the same affine orientation \"LSA\", however flipping NIFTI volume on the Z-axis does not show the right segmentation mask, and need to keep the original volume. <br>\nsee e.g  1.2.826.0.1.3680043.31077 (need Z flip) and  1.2.826.0.1.3680043.23904 (does not need flip on Z).</p>\n<p>I can't see any information in the header attribute that could help in distinguishing the orientation to decide whether or not to make the flip, any help is appreciated</p>",
  "messages": [
    {
      "id": 1909151,
      "postDate": "2022-08-22T11:26:14.157Z",
      "content": "<p>All the segmentations related NIFTI files show the same affine orientation \"LSA\", however flipping NIFTI volume on the Z-axis does not show the right segmentation mask, and need to keep the original volume. <br>\nsee e.g  1.2.826.0.1.3680043.31077 (need Z flip) and  1.2.826.0.1.3680043.23904 (does not need flip on Z).</p>\n<p>I can't see any information in the header attribute that could help in distinguishing the orientation to decide whether or not to make the flip, any help is appreciated</p>",
      "rawMarkdown": "All the segmentations related NIFTI files show the same affine orientation \"LSA\", however flipping NIFTI volume on the Z-axis does not show the right segmentation mask, and need to keep the original volume. \nsee e.g  1.2.826.0.1.3680043.31077 (need Z flip) and  1.2.826.0.1.3680043.23904 (does not need flip on Z).\n\nI can't see any information in the header attribute that could help in distinguishing the orientation to decide whether or not to make the flip, any help is appreciated",
      "votes": 3
    },
    {
      "id": 1909208,
      "postDate": "2022-08-22T12:39:20.630Z",
      "content": "<p>Faced this same issue, I'm checking the imageposition in the header between first and last dicom slice, I don't really know if it is the best way of doing it, but works.</p>\n<pre><code>def get_z_direction(dicom_1_path,dicom_last_path):\n\n    dicom_1 = pydicom.dcmread(dicom_1_path)\n    dicom_last = pydicom.dcmread(dicom_last_path)\n\n    if dicom_1.ImagePositionPatient[2] - dicom_last.ImagePositionPatient[2] &gt; 0:\n        return True\n    else:\n        return False\n</code></pre>",
      "rawMarkdown": "Faced this same issue, I'm checking the imageposition in the header between first and last dicom slice, I don't really know if it is the best way of doing it, but works.\n\n```\ndef get_z_direction(dicom_1_path,dicom_last_path):\n\n    dicom_1 = pydicom.dcmread(dicom_1_path)\n    dicom_last = pydicom.dcmread(dicom_last_path)\n\n    if dicom_1.ImagePositionPatient[2] - dicom_last.ImagePositionPatient[2] > 0:\n        return True\n    else:\n        return False\n```",
      "votes": 2,
      "replies": [
        {
          "id": 1909356,
          "postDate": "2022-08-22T15:00:37.987Z",
          "content": "<p><a href=\"https://www.kaggle.com/javiervera\" target=\"_blank\">@javiervera</a>  Thank you for your reply, I didn't think to check dicom position.  It solved the issue.</p>",
          "rawMarkdown": "@javiervera  Thank you for your reply, I didn't think to check dicom position.  It solved the issue.",
          "votes": 2
        }
      ]
    }
  ],
  "comments": [
    {
      "id": 1909208,
      "author_name": "Javier Vera",
      "author_url": "",
      "post_date": "2022-08-22T12:39:20.630000",
      "content": "<p>Faced this same issue, I'm checking the imageposition in the header between first and last dicom slice, I don't really know if it is the best way of doing it, but works.</p>\n<pre><code>def get_z_direction(dicom_1_path,dicom_last_path):\n\n    dicom_1 = pydicom.dcmread(dicom_1_path)\n    dicom_last = pydicom.dcmread(dicom_last_path)\n\n    if dicom_1.ImagePositionPatient[2] - dicom_last.ImagePositionPatient[2] &gt; 0:\n        return True\n    else:\n        return False\n</code></pre>",
      "votes": 2,
      "replies": [
        {
          "id": 1909356,
          "author_name": "Abdmar",
          "author_url": "",
          "post_date": "2022-08-22T15:00:37.987000",
          "content": "<p><a href=\"https://www.kaggle.com/javiervera\" target=\"_blank\">@javiervera</a>  Thank you for your reply, I didn't think to check dicom position.  It solved the issue.</p>",
          "votes": 2,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1909151": "All the segmentations related NIFTI files show the same affine orientation \"LSA\", however flipping NIFTI volume on the Z-axis does not show the right segmentation mask, and need to keep the original volume. \nsee e.g  1.2.826.0.1.3680043.31077 (need Z flip) and  1.2.826.0.1.3680043.23904 (does not need flip on Z).\n\nI can't see any information in the header attribute that could help in distinguishing the orientation to decide whether or not to make the flip, any help is appreciated",
    "1909208": "Faced this same issue, I'm checking the imageposition in the header between first and last dicom slice, I don't really know if it is the best way of doing it, but works.\n\n```\ndef get_z_direction(dicom_1_path,dicom_last_path):\n\n    dicom_1 = pydicom.dcmread(dicom_1_path)\n    dicom_last = pydicom.dcmread(dicom_last_path)\n\n    if dicom_1.ImagePositionPatient[2] - dicom_last.ImagePositionPatient[2] > 0:\n        return True\n    else:\n        return False\n```"
  }
}