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.14k stars 493 forks source link

examples in nifti format? #381

Closed tli3 closed 6 years ago

tli3 commented 6 years ago

Hello, I am trying my own PET image with a tumor mask image both in nifti format using PyRadiomics. When I run the following script in python, " ... params = os.path.join(dataDir, "examples", "exampleSettings", "Params.yaml") extractor = featureextractor.RadiomicsFeaturesExtractor(params) result = extractor.execute(imageName, maskName) " it turns out that result=[] is empty. but I've tried your example nrrd files which work successfully. I wonder do PyRadiomics support the .nii.gz format? is there some requirement for the header files of the nifti? do you have some examples in that format? Many thanks.

JoostJM commented 6 years ago

PyRadiomics should be able to parse the niftii format (It can basically take anything that can be read by SimpleITK, with the additional constraint that it is a 3D grayscale image and mask with integer, not float, values).

I don't know what's causing your empty result, but most likely something is causing PyRadiomics to abort the extraction. If you re-run the extraction with logging enabled, the cause of your error will most likely be logged by PyRadiomics.

ihnorton commented 5 years ago

related question I happened across: https://stackoverflow.com/questions/50845524/medical-imaging-pyradiomics-with-nii-gz-files

fedorov commented 5 years ago

NIFTI should work as fine as NRRD, or any other ITK readable format. The problem is due to something else. If you can share the dataset or log we can investigate.

JoostJM commented 5 years ago

I agree with @fedorov. If I'm correct, PyRadiomics should print out an error message detailing why it is not working. Seeing as it's NIFTII, it is possible there is some issue with direction/origin (same problem as in the post @ihnorton mentioned)

ihnorton commented 5 years ago

Not my question guys, just came across it on stackoverflow 😃

mcgoughlin commented 1 year ago

I came across this issue, of trying to extract radiomic features from .nii.gz image/mask file types. The issue was routed in SimpleITK's inability to read the files (Error could be sourced happened to line 378 of featureextractor.py):

mask = sitk.ReadImage(MaskFilePath)

To make a very long story short, this error happened due to the NIFTI file type - I had saved my NIFTI files using the NIFTI2 image protocol (specifically, using nibabel's Nifti2Image function). At the time of writing this message, SimpleITK can only read in .nii.gz files of the NITFI1 protocol - thus, I fixed this problem by iterating through each .nii.gz file and converting them from NIFTI2 to NIFTI1. This fixed my issues completely, and pyradiomics could perform its magic perfectly well afterwards :)

I hope this helps someone!