Function Signature

The complete signature of the main function with all available parameters:

extract_radiomic_features(img_input, mask_input, voxel_spacing_input;
                          features=Symbol[],
                          labels=nothing,
                          n_bins=nothing,
                          bin_width=nothing,
                          weighting_norm=nothing,
                          keep_largest_only::Bool=true,
                          get_raw_matrices::Bool=false,
                          slices_2d=nothing,
                          use_gpu::Bool=false,
                          suv_ibsi_normalization::Bool=false,
                          verbose::Bool=false)

# Parameters:
#  img_input           – The input image (Array), either 2D or 3D. If a 3D image is passed and the "slices_2d" parameter is defined, 
                            it computes the features on 2D images according to the specified plan/slice pairs..
#  mask_input          – Mask defining the region of interest (Array) with same shape of `img_input`.
#  voxel_spacing_input – Voxel spacing in mm, e.g. [1.0, 1.0, 2.5] (Array).
#  features            – Symbols selecting which groups to compute.
#                        Options: :first_order, :glcm, :shape2d, :shape3d,
#                                 :glszm, :ngtdm, :glrlm, :gldm.
#                        Default Symbol[] computes all groups.
#  labels              – Int, Vector{Int}, or nothing (defaults to label 1).
#  n_bins              – Number of histogram bins for discretisation.
#  bin_width           – Fixed bin width for discretisation (alternative to n_bins).
#  weighting_norm      – Norm used for GLCM distance weighting.
#  keep_largest_only   – If true, only the largest connected component is used.
#  get_raw_matrices    – If true, returns the raw matrices for texture features.
#  slices_2d           – If present, calculate all features on 2D slices - mask. When this parameter is used you can pass 
                            a vector of tuples (plan, slice_idx) where plan is the plane number (1, 2, or 3) and slice_idx is the slice index.
#  use_gpu             – If true, performs CUDA compatibility checks and enables GPU acceleration when a supported GPU is available..
#  suv_ibsi_normalization – If true, performs SUV-IBSI normalization on the image before feature extraction.
#  verbose             – Print progress information during extraction.

# Returns:
# Single label or nothing: Dict{String,Any} with feature names as keys
# Multiple labels: Dict{Int,Dict{String,Any}} where outer keys are label values

Features Extraction with CUDA

Setting flag to use GPU

Load image and mask, then extract all radiomic features using specific flag to activate GPU:

using Radiomics 

anatomical_image = "Path/to/Volume"
mask = "Path/to/Mask"

features = Radiomics.extract_radiomic_features(anatomical_image, mask, use_gpu=true);

Features Extraction

Basic Usage

Load image and mask, then extract all radiomic features with default settings:

using Radiomics

anatomical_image = "Path/to/Volume"
mask = "Path/to/Mask"

features = Radiomics.extract_radiomic_features(anatomical_image, mask)

Select Specific Feature Groups

To compute only a subset of features, specify the desired ones using the features flags:

using Radiomics

anatomical_image = "Path/to/Volume"
mask = "Path/to/Mask"

features = Radiomics.extract_radiomic_features(anatomical_image, mask; features=[:first_order, :glcm]);

Select Specific label

To extract features from a specific label (default is 1), execute:

using Radiomics

anatomical_image = "Path/to/Volume"
mask = "Path/to/Mask"

features = Radiomics.extract_radiomic_features(anatomical_image, mask; labels=1);

Select list of labels

To extract features from a list of labels, execute:

using Radiomics

anatomical_image = "Path/to/Volume"
mask = "Path/to/Mask"

features = Radiomics.extract_radiomic_features(anatomical_image, mask; labels=[1,2]);

Please note that, in this case, the function returns a dictionary with integer keys (e.g., 3, 5, and 11).

Extraction with a specific bin_width

To compute more features with a specific bin_width (by default it is 25.0):

using Radiomics

anatomical_image = "Path/to/Volume"
mask = "Path/to/Mask"

features = Radiomics.extract_radiomic_features(anatomical_image, mask; bin_width=35);

Standard Deviation Calculation

The following example shows how to calculate the standard deviation from the extracted texture features:

using Radiomics

anatomical_image = "Path/to/Volume"
mask = "Path/to/Mask"

features = Radiomics.extract_radiomic_features(anatomical_image, mask; features_std = true);

Extraction with a specific n_bins

To compute with a specific number of bins:

using Radiomics

anatomical_image = "Path/to/Volume"
mask = "Path/to/Mask"

features = Radiomics.extract_radiomic_features(anatomical_image, mask; n_bins=16);

Extraction all islands

To compute features from the entire mask regardless of fragmentation, set keep_largest_only to false; set it to true to isolate and analyze only the largest connected component:

using Radiomics

anatomical_image = "Path/to/Volume"
mask = "Path/to/Mask"

features = Radiomics.extract_radiomic_features(anatomical_image, mask; keep_largest_only=false)

Extraction with a specific weighting_norm

To compute with a specific weighting_norm

using Radiomics

anatomical_image = "Path/to/Volume"
mask = "Path/to/Mask"

features = Radiomics.extract_radiomic_features(anatomical_image, mask; keep_largest_only=false, weighting_norm="euclidean");

Extraction raw matrices from Texture Features

Basic Usage

To compute the raw matrices from the texture features, set get_raw_matrices. This option returns a dictionary containing the raw matrix for each direction. When enabled, the output will include all the extracted features as well as the raw texture matrices. Please note that activating this option can significantly increase memory usage.

using Radiomics

anatomical_image = "Path/to/Volume"
mask = "Path/to/Mask"

features = Radiomics.extract_radiomic_features(anatomical_image, mask; get_raw_matrices=true);

Get raw matrices from specific features

To compute the raw matrices from the texture features, set features param.

using Radiomics

anatomical_image = "Path/to/Volume"
mask = "Path/to/Mask"

features = Radiomics.extract_radiomic_features(anatomical_image, mask; get_raw_matrices=true, features=[:glrlm, :glcm]);

Get raw matrices from labels

To compute the raw matrices from the texture features, set labels param.

using Radiomics

anatomical_image = "Path/to/Volume"
mask = "Path/to/Mask"

features = Radiomics.extract_radiomic_features(anatomical_image, mask; get_raw_matrices=true, labels=[1,2]);

Accessing matrix data

To access the raw matrices from the texture features, use the following code:

mat = features["raw_glcm_matrices"]