Created
July 25, 2020 02:59
-
-
Save mcdlee/aaa35896f612fd84fb6342f96120856c to your computer and use it in GitHub Desktop.
PyRadiomics to Pandas DataFrame
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
import radiomics | |
import six | |
from radiomics import featureextractor | |
import pandas as pd | |
import numpy as np | |
from matplotlib import pyplot as plt | |
extractor = featureextractor.RadiomicsFeatureExtractor() | |
def feature2pd(image, mask, index): | |
result = extractor.execute(image, mask) | |
sub_dict = {} | |
for key, value in six.iteritems(result): | |
if key.find('original') == 0: #篩選key的開頭是'original' | |
#print(key) | |
#print(float(value)) | |
key = key[9:] | |
value=float(value) | |
sub_dict.update({key:value}) | |
output = pd.DataFrame.from_dict(sub_dict, orient='index', columns=[index]).transpose() | |
return output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment