{
  "id": 244898,
  "title": "Clarification on Study Images",
  "url": "/competitions/siim-covid19-detection/discussion/244898",
  "author_name": "",
  "post_date": "2021-06-08T18:58:31.650140500Z",
  "votes": 1,
  "comment_count": 5,
  "views": 0,
  "content": "<p>Hi All,</p>\n<p>I was trying to read dicom images of the \"study\"  data and found out that reading some of the images gives me an error.  I am using the following code snippet to iterate through the python dataframe (new_study_df) which consists of the image paths and the labels.</p>\n<p><strong><code>\nfor i,img_data in new_study_df.iterrows():\n    img_path = img_data.loc['image']\n    try:\n        data = pydicom.read_file(img_path)\n        image = data.pixel_array   \n    except:\n        count = count + 1\n        new_study_df.loc[i] = np.nan\n        print(\"Some error occured while trying to convert to pixel array {}\",i)\n        pass\n</code></strong></p>\n<p>The above code went to except block for 440 image paths.<br>\nIs it possible to know whether this is a know issue or whether I am dong something wrong here?</p>\n<p>Thanks a lot</p>",
  "messages": [
    {
      "id": "1341612",
      "postDate": "06/08/2021 18:58:31",
      "content": "<p>Hi All,</p>\n<p>I was trying to read dicom images of the \"study\"  data and found out that reading some of the images gives me an error.  I am using the following code snippet to iterate through the python dataframe (new_study_df) which consists of the image paths and the labels.</p>\n<p><strong><code>\nfor i,img_data in new_study_df.iterrows():\n    img_path = img_data.loc['image']\n    try:\n        data = pydicom.read_file(img_path)\n        image = data.pixel_array   \n    except:\n        count = count + 1\n        new_study_df.loc[i] = np.nan\n        print(\"Some error occured while trying to convert to pixel array {}\",i)\n        pass\n</code></strong></p>\n<p>The above code went to except block for 440 image paths.<br>\nIs it possible to know whether this is a know issue or whether I am dong something wrong here?</p>\n<p>Thanks a lot</p>",
      "rawMarkdown": "Hi All,\n\nI was trying to read dicom images of the \"study\"  data and found out that reading some of the images gives me an error.  I am using the following code snippet to iterate through the python dataframe (new_study_df) which consists of the image paths and the labels.\n\n**```\nfor i,img_data in new_study_df.iterrows():\n    img_path = img_data.loc['image']\n    try:\n        data = pydicom.read_file(img_path)\n        image = data.pixel_array   \n    except:\n        count = count + 1\n        new_study_df.loc[i] = np.nan\n        print(\"Some error occured while trying to convert to pixel array {}\",i)\n        pass\n```**\n\nThe above code went to except block for 440 image paths.\nIs it possible to know whether this is a know issue or whether I am dong something wrong here?\n\nThanks a lot",
      "votes": null
    },
    {
      "id": "1341614",
      "postDate": "06/08/2021 19:00:50",
      "content": "<p>The code snippet did not display properly. <br>\ncount = 0<br>\nfor i,img_data in new_study_df.iterrows(): <br>\n      img_path = img_data.loc['image'] <br>\n     try: <br>\n        data = pydicom.read_file(img_path) <br>\n        image = data.pixel_array <br>\n    except:  <br>\n       count = count + 1 <br>\n       new_study_df.loc[i] = np.nan <br>\n       print(\"Some error occured while trying to convert to pixel array {}\",i) <br>\n       pass</p>",
      "rawMarkdown": "The code snippet did not display properly. \ncount = 0\nfor i,img_data in new_study_df.iterrows(): \n      img_path = img_data.loc['image'] \n     try: \n        data = pydicom.read_file(img_path) \n        image = data.pixel_array \n    except:  \n       count = count + 1 \n       new_study_df.loc[i] = np.nan \n       print(\"Some error occured while trying to convert to pixel array {}\",i) \n       pass",
      "votes": null
    },
    {
      "id": "1342193",
      "postDate": "06/09/2021 08:52:03",
      "content": "<p>!conda install gdcm -c conda-forge -y </p>\n<p>hope this will help </p>",
      "rawMarkdown": "!conda install gdcm -c conda-forge -y \n\nhope this will help",
      "votes": null
    },
    {
      "id": "1343231",
      "postDate": "06/10/2021 05:50:24",
      "content": "<p>Thanks Shubham Thapa!<br>\nShould I run this command and install gdcm every time I start the notebook or create a new notebook?</p>",
      "rawMarkdown": "Thanks Shubham Thapa!\nShould I run this command and install gdcm every time I start the notebook or create a new notebook?",
      "votes": null
    },
    {
      "id": "1343334",
      "postDate": "06/10/2021 06:57:43",
      "content": "<p>yes for the training notebook you can do this but for inference you need to install it offline as internet is not allowed <a href=\"https://www.kaggle.com/awsaf49/pydicom-conda-helper\" target=\"_blank\">https://www.kaggle.com/awsaf49/pydicom-conda-helper</a> add this notebook to your dataset and then install or append it to your system  for your inference notebook !</p>",
      "rawMarkdown": "yes for the training notebook you can do this but for inference you need to install it offline as internet is not allowed https://www.kaggle.com/awsaf49/pydicom-conda-helper add this notebook to your dataset and then install or append it to your system  for your inference notebook !",
      "votes": null
    },
    {
      "id": "1347281",
      "postDate": "06/13/2021 05:33:31",
      "content": "<p>Thanks a lot Shubham Thapa!</p>",
      "rawMarkdown": "Thanks a lot Shubham Thapa!",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1341614,
      "author_name": "radike",
      "author_url": "",
      "post_date": "06/08/2021 19:00:50",
      "content": "<p>The code snippet did not display properly. <br>\ncount = 0<br>\nfor i,img_data in new_study_df.iterrows(): <br>\n      img_path = img_data.loc['image'] <br>\n     try: <br>\n        data = pydicom.read_file(img_path) <br>\n        image = data.pixel_array <br>\n    except:  <br>\n       count = count + 1 <br>\n       new_study_df.loc[i] = np.nan <br>\n       print(\"Some error occured while trying to convert to pixel array {}\",i) <br>\n       pass</p>",
      "votes": null,
      "replies": [
        {
          "id": 1342193,
          "author_name": "trooperog",
          "author_url": "",
          "post_date": "06/09/2021 08:52:03",
          "content": "<p>!conda install gdcm -c conda-forge -y </p>\n<p>hope this will help </p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1343231,
      "author_name": "radike",
      "author_url": "",
      "post_date": "06/10/2021 05:50:24",
      "content": "<p>Thanks Shubham Thapa!<br>\nShould I run this command and install gdcm every time I start the notebook or create a new notebook?</p>",
      "votes": null,
      "replies": [
        {
          "id": 1343334,
          "author_name": "trooperog",
          "author_url": "",
          "post_date": "06/10/2021 06:57:43",
          "content": "<p>yes for the training notebook you can do this but for inference you need to install it offline as internet is not allowed <a href=\"https://www.kaggle.com/awsaf49/pydicom-conda-helper\" target=\"_blank\">https://www.kaggle.com/awsaf49/pydicom-conda-helper</a> add this notebook to your dataset and then install or append it to your system  for your inference notebook !</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1347281,
      "author_name": "radike",
      "author_url": "",
      "post_date": "06/13/2021 05:33:31",
      "content": "<p>Thanks a lot Shubham Thapa!</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1341612": "Hi All,\n\nI was trying to read dicom images of the \"study\"  data and found out that reading some of the images gives me an error.  I am using the following code snippet to iterate through the python dataframe (new_study_df) which consists of the image paths and the labels.\n\n**```\nfor i,img_data in new_study_df.iterrows():\n    img_path = img_data.loc['image']\n    try:\n        data = pydicom.read_file(img_path)\n        image = data.pixel_array   \n    except:\n        count = count + 1\n        new_study_df.loc[i] = np.nan\n        print(\"Some error occured while trying to convert to pixel array {}\",i)\n        pass\n```**\n\nThe above code went to except block for 440 image paths.\nIs it possible to know whether this is a know issue or whether I am dong something wrong here?\n\nThanks a lot",
    "1341614": "The code snippet did not display properly. \ncount = 0\nfor i,img_data in new_study_df.iterrows(): \n      img_path = img_data.loc['image'] \n     try: \n        data = pydicom.read_file(img_path) \n        image = data.pixel_array \n    except:  \n       count = count + 1 \n       new_study_df.loc[i] = np.nan \n       print(\"Some error occured while trying to convert to pixel array {}\",i) \n       pass",
    "1342193": "!conda install gdcm -c conda-forge -y \n\nhope this will help",
    "1343231": "Thanks Shubham Thapa!\nShould I run this command and install gdcm every time I start the notebook or create a new notebook?",
    "1343334": "yes for the training notebook you can do this but for inference you need to install it offline as internet is not allowed https://www.kaggle.com/awsaf49/pydicom-conda-helper add this notebook to your dataset and then install or append it to your system  for your inference notebook !",
    "1347281": "Thanks a lot Shubham Thapa!"
  },
  "source": "meta"
}