Closed janebat closed 2 years ago
import SimpleITK as sitk
import numpy as np
grayscale = np.array(grayscale)
im = sitk.GetImageFromArray(grayscale)
ma = sitk.GetImageFromArray(np.ones(grayscale.shape), dtype='uint8')
# Store to nrrd:
sitk.WriteImage(im, 'image.nrrd')
sitk.WriteImage(ma, 'mask.nrrd', True) # enable compression to save disk space
# or extract features:
from radiomics import featureextractor
extractor = featureextractor.RadiomicsFeatureExtractor(r'path/to/params.yml')
features = extractor.execute(im, ma, label=1)
Hi there. Thanks for this package.
Your suggested code above returns an error:
ValueError: No labels found in this mask (i.e. nothing is segmented)!
Any ideas of what the issue could be? I understand that a mask is needed. One can create a mask from the image right? At least that's what I understood from the above and also from here
I simple have x-ray images (jpeg and possibly DICOM) from which I want to extract quantitative features. I don't know how to segment it.
P.S: had to made a small correction on your code above:
test_arr = np.ones((grayscale.shape), dtype='uint8')
ma = sitk.GetImageFromArray(test_arr)
Hello, thank you so much for your reply! I already understand these two files are needed and what needs to be done to make it work. I think I’m gonna give a try with photoshop first to segment the lungs (what I need). Thanks and cheers
From: advset notifications@github.com Reply to: Radiomics/pyradiomics reply@reply.github.com Date: Saturday, 2 May 2020 at 09:06 To: Radiomics/pyradiomics pyradiomics@noreply.github.com Cc: Filipa filipamnmlopes@hotmail.com, Comment comment@noreply.github.com Subject: Re: [Radiomics/pyradiomics] convert jpg to nrrd (#546)
Ms Filipa, I think the problem is that we need 2 separate files, the image itself and the mask. Please try using the provided data here https://github.com/Radiomics/pyradiomics/tree/master/data
If you need to apply your own data, you have to segment it beforehand, in which I don't know which tool to use @_@ (I am a fellow newbie ha ha)
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/Radiomics/pyradiomics/issues/546#issuecomment-622765026, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AKHEHL224DTDCWFDA545Z43RPPBAZANCNFSM4KBZ457A.
I have an image that I wish to perform on all of it GLCM and GLRLM. I can not find how to convert the the gray image to nrrd and perfom the features. Furthermore, is there a better way to load (I used a URL just for accessibility, it would be fine also to load from HDD) and convert an image to gray using pyradiomics functions?
Code: from skimage import io from skimage.color import rgb2gray
import numpy as np import matplotlib.pyplot as plt
import SimpleITK as sitk from radiomics import featureextractor
url_path = "http://www.histologyguide.com/imgs/slide08.jpg"
original = io.imread(url_path) grayscale = rgb2gray(original)
fig, axes = plt.subplots(1, 2, figsize=(8, 4)) ax = axes.ravel()
ax[0].imshow(original) ax[0].set_title("Original")a ax[1].imshow(grayscale, cmap=plt.cm.gray) ax[1].set_title("Grayscale")
fig.tight_layout() plt.show()