Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TEST: Use different Notebooks while testing in CircleCI
Update the config.yml to test the hello* notebooks and the PyRadiomicsExample.ipynb, which more extensively tests different parts of the toolbox and different ways the toolbox can be used.
- Loading branch information
Showing
19 changed files
with
863 additions
and
447 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#!/usr/bin/env python | ||
|
||
from __future__ import print_function | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
#!/usr/bin/env python | ||
|
||
from __future__ import print_function | ||
|
||
import logging | ||
import os | ||
|
||
import SimpleITK as sitk | ||
import six | ||
|
||
import radiomics | ||
from radiomics import featureextractor | ||
|
||
def tqdmProgressbar(): | ||
""" | ||
This function will setup the progress bar exposed by the 'tqdm' package. | ||
Progress reporting is only used in PyRadiomics for the calculation of GLCM and GLSZM in full python mode, therefore | ||
enable GLCM and full-python mode to show the progress bar functionality | ||
N.B. This function will only work if the 'click' package is installed (not included in the PyRadiomics requirements) | ||
""" | ||
global extractor | ||
extractor.kwargs['enableCExtensions'] = False | ||
# Enable the GLCM class to show the progress bar | ||
extractor.enableFeatureClassByName('glcm') | ||
|
||
radiomics.setVerbosity(logging.INFO) # Verbosity must be at least INFO to enable progress bar | ||
|
||
import tqdm | ||
radiomics.progressReporter = tqdm.tqdm | ||
|
||
def clickProgressbar(): | ||
""" | ||
This function will setup the progress bar exposed by the 'click' package. | ||
Progress reporting is only used in PyRadiomics for the calculation of GLCM and GLSZM in full python mode, therefore | ||
enable GLCM and full-python mode to show the progress bar functionality. | ||
Because the signature used to instantiate a click progress bar is different from what PyRadiomics expects, we need to | ||
write a simple wrapper class to enable use of a click progress bar. In this case we only need to change the 'desc' | ||
keyword argument to a 'label' keyword argument. | ||
N.B. This function will only work if the 'click' package is installed (not included in the PyRadiomics requirements) | ||
""" | ||
global extractor | ||
|
||
extractor.kwargs['enableCExtensions'] = False | ||
# Enable the GLCM class to show the progress bar | ||
extractor.enableFeatureClassByName('glcm') | ||
|
||
radiomics.setVerbosity(logging.INFO) # Verbosity must be at least INFO to enable progress bar | ||
|
||
import click | ||
|
||
class progressWrapper(): | ||
def __init__(self, iterable, desc=''): | ||
# For a click progressbar, the description must be provided in the 'label' keyword argument. | ||
self.bar = click.progressbar(iterable, label=desc) | ||
|
||
def __iter__(self): | ||
return self.bar.__iter__() # Redirect to the __iter__ function of the click progressbar | ||
|
||
def __enter__(self): | ||
return self.bar.__enter__() # Redirect to the __enter__ function of the click progressbar | ||
|
||
def __exit__(self, exc_type, exc_value, tb): | ||
return self.bar.__exit__(exc_type, exc_value, tb) # Redirect to the __exit__ function of the click progressbar | ||
|
||
radiomics.progressReporter = progressWrapper | ||
|
||
# Get some test data | ||
|
||
# repositoryRoot points to the root of the repository. The following line gets that location if this script is run | ||
# from it's default location in \pyradiomics\bin. Otherwise, it will point to some (invalid) folder, causing the | ||
# getTestCase function to fail to find the test case in the repository. In that case, a test case will be downloaded to | ||
# temporary files and it's location is returned. | ||
repositoryRoot = os.path.abspath(os.path.join(os.getcwd(), "..")) | ||
imageName, maskName = radiomics.getTestCase('brain1', repositoryRoot) | ||
|
||
# Get the location of the example settings file | ||
paramsFile = os.path.abspath(r'exampleSettings\Params.yaml') | ||
|
||
if imageName is None or maskName is None: # Something went wrong, in this case PyRadiomics will also log an error | ||
print('Error getting testcase!') | ||
exit() | ||
|
||
# Regulate verbosity with radiomics.verbosity | ||
# radiomics.setVerbosity(logging.INFO) | ||
|
||
# Get the PyRadiomics logger (default log-level = INFO | ||
logger = radiomics.logger | ||
logger.setLevel(logging.DEBUG) # set level to DEBUG to include debug log messages in log file | ||
|
||
# Write out all log entries to a file | ||
handler = logging.FileHandler(filename='testLog.txt', mode='w') | ||
formatter = logging.Formatter("%(levelname)s:%(name)s: %(message)s") | ||
handler.setFormatter(formatter) | ||
logger.addHandler(handler) | ||
|
||
# Initialize feature extractor using the settings file | ||
extractor = featureextractor.RadiomicsFeaturesExtractor(paramsFile) | ||
|
||
# Uncomment one of these functions to show how PyRadiomics can use the 'tqdm' or 'click' package to report progress when | ||
# running in full python mode. Assumes the respective package is installed (not included in the requirements) | ||
|
||
# tqdmProgressbar() | ||
# clickProgressbar() | ||
|
||
print("Active features:") | ||
for cls, features in six.iteritems(extractor.enabledFeatures): | ||
if len(features) == 0: | ||
features = extractor.getFeatureNames(cls) | ||
for f in features: | ||
print(f) | ||
print(getattr(extractor.featureClasses[cls], 'get%sFeatureValue' % f).__doc__) | ||
|
||
print("Calculating features") | ||
featureVector = extractor.execute(imageName, maskName) | ||
|
||
for featureName in featureVector.keys(): | ||
print("Computed %s: %s" % (featureName, featureVector[featureName])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
ID,Image,Mask | ||
brain1,..\data\brain1_image.nrrd,..\data\brain1_label.nrrd | ||
brain2,..\data\brain2_image.nrrd,..\data\brain2_label.nrrd | ||
breast1,..\data\breast1_image.nrrd,..\data\breast1_label.nrrd | ||
lung1,..\data\lung1_image.nrrd,..\data\lung1_label.nrrd | ||
lung2,..\data\lung2_image.nrrd,..\data\lung2_label.nrrd |
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.