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.17k stars 497 forks source link

[FEAT EXTRACTION] #700

Closed HowardEMorgan closed 3 years ago

HowardEMorgan commented 3 years ago

Hi,

I am currently attempting to extract features from NIFTI files (.nii.gz) using pyradiomics; however, I am having an issue with the batch feature extraction in the command line using CSV files. I saw that a similar issue was reported in Issue #650. I attempted the suggestions under that thread but am still encountering this issue. I was hoping to ask you if you may have suggestions of what the issue may be that I could evaluate further.

When I attempt to extract features in batch mode from my CSV file, I get the following error stating that there is an "error reading image Filepath or SimpleITK object." [2021-05-07 12:29:54] E: radiomics.script: Feature extraction failed! Traceback (most recent call last): File "C:\Python\Anaconda\lib\site-packages\pyradiomics-3.0.1-py3.8-win-amd64.egg\radiomics\scripts\segment.py", line 70, in _extractFeatures feature_vector.update(extractor.execute(imageFilepath, maskFilepath, label, label_channel)) File "C:\Python\Anaconda\lib\site-packages\pyradiomics-3.0.1-py3.8-win-amd64.egg\radiomics\featureextractor.py", line 272, in execute image, mask = self.loadImage(imageFilepath, maskFilepath, generalInfo, **_settings) File "C:\Python\Anaconda\lib\site-packages\pyradiomics-3.0.1-py3.8-win-amd64.egg\radiomics\featureextractor.py", line 375, in loadImage raise ValueError('Error reading image Filepath or SimpleITK object') ValueError: Error reading image Filepath or SimpleITK object

As also reported in Issue #650, when I use the same paths (copied and pasted directly from my CSV file) in the single extraction mode using "pyradiomics path/to/image path/to/mask --param path/to/YAML -o path/to/Output -f csv" in the command line, this works, and I am able to generate an output file. However, if I do the same with the CSV file, I get the above error.

Per the prior thread, the issue appeared to have resolved when they uninstalled and reinstalled pyradiomics. I attempted this, but the issue is still persisting.

I attempted using prior CSV files that I used to extract features in batch mode about 6 months ago (which were able to be extracted successfully at that time), but I encountered the above error.

I also attempted using --validate as suggested in the prior thread. It reported the following for all cases (last ones shown): [2021-05-07 13:25:14] E: radiomics.script: Image path for case (174/174) does not exist! [2021-05-07 13:25:14] E: radiomics.script: Mask path for case (174/174) does not exist!

Given the features are extracting successfully when extracting single images/masks from the command line individually (using the same paths as those found in the CSV file), I am interpreting this as some sort of issue with reading the paths from the CSV file. I wanted to check if you may have any other suggestions on other things I should try to resolve this?

Happy to hear any suggestions/thoughts about this. Thank you! Howard

JoostJM commented 3 years ago

The issue is indeed in how your paths are formatted in your CSV file. The --validate options shows this; it cannot find the file. Can you post a line from your csv file (opened using a text editor) including the headers? Maybe I can give you some pointers on how it is formatted.

Are you using relative paths? These should be relative to the folder holding your csv file. As also suggested in #650, are you using backslash escapes for spaces? These should be removed, as all values in the csv are treated as if enclosed in quotes on the cmd line.

HowardEMorgan commented 3 years ago

Thank you for your response! Sorry, I thought I had sent a reply, but looks like it did not send. I have resolved this issue.

ibowennn commented 2 years ago

Thank you for your response! Sorry, I thought I had sent a reply, but looks like it did not send. I have resolved this issue.

Hello, I had the same issue. Could you please tell me how you resolve this problem? Thank you!

JoostJM commented 2 years ago

@ibowennn have you tried the suggestions above and in #650?

ibowennn commented 2 years ago

@ibowennn have you tried the suggestions above and in #650?

Thank you for your response. The problem has been solved. The command "pyradiomics file.csv -p params.yaml -o output.csv -f csv -j 30" work in my PC. However, I encountered pause when the calculation almost done. As you can see, there were pause between 2021-12-30 01:57 and 2021-12-30 07:19, and between 2021-12-30 07:24 and 2021-12-30 16:42.

411641295830_ pic