AIM-Harvard / pyradiomics

Open-source python package for the extraction of Radiomics features from 2D and 3D images and binary masks. Support: https://discourse.slicer.org/c/community/radiomics
http://pyradiomics.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.16k stars 499 forks source link

[FEAT EXTRACTION] #649

Closed stefhec closed 3 years ago

stefhec commented 4 years ago

Hi,

I have a question regarding voxel-based extraction of radiomics features. I am currently performing this with the default voxel-based settings using the code below:

featureVector = extractor.execute(im,ma,voxelBased=True) for key, val in six.iteritems(featureVector): if isinstance(val, sitk.Image): parametermap = sitk.GetArrayFromImage(val)

For now I am only extracting glcm features (extractor.enableFeatureClassByName('glcm'))

This runs without any error messages. However, I am confused by the size of parametermap. np.shape(parametermap) returns (14, 14, 9), while the shape of my image is (49, 816, 1361).

What do the 3D dimensions of the parametermap represent?

Thanks!

JoostJM commented 4 years ago

During pre-processing the image is optionally resampled and always cropped onto the bounding box of the mask. The output remains in the geometry after this pre-processing. As they are SimpleITK.Image objects, they contain the necessary information to ensure correct alignment to the original image.

If no resampling was performed, you can easily port the output map to the original space if necessary:

import SimpleITK as sitk
im = sitk.ReadImage('<path/to/original_image.nrrd>')
map = sitk.ReadImage('<path/to/feature_map.nrrd>')

rif =  sitk.ResampleImageFilter()
rif.SetInterpolator(sitk.sitkNearestNeighbor)  # Pixel locations overlap, but feature map is cropped
rif.SetReferenceImage(im)
rif.SetOutputPixelType(map.GetPixelID())
map = rif.Execute(map)
sitk.WriteImage(map, '<path/to/output.nrrd>')