13 MRI Parameters
13.1 Image Filter
In PyRadiomics, the specified imageType
filters (Original
, LoG
, and Wavelet
) are applied before the extraction of features from each featureClass
. Here’s how it works:
13.1.1 How imageType
Works
- Definition: Each
imageType
specifies a pre-processing step (e.g., no filtering forOriginal
, edge enhancement forLoG
, or multi-frequency decomposition forWavelet
) applied to the input image before feature extraction. - Behavior: For each enabled
imageType
, PyRadiomics generates a new version of the image and applies all specifiedfeatureClass
extractions to that version of the image.
13.1.2 Filter-Specific Behavior
Original
- Description: Uses the unprocessed input image directly for feature extraction.
- Workflow:
- No filtering is applied.
- All enabled
featureClass
(e.g.,firstorder
,shape
,glcm
, etc.) are computed on the original image.
- Usage: Baseline features to capture raw intensity and shape information.
LoG
(Laplacian of Gaussian)- Description: Enhances edges and fine details in the image. The filter is applied at different scales specified by
sigma
values. - Workflow:
- The LoG filter is applied to the input image for each
sigma
value (e.g.,[2.0, 3.0, 4.0]
). - Each filtered image is treated as a separate version of the input image.
- All enabled
featureClass
are computed for eachLoG
-filtered image.
- The LoG filter is applied to the input image for each
- Usage: Extracts texture features sensitive to specific spatial scales.
- Description: Enhances edges and fine details in the image. The filter is applied at different scales specified by
Wavelet
- Description: Applies a wavelet transformation to decompose the image into multiple frequency components. For each wavelet decomposition, eight sub-bands (LL, LH, HL, HH, etc.) are generated.
- Workflow:
- The wavelet filter decomposes the input image into sub-bands.
- Each sub-band is treated as a separate version of the input image.
- All enabled
featureClass
are computed for each wavelet sub-band.
- Usage: Captures multi-scale texture and frequency patterns.
13.1.2.1 Relationship Between imageType
and featureClass
- For each enabled
imageType
, all specifiedfeatureClass
(e.g.,firstorder
,glcm
,glrlm
, etc.) are applied. - This means PyRadiomics performs the following:
- Extract features from the original image for all enabled
featureClass
. - Apply the LoG filter for each
sigma
value and extract features for all enabledfeatureClass
for each filtered image. - Apply the wavelet transformation, and extract features for all enabled
featureClass
for each sub-band.
- Extract features from the original image for all enabled
13.1.3 Practical Example
Configuration
imageType:
Original: {}
LoG:
sigma: [2.0, 3.0]
Wavelet: {}
featureClass:
firstorder: true
glcm: true
shape: true
Execution Workflow
- Original Image:
- Extract
firstorder
,glcm
, andshape
features.
- Extract
- LoG Filter (σ = 2.0):
- Apply the LoG filter with
sigma = 2.0
. - Extract
firstorder
,glcm
, andshape
features from this filtered image.
- Apply the LoG filter with
- LoG Filter (σ = 3.0):
- Apply the LoG filter with
sigma = 3.0
. - Extract
firstorder
,glcm
, andshape
features from this filtered image.
- Apply the LoG filter with
- Wavelet:
- Decompose the image into 8 sub-bands (LL, LH, HL, HH, etc.).
- Extract
firstorder
,glcm
, andshape
features from each sub-band.
Result:
- Features are computed multiple times: once for each image type and filter configuration.
- The resulting feature set will include:
- Features from the original image.
- Features for each LoG σ value.
- Features for each wavelet sub-band.
13.1.4 Why Does PyRadiomics Do This?
- Enhanced Feature Representation:
- Different filters (e.g., LoG, wavelet) capture specific spatial or frequency-based patterns that the original image may not reveal.
- Multi-Scale Analysis:
- LoG captures patterns at specific spatial scales, while wavelets decompose the image into low- and high-frequency components.
- Comprehensive Texture Analysis:
- Computing features on multiple filtered images enriches the feature set, potentially improving model performance in downstream tasks.
13.1.5 Summary
- PyRadiomics applies all
imageType
filters before extracting the specified features for eachfeatureClass
. - For each
imageType
: PyRadiomics processes the filtered image and computes all enabled features, leading to a comprehensive feature set. - Implication: The feature set size increases significantly with each additional
imageType
and filter parameter (e.g.,sigma
values for LoG, sub-bands for wavelets).
13.2 Thin-slice MRI Radiomics (3 mm)
The exampleMR_3mm.yaml
configuration file is tailored for thin-slice MRI scans (~3 mm slice thickness). Thin slices offer better spatial resolution and are particularly useful for detecting fine anatomical details, but they also introduce considerations for radiomics analysis. Below, I’ll explain why this setting is appropriate for such data.
13.2.1 imageType
imageType:
Original: {}
LoG:
sigma: [2.0, 3.0, 4.0, 5.0]
Wavelet: {}
Original
: Features are extracted directly from the unfiltered image, capturing raw intensity and texture information.LoG
(Laplacian of Gaussian):- Highlights edges and regions with specific spatial scales, determined by
sigma
values. - Thin slices: Sigma values ≥ 2 mm are appropriate to avoid noise sensitivity at very fine scales.
- Larger sigma values (e.g., 4.0, 5.0) capture coarser textures, which can be useful for thin slices with isotropic voxels.
- Highlights edges and regions with specific spatial scales, determined by
Wavelet
: Decomposes the image into multi-frequency components, capturing texture at multiple scales.
13.2.2 featureClass
featureClass:
shape:
firstorder:
glcm:
- 'Autocorrelation'
- 'ClusterProminence'
- ... (remaining GLCM features)
glrlm:
glszm:
gldm:
- Included Feature Classes:
shape
: Extracts 3D geometric features such as volume, surface area, compactness, and sphericity.firstorder
: Basic intensity statistics (mean, median, skewness, etc.), critical for characterizing signal distributions in MR data.glcm
: Gray Level Co-occurrence Matrix for texture features, with a custom list of relevant features enabled (e.g.,Contrast
,Correlation
).glrlm
,glszm
,gldm
: Additional texture-based feature classes for advanced heterogeneity analysis.
- Exclusions:
- The
SumAverage
GLCM feature is excluded due to redundancy with other intensity-related features.
- The
13.2.3 setting: normalize
normalize: true
normalizeScale: 100
- Why Normalize for MRI?
- MRI intensity values are relative and vary by scanner, vendor, and protocol. Normalization ensures consistency across scans.
- Thin slices: Often have higher intensity variability within a region due to better spatial resolution, making normalization even more critical.
- Normalization Scale (
normalizeScale
):- Rescales normalized values to a range suitable for radiomics calculations (e.g., ~[0, 100]).
13.2.4 setting: resampledPixelSpacing
resampledPixelSpacing: [2, 2, 2]
- Why Resample?
- Ensures isotropic voxels (uniform resolution in all directions) for consistent feature extraction.
- Thin slices (e.g., ~3 mm) typically have anisotropic voxels where the in-plane resolution is finer than the slice thickness.
- Resampling to [2, 2, 2] mm balances computational efficiency with spatial detail:
- Coarser resampling (e.g., [2, 2, 2]) reduces noise and ensures stability for texture features.
- Avoids overly fine resampling (e.g., [1, 1, 1]), which could introduce artifacts or excessive computational load.
13.2.5 setting: binWidth
binWidth: 5
- Why Bin Width Matters:
- Texture features (e.g., GLCM, GLRL) rely on discretizing intensity values into bins.
- The choice of bin width affects sensitivity to small intensity differences and the stability of extracted features.
- Bin Width = 5:
- Appropriate for MRI datasets with thin slices, where intensity ranges are typically smaller than CT data.
- Results in a manageable number of bins (~16–128), improving the stability and interpretability of texture features.
13.2.6 setting: voxelArrayShift
voxelArrayShift: 300
- Purpose:
- Shifts voxel intensities by 300 to make most values positive after normalization (mean-centered normalization can produce negative values).
- Ensures numerical stability for feature extraction.
- Why It’s Important for MRI:
- Thin-slice MRI often has a wider intensity distribution due to finer spatial detail, so the shift prevents issues with negative voxel values.
13.2.7 setting: interpolator
interpolator: 'sitkBSpline'
sitkBSpline
(interpolation):- Smooths voxel intensities during resampling to preserve detail without introducing artifacts.
- Works well with the inherently smooth nature of MRI data.
13.2.8 Other Notes
- GLCM Feature Selection: Disabling redundant features like
SumAverage
ensures computational efficiency and avoids feature redundancy. - Resampling Trade-Offs:
- Resampling to [2, 2, 2] sacrifices some detail but ensures robust feature calculation, which is critical for thin slices with high resolution.
13.2.9 Why It’s Appropriate for Thin-Slice MRI
- Normalization: Accounts for scanner variability and relative MRI intensities.
- Resampling: Reduces the effect of anisotropy while preserving sufficient detail for texture analysis.
- Feature Selection: Focuses on features that leverage the higher resolution of thin slices (e.g., texture, shape).
- Bin Width and Shift: Optimized for MRI intensity ranges and ensures numerical stability.
- LoG Filtering: Emphasizes spatial details at multiple scales, appropriate for high-resolution data.
13.3 Thick-slice MRI Radiomics (5 mm)
#| code-fold: true
# This is an example of settings that can be used as a starting point for analyzing MR data with large(r) (~5mm) slice
# thickness. This is only intended as a starting point and is not likely to be the optimal settings for your dataset.
# Some points in determining better values are added as comments where appropriate
# When adapting and using these settings for an analysis, be sure to add the PyRadiomics version used to allow you to
# easily recreate your extraction at a later timepoint:
# ############################# Extracted using PyRadiomics version: <version> ######################################
imageType:
Original: {}
LoG:
# Because of resampling to (3, 3, 3), the use of sigmas < 3 mm is not recommended.
sigma: [3.0, 5.0]
Wavelet: {}
featureClass:
# redundant Compactness 1, Compactness 2 an Spherical Disproportion features are disabled by default, they can be
# enabled by specifying individual feature names (as is done for glcm) and including them in the list.
shape:
firstorder:
glcm: # Disable SumAverage by specifying all other GLCM features available
- 'Autocorrelation'
- 'JointAverage'
- 'ClusterProminence'
- 'ClusterShade'
- 'ClusterTendency'
- 'Contrast'
- 'Correlation'
- 'DifferenceAverage'
- 'DifferenceEntropy'
- 'DifferenceVariance'
- 'JointEnergy'
- 'JointEntropy'
- 'Imc1'
- 'Imc2'
- 'Idm'
- 'Idmn'
- 'Id'
- 'Idn'
- 'InverseVariance'
- 'MaximumProbability'
- 'SumEntropy'
- 'SumSquares'
glrlm:
glszm:
gldm:
setting:
# Normalization:
# MR signal is usually relative, with large differences between scanners and vendors. By normalizing the image before
# feature calculation, this confounding effect may be reduced. However, if only one specific scanner is used, or the
# images reflect some absolute world value (e.g. ADC maps, T2maps (NOT T2 weighted)), consider disabling the
# normalization.
normalize: true
normalizeScale: 100 # This allows you to use more or less the same bin width.
# Resampling:
# Increasing the resampled spacing forces PyRadiomics to look at more coarse textures, which may or
# may not increase accuracy and stability of your extracted features. Using a small spacing in large slices generates
# many interpolated voxels, potentially 'masking' the signal contained in the image.
interpolator: 'sitkBSpline'
resampledPixelSpacing: [3, 3, 3]
# Mask validation:
# correctMask and geometryTolerance are not needed, as both image and mask are resampled, if you expect very small
# masks, consider to enable a size constraint by uncommenting settings below:
#minimumROIDimensions: 2
#minimumROISize: 50
# Image discretization:
# The ideal number of bins is somewhere in the order of 16-128 bins. A possible way to define a good binwidt is to
# extract firstorder:Range from the dataset to analyze, and choose a binwidth so, that range/binwidth remains approximately
# in this range of bins.
binWidth: 5
# first order specific settings:
# When normalizing, gray values below the mean will be negative. Shifting by 300 (3 StdDevs * 100) ensures that the
# majority of voxels is positive (only outliers >3 SD lower than the mean will be negative).
voxelArrayShift: 300
# Misc:
# default label value. Labels can also be defined in the call to featureextractor.execute, as a commandline argument,
# or in a column "Label" in the input csv (batchprocessing)
label: 1
The exampleMR_5mm.yaml
file is tailored for MRI scans with larger slice thickness (~5 mm) and has several differences compared to the thin-slice setting (exampleMR_3mm.yaml
). Below is a detailed comparison of the key parameters, explaining the reasoning behind each setting and its adaptation for the specific slice thickness.
13.3.1 Thick vs Thin-Slice Comparison
Parameter | Thin Slice (exampleMR_3mm.yaml ) |
Thick Slice (exampleMR_5mm.yaml ) |
Explanation |
---|---|---|---|
resampledPixelSpacing |
[2, 2, 2] |
[3, 3, 3] |
Larger resampling spacing for thicker slices. Thicker slices have less detail along the z-axis; coarse resampling avoids over-smoothing. |
LoG: sigma |
[2.0, 3.0, 4.0, 5.0] |
[3.0, 5.0] |
Thicker slices capture coarser details, so only larger sigma values are relevant to avoid noise sensitivity. |
Normalization (normalize ) |
true |
true |
Normalization remains consistent because MRI intensity values vary across scanners regardless of slice thickness. |
Normalization Scale (normalizeScale ) |
100 |
100 |
Both settings use the same normalization scale, as this does not depend on slice thickness. |
Image Discretization (binWidth ) |
5 |
5 |
Same bin width for consistency in texture calculation. The choice is determined by intensity range, not slice thickness. |
Wavelet Transformation |
Enabled | Enabled | Wavelet remains enabled in both settings because it captures multi-scale texture features independent of slice thickness. |
Shape Features (shape ) |
Enabled | Enabled | Both settings extract shape features, which are critical for volumetric analysis regardless of slice thickness. |
GLCM Features (glcm ) |
Full list of GLCM features enabled | Full list of GLCM features enabled | Same set of GLCM features for texture analysis; differences arise from spatial resolution and resampling settings. |
voxelArrayShift |
300 |
300 |
Same shift value to handle negative voxel intensities after normalization. |
13.3.2 Key Differences and Rationale
resampledPixelSpacing
- 3mm Setting:
[2, 2, 2]
provides finer resolution for thin slices, preserving more texture detail along all axes. - 5mm Setting:
[3, 3, 3]
ensures stability by coarsening the resampling grid to match the thicker slices, avoiding over-interpolation. - Rationale: Thicker slices already have reduced detail along the z-axis. Coarser resampling aligns better with the inherent resolution, ensuring that texture features are representative.
- 3mm Setting:
LoG: sigma
- 3mm Setting:
[2.0, 3.0, 4.0, 5.0]
includes smaller sigma values to capture finer spatial details present in thin slices. - 5mm Setting:
[3.0, 5.0]
focuses on coarser textures, as finer details are less likely to exist in thicker slices. - Rationale: Smaller sigma values (<3.0) are not meaningful for thicker slices due to limited resolution.
- 3mm Setting:
- Wavelet Transformation
- Both Settings: Enabled in both cases to analyze multi-scale textures.
- Rationale: Wavelet features are not directly affected by slice thickness and remain applicable for both settings.
- Normalization
- Both Settings: Normalization (
normalize: true
) is used for both settings. - Rationale: MRI intensities are relative and scanner-dependent regardless of slice thickness, so normalization is necessary in both cases.
- Both Settings: Normalization (
- Resampling Trade-Off
- 3mm Setting: Smaller voxel spacing (
[2, 2, 2]
) allows capturing finer textures. - 5mm Setting: Coarser voxel spacing (
[3, 3, 3]
) prevents excessive computational overhead and avoids artifacts due to interpolation noise.
- 3mm Setting: Smaller voxel spacing (
- GLCM Features
- Both Settings: Full set of GLCM features is included in both, as these are essential for texture analysis.
- Rationale: The choice of GLCM features is not affected by slice thickness, but the resolution of the resampling affects the calculated values.
- Discretization (
binWidth
)- Both Settings: Bin width of 5 is used in both settings.
- Rationale: Bin width is determined by the intensity range of the MRI data, not the slice thickness.
voxelArrayShift
- Both Settings:
300
is used in both settings. - Rationale: Ensures positive intensities after normalization for numerical stability, applicable for both thin and thick slices.
- Both Settings:
13.3.3 Conclusion
The key differences in exampleMR_3mm.yaml
(thin slice) vs. exampleMR_5mm.yaml
(thick slice) lie in the resampling settings (resampledPixelSpacing
) and the LoG
filter sigma values. These adjustments align with the spatial resolution and expected level of detail in the data:
- Thin Slice Setting (3 mm): Optimized for finer spatial details and textures with higher resolution.
- Thick Slice Setting (5 mm): Adjusted for coarser spatial features, reducing sensitivity to interpolation artifacts.
Would you like further assistance tailoring these configurations to your specific dataset or workflow?
13.4 2D vs 3D Feature Extraction
13.4.1 3D Feature Extraction
- Definition: Involves analyzing a 3D volume of the Region of Interest (ROI) defined by the segmentation mask.
- How it works: The entire ROI is treated as a single volumetric entity, and radiomics features are extracted based on the spatial relationships across all three dimensions (X, Y, Z).
- Example: Texture features (e.g., GLCM, GLRLM) are calculated using voxel neighbors in all directions (26-neighborhood connectivity for 3D).
- Advantages:
- Captures volumetric heterogeneity and spatial relationships throughout the ROI.
- Suitable for volumetric imaging modalities (e.g., 3D MRI, CT).
- Disadvantages:
- Computationally more expensive.
- Sensitive to voxel anisotropy (non-uniform voxel dimensions in different directions).
13.4.2 2D Feature Extraction
- Definition: Involves analyzing the ROI slice-by-slice, effectively treating each 2D slice in the ROI independently.
- How it works: Features are extracted for each 2D plane separately, and the spatial relationships in the third dimension are ignored.
- Example: Texture features are calculated based on voxel neighbors within a 2D plane (8-neighborhood connectivity for 2D).
- Advantages:
- Useful for inherently 2D acquisitions (e.g., ultrasound, certain MRI sequences acquired slice-by-slice).
- Avoids artifacts or errors introduced by anisotropic voxels.
- Disadvantages:
- Does not capture volumetric information or spatial relationships between slices.
- Results in multiple feature sets (one per slice), which may require aggregation (e.g., mean, median).
13.4.3 The force2D
Parameter
force2D: true
force2Ddimension: 0
13.4.3.1 What force2D
Does
- Purpose: Forces PyRadiomics to extract features in 2D instead of 3D, regardless of whether the input image is 3D.
- Behavior:
- When
force2D: true
, the software processes each slice independently. - Features are calculated within the 2D plane defined by the
force2Ddimension
parameter (e.g., axial, coronal, sagittal).
- When
13.4.4 The force2Ddimension
Parameter
- Definition: Specifies the plane along which 2D slicing occurs:
0
→ Axial plane (default for most MRI/CT data).1
→ Coronal plane.2
→ Sagittal plane.
For example: - If your MRI volume is axial, set force2Ddimension: 0
to extract features for each axial slice separately.
13.4.5 Use Cases for force2D: true
- Slice-by-Slice Analysis:
- For scenarios where the tumor or lesion varies significantly across slices, 2D analysis provides per-slice feature sets for detailed evaluation.
- Common in certain MRI studies, like evaluating orbital tumors in axial slices.
- Avoiding Inter-Slice Artifacts:
- When voxel dimensions are anisotropic (e.g., much thicker slices along Z than X/Y), 3D extraction can be biased. 2D extraction avoids this by only considering the isotropic in-plane resolution.
13.4.6 What Happens in 2D Mode
- The ROI is segmented and processed for each slice independently.
- For each slice containing ROI pixels, PyRadiomics computes features.
- The output for multiple slices can either be analyzed slice-by-slice or aggregated (e.g., mean, median) for a single representative feature set.
13.4.7 Comparison: 2D vs. 3D Feature Extraction
Aspect | 2D Extraction | 3D Extraction |
---|---|---|
Scope | Slice-by-slice (2D plane) | Entire 3D volume |
Neighborhood | 8-neighborhood (within slice) | 26-neighborhood (across slices and planes) |
Input | 2D slices or 3D volume (processed as 2D slices) | 3D volume |
Computational Load | Lower (processes each slice separately) | Higher (processes the entire volume at once) |
Use Case | Slice-wise variability, anisotropic voxels, ultrasound | 3D volumetric data, isotropic resolution, CT/MRI |
Output | Features per slice or aggregated across slices | Single feature set for the entire volume |
13.4.7.1 Practical Recommendation
- Use
force2D: true
when:- Your input data or segmentation mask is slice-based (e.g., orbital MRI).
- There is significant anisotropy in voxel spacing.
- You need per-slice feature extraction.
- Use 3D mode when:
- The segmentation mask spans the entire tumor or ROI across multiple slices, and volumetric relationships are important.