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.18k stars 497 forks source link

Image extraction, segmentation, resampling, 2D, MRI cardiac images #360

Closed tommydino93 closed 5 years ago

tommydino93 commented 6 years ago

Hi everyone! Since I am about to begin a radiomic study ex novo, I just wanted to ask some questions so as to avoid annoying future problems. We will extract images and masks of interest next week from cardiac MRI with the intent of performing a future binary classification.

1) Should I necessarily extract images in .nrrd format or the .dcm (DICOM) format is fine and easy to convert into .nrrd?

2) Should the mask simply be an image with ones in the ROI and zeros outside of it?

3) Since we will probably work with single slices (we will select the most significant 2D slice for each patient), how should I set my third dimension since pyradiomics wants volumes as input? Moreover, which are the features that I will be able to extract? (meaning...are there some features that are only applicable in 3D?)

4) This is a strange question: one of the two ground truths of the final binary classification is myocarditis and this has the problem that it often doesn't appear as a single concentrated region in the image. As a matter of fact, since it is an inflammatory phenomenon, it often appears as sparse sub regions on the image. How should we deal with masks in this case? Should we just select the biggest region of inflammation? Should we somehow average the inflamed regions?

Thank you very much in advance, Tommaso

tommydino93 commented 5 years ago

Hi @JoostJM! Sorry for re-opening this after some time. I just had a quick question. It's about when you said:

"If you extract features in 3D you need to ensure that either the voxels are isotropic, or you take the different distances-to-neighbor into account (see weightingNorm). To ensure isotropic voxels, you can utilize resampling"

my questions are: 1) what is the problem of extracting 3D features from the stack of images resampled only along xy (and not along the z axis)?

2) Also, what does the resampling along the z axis do? I am having difficulties visualizing/understanding it. 3) would the 3D feature extraction be wrong if using non isotropic voxels or just not optimal?

Thanks again a lot for your support :) Tommaso

JoostJM commented 5 years ago

@tommydino93 No problem!

  1. Computationally, there is no problem. However, unless weighting by distance (weightingNorm) or force2D is used, PyRadiomics considers neighbors in-plane and out-of-plane to be comparable. If, however, z is e.g. 5 mm and xy are 1 mm, neighbours in z are 5 times further away, and therefore not exactly comparable. This then violates the comparable-neighbors assumption, upon which the feature formulas are based. There are 3 options in PyRadiomics for dealing with this:
    1. Enable resampling to ensure isotropic voxels (see below).
    2. Enable weighting, i.e. taking the distance into account when building the feature matrix.
    3. Enable force2D, ignoring ofsets out-of-plane, thereby only considering neighbors that are in-plane and therefore comparable.
  2. With resampling, you define new gridpoints in your volume, and then calculate the values at those points using interpolation (different interpolators exist, such as linear, nearest neighbor and b-spline). You can best visualize this as your volume being a continuous space, and the values of voxels being the value of discreet points in that space. Resampling means you just 'sample' the volume at different discreet locations.
  3. This is more a philosophical question. I think I'd go for "not optimal", as there will still be valuable information extracted. It mostly reduces the rotation invariance of the extracted features.
tommydino93 commented 5 years ago

@JoostJM Thanks a lot for the immediate answer and detailed explanation!!

So, suppose I wanted to go for option:

i. Enable resampling to ensure isotropic voxels

should I just set the three values of resampledPixelSpacing to the same number like below?

        # settings for the feature calculation.
        settings = {
          'binWidth': 25,
          'interpolator': sitk.sitkLinear,
          'resampledPixelSpacing': [0.8, 0.8, 0.8]  # in [mm]
        }

Also, completely off-topic question: is there, to your knowledge, a gold standard on if/how many filters to apply to the original images for extracting features? I mean, is it standard, optional, rare?

Thanks again :)

JoostJM commented 5 years ago

@tommydino93 Yes, that enables resampling to isotropic voxels. On what size to use, I usually advise to take a compromise with deleting information in-plane and 'creating' it out-of plane. E.g. in the case of x,y = 1mm, z = 5 mm, I usually go for 2 or 3mm isotropic. Always keep in mind that larger voxels are not necessariliy bad, as small voxels are more sensitive to noise. On the other hand, if your lesions are very small, large voxels may result in ROIs with only few number of voxels, which is also unstable.

as to your off-topic question. No gold standard. There is not even a standard (yet) on which to apply and how. Generally some are usually applied and most good radiomics packages do implement at least some.

tommydino93 commented 5 years ago

Thank you very much again! I will open a new quick issue since it's a completely different topic.

harun-cu commented 3 years ago

@JoostJM @fedorov Hi, Is there any way to convert .tiff image to .nifti. My original images are in DICOM but after creating mask using ImageJ it saved as .tiff. Would you suggest me anyway?

Thanks

JoostJM commented 3 years ago

The easiest way to do it in python is to load both image and mask in SimpleITK, then set the image as the reference volume for the mask, the save the mask as niftii. One question though, is your image 2d or 3d? I believe tiff will only save in 2d, so you'd need to specify which slice it is. Additionally, a good thing to do is to enter a vector index from the mask if it has a vector pixel type (I.e. color image). If it appears white, most likely all color channels have the value aet to 255, so the index doesn't matter.