{
  "id": 18615,
  "title": "code for Osirix Lite \"Location\" field",
  "url": "/competitions/second-annual-data-science-bowl/discussion/18615",
  "author_name": "udibr",
  "post_date": "2016-01-28T00:56:51.117000",
  "votes": 3,
  "comment_count": 0,
  "views": 442,
  "content": "<p>If you are using Osirix Lite perhaps you have noticed the &quot;Location&quot; field located at the bottom left corner of the image being displayed.</p>\n\n<p>I think I managed to reverse engineer how it is computed from the dicom image.\nHope I did'nt made mistakes and would be happy to know why it is the way it is.</p>\n\n<pre><code>image_center2D = dicom.PixelSpacing * (np.array([dicom.Columns,dicom.Rows])-np.ones(2))/2.\nimage_center3D = np.dot(image_center2D, np.reshape(dicom.ImageOrientationPatient,(2,3)))\ncenter =  dicom.ImagePositionPatient + image_center3D\ndirection = np.argmax(np.abs(np.cross(dicom.ImageOrientationPatient[:3],dicom.ImageOrientationPatient[3:])))\nprint np.round(center[direction],2)\n</code></pre>",
  "messages": [
    {
      "id": 106037,
      "postDate": "2016-01-28T00:56:51.117Z",
      "content": "<p>If you are using Osirix Lite perhaps you have noticed the &quot;Location&quot; field located at the bottom left corner of the image being displayed.</p>\n\n<p>I think I managed to reverse engineer how it is computed from the dicom image.\nHope I did'nt made mistakes and would be happy to know why it is the way it is.</p>\n\n<pre><code>image_center2D = dicom.PixelSpacing * (np.array([dicom.Columns,dicom.Rows])-np.ones(2))/2.\nimage_center3D = np.dot(image_center2D, np.reshape(dicom.ImageOrientationPatient,(2,3)))\ncenter =  dicom.ImagePositionPatient + image_center3D\ndirection = np.argmax(np.abs(np.cross(dicom.ImageOrientationPatient[:3],dicom.ImageOrientationPatient[3:])))\nprint np.round(center[direction],2)\n</code></pre>",
      "rawMarkdown": "If you are using Osirix Lite perhaps you have noticed the \"Location\" field located at the bottom left corner of the image being displayed.\r\n\r\nI think I managed to reverse engineer how it is computed from the dicom image.\r\nHope I did'nt made mistakes and would be happy to know why it is the way it is.\r\n\r\n    image_center2D = dicom.PixelSpacing * (np.array([dicom.Columns,dicom.Rows])-np.ones(2))/2.\r\n    image_center3D = np.dot(image_center2D, np.reshape(dicom.ImageOrientationPatient,(2,3)))\r\n    center =  dicom.ImagePositionPatient + image_center3D\r\n    direction = np.argmax(np.abs(np.cross(dicom.ImageOrientationPatient[:3],dicom.ImageOrientationPatient[3:])))\r\n    print np.round(center[direction],2)\r\n\r\n",
      "votes": 3
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "106037": "If you are using Osirix Lite perhaps you have noticed the \"Location\" field located at the bottom left corner of the image being displayed.\r\n\r\nI think I managed to reverse engineer how it is computed from the dicom image.\r\nHope I did'nt made mistakes and would be happy to know why it is the way it is.\r\n\r\n    image_center2D = dicom.PixelSpacing * (np.array([dicom.Columns,dicom.Rows])-np.ones(2))/2.\r\n    image_center3D = np.dot(image_center2D, np.reshape(dicom.ImageOrientationPatient,(2,3)))\r\n    center =  dicom.ImagePositionPatient + image_center3D\r\n    direction = np.argmax(np.abs(np.cross(dicom.ImageOrientationPatient[:3],dicom.ImageOrientationPatient[3:])))\r\n    print np.round(center[direction],2)\r\n\r\n"
  }
}