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.11k stars 485 forks source link

[FEAT EXTRACTION] #814

Open vinayaga8821 opened 1 year ago

vinayaga8821 commented 1 year ago

Describe the bug A clear and concise question regarding your extraction. Please check FAQ section, PyRadiomics issues and PyRadiomics Slicer Discourse to check if your question has been encountered before. If so, but you still require additional help, please reference related issues.

PyRadiomics configuration Add any customization you applied here (i.e. the content of the parameter file used)

PyRadiomics log file If available, add section of the PyRadiomics log related to your question. For help on setting up logging, see the online documentation

To Reproduce Steps to reproduce the behavior:

Version (please complete the following information):

Additional context Add any other context about your question here.

vinayaga8821 commented 1 year ago

Hi I am new to python. when I try to run existing code for feature extraction its works with data that is already available eg( brain1 or lung1). I tried feeding my own nrrd file and I am getting an error message. Kindly help me out How I can provide correct path for image and label nrrd file

dorkylever commented 1 year ago

Hi,

i'm not a dev but I use the pyradiomics pipeline a fair bit.

Firstly imports: from radiomics import featureextractor import SimpleITK as sitk import pandas as pd

So to firstly set up the feature extractor you need:

extractor = featureextractor.RadiomicsFeatureExtractor() extractor.enableAllImageTypes() extractor.enableAllFeatures()

That sets up the feature extractor.

To load the files:

img = sitk.ReadImage("full_img_path.nrrd")

label = sitk.ReadImage("full_label_path.nrrd")

Then to execute the feature extraction: result = extractor.execute(img, mask)

This gives a set of dictionary values - but I prefer to convert it to a pandas dataframe, transpose it (so each feature is a column) and save to a csv file.

features = pd.DataFrame.from_dict(result, orient='index') features = features.transpose()

features.to_csv("full_output_path.csv')

dorkylever commented 1 year ago

For python libraries I create a setup.py file and then in bash run:

pyhon3 setup.py install --user

(there should be plenty of tutorials on how to create one or you can base it off: https://github.com/dorkylever/LAMA/blob/master/setup.py

JoostJM commented 1 year ago

@dorkylever Thanks! Further examples are provided in the repository (examples, notebooks) and the online documentation.