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.14k stars 492 forks source link

Patients with unequal sizes for image and mask should be excluded or the image-mask pairs should be correctly processed to same size #763

Closed huangmozhilv closed 2 years ago

huangmozhilv commented 2 years ago

In my case, the mask contains only the slices with tumor, thus having a size different from that of the image. Pyradiomics(v2.0.1) first resampled the image/mask to the target spacing ([1,1,1]), which resulted in the same resampled size for image and mask, therefore it did not warn that the original sizes are different. This is problematic as the two array are actually not alligned. Below are some problemic cases in my work. 1

The correct way should be excluding this patient to ask the user to check the files, or register the two files if the metadata show they are unalligned. Python package nibabel can be used to retrieve the affine matrices from the nifiti files and transform the image and mask to the same reference space.

JoostJM commented 2 years ago

TLDR: This is incorrect. If the image and mask align in programs like 3D slicer, they'll also align correctly in PyRadiomics.

This is incorrect. PyRadiomics is aware of geometric spacing, meaning that image and mask are aligned based on there physical positions. This is why it is so important that geometric information is included in the images passed to PyRadiomics.

When resampling is enabled, no warning is issued as both image and mask are resampled to the new grid. If no resampling is enabled and differences in size are found, a warning is issued. If the user has enable correctMask, the mask is then resampled to the image geometric space and feature extraction can proceed.

The only case where this can go wrong is when users remove geometric information and different sizes exist. In these cases there are often more issues, as for example spacing affects some (shape) features.