Issue with 2D extraction and resampling

106 views
Skip to first unread message

Renato Cuocolo

unread,
Jan 26, 2020, 4:31:04 AM1/26/20
to pyradiomics
I am crossposting from the Slicer forums as there has been no answer there yet, maybe someone here ran in a similar issue:

Hello, I am havong an issue on PyRadiomics 2.2.0 using the terminal (Ubuntu 18.04) for batch extraction.
I have images and masks in .nii.gz format, both with 1x1x3 mm voxels. I have drawn bidimensional ROIs on ITKSnap with 10x10x1 dimensions, which translate to 10x10x3 mm. Unfortunately some ROIs are also drawn on different planes (e.g. 10x1x10 mm).
When extracting I tried to use force2D: true to enable shape2D features and true bidimensional extraction, only when paired with 1x1x1 resampling the process fails due to the ROI not having a z value of 1 anymore (e.g. after resampling it becomes 10x10x3). Reading the docs, it states that resampling in one of the planes should be left as 0 to keep original dimensions and only perform in-plane resampling which I suspect would solve my issue.
I am not able to get the extraction to work, could someone give a parameter file example for the relevant settings to allow correct 2D extraction in a similar situation?

Steve Pieper

unread,
Jan 27, 2020, 2:49:56 PM1/27/20
to Renato Cuocolo, pyradiomics
Hi - 

If I understand correctly you have some segmentations drawn on the sagittal or coronal plane when the acquisition is axial?  I'm not sure those will be directly comparable with radiomics, but I suspect the easiest would be to 'fake it' by forcing them to all have the same direction matrix before resampling.

Best,
Steve

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/pyradiomics/d29901c5-5f6f-4e4b-a353-aff94fb92d07%40googlegroups.com.

Joost van Griethuysen

unread,
Jan 28, 2020, 4:02:02 AM1/28/20
to pyradiomics
I agree with Steve here. You can check if your geometric information is correct by loading both into Slicer. If they match, then you're quite safe to resample the mask to the image space:

```
import SimpleITK as sitk

ma = sitk.ReadImage('maskfilepath')
im = sitk.ReadImage('imagefilepath')

rif = sitk.ResampleImageFilter()
rif.SetReferenceImage(im)
rif.SetInterpolator(sitk.sitkNearestNeighbor)
rif.SetOutputPixelType(sitk.sitkUInt8)

ma = rif.Execute(ma)

sitk.WriteImage(ma, 'maskfilepath_resampled.nii.gz', True)
```

Regards,

Joost

Op maandag 27 januari 2020 20:49:56 UTC+1 schreef Steven D. Pieper:
To unsubscribe from this group and stop receiving emails from it, send an email to pyradiomics+unsubscribe@googlegroups.com.

Renato Cuocolo

unread,
Jan 28, 2020, 6:06:58 AM1/28/20
to pyradiomics
Thank you for the interest in my issue, I think it was solved.
The mistake was due to interpreting the orientation referred to in the documentation as "absolute" rather than relative to image acquisition orientation. Therefore, I was setting the force2Ddimension parameter wrongly in relation to the resampling. I made several tests checking the output of image and mask resegmentation to confirm my misunderstanding. Maybe this could be explained more clearly in the documentation as MRI acquisitions are often not aligned with the actual x, y and z axes of the patient, and the 2D dimensions refer to the acquisition volumes axes rather than the "true" axial, coronal and sagittal planes.
To unsubscribe from this group and stop receiving emails from it, send an email to pyrad...@googlegroups.com.

Steve Pieper

unread,
Jan 28, 2020, 8:24:43 AM1/28/20
to Renato Cuocolo, pyradiomics
Hi Renato -

Glad you sorted it out!

If you could make a pull request with specific suggestions for improving the documentation it would be very much appreciated.

Regards,
Steve

To unsubscribe from this group and stop receiving emails from it, send an email to pyradiomics...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyradiomics/127d4e88-0f38-42f0-8816-47333cea75c8%40googlegroups.com.

Renato Cuocolo

unread,
Feb 3, 2020, 5:07:00 AM2/3/20
to pyradiomics
As stated on the Slicer forums, I made a pull request adding an example file specific for this use case. However, the online documentation should also be edited to avoid this issue in the future.
Thank you for your work.

Renato

Steve Pieper

unread,
Feb 3, 2020, 10:47:32 AM2/3/20
to Renato Cuocolo, pyradiomics
Great - thanks for the contribution. 👍 . As Andrey noted on github, the online documents are generated from the source files so you can easily make edits there.

Cheers,
Steve

To unsubscribe from this group and stop receiving emails from it, send an email to pyradiomics...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyradiomics/c26fa330-1982-4905-8851-e272ebe6a99b%40googlegroups.com.

Renato Cuocolo

unread,
Feb 3, 2020, 11:25:28 AM2/3/20
to Steve Pieper, pyradiomics
Thank you, I was notified of the right file to edit and will propose an edit as soon as possible. Unfortunately, I am pretty new to editing files on large projects, I mainly use git for small private scripts I use for quality of life in my workflow.

Renato

Andrey Fedorov

unread,
Feb 3, 2020, 11:28:00 AM2/3/20
to Renato Cuocolo, Steve Pieper, pyradiomics
Thank you for your contribution, Renato!

I included pointer to the top-level folder for documentation. If you need help navigating or discuss where the update should go, please add comments to the issue, and we will try to help!

Reply all
Reply to author
Forward
0 new messages