Problems about usage of pyradiomics-dcm.py

472 views
Skip to first unread message

Qingwei Zhang

unread,
Jan 16, 2019, 9:45:58 AM1/16/19
to pyradiomics

Hello everyone and pyradiomics working team,

 

I had some problem but failed to solve it by myself.

 

The question is that: I tried to extract radiomics from DICOM files. First, I tried to transit the DICOM files into the NRRD files using the command line by the pyradiomics-dcm.py. But the error message showed that

File "pyradiomics-dcm.py", line 18, in <module>

    from radiomics import featureextractor

ModuleNotFoundError: No module named 'radiomics'

 

I really did not know why.

The code for the command line were listed as follows:


cd C:\Users\zhang\Desktop\radiomics\data\DICOM

python pyradiomics-dcm.py ..\DICOM .\NRRD

 

I attached the files (DICOM form TICA) in the attachment.

 

Qing-Wei Zhang

Shanghai Jiaotong University, Shanghai, China.


Joost van Griethuysen

unread,
Jan 16, 2019, 10:08:02 AM1/16/19
to pyradiomics
Hello Qing-Wei,

This error is raised if python is unable to find the PyRadiomics module (i.e. not yet installed). Did you install the package? Check the documentation on installation, that should fix your error.

Regards,

Joost

Op woensdag 16 januari 2019 15:45:58 UTC+1 schreef Qingwei Zhang:

Qingwei Zhang

unread,
Jan 16, 2019, 8:27:20 PM1/16/19
to pyradiomics
Yes, I have installed the package. When I wrote the pyradiomics -h in the commandline, the introduction to the  pyradiomics could be shown, which indicated PyRadiomics module have been successfully installed.

So, I was really confused when I used pyradiomics-dcm.py in the commandline, the error showed ModuleNotFoundError: No module named 'radiomics'



在 2019年1月16日星期三 UTC+8下午11:08:02,Joost van Griethuysen写道:

Joost van Griethuysen

unread,
Jan 17, 2019, 4:05:44 AM1/17/19
to pyradiomics
Do you have multiple versions of python, or are you using virtual environments? Then you need to make sure PyRadiomics is installed in the same version/environment as you are running the pyradiomics-dcm.py script in.

You can check this by running `python -m pip list`

Op donderdag 17 januari 2019 02:27:20 UTC+1 schreef Qingwei Zhang:

Qingwei Zhang

unread,
Jan 21, 2019, 10:26:09 AM1/21/19
to pyradiomics
Thank you for solving my problem. According to your suggestion, we have resolved the problem. However, another problem when I tried to convert the dicom to the nrrd files. 

The code was as follows: 


cd C:\Users\zhang\Desktop\radiomics\data\DICOM
python pyradiomics-dcm.py ..\DICOM GC_label.nrrd .\NRRD

The message showed that 
usage: pyradiomics-dcm.py --input-image <dir> --input-seg <name> --output-sr <name>

Warning: This is a "pyradiomics labs" script, which means it is an experimental feature in development!
The intent of this helper script is to enable pyradiomics feature extraction directly from/to DICOM data.
The segmentation defining the region of interest must be defined as a DICOM Segmentation image.
Support for DICOM Radiotherapy Structure Sets for defining region of interest may be added in the future.
pyradiomics-dcm.py: error: the following arguments are required: --input-image-dir, --input-seg-file, --output-dir

However, I checked it for several times, and I really did not know why.
在 2019年1月17日星期四 UTC+8下午5:05:44,Joost van Griethuysen写道:

Joost van Griethuysen

unread,
Jan 21, 2019, 10:50:03 AM1/21/19
to pyradiomics
PyRadiomics-dcm is a lab that runs in full DICOM input-output. Therefore it expected your segmentation to be a RT-struct.

According to your code, you already have a .nrrd segmentation, and only DICOM images.
What you can do is use nrrdify (download from github, then install using `python setup.py install`) to first convert your DICOM to nrrd, then run PyRadiomics normally:

once Nrrdify is installed, run the following:
`nrrdify ..\DICOM -o nrrd -co files.csv` (you don't have to prepend python, and ensure a folder `nrrd` exists)

This will also generate a csv file (files.csv) which contains the file locations of all generated files (=Series), which you can use in PyRadiomics

Once that is done, you can run PyRadiomics with

`pyradiomics <im_file> <ma_file> [-p <parameter_file>]`

Alternative (batch mode)

`pyradiomics input.csv [-p <parameter_file>]` (input csv should have 1st row as headers, containing at least "Image" and "Mask" which should point to image and mask for that case. 1 row per image/mask combination

Regards,

Joost 



Op maandag 21 januari 2019 16:26:09 UTC+1 schreef Qingwei Zhang:

Andrey Fedorov

unread,
Jan 21, 2019, 11:00:04 AM1/21/19
to Joost van Griethuysen, pyradiomics
> PyRadiomics-dcm is a lab that runs in full DICOM input-output. Therefore it expected your segmentation to be a RT-struct.

To clarify, it expects the segmentation is represented as DICOM
Segmentation object.

It is NOT the purpose of pyradiomics-dcm to serve as a converter from
DICOM into NRRD. You could look into plastimatch convert if you want
specifically NRRD, or dcm2niix if NIfTI output is acceptable. Both
NRRD and NIFTI, along with any other ITK-readable format, are
acceptable by pyradiomics.
> --
> You received this message because you are subscribed to the Google Groups "pyradiomics" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pyradiomics...@googlegroups.com.
> To post to this group, send email to pyrad...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/pyradiomics/509d71f6-1b35-417a-b7f8-37a7553a9b20%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Qingwei Zhang

unread,
Jan 24, 2019, 7:18:28 PM1/24/19
to pyradiomics
Thank you very much. I have done it

在 2019年1月21日星期一 UTC+8下午11:50:03,Joost van Griethuysen写道:

Qingwei Zhang

unread,
Jan 24, 2019, 7:18:57 PM1/24/19
to pyradiomics
Thank you very much. I have done it

在 2019年1月22日星期二 UTC+8上午12:00:04,Andrey Fedorov写道:
Reply all
Reply to author
Forward
0 new messages