-
Notifications
You must be signed in to change notification settings - Fork 498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove dependency for tqdm
#232
Conversation
Remove dependency for the tqdm package, as this is rarely used (only for GLCM and GLSZM in full-python mode). Instead provide 3 variables which can hold function definitions used for instantiating and interacting with a progress bar. In the helloRadiomics script and notebook, this changed functionality is illustrated with a commented out section in the script and a separate cell in the notebook. This section and cell assume the `tqdm` package is installed and use it to show a progressbar during calculation of the glcm matrix in full-python mode.
radiomics/glszm.py
Outdated
else: | ||
# Ensure that even if progress functions are defined, progress is only given if 'verbose' is True | ||
self.initProgress = None | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code should probably be moved to the base class.
radiomics/__init__.py
Outdated
@@ -161,6 +161,18 @@ def getInputImageTypes(): | |||
return _inputImages | |||
|
|||
|
|||
def getProgressFunctions(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should that function be private: _getProgressFunctions()
? Or should the variable (init|report|close)progress
be private global ?
Either way we need to document the signature of the functions too.
As @jcfr showed in AIM-Harvard#230, the progress reporting can be simplified, requiring the user only to specify one variable that holds a progress reporter. Update PyRadiomics to this implementation and add examples for both use with `tqdm.tqdm` (which can be used directly) or `click.progressbar` (which requires a simple wrapper class). Examples are provided in both the helloRadiomics script and notebook. Progress reporting in full-python mode in GLCM and GLSZM now uses a progress reporter that is instantiated with an interator (as opposed to a length) and uses this progress reporter in the loop to iterate over the gray levels. This is encapsulated in a `with` statement to ensure correct closure. Finally, a dummy progress reporter is provided for the cases where no progressbar is needed (none specified or verbosity level > INFO). In those cases the `_dummyProgressReporter` (defined in `__init__.py`) is used, which accepts the arguments from PyRadiomics and iterates over the gray levels passed in the iterable, but does not report any progress back to the user.
Add documentation on how to add a progress reporter in the developers section of the documentation. The `_DummyProgressReporter` class and `_getProgressReporter` function also have documentation, but these are not included in the sphinx-generated documentation.
a393b13
to
c5620fc
Compare
Remove dependency for the tqdm package, as this is rarely used (only for GLCM and GLSZM in full-python mode).
Instead provide 3 variables which can hold function definitions used for instantiating and interacting with a progress bar.
In the helloRadiomics script and notebook, this changed functionality is illustrated with a commented out section in the script and a separate cell in the notebook. This section and cell assume the
tqdm
package is installed and use it to show a progressbar during calculation of the glcm matrix in full-python mode.TODO before merge:
_getProgressReporter
function in__init__.py