{
  "id": 355738,
  "title": "Noise in Segmentation Data",
  "url": "/competitions/rsna-2022-cervical-spine-fracture-detection/discussion/355738",
  "author_name": "Anouk Stein, MD",
  "post_date": "2022-09-28T00:44:48.890000",
  "votes": 12,
  "comment_count": 3,
  "views": 0,
  "content": "<p>There are 4 cases with random nonzero pixels that prevent bounding box access via the function cv2.boundingRect(cv2.findNonZero(img)). These are the ones I found so far: '1.2.826.0.1.3680043.6125', '1.2.826.0.1.3680043.1542',  '1.2.826.0.1.3680043.24891', '1.2.826.0.1.3680043.11827'</p>\n<p>Also '1.2.826.0.1.3680043.1363' has random labels for C5 and C6 on the first slice. There are likely other cases. I'm trying to find a simple way to denoise these.</p>",
  "messages": [
    {
      "id": 1959113,
      "postDate": "2022-09-28T00:44:48.890Z",
      "content": "<p>There are 4 cases with random nonzero pixels that prevent bounding box access via the function cv2.boundingRect(cv2.findNonZero(img)). These are the ones I found so far: '1.2.826.0.1.3680043.6125', '1.2.826.0.1.3680043.1542',  '1.2.826.0.1.3680043.24891', '1.2.826.0.1.3680043.11827'</p>\n<p>Also '1.2.826.0.1.3680043.1363' has random labels for C5 and C6 on the first slice. There are likely other cases. I'm trying to find a simple way to denoise these.</p>",
      "rawMarkdown": "There are 4 cases with random nonzero pixels that prevent bounding box access via the function cv2.boundingRect(cv2.findNonZero(img)). These are the ones I found so far: '1.2.826.0.1.3680043.6125', '1.2.826.0.1.3680043.1542',  '1.2.826.0.1.3680043.24891', '1.2.826.0.1.3680043.11827'\n\nAlso '1.2.826.0.1.3680043.1363' has random labels for C5 and C6 on the first slice. There are likely other cases. I'm trying to find a simple way to denoise these.\n    ",
      "votes": 12
    },
    {
      "id": 1960707,
      "postDate": "2022-09-28T18:06:29.373Z",
      "content": "<p>You could get rid of single pixel lines and other small features with something like this,<br>\nwhere img is a 512 x 512 array of segmentation values (0…)</p>\n<pre><code>img2 = img.copy\nimg2[img2 &gt; 0] = 1    # make the image 0 or 1 only\n#filter with 3x3 array of 1's  \nimg2=scipy.signal.convolve2d(img2.astype(np.float32), np.ones((3,3)), mode='same', boundary='symm')\n#remove anything that is 4 or less\nimg[img2 &lt; 5] = 0  # remove single pixel lines and other small features\n</code></pre>\n<p>For example, this would remove the middle 1 from a 3x3 section that looked like:</p>\n<pre><code>010\n110\n010\n</code></pre>\n<p>but would not remove the middle of:</p>\n<pre><code>010\n111\n010\n</code></pre>\n<p>As a side note, there are values in the segmentation file that go higher than 7 (I forget the exact maximum), so watch for 8s and 9s!</p>",
      "rawMarkdown": "You could get rid of single pixel lines and other small features with something like this,\nwhere img is a 512 x 512 array of segmentation values (0...)\n```\nimg2 = img.copy\nimg2[img2 > 0] = 1    # make the image 0 or 1 only\n#filter with 3x3 array of 1's  \nimg2=scipy.signal.convolve2d(img2.astype(np.float32), np.ones((3,3)), mode='same', boundary='symm')\n#remove anything that is 4 or less\nimg[img2 < 5] = 0  # remove single pixel lines and other small features\n\n```\nFor example, this would remove the middle 1 from a 3x3 section that looked like:\n```\n010\n110\n010\n```\nbut would not remove the middle of:\n```\n010\n111\n010\n```\nAs a side note, there are values in the segmentation file that go higher than 7 (I forget the exact maximum), so watch for 8s and 9s!",
      "votes": 2,
      "replies": [
        {
          "id": 1960931,
          "postDate": "2022-09-28T22:00:47.927Z",
          "content": "<p>Nice! Thank you!</p>",
          "rawMarkdown": "Nice! Thank you!"
        }
      ]
    },
    {
      "id": 1960078,
      "postDate": "2022-09-28T13:22:06.403Z",
      "content": "<p>I've found the same. It's a lot more than 4 cases though. I'd estimate about 40% of the segmentations have small errors in them. </p>\n<p><a href=\"https://postimg.cc/QFcPPVPB\" target=\"_blank\"><img src=\"https://i.postimg.cc/6pPX8vfh/8884.png\" alt=\"8884.png\"></a></p>\n<p><a href=\"https://postimg.cc/xXHD26k1\" target=\"_blank\"><img src=\"https://i.postimg.cc/CxrFbtSk/mask2.png\" alt=\"mask2.png\"></a></p>",
      "rawMarkdown": "I've found the same. It's a lot more than 4 cases though. I'd estimate about 40% of the segmentations have small errors in them. \n\n[![8884.png](https://i.postimg.cc/6pPX8vfh/8884.png)](https://postimg.cc/QFcPPVPB)\n\n[![mask2.png](https://i.postimg.cc/CxrFbtSk/mask2.png)](https://postimg.cc/xXHD26k1)",
      "votes": 2
    }
  ],
  "comments": [
    {
      "id": 1960707,
      "author_name": "SolverWorld",
      "author_url": "",
      "post_date": "2022-09-28T18:06:29.373000",
      "content": "<p>You could get rid of single pixel lines and other small features with something like this,<br>\nwhere img is a 512 x 512 array of segmentation values (0…)</p>\n<pre><code>img2 = img.copy\nimg2[img2 &gt; 0] = 1    # make the image 0 or 1 only\n#filter with 3x3 array of 1's  \nimg2=scipy.signal.convolve2d(img2.astype(np.float32), np.ones((3,3)), mode='same', boundary='symm')\n#remove anything that is 4 or less\nimg[img2 &lt; 5] = 0  # remove single pixel lines and other small features\n</code></pre>\n<p>For example, this would remove the middle 1 from a 3x3 section that looked like:</p>\n<pre><code>010\n110\n010\n</code></pre>\n<p>but would not remove the middle of:</p>\n<pre><code>010\n111\n010\n</code></pre>\n<p>As a side note, there are values in the segmentation file that go higher than 7 (I forget the exact maximum), so watch for 8s and 9s!</p>",
      "votes": 2,
      "replies": [
        {
          "id": 1960931,
          "author_name": "Anouk Stein, MD",
          "author_url": "",
          "post_date": "2022-09-28T22:00:47.927000",
          "content": "<p>Nice! Thank you!</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 1960078,
      "author_name": "Samuel Cortinhas",
      "author_url": "",
      "post_date": "2022-09-28T13:22:06.403000",
      "content": "<p>I've found the same. It's a lot more than 4 cases though. I'd estimate about 40% of the segmentations have small errors in them. </p>\n<p><a href=\"https://postimg.cc/QFcPPVPB\" target=\"_blank\"><img src=\"https://i.postimg.cc/6pPX8vfh/8884.png\" alt=\"8884.png\"></a></p>\n<p><a href=\"https://postimg.cc/xXHD26k1\" target=\"_blank\"><img src=\"https://i.postimg.cc/CxrFbtSk/mask2.png\" alt=\"mask2.png\"></a></p>",
      "votes": 2,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1959113": "There are 4 cases with random nonzero pixels that prevent bounding box access via the function cv2.boundingRect(cv2.findNonZero(img)). These are the ones I found so far: '1.2.826.0.1.3680043.6125', '1.2.826.0.1.3680043.1542',  '1.2.826.0.1.3680043.24891', '1.2.826.0.1.3680043.11827'\n\nAlso '1.2.826.0.1.3680043.1363' has random labels for C5 and C6 on the first slice. There are likely other cases. I'm trying to find a simple way to denoise these.\n    ",
    "1960707": "You could get rid of single pixel lines and other small features with something like this,\nwhere img is a 512 x 512 array of segmentation values (0...)\n```\nimg2 = img.copy\nimg2[img2 > 0] = 1    # make the image 0 or 1 only\n#filter with 3x3 array of 1's  \nimg2=scipy.signal.convolve2d(img2.astype(np.float32), np.ones((3,3)), mode='same', boundary='symm')\n#remove anything that is 4 or less\nimg[img2 < 5] = 0  # remove single pixel lines and other small features\n\n```\nFor example, this would remove the middle 1 from a 3x3 section that looked like:\n```\n010\n110\n010\n```\nbut would not remove the middle of:\n```\n010\n111\n010\n```\nAs a side note, there are values in the segmentation file that go higher than 7 (I forget the exact maximum), so watch for 8s and 9s!",
    "1960078": "I've found the same. It's a lot more than 4 cases though. I'd estimate about 40% of the segmentations have small errors in them. \n\n[![8884.png](https://i.postimg.cc/6pPX8vfh/8884.png)](https://postimg.cc/QFcPPVPB)\n\n[![mask2.png](https://i.postimg.cc/CxrFbtSk/mask2.png)](https://postimg.cc/xXHD26k1)"
  }
}