Skip to content

Commit

Permalink
BUG: notebook in python 3 failing
Browse files Browse the repository at this point in the history
The helloRadiomics notebook was failing due to an error that was thrown by the Click progressbar. Remove the Click progressbar example, as it also does not render the progressbar if the output is not a terminal (as is the case in a jupyter notebook).
  • Loading branch information
JoostJM committed May 16, 2017
1 parent 5f83aba commit 1b69bdd
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 50 deletions.
49 changes: 0 additions & 49 deletions notebooks/helloRadiomics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -270,55 +270,6 @@
" pass # tqdm package not available, skip setting up the progressbar for tqdm"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The `click` package also exposes a progress bar, which can also take an iterable as its first argument, but the label is passed in keyword 'label'. To use `click`, we need to create a simple wrapper that redirects the 'desc' keyword to the 'label' keyword.\n",
"\n",
"The cell below is an alternative to the cell showing how to use `tqdm` as progressbar.\n",
"\n",
"**N.B. This cell will only work if the 'click' package is installed, which is not included in the requirements of PyRadiomics.**"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"try:\n",
" import click\n",
"\n",
" class progressWrapper():\n",
" def __init__(self, iterable, desc=''):\n",
" # For a click progressbar, the description must be provided in the 'label' keyword argument.\n",
" # The iterable can be passed as first argument to click, no changes needed\n",
" self.bar = click.progressbar(iterable, label=desc) \n",
"\n",
" def __iter__(self):\n",
" return self.bar.__iter__() # Redirect to the __iter__ function of the click progressbar\n",
"\n",
" def __enter__(self):\n",
" return self.bar.__enter__() # Redirect to the __enter__ function of the click progressbar\n",
"\n",
" def __exit__(self, exc_type, exc_value, tb):\n",
" return self.bar.__exit__(exc_type, exc_value, tb) # Redirect to the __exit__ function of the click progressbar\n",
"\n",
" radiomics.progressReporter = progressWrapper\n",
" \n",
" extractor.settings['enableCExtensions'] = False\n",
"\n",
" # Enable the GLCM class to show the progress bar\n",
" extractor.enableFeatureClassByName('glcm')\n",
"\n",
" radiomics.setVerbosity(logging.INFO) # Verbosity must be at least INFO to enable progress bar\n",
"except ImportError:\n",
" pass # Click package not available, skip setting up the progressbar for click"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
2 changes: 1 addition & 1 deletion radiomics/imageoperations.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def _checkROI(imageNode, maskNode, label):
# The additional 0.5 is to allow for different spacings (defines the edges, not the centers of the edge-voxels
tolerance = 1e-3 # Define a tolerance to correct for machine precision errors
if numpy.any(numpy.min(ROIBounds, axis=0) < (- .5 - tolerance)) or \
numpy.any(numpy.max(ROIBounds, axis=0) > (numpy.array(imageNode.GetSize()) - .5 + tolerance)):
numpy.any(numpy.max(ROIBounds, axis=0) > (numpy.array(imageNode.GetSize()) - .5 + tolerance)):
logger.error('Bounding box of ROI is larger than image space:\n\t'
'ROI bounds (image coordinate space) %s\n\tImage Size %s', ROIBounds, imageNode.GetSize())
return None
Expand Down

0 comments on commit 1b69bdd

Please sign in to comment.