{
  "id": 177760,
  "title": "Error while making lungmask",
  "url": "/competitions/osic-pulmonary-fibrosis-progression/discussion/177760",
  "author_name": "Ashish",
  "post_date": "2020-08-27T09:22:32.654000",
  "votes": 0,
  "comment_count": 0,
  "views": 0,
  "content": "<p>I was getting this error on some of the image IDs while trying to make a lungmask.<br>\n <code>ValueError: Input contains NaN, infinity or a value too large for dtype('float64')</code><br>\n (<code>make_lungmask</code> function <a href=\"https://www.raddq.com/dicom-processing-segmentation-visualization-in-python/\" target=\"_blank\">link</a>) <br>\nTo avoid this error, just add something like <code>1e-6</code> to the standard deviation if its zero. </p>\n<pre><code>if std==0:\n    std+=1e-6\n</code></pre>\n<p>The reason for this error is that some of the images had 0 standard deviation which when was being used in <code>img=img/std</code>, was giving <code>nan</code> values and thus giving this error. <br>\nJust posting this to help anyone else to not waste time like me 😅 (Sorry, if a post for this already exists).</p>",
  "messages": [
    {
      "id": 987454,
      "postDate": "2020-08-27T09:22:32.653Z",
      "content": "<p>I was getting this error on some of the image IDs while trying to make a lungmask.<br>\n <code>ValueError: Input contains NaN, infinity or a value too large for dtype('float64')</code><br>\n (<code>make_lungmask</code> function <a href=\"https://www.raddq.com/dicom-processing-segmentation-visualization-in-python/\" target=\"_blank\">link</a>) <br>\nTo avoid this error, just add something like <code>1e-6</code> to the standard deviation if its zero. </p>\n<pre><code>if std==0:\n    std+=1e-6\n</code></pre>\n<p>The reason for this error is that some of the images had 0 standard deviation which when was being used in <code>img=img/std</code>, was giving <code>nan</code> values and thus giving this error. <br>\nJust posting this to help anyone else to not waste time like me 😅 (Sorry, if a post for this already exists).</p>",
      "rawMarkdown": "I was getting this error on some of the image IDs while trying to make a lungmask.\n ```ValueError: Input contains NaN, infinity or a value too large for dtype('float64')```\n (```make_lungmask``` function [link](https://www.raddq.com/dicom-processing-segmentation-visualization-in-python/)) \nTo avoid this error, just add something like ```1e-6``` to the standard deviation if its zero. \n```python\nif std==0:\n    std+=1e-6\n```\nThe reason for this error is that some of the images had 0 standard deviation which when was being used in ```img=img/std```, was giving ```nan``` values and thus giving this error. \nJust posting this to help anyone else to not waste time like me 😅 (Sorry, if a post for this already exists)."
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "987454": "I was getting this error on some of the image IDs while trying to make a lungmask.\n ```ValueError: Input contains NaN, infinity or a value too large for dtype('float64')```\n (```make_lungmask``` function [link](https://www.raddq.com/dicom-processing-segmentation-visualization-in-python/)) \nTo avoid this error, just add something like ```1e-6``` to the standard deviation if its zero. \n```python\nif std==0:\n    std+=1e-6\n```\nThe reason for this error is that some of the images had 0 standard deviation which when was being used in ```img=img/std```, was giving ```nan``` values and thus giving this error. \nJust posting this to help anyone else to not waste time like me 😅 (Sorry, if a post for this already exists)."
  }
}