-
Notifications
You must be signed in to change notification settings - Fork 481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How does Pyradiomics deal with several structures segmented in a nrrd file? [FEAT EXTRACTION] #528
Comments
For each case, PyRadiomics only computes the features for 1 ROI in your mask file (identified by the value of See also this example of plastimatch. Multiple ROIs are assigned to the ith bit in the output volume, allowing for overlapping structures. Additionally, plastimatch can output a file showing your segments. Be aware that PyRadiomics will not function correctly if you have overlapping segments! PyRadiomics only looks at the value as a whole, not a specific index. Overlapping structures in a mask are allowed by supplying a 4D volume as a mask. If there is no overlap it should work fine (i.e. possible labels are 1, 2, 4, 8, etc.) If you know which labels are present in your mask, you can define them when using PyRadiomics in batch mode (column "Label"). |
Thanks a lot @JoostJM 0|0 255 0|BODY However, the labels don't match the numbers here. |
Can you share the converted mask file? Then I think I can figure out what's what. |
This is the link to the .nrrd file. |
The output file is indeed more or less like specified in the documentation of plastimatch. However, the datatype is uint8 (meaning 8 bits = 8 possible labels). To allow for more segments (38 in your case), the volume is transformed into a 4D volume, so 8 labels per channel. To get something that Slicer and PyRadiomics understands, we need to do some restructuring:
This piece of code iterates over all possible labels and if it finds voxels that match, stores them in a labelmap (be aware that this assumes a 3D volume, with uint8 datatype). Then at the end, it makes 1 4D matrix and builds an image. As a final step, the geometric information of the mask is copied and the segmentation is stored as a segmentation. This you can load into slicer to see if it is correct. The first value in the output file (0-37) should match the index in the segmentation. If you want to extract features for, say, "Art_IMA", run PyRadiomics with setting Finally, you can also use the SlicerRT extension to load the RTSTRUCT directly into a slicer node and use it to make the segmentation files (which will then also automatically incorporate the name). |
Thanks a ton! @JoostJM |
Happy to help |
How would you incorporate that code into the batch file example "batchprocessing.py"? |
@JE-Jimenez, the advised entrypoint for batchprocessing in PyRadiomics is via the command line (better error handling, multiprocessing support, etc). In that case you can specify a combination of image, mask and label in the csv file using the columns "Image", "Mask" and "Label"/"Label_channel", respectively ("Label" indicates a label value in a labelmap, "Label_channel" the 0-based index of the segment, see 3D Slicer on labelmaps and segmentations for the differences). |
In batch processing.py, you can achieve something similar, though currently it is only provided for |
I am trying pyradiomics on a CT scan with DICOM data and a DICOM RTSS structure file. The RTSS file has several structures in it. I have successfully used plastimatch via command line to convert the dicom image files to a single 3d nrrd file and then converted the RTSS dicom file to another nrrd file.
When I perform a feature extraction with pydicom, I get some results, but it is a single set of numbers. I was expecting that I would get values for each structure in the nrrd structure set image. Does pydicom work for only one structure per mask?
Version (please complete the following information):
The text was updated successfully, but these errors were encountered: