{
  "id": 372322,
  "title": "Submission Constantly Fails",
  "url": "/competitions/rsna-breast-cancer-detection/discussion/372322",
  "author_name": "Rabia Eda Yılmaz",
  "post_date": "2022-12-15T12:38:09.418000",
  "votes": 3,
  "comment_count": 7,
  "views": 0,
  "content": "<p>I read about the other discussions but none of them seemed to solve my problem. Whenever I submit the output, it just fails. The format of the csv file seems okay. But I always get <em>Notebook Threw Exception\nYour notebook hit an unhandled error while rerunning your code. Note that the hidden dataset can be larger/smaller/different than the public dataset.</em> error.</p>\n<p>Do you have any idea why is it like that? :(</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7480915%2F15ae0ef55b0e4dfb581d51b40f2b7ccc%2Fsample.png?generation=1671107884722133&amp;alt=media\" alt=\"\"></p>",
  "messages": [
    {
      "id": 2070551,
      "postDate": "2022-12-20T06:22:59.087Z",
      "content": "<p>Read this <a href=\"https://www.kaggle.com/competitions/rsna-breast-cancer-detection/discussion/370156#2053540\" target=\"_blank\">discussion</a></p>",
      "rawMarkdown": "Read this [discussion](https://www.kaggle.com/competitions/rsna-breast-cancer-detection/discussion/370156#2053540)",
      "votes": 1
    },
    {
      "id": 2066415,
      "postDate": "2022-12-15T17:07:26.190Z",
      "content": "<p>I get your point. :-)<br>\nOne suggestion that may or may not be useful (it helped me); I notice that you are using converted images rather than converting everything yourself. You may want to consider running your conversion on the entire training set. If your processing has problems with certain files you may see those problems in the interactive run rather than getting a hidden error that results in \"Threw exception\".</p>",
      "rawMarkdown": "I get your point. :-)\nOne suggestion that may or may not be useful (it helped me); I notice that you are using converted images rather than converting everything yourself. You may want to consider running your conversion on the entire training set. If your processing has problems with certain files you may see those problems in the interactive run rather than getting a hidden error that results in \"Threw exception\".",
      "votes": 1,
      "replies": [
        {
          "id": 2066552,
          "postDate": "2022-12-15T20:01:41.507Z",
          "content": "<p>Great idea, thank you!</p>",
          "rawMarkdown": "Great idea, thank you!",
          "votes": 1
        }
      ]
    },
    {
      "id": 2066142,
      "postDate": "2022-12-15T12:46:38.230Z",
      "content": "<p>I have struggled with this as well (and \"Out of memory\" and \"Timeout\").<br>\nThe \"threw exception\" turned out to be the way some of the images in the hidden dataset are compressed which caused pydicom.dcmread to fail. I'm now using dicomsdl.open instead and that works (using <a href=\"https://www.kaggle.com/code/hey24sheep/frozen-packages-for-offline-use)\" target=\"_blank\">https://www.kaggle.com/code/hey24sheep/frozen-packages-for-offline-use)</a>.</p>",
      "rawMarkdown": "I have struggled with this as well (and \"Out of memory\" and \"Timeout\").\nThe \"threw exception\" turned out to be the way some of the images in the hidden dataset are compressed which caused pydicom.dcmread to fail. I'm now using dicomsdl.open instead and that works (using https://www.kaggle.com/code/hey24sheep/frozen-packages-for-offline-use).",
      "votes": 1,
      "replies": [
        {
          "id": 2066159,
          "postDate": "2022-12-15T12:53:53.110Z",
          "content": "<p>Thank you for your reply! But I'm already using that function to read dicom files:</p>\n<blockquote>\n  <p>def read_dicom(path, fix_monochrome = True):<br>\n      dicom = dicomsdl.open(path)<br>\n      data = dicom.pixelData(storedvalue=False)  # storedvalue = True for int16 return otherwise float32<br>\n      data = data - np.min(data)<br>\n      data = data / np.max(data)<br>\n      if fix_monochrome and dicom.PhotometricInterpretation == \"MONOCHROME1\":<br>\n          data = 1.0 - data<br>\n      return data</p>\n</blockquote>",
          "rawMarkdown": "Thank you for your reply! But I'm already using that function to read dicom files:\n\n>def read_dicom(path, fix_monochrome = True):\n    dicom = dicomsdl.open(path)\n    data = dicom.pixelData(storedvalue=False)  # storedvalue = True for int16 return otherwise float32\n    data = data - np.min(data)\n    data = data / np.max(data)\n    if fix_monochrome and dicom.PhotometricInterpretation == \"MONOCHROME1\":\n        data = 1.0 - data\n    return data"
        }
      ]
    },
    {
      "id": 2066135,
      "postDate": "2022-12-15T12:38:09.420Z",
      "content": "<p>I read about the other discussions but none of them seemed to solve my problem. Whenever I submit the output, it just fails. The format of the csv file seems okay. But I always get <em>Notebook Threw Exception\nYour notebook hit an unhandled error while rerunning your code. Note that the hidden dataset can be larger/smaller/different than the public dataset.</em> error.</p>\n<p>Do you have any idea why is it like that? :(</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7480915%2F15ae0ef55b0e4dfb581d51b40f2b7ccc%2Fsample.png?generation=1671107884722133&amp;alt=media\" alt=\"\"></p>",
      "rawMarkdown": "I read about the other discussions but none of them seemed to solve my problem. Whenever I submit the output, it just fails. The format of the csv file seems okay. But I always get *Notebook Threw Exception\nYour notebook hit an unhandled error while rerunning your code. Note that the hidden dataset can be larger/smaller/different than the public dataset.* error.\n\nDo you have any idea why is it like that? :(\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7480915%2F15ae0ef55b0e4dfb581d51b40f2b7ccc%2Fsample.png?generation=1671107884722133&alt=media)",
      "votes": 2
    },
    {
      "id": 2066254,
      "postDate": "2022-12-15T14:15:02.130Z",
      "content": "<p>That's interesting. Maybe PhotometricInterpretation is missing from some of the images in the test set? I just have:<br>\n        dicom1 = dicomsdl.open(VAL_PATH + str(row['patient_id']) + '/' + str(row['image_id']) + '.dcm')<br>\n        image1 = dicom1.pixelData(storedvalue=True)<br>\n        img_max = np.amax(image1)<br>\n        img_min = np.amin(image1)<br>\n        image1 = ((image1 - img_min) / (img_max - img_min))<br>\n        if image1.mean() &gt; 128:  # Inverted image detected. Invert again<br>\n            image1 = 255 - image1<br>\n        img = crop_image(Image.fromarray(image1))</p>",
      "rawMarkdown": "That's interesting. Maybe PhotometricInterpretation is missing from some of the images in the test set? I just have:\n\t\tdicom1 = dicomsdl.open(VAL_PATH + str(row['patient_id']) + '/' + str(row['image_id']) + '.dcm')\n\t\timage1 = dicom1.pixelData(storedvalue=True)\n\t\timg_max = np.amax(image1)\n\t\timg_min = np.amin(image1)\n\t\timage1 = ((image1 - img_min) / (img_max - img_min))\n\t\tif image1.mean() > 128:  # Inverted image detected. Invert again\n\t\t\timage1 = 255 - image1\n\t\timg = crop_image(Image.fromarray(image1))\n",
      "replies": [
        {
          "id": 2066392,
          "postDate": "2022-12-15T16:49:43.873Z",
          "content": "<p>Thank you for sharing the function that worked out for you but I don't think it fails because of the PhotometricInterpretation in test set since this function is used by many else too. I set my notebook as  public. If you have time, I would be really happy to know my noob mistake.</p>\n<p><a href=\"https://www.kaggle.com/code/truthisneverlinear/rsna-efficientnetv2-xl-pytorch\" target=\"_blank\">https://www.kaggle.com/code/truthisneverlinear/rsna-efficientnetv2-xl-pytorch</a></p>",
          "rawMarkdown": "Thank you for sharing the function that worked out for you but I don't think it fails because of the PhotometricInterpretation in test set since this function is used by many else too. I set my notebook as  public. If you have time, I would be really happy to know my noob mistake.\n\nhttps://www.kaggle.com/code/truthisneverlinear/rsna-efficientnetv2-xl-pytorch"
        }
      ]
    }
  ],
  "comments": [
    {
      "id": 2070551,
      "author_name": "Hey24sheep",
      "author_url": "",
      "post_date": "2022-12-20T06:22:59.087000",
      "content": "<p>Read this <a href=\"https://www.kaggle.com/competitions/rsna-breast-cancer-detection/discussion/370156#2053540\" target=\"_blank\">discussion</a></p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 2066415,
      "author_name": "lmadsen",
      "author_url": "",
      "post_date": "2022-12-15T17:07:26.190000",
      "content": "<p>I get your point. :-)<br>\nOne suggestion that may or may not be useful (it helped me); I notice that you are using converted images rather than converting everything yourself. You may want to consider running your conversion on the entire training set. If your processing has problems with certain files you may see those problems in the interactive run rather than getting a hidden error that results in \"Threw exception\".</p>",
      "votes": 1,
      "replies": [
        {
          "id": 2066552,
          "author_name": "Rabia Eda Yılmaz",
          "author_url": "",
          "post_date": "2022-12-15T20:01:41.507000",
          "content": "<p>Great idea, thank you!</p>",
          "votes": 1,
          "replies": []
        }
      ]
    },
    {
      "id": 2066142,
      "author_name": "lmadsen",
      "author_url": "",
      "post_date": "2022-12-15T12:46:38.230000",
      "content": "<p>I have struggled with this as well (and \"Out of memory\" and \"Timeout\").<br>\nThe \"threw exception\" turned out to be the way some of the images in the hidden dataset are compressed which caused pydicom.dcmread to fail. I'm now using dicomsdl.open instead and that works (using <a href=\"https://www.kaggle.com/code/hey24sheep/frozen-packages-for-offline-use)\" target=\"_blank\">https://www.kaggle.com/code/hey24sheep/frozen-packages-for-offline-use)</a>.</p>",
      "votes": 1,
      "replies": [
        {
          "id": 2066159,
          "author_name": "Rabia Eda Yılmaz",
          "author_url": "",
          "post_date": "2022-12-15T12:53:53.110000",
          "content": "<p>Thank you for your reply! But I'm already using that function to read dicom files:</p>\n<blockquote>\n  <p>def read_dicom(path, fix_monochrome = True):<br>\n      dicom = dicomsdl.open(path)<br>\n      data = dicom.pixelData(storedvalue=False)  # storedvalue = True for int16 return otherwise float32<br>\n      data = data - np.min(data)<br>\n      data = data / np.max(data)<br>\n      if fix_monochrome and dicom.PhotometricInterpretation == \"MONOCHROME1\":<br>\n          data = 1.0 - data<br>\n      return data</p>\n</blockquote>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 2066254,
      "author_name": "lmadsen",
      "author_url": "",
      "post_date": "2022-12-15T14:15:02.130000",
      "content": "<p>That's interesting. Maybe PhotometricInterpretation is missing from some of the images in the test set? I just have:<br>\n        dicom1 = dicomsdl.open(VAL_PATH + str(row['patient_id']) + '/' + str(row['image_id']) + '.dcm')<br>\n        image1 = dicom1.pixelData(storedvalue=True)<br>\n        img_max = np.amax(image1)<br>\n        img_min = np.amin(image1)<br>\n        image1 = ((image1 - img_min) / (img_max - img_min))<br>\n        if image1.mean() &gt; 128:  # Inverted image detected. Invert again<br>\n            image1 = 255 - image1<br>\n        img = crop_image(Image.fromarray(image1))</p>",
      "votes": 0,
      "replies": [
        {
          "id": 2066392,
          "author_name": "Rabia Eda Yılmaz",
          "author_url": "",
          "post_date": "2022-12-15T16:49:43.873000",
          "content": "<p>Thank you for sharing the function that worked out for you but I don't think it fails because of the PhotometricInterpretation in test set since this function is used by many else too. I set my notebook as  public. If you have time, I would be really happy to know my noob mistake.</p>\n<p><a href=\"https://www.kaggle.com/code/truthisneverlinear/rsna-efficientnetv2-xl-pytorch\" target=\"_blank\">https://www.kaggle.com/code/truthisneverlinear/rsna-efficientnetv2-xl-pytorch</a></p>",
          "votes": 0,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "2070551": "Read this [discussion](https://www.kaggle.com/competitions/rsna-breast-cancer-detection/discussion/370156#2053540)",
    "2066415": "I get your point. :-)\nOne suggestion that may or may not be useful (it helped me); I notice that you are using converted images rather than converting everything yourself. You may want to consider running your conversion on the entire training set. If your processing has problems with certain files you may see those problems in the interactive run rather than getting a hidden error that results in \"Threw exception\".",
    "2066142": "I have struggled with this as well (and \"Out of memory\" and \"Timeout\").\nThe \"threw exception\" turned out to be the way some of the images in the hidden dataset are compressed which caused pydicom.dcmread to fail. I'm now using dicomsdl.open instead and that works (using https://www.kaggle.com/code/hey24sheep/frozen-packages-for-offline-use).",
    "2066135": "I read about the other discussions but none of them seemed to solve my problem. Whenever I submit the output, it just fails. The format of the csv file seems okay. But I always get *Notebook Threw Exception\nYour notebook hit an unhandled error while rerunning your code. Note that the hidden dataset can be larger/smaller/different than the public dataset.* error.\n\nDo you have any idea why is it like that? :(\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7480915%2F15ae0ef55b0e4dfb581d51b40f2b7ccc%2Fsample.png?generation=1671107884722133&alt=media)",
    "2066254": "That's interesting. Maybe PhotometricInterpretation is missing from some of the images in the test set? I just have:\n\t\tdicom1 = dicomsdl.open(VAL_PATH + str(row['patient_id']) + '/' + str(row['image_id']) + '.dcm')\n\t\timage1 = dicom1.pixelData(storedvalue=True)\n\t\timg_max = np.amax(image1)\n\t\timg_min = np.amin(image1)\n\t\timage1 = ((image1 - img_min) / (img_max - img_min))\n\t\tif image1.mean() > 128:  # Inverted image detected. Invert again\n\t\t\timage1 = 255 - image1\n\t\timg = crop_image(Image.fromarray(image1))\n"
  }
}