RIA package manual

Márton Kolossváry

2017-08-11

Radiomics Image Analysis (RIA) package was developed to facilitate radiomic analysis of grayscale images. RIA can calculate hundreds of different statistics on both 2D and 3D images. Almost all calculations are vectorized and therefore are super-efficient. The package is developed by Márton Kolossváry a medical doctor not an engineer, therefore all functionalities of the software package are developed in a way that can be learnt non-professionals. RIA is constantly updated with new functionalities and wrap-around functions to make the calculation of radiomic metrics even simpler.

First, lest simply load RIA

library(RIA)
#> 
#> ##############################
#> ##         WELCOME TO       ##
#> ##         __________       ##
#> ##        / _  / / _ |      ##
#> ##       / , _/ / __ |      ##
#> ##      /_/|_/_/_/ |_|      ##
#> ## RADIOMICS IMAGE ANALYSIS ##
#> ##    Márton Kolossváry     ##
#> ##############################
#> 
#> Please cite: KOLOSSVÁRY, Márton, et al.
#> Cardiac Computed Tomography Radiomics: A Comprehensive Review on Radiomic Techniques.
#> Journal of Thoracic Imaging (2017).
#> DOI: 10.1097/RTI.0000000000000268
#> 
#> Please check for updates regularly for bug fixes and new functionalities!
#> 

Converting DICOM images to RIA_image

DICOM images can be converted to RIA_image class using the load_dicom function. All you have to do is give the location of the .dcm or .dicom files as a string.

DICOM = load_dicom(filename = "C:\\DICOM\\")

load_dicom does several things:

  1. Converts DICOM files to RIA_image class using the readDICOM function of the oro.dicom package

  2. The 2D or 3D image is croped to the smallest bounding box still containing the whole image. It is useful to minimize the size of the image to save memory. The zero_value supplied to the load_dicom function is used to identify voxels not containing any data. If it is not supplied, then the smallest value present in the dataset is considered as indicating voxels without any data. If for some reason it is important that the RIA_image be the same size (same x,y,z dimensions) as the original supplied image, then this functionality can be turn off by:

    DICOM = load_dicom(filename = "C:\\DICOM\\", crop_in = FALSE)
  3. Then the smallest values which indicate no data, are changed to NA for further calculations. If wished to be turned of, then use:

    DICOM = load_dicom(filename = "C:\\DICOM\\", replace_in = FALSE)
  4. Since some DICOM images do not store negative values, rather store all values as non-negative integers, shifting of the values is needed. The desired smallest value is set by the min_to input. If not specified then by default it is set to -1024. Please check for all data whether shifting is needed! If shifting of the values is not needed then use:

    DICOM = load_dicom(filename = "C:\\DICOM\\", center_in = FALSE)
  5. Finally, load_dicom adds basic information regarding the original image and ran processes into the header and log slot of RIA_image

All above mentioned settings can be combined as wished to achieve proper conversion of the DICOM image. Furthermore, all parameters of the readDICOM function of the oro.dicom package can also be set in the load_dicom function.

As a result the DICOM object will have three slots:

  1. DICOM$data which contains the original image as a 2D or 3D numerical array in DICOM$data$orig, and a modified image in DICOM$data$modif that has been created using one of the functions. Only one original and one modified image are stored in the DICOM$data slot. However, several modified images can be saved to new slots as we will see later.

  2. DICOM$header which contains basic information regarding the loaded image. These entries are populated from the DICOM header of the image. Elements can be added or removed from the predefined set of DICOM_codes:

    DICOM_codes
    #>                    Name Group Element
    #> 1             StudyDate     8      22
    #> 2             StudyTime     8      30
    #> 3          PatientsName    10      10
    #> 4     PatientsBirthDate    10      30
    #> 5           PatientsSex    10      40
    #> 6             PatientID    10      20
    #> 7          PatientsSize    10    1020
    #> 8        PatientsWeight    10    1030
    #> 9                   kVp    18      60
    #> 10                  mAs    18    1152
    #> 11       SliceThickness    18      50
    #> 12 SpacingBetweenSlices    18      88
    #> 13                 Rows    28      10
    #> 14              Columns    28      11
    #> 15         PixelSpacing    28      30

    Elements can be added by specifying the desired DICOM codes. For example the Manufacturer can be add by:

    add <- as.data.frame(array(c("Manufacturer", "0008", "0070"), dim = c(1,3)))
    colnames(add) <- c("Name", "Group", "Element")
    DICOM = load_dicom(filename = "C:\\DICOM\\", header_add = add)

    Or elements can be removed. For example if you wish to anonymize your data:

    exclude <- as.data.frame(DICOM_codes[3:6,])
    DICOM = load_dicom(filename = "C:\\DICOM\\", header_exclude = exclude)
  3. DICOM$log which contains information regarding the original image and ran processes on the RIA_image. The log is constantly updated by the functions, and some functions use it for inputs. load_dicom adds the following to the log:
    • DICOM$log$events is a vector containing the ran processes.
    • DICOM$log$orig_dim is a vector containing the original dimensions of the DICOM image.
    • DICOM$log$directory is a string containing the location of the DICOM images.
    • DICOM$log$logic_x is a vector with a length of the original x dimension. Ones indicate slices which contained data and zeros which did not in the x dimension. Same is true for DICOM$log$logic_y and DICOM$log$logic_z.
    • DICOM$log$zero_value is a number indicating the value that was considered to indicate no data
    • DICOM$log$changed_to is the value to which voxel considered not to have any data were transferred to.
    • DICOM$log$shift the value that was added to all voxel values to achieve proper values.
    • DICOM$log$orig_vol_mm the volume of the original image. The volume is calculated by calculating how many voxels contain data and multiplying it by x,y and z length of the voxels.
    • DICOM$log$orig_surf_mm the surface of the original image. The surface is calculated by assessing which sides of the voxels do not have any neighbors and then summing all of these surfaces which are calculated from the lengths of the sides of the voxels.
    • DICOM$log$surface_volume_r the value of the surface to volume ratio of the original image.
    • DICOM$log$orig_xy_dim the length of each voxel in the x and the y planes. This is also called the in-plane resolution
    • DICOM$log$orig_z_dim the length of each voxel in the z plane. This is also called the cross-plane resolution.

As we will see, functions can add new elements to the log and also add new slots to the RIA_image. If the loading was successful, we will be notified by RIA in the console. All messages may be suppressed by setting the verbose_in parameter to FALSE.

With the package two preloaded datasets are given:

We will be using the NRS dataset for all following examples. Load the data using:

DICOM <- NRS

Discretization of voxel values

Discretization of voxel values is crucial for radiomic analysis. Since many metrics rely on the spatial relationship of different voxel values, we need to decrease the number of possible values. This is needed since we do not want to consider for example a voxel value of 456 any different from 457, since the difference is probably attributable to noise and does not hold any information regarding spatial heterogeneity. Discretization is done using the discretize function. It receives a RIA_image and outputs a RIA_image with a new slot DICOM$discretized containing the images with discretized values.

Discretization is effected by two variables:

Specifing the number of bins

The number of bins can be easily specified using the bins_in parameter.

DICOM = discretize(RIA_data_in = DICOM, bins_in = 2)
#> SUCCESSFULLY DISCRETIZED DATA INTO 2 NUMBER OF EQUALLY SIZED BINS

Specifing the length of each bin

There are two main types of discretizations. We either have equally sized or equally probable bins. Equally sized bins mean that the range between the minimum and the maximum value is divided into a predefined number of bins of which all have the same lengths. For example is our smallest value is 0 and the largest is 100 and we wish to discretize into 4 equally sized bins then the cut points will be at 25, 50 and 75, result in 4 bins each with a length of 25 units. However if the discretization is done using equally probable bins then the length of each bin might be different, but the number of elements in it are the same. This might result is cut points such as: 10, 35 and 55 for example in case of a rightly skewed dataset. The type of discretization is defined by the equal_prob parameter. The default is FALSE, therefore by default images are dichtomized using equal sized bins. Setting it to TRUE will result in equally probable bins:

DICOM = discretize(RIA_data_in = DICOM, bins_in = 2, equal_prob = TRUE)
#> SUCCESSFULLY DISCRETIZED DATA INTO 2 NUMBER OF EQUAL PROBABILITY BINS

The discretize function updates the log of the RIA_image by adding the discretization to the events:

DICOM$log$events
#> [1] "Created"                   "Cropped"                  
#> [3] "Changed_to_NA"             "Shifted_by_-1024"         
#> [5] "Discretized_equal_sized_2" "Discretized_equal_prob_2"

It also adds the cut points that were used for the discretization:

DICOM$log$cuts_es_2
#> [1] 195
DICOM$log$cuts_ep_2
#> [1] 65

The names of the created images and corresponding elements in the log can be changed as we will see later. But for convenience RIA automatically names the new images. If not crucial for some reason, I would suggest to stick with the automatically predefined names.

Additional input parameters of discretize function

-use_orig whether to use the original image (which might be croped etc.) stored in RIA_image$data$orig or to use the modified image stored in RIA_image$data$modif. By default it is set to TRUE. Only in very special cases might one want to discretize an image that has already been discretized or modified by an other function.

-write_orig whether to overwrite the original image stored in RIA_image$data$orig. Usually it is not advised to overwrite the master image since then only modified images can be further processed. Therefore, by default it is set to FALSE

-verbose_in whether write information regarding the running processes in the console.

Batch discretization

Since the number of bins and the type of discretization can significantly effect our later results, usually several discretizations are performed on a image to receive many different images. Using RIA it is very easy perform several different discretizations with just one line of code. For example if you wish to discretize your image to 4, 8, 16 and 32 equally sized bins, all you have to do is:

DICOM = discretize(RIA_data_in = DICOM, bins_in = c(4,8,16,32))
#> SUCCESSFULLY DISCRETIZED DATA INTO 4 NUMBER OF EQUALLY SIZED BINS
#> SUCCESSFULLY DISCRETIZED DATA INTO 8 NUMBER OF EQUALLY SIZED BINS
#> SUCCESSFULLY DISCRETIZED DATA INTO 16 NUMBER OF EQUALLY SIZED BINS
#> SUCCESSFULLY DISCRETIZED DATA INTO 32 NUMBER OF EQUALLY SIZED BINS

or more easily if you want 4, 8, 16 and 32 equally probable bins:

DICOM = discretize(RIA_data_in = DICOM, bins_in = 2^(2:5), equal_prob = TRUE)
#> SUCCESSFULLY DISCRETIZED DATA INTO 4 NUMBER OF EQUAL PROBABILITY BINS
#> SUCCESSFULLY DISCRETIZED DATA INTO 8 NUMBER OF EQUAL PROBABILITY BINS
#> SUCCESSFULLY DISCRETIZED DATA INTO 16 NUMBER OF EQUAL PROBABILITY BINS
#> SUCCESSFULLY DISCRETIZED DATA INTO 32 NUMBER OF EQUAL PROBABILITY BINS

These resulted in our image discretized in 2,4,8,16,32 equally probable and equally sized bins, which are stored in the $discretized slot of the RIA_image:

DICOM$log$events
#>  [1] "Created"                    "Cropped"                   
#>  [3] "Changed_to_NA"              "Shifted_by_-1024"          
#>  [5] "Discretized_equal_sized_2"  "Discretized_equal_prob_2"  
#>  [7] "Discretized_equal_sized_4"  "Discretized_equal_sized_8" 
#>  [9] "Discretized_equal_sized_16" "Discretized_equal_sized_32"
#> [11] "Discretized_equal_prob_4"   "Discretized_equal_prob_8"  
#> [13] "Discretized_equal_prob_16"  "Discretized_equal_prob_32"
names(DICOM$discretized)
#>  [1] "es_2"  "ep_2"  "es_4"  "es_8"  "es_16" "es_32" "ep_4"  "ep_8" 
#>  [9] "ep_16" "ep_32"

First-order statistics

First-order statistics are derived from the distribution of values and therefore discard all spatial information. Many of these metrics are commonly known (mean, median), however several metrics describing the heterogeneity of the values might be less known (energy, entropy). RIA can calculate 35 different first-order statistics (some containing not only one value) using the first_order function. As with all statistical measures, it is saved in a separate slot of the RIA_image, and the name of the slot starts with stat_ and since first-order, end with fo, resulting in the slot name of stat_fo. By default, first_order calculates statistics on the image present in DICOM$data$orig.

DICOM = first_order(RIA_data_in = DICOM)
#> FIRST-ORDER STATISTICS WAS SUCCESSFULLY ADDED TO 'orig' SLOT OF RIA_image$stat_fo
RIA:::list_to_df(DICOM$stat_fo$orig)
#>                           Values
#> Mean                85.755226925
#> Median              65.000000000
#> Mode                41.000000000
#> Geo_mean           299.098051887
#> Geo_mean2          101.341240936
#> Geo_mean3          156.637495051
#> Har_mean            63.405742203
#> Trim_mean_5         82.659151906
#> Trim_mean_10        80.674220963
#> Trim_mean_20        77.515615041
#> IQ_mean             70.741080530
#> Tri_mean            42.500000000
#> Mn_AD_mn            71.352286465
#> Mn_AD_md            69.616012239
#> Md_AD_mn            63.755226925
#> Md_AD_md            58.000000000
#> MAD                 85.990800000
#> Max_AD_mn          395.244773075
#> Max_AD_md          416.000000000
#> RMS                122.623352125
#> Min                -91.000000000
#> Max                481.000000000
#> Quartiles.25%       20.000000000
#> Quartiles.75%      143.000000000
#> IQR                123.000000000
#> Low_notch         -164.500000000
#> High_notch         204.500000000
#> Range              572.000000000
#> Deciles.10%         -9.000000000
#> Deciles.20%          9.000000000
#> Deciles.30%         28.000000000
#> Deciles.40%         44.000000000
#> Deciles.50%         65.000000000
#> Deciles.60%         92.000000000
#> Deciles.70%        125.000000000
#> Deciles.80%        160.000000000
#> Deciles.90%        208.000000000
#> Variance          7686.447198431
#> SD                  87.672385609
#> Skew                 0.884511444
#> Kurtosis             0.602173278
#> Energy        29486550.000000000
#> Uniformity           0.004236877
#> Entropy              0.005577447

If you wish to calculate statistics on a modified image, then by setting the use_orig to FALSE, the image present in the DICOM$data$modif will be used. This is usually the last image that was created using some kind of image manipulation.

DICOM = first_order(RIA_data_in = DICOM, use_orig = FALSE)
#> FIRST-ORDER STATISTICS WAS SUCCESSFULLY ADDED TO 'ep_32' SLOT OF RIA_image$stat_fo
RIA:::list_to_df(DICOM$stat_fo$ep_32)
#>                         Values
#> Mean              16.551759306
#> Median            17.000000000
#> Mode              11.000000000
#> Geo_mean          39.880592472
#> Geo_mean2         39.880592472
#> Geo_mean3         12.869550871
#> Har_mean           7.991311367
#> Trim_mean_5       16.554482018
#> Trim_mean_10      16.555240793
#> Trim_mean_20      16.557680051
#> IQ_mean           16.569826707
#> Tri_mean          13.000000000
#> Mn_AD_mn           7.990434066
#> Mn_AD_md           7.989291178
#> Md_AD_mn           8.448240694
#> Md_AD_md           8.000000000
#> MAD               11.860800000
#> Max_AD_mn         15.551759306
#> Max_AD_md         16.000000000
#> RMS               18.947147295
#> Min                1.000000000
#> Max               32.000000000
#> Quartiles.25%      9.000000000
#> Quartiles.75%     25.000000000
#> IQR               16.000000000
#> Low_notch        -15.000000000
#> High_notch        33.000000000
#> Range             31.000000000
#> Deciles.10%        4.000000000
#> Deciles.20%        7.000000000
#> Deciles.30%       10.000000000
#> Deciles.40%       13.000000000
#> Deciles.50%       17.000000000
#> Deciles.60%       20.000000000
#> Deciles.70%       23.000000000
#> Deciles.80%       26.000000000
#> Deciles.90%       29.000000000
#> Variance          85.077038995
#> SD                 9.223721537
#> Skew              -0.004299735
#> Kurtosis          -1.204332093
#> Energy        703988.000000000
#> Uniformity         0.031417069
#> Entropy            0.150231914

If the desired image is not present in the modif slot, since it was created earlier, then instead of switching the DICOM$data$modif image to the desired one, you may give a specific image you wish to use using the use_slot parameter. If the image you wish to use is in DICOM$discretized$es_2, then you can calculate first-order statistics on it by:

DICOM = first_order(RIA_data_in = DICOM, use_orig = FALSE, use_slot = "discretized$es_2")
#> FIRST-ORDER STATISTICS WAS SUCCESSFULLY ADDED TO 'es_2' SLOT OF RIA_image$stat_fo
RIA:::list_to_df(DICOM$stat_fo$es_2)
#>                     Values
#> Mean             1.1259561
#> Median           1.0000000
#> Mode             1.0000000
#> Geo_mean         1.1342324
#> Geo_mean2        1.1342324
#> Geo_mean3        1.0912307
#> Har_mean         1.0672109
#> Trim_mean_5      1.1062802
#> Trim_mean_10     1.0844193
#> Trim_mean_20     1.0325048
#> IQ_mean          1.0000000
#> Tri_mean         1.0000000
#> Mn_AD_mn         0.2201824
#> Mn_AD_md         0.1259561
#> Md_AD_mn         0.1259561
#> Md_AD_md         0.0000000
#> MAD              0.0000000
#> Max_AD_mn        0.8740439
#> Max_AD_md        1.0000000
#> RMS              1.1738264
#> Min              1.0000000
#> Max              2.0000000
#> Quartiles.25%    1.0000000
#> Quartiles.75%    1.0000000
#> IQR              0.0000000
#> Low_notch        1.0000000
#> High_notch       1.0000000
#> Range            1.0000000
#> Deciles.10%      1.0000000
#> Deciles.20%      1.0000000
#> Deciles.30%      1.0000000
#> Deciles.40%      1.0000000
#> Deciles.50%      1.0000000
#> Deciles.60%      1.0000000
#> Deciles.70%      1.0000000
#> Deciles.80%      1.0000000
#> Deciles.90%      2.0000000
#> Variance         0.1101474
#> SD               0.3318846
#> Skew             2.2529105
#> Kurtosis         3.0771758
#> Energy        2702.0000000
#> Uniformity       0.7798176
#> Entropy          0.1697589

Additional input parameters of first_order function

Calculation of first-order statistics can be further specified using the following inputs.

DICOM = first_order(RIA_data_in = DICOM, use_orig = FALSE, use_slot = "discretized$es_2", save_name = c("equaly_sized_2bins"))
#> FIRST-ORDER STATISTICS WAS SUCCESSFULLY ADDED TO 'equaly_sized_2bins' SLOT OF RIA_image$stat_fo
RIA:::list_to_df(DICOM$stat_fo$equaly_sized_2bins)
#>                     Values
#> Mean             1.1259561
#> Median           1.0000000
#> Mode             1.0000000
#> Geo_mean         1.1342324
#> Geo_mean2        1.1342324
#> Geo_mean3        1.0912307
#> Har_mean         1.0672109
#> Trim_mean_5      1.1062802
#> Trim_mean_10     1.0844193
#> Trim_mean_20     1.0325048
#> IQ_mean          1.0000000
#> Tri_mean         1.0000000
#> Mn_AD_mn         0.2201824
#> Mn_AD_md         0.1259561
#> Md_AD_mn         0.1259561
#> Md_AD_md         0.0000000
#> MAD              0.0000000
#> Max_AD_mn        0.8740439
#> Max_AD_md        1.0000000
#> RMS              1.1738264
#> Min              1.0000000
#> Max              2.0000000
#> Quartiles.25%    1.0000000
#> Quartiles.75%    1.0000000
#> IQR              0.0000000
#> Low_notch        1.0000000
#> High_notch       1.0000000
#> Range            1.0000000
#> Deciles.10%      1.0000000
#> Deciles.20%      1.0000000
#> Deciles.30%      1.0000000
#> Deciles.40%      1.0000000
#> Deciles.50%      1.0000000
#> Deciles.60%      1.0000000
#> Deciles.70%      1.0000000
#> Deciles.80%      1.0000000
#> Deciles.90%      2.0000000
#> Variance         0.1101474
#> SD               0.3318846
#> Skew             2.2529105
#> Kurtosis         3.0771758
#> Energy        2702.0000000
#> Uniformity       0.7798176
#> Entropy          0.1697589

Batch calculation of first-order statistics

RIA supports batch calculation of first-order statistics. In many cases one wants to calculate the statistics on all modified images. Using one line of code you can calculate first-order statistics for all discretized images:

DICOM = first_order(RIA_data_in = DICOM, use_type = "discretized")
#> FIRST-ORDER STATISTICS WAS SUCCESSFULLY ADDED TO 'es_2' SLOT OF RIA_image$stat_fo
#> FIRST-ORDER STATISTICS WAS SUCCESSFULLY ADDED TO 'ep_2' SLOT OF RIA_image$stat_fo
#> FIRST-ORDER STATISTICS WAS SUCCESSFULLY ADDED TO 'es_4' SLOT OF RIA_image$stat_fo
#> FIRST-ORDER STATISTICS WAS SUCCESSFULLY ADDED TO 'es_8' SLOT OF RIA_image$stat_fo
#> FIRST-ORDER STATISTICS WAS SUCCESSFULLY ADDED TO 'es_16' SLOT OF RIA_image$stat_fo
#> FIRST-ORDER STATISTICS WAS SUCCESSFULLY ADDED TO 'es_32' SLOT OF RIA_image$stat_fo
#> FIRST-ORDER STATISTICS WAS SUCCESSFULLY ADDED TO 'ep_4' SLOT OF RIA_image$stat_fo
#> FIRST-ORDER STATISTICS WAS SUCCESSFULLY ADDED TO 'ep_8' SLOT OF RIA_image$stat_fo
#> FIRST-ORDER STATISTICS WAS SUCCESSFULLY ADDED TO 'ep_16' SLOT OF RIA_image$stat_fo
#> FIRST-ORDER STATISTICS WAS SUCCESSFULLY ADDED TO 'ep_32' SLOT OF RIA_image$stat_fo
names(DICOM$stat_fo)
#>  [1] "orig"               "ep_32"              "es_2"              
#>  [4] "equaly_sized_2bins" "ep_2"               "es_4"              
#>  [7] "es_8"               "es_16"              "es_32"             
#> [10] "ep_4"               "ep_8"               "ep_16"

The use_type input can be used to specify how the function behaves. By default, it is set to “single”, indicating single image processing. As seen above, there are multiple ways first-order statistics can be calculated on single images. However, if use_type is set to “discretized”, then the function will calculate the statistical metrics for all instances present in the given slot.

The save_name parameter can still be used to rename the name of the statistics is needed.

DICOM = first_order(RIA_data_in = DICOM, use_type = "discretized",
                    save_name = c("Name_1", "Name_2", "Name_3", "Name_4",
                                  "Name_5", "Name_6", "Name_7", "Name_8",
                                  "Name_9", "Name_10"))
#> FIRST-ORDER STATISTICS WAS SUCCESSFULLY ADDED TO 'Name_1' SLOT OF RIA_image$stat_fo
#> FIRST-ORDER STATISTICS WAS SUCCESSFULLY ADDED TO 'Name_2' SLOT OF RIA_image$stat_fo
#> FIRST-ORDER STATISTICS WAS SUCCESSFULLY ADDED TO 'Name_3' SLOT OF RIA_image$stat_fo
#> FIRST-ORDER STATISTICS WAS SUCCESSFULLY ADDED TO 'Name_4' SLOT OF RIA_image$stat_fo
#> FIRST-ORDER STATISTICS WAS SUCCESSFULLY ADDED TO 'Name_5' SLOT OF RIA_image$stat_fo
#> FIRST-ORDER STATISTICS WAS SUCCESSFULLY ADDED TO 'Name_6' SLOT OF RIA_image$stat_fo
#> FIRST-ORDER STATISTICS WAS SUCCESSFULLY ADDED TO 'Name_7' SLOT OF RIA_image$stat_fo
#> FIRST-ORDER STATISTICS WAS SUCCESSFULLY ADDED TO 'Name_8' SLOT OF RIA_image$stat_fo
#> FIRST-ORDER STATISTICS WAS SUCCESSFULLY ADDED TO 'Name_9' SLOT OF RIA_image$stat_fo
#> FIRST-ORDER STATISTICS WAS SUCCESSFULLY ADDED TO 'Name_10' SLOT OF RIA_image$stat_fo
names(DICOM$stat_fo)
#>  [1] "orig"               "ep_32"              "es_2"              
#>  [4] "equaly_sized_2bins" "ep_2"               "es_4"              
#>  [7] "es_8"               "es_16"              "es_32"             
#> [10] "ep_4"               "ep_8"               "ep_16"             
#> [13] "Name_1"             "Name_2"             "Name_3"            
#> [16] "Name_4"             "Name_5"             "Name_6"            
#> [19] "Name_7"             "Name_8"             "Name_9"            
#> [22] "Name_10"

Please provide the same number of names as the number of discretizations. If there is a discrepancy between the number of provided names and images, then the process will be stopped giving an error.

DICOM = first_order(RIA_data_in = DICOM, use_type = "discretized",
                    save_name = c("Name_1", "Name_2", "Name_3", "Name_4"))
#> Error in first_order(RIA_data_in = DICOM, use_type = "discretized", save_name = c("Name_1", : PLEASE PROVIDE THE SAME NUMBER OF NAMES AS THERE ARE IMAGES!
#> NUMBER OF NAMES:  4
#> NUMBER OF IMAGES: 10

Gray level co-occurrence matrix (GLCM) calculations and statistics

The function glcm calculates GLCM matrices of 2D and 3D images. GLCMs are second-order statistics, meaning that statistics are calculated from the spatial relationship of two voxel values and not from the values themselves. GLCM are square matrices, where there are as many rows and columns as there are different voxel values. The values in the ith row and jth column represents the probability of finding a j value voxel next to a i value voxel in a given direction and distance. Therefore, for a given image several different GLCM matrices may be calculated, depending on the direction and the distance. In RIA direction and distance is determined by three integer parameters specifying where the examined voxel is compared to the index voxel.

For example: to calculate the GLCM matrix of the last modified image stored in DICOM$data$modif, in the direction of right: 1; down: 2; z-plane: 2; you just have to write:

DICOM = glcm(RIA_data_in = DICOM, off_right = 1, off_down = 2, off_z = 2)
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_32_122' SLOT OF RIA_image$glcm
dim(DICOM$glcm$ep_32)
#> [1] 32 32

As discussed in the first-order case, the image wished to be analyzed may be set using the use_orig, use_slot and save_name parameters. RIA looks at the name of the provided image, if numbers are present in it, the it will set the dimensions and the resulting name of the GLCM based-on these values. If no numbers are present, then it will the automatic name generator of RIA to figure out the name of the last image manipulation. If it does not succeed, then it will calculate how many different gray levels there are in the image to set the dimensions of GLCM matrix and the name of the statistic. However, it might occur for example that the data was discretized to 32 equally sized bins, and then one of the bins does not contain any data. In these cases the GLCM will only be 31 x 31!

Additional input parameters of glcm function

Tow further parameters may be set to change the output of the function:

DICOM = glcm(RIA_data_in = DICOM, use_slot = "discretized$ep_2", off_right = 1, off_down = 2, off_z = 2, symmetric = FALSE, normalize = FALSE)
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_2_122' SLOT OF RIA_image$glcm
DICOM$glcm$ep_2
#>      [,1] [,2]
#> [1,]    0    2
#> [2,]    0    3
DICOM = glcm(RIA_data_in = DICOM, use_slot = "discretized$ep_2", off_right = 1, off_down = 2, off_z = 2, symmetric = TRUE, normalize = FALSE)
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_2_122' SLOT OF RIA_image$glcm
DICOM$glcm$ep_2
#>      [,1] [,2]
#> [1,]    0    2
#> [2,]    2    6
DICOM = glcm(RIA_data_in = DICOM, use_slot = "discretized$ep_2", off_right = 1, off_down = 2, off_z = 2, symmetric = TRUE, normalize = FALSE)
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_2_122' SLOT OF RIA_image$glcm
DICOM$glcm$ep_2
#>      [,1] [,2]
#> [1,]    0    2
#> [2,]    2    6
DICOM = glcm(RIA_data_in = DICOM, use_slot = "discretized$ep_2", off_right = 1, off_down = 2, off_z = 2, symmetric = TRUE, normalize = TRUE)
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_2_122' SLOT OF RIA_image$glcm
DICOM$glcm$ep_2
#>      [,1] [,2]
#> [1,]  0.0  0.2
#> [2,]  0.2  0.6

As GLCM statistics require probability values and in most cases GLCMs are calculated in all directions, both parameters are TRUE by default.

Batch calculation of GLCM

The glcm function also support batch calculations. Therefore, if you wish to calculate a given GLCM for all discretizations all you have to do is:

DICOM = glcm(RIA_data_in = DICOM, use_type = "discretized",
             off_right = 1, off_down = 2, off_z = 2)
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_2_122' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_2_122' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_4_122' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_8_122' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_16_122' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_32_122' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_4_122' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_8_122' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_16_122' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_32_122' SLOT OF RIA_image$glcm
names(DICOM$glcm)
#>  [1] "ep_32_122" "ep_2_122"  "es_2_122"  "es_4_122"  "es_8_122" 
#>  [6] "es_16_122" "es_32_122" "ep_4_122"  "ep_8_122"  "ep_16_122"

Statistics on GLCM matrices

The main purpose of calculating GLCMs, is to derive statistics from them. GLCM statistics can be calculated using the glcm_stat function. Overall, RIA can calculate 240 different GLCM statistics of which some contain more than one value. As previous functions, glcm_stat can process single or multiple GLCMs For single data processing, one can use the use_slot parameter to calculate GLCM statistics on a specific GLCM

DICOM = glcm_stat(DICOM, use_type = "single", use_slot = "glcm$ep_2_122")
#> GLCM STATISTICS WAS SUCCESSFULLY ADDED TO 'ep_2_122' SLOT OF RIA_image$stat_glcm

The results as all statistical calculations, are saved to a “stat_” slot of the RIA_image, specifically to the RIA_image$stat_glcm slot. The name is automatically generated based on the supplied GLCM name. However it may be changed by the save_name input if desired.

Batch calculation of GLCM statistics

The glcm_stat function also support batch calculations. Therefore, if you wish to calculate statistics for all calculated GLCMs the you can achieve this by one line of code:

DICOM = glcm_stat(DICOM, use_type = "glcm")
#> GLCM STATISTICS WAS SUCCESSFULLY ADDED TO 'ep_32_122' SLOT OF RIA_image$stat_glcm
#> GLCM STATISTICS WAS SUCCESSFULLY ADDED TO 'ep_2_122' SLOT OF RIA_image$stat_glcm
#> GLCM STATISTICS WAS SUCCESSFULLY ADDED TO 'es_2_122' SLOT OF RIA_image$stat_glcm
#> GLCM STATISTICS WAS SUCCESSFULLY ADDED TO 'es_4_122' SLOT OF RIA_image$stat_glcm
#> GLCM STATISTICS WAS SUCCESSFULLY ADDED TO 'es_8_122' SLOT OF RIA_image$stat_glcm
#> GLCM STATISTICS WAS SUCCESSFULLY ADDED TO 'es_16_122' SLOT OF RIA_image$stat_glcm
#> GLCM STATISTICS WAS SUCCESSFULLY ADDED TO 'es_32_122' SLOT OF RIA_image$stat_glcm
#> GLCM STATISTICS WAS SUCCESSFULLY ADDED TO 'ep_4_122' SLOT OF RIA_image$stat_glcm
#> GLCM STATISTICS WAS SUCCESSFULLY ADDED TO 'ep_8_122' SLOT OF RIA_image$stat_glcm
#> GLCM STATISTICS WAS SUCCESSFULLY ADDED TO 'ep_16_122' SLOT OF RIA_image$stat_glcm
names(DICOM$stat_glcm)
#>  [1] "ep_2_122"  "ep_32_122" "es_2_122"  "es_4_122"  "es_8_122" 
#>  [6] "es_16_122" "es_32_122" "ep_4_122"  "ep_8_122"  "ep_16_122"

The names of the outputs can also be specified. Be aware of providing the same amount of names as there are GLCMs being processed. Failing to do so will throw an error.

Batch calculation of GLCM matrices in all directions

To achieve rotationally invariant results, usually GLCM matrices are calculated in all directions. Using RIA, with one line of code you can calulate the GLCMs in all the different directions simply by calling:

DICOM = glcm_all(DICOM, use_type = "single")
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_32_100' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_32_010' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_32_110' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_32_1-10' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_32_101' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_32_011' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_32_111' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_32_1-11' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_32_10-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_32_01-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_32_11-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_32_1-1-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_32_001' SLOT OF RIA_image$glcm
names(DICOM$glcm)
#>  [1] "ep_32_122"   "ep_2_122"    "es_2_122"    "es_4_122"    "es_8_122"   
#>  [6] "es_16_122"   "es_32_122"   "ep_4_122"    "ep_8_122"    "ep_16_122"  
#> [11] "ep_32_100"   "ep_32_010"   "ep_32_110"   "ep_32_1-10"  "ep_32_101"  
#> [16] "ep_32_011"   "ep_32_111"   "ep_32_1-11"  "ep_32_10-1"  "ep_32_01-1" 
#> [21] "ep_32_11-1"  "ep_32_1-1-1" "ep_32_001"

This uses the image stored in the DICOM$data$modif. This can be changed similarly to all other functions using the use_orig, use_slot and save_name parameters. RIA can also calculate all the different GLCMs on all modified images just by simply calling:

DICOM = glcm_all(DICOM, use_type = "discretized")
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_2_100' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_2_100' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_4_100' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_8_100' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_16_100' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_32_100' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_4_100' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_8_100' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_16_100' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_32_100' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_2_010' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_2_010' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_4_010' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_8_010' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_16_010' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_32_010' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_4_010' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_8_010' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_16_010' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_32_010' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_2_110' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_2_110' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_4_110' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_8_110' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_16_110' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_32_110' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_4_110' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_8_110' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_16_110' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_32_110' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_2_1-10' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_2_1-10' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_4_1-10' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_8_1-10' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_16_1-10' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_32_1-10' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_4_1-10' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_8_1-10' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_16_1-10' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_32_1-10' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_2_101' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_2_101' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_4_101' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_8_101' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_16_101' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_32_101' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_4_101' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_8_101' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_16_101' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_32_101' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_2_011' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_2_011' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_4_011' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_8_011' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_16_011' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_32_011' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_4_011' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_8_011' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_16_011' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_32_011' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_2_111' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_2_111' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_4_111' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_8_111' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_16_111' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_32_111' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_4_111' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_8_111' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_16_111' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_32_111' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_2_1-11' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_2_1-11' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_4_1-11' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_8_1-11' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_16_1-11' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_32_1-11' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_4_1-11' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_8_1-11' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_16_1-11' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_32_1-11' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_2_10-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_2_10-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_4_10-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_8_10-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_16_10-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_32_10-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_4_10-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_8_10-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_16_10-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_32_10-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_2_01-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_2_01-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_4_01-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_8_01-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_16_01-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_32_01-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_4_01-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_8_01-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_16_01-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_32_01-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_2_11-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_2_11-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_4_11-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_8_11-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_16_11-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_32_11-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_4_11-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_8_11-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_16_11-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_32_11-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_2_1-1-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_2_1-1-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_4_1-1-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_8_1-1-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_16_1-1-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_32_1-1-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_4_1-1-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_8_1-1-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_16_1-1-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_32_1-1-1' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_2_001' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_2_001' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_4_001' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_8_001' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_16_001' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'es_32_001' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_4_001' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_8_001' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_16_001' SLOT OF RIA_image$glcm
#> GLCM WAS SUCCESSFULLY ADDED TO 'ep_32_001' SLOT OF RIA_image$glcm
names(DICOM$glcm)
#>   [1] "ep_32_122"   "ep_2_122"    "es_2_122"    "es_4_122"    "es_8_122"   
#>   [6] "es_16_122"   "es_32_122"   "ep_4_122"    "ep_8_122"    "ep_16_122"  
#>  [11] "ep_32_100"   "ep_32_010"   "ep_32_110"   "ep_32_1-10"  "ep_32_101"  
#>  [16] "ep_32_011"   "ep_32_111"   "ep_32_1-11"  "ep_32_10-1"  "ep_32_01-1" 
#>  [21] "ep_32_11-1"  "ep_32_1-1-1" "ep_32_001"   "es_2_100"    "ep_2_100"   
#>  [26] "es_4_100"    "es_8_100"    "es_16_100"   "es_32_100"   "ep_4_100"   
#>  [31] "ep_8_100"    "ep_16_100"   "es_2_010"    "ep_2_010"    "es_4_010"   
#>  [36] "es_8_010"    "es_16_010"   "es_32_010"   "ep_4_010"    "ep_8_010"   
#>  [41] "ep_16_010"   "es_2_110"    "ep_2_110"    "es_4_110"    "es_8_110"   
#>  [46] "es_16_110"   "es_32_110"   "ep_4_110"    "ep_8_110"    "ep_16_110"  
#>  [51] "es_2_1-10"   "ep_2_1-10"   "es_4_1-10"   "es_8_1-10"   "es_16_1-10" 
#>  [56] "es_32_1-10"  "ep_4_1-10"   "ep_8_1-10"   "ep_16_1-10"  "es_2_101"   
#>  [61] "ep_2_101"    "es_4_101"    "es_8_101"    "es_16_101"   "es_32_101"  
#>  [66] "ep_4_101"    "ep_8_101"    "ep_16_101"   "es_2_011"    "ep_2_011"   
#>  [71] "es_4_011"    "es_8_011"    "es_16_011"   "es_32_011"   "ep_4_011"   
#>  [76] "ep_8_011"    "ep_16_011"   "es_2_111"    "ep_2_111"    "es_4_111"   
#>  [81] "es_8_111"    "es_16_111"   "es_32_111"   "ep_4_111"    "ep_8_111"   
#>  [86] "ep_16_111"   "es_2_1-11"   "ep_2_1-11"   "es_4_1-11"   "es_8_1-11"  
#>  [91] "es_16_1-11"  "es_32_1-11"  "ep_4_1-11"   "ep_8_1-11"   "ep_16_1-11" 
#>  [96] "es_2_10-1"   "ep_2_10-1"   "es_4_10-1"   "es_8_10-1"   "es_16_10-1" 
#> [101] "es_32_10-1"  "ep_4_10-1"   "ep_8_10-1"   "ep_16_10-1"  "es_2_01-1"  
#> [106] "ep_2_01-1"   "es_4_01-1"   "es_8_01-1"   "es_16_01-1"  "es_32_01-1" 
#> [111] "ep_4_01-1"   "ep_8_01-1"   "ep_16_01-1"  "es_2_11-1"   "ep_2_11-1"  
#> [116] "es_4_11-1"   "es_8_11-1"   "es_16_11-1"  "es_32_11-1"  "ep_4_11-1"  
#> [121] "ep_8_11-1"   "ep_16_11-1"  "es_2_1-1-1"  "ep_2_1-1-1"  "es_4_1-1-1" 
#> [126] "es_8_1-1-1"  "es_16_1-1-1" "es_32_1-1-1" "ep_4_1-1-1"  "ep_8_1-1-1" 
#> [131] "ep_16_1-1-1" "es_2_001"    "ep_2_001"    "es_4_001"    "es_8_001"   
#> [136] "es_16_001"   "es_32_001"   "ep_4_001"    "ep_8_001"    "ep_16_001"

In the near future RIA will have functions capable of calculating statistics and deriving aggregated statistics in a similar fashion.

Gray level run length matrix (GLRLM) calculations and statistics

The function glrlm calculates GLRLM matrices of 2D and 3D images. GLRLM are higher-order statistics, meaning that statistics are calculated from the spatial relationship of more than two voxel values. GLRLM are matrices, where the number of rows equals the number of gray levels, while the number of columns equals the length of the longest run. Run length is defined as the number of voxels occurring next to each other with same values in a given direction. The ith row and jth column of the GLRLM represents how many times it occurs in the image, that i value voxels are next to each other j times. Therefore, for a given image several different GLRLM matrices may be calculated, depending on the direction. In RIA direction is determined by three integer parameters specifying the direction as a vector in co-ordinate space. There is no distance parameter, since we want to calculate how many same value voxels occur next to each other in that direction. Therefore the three inputs are logicals not integers.

For example: to calculate the GLRLM matrix of the last modified image stored in DICOM$data$modif, in the direction of right: 1; down: 0; z-plane: 1; you just have to write:

DICOM = glrlm(RIA_data_in = DICOM, off_right = 1, off_down = 0, off_z = 1)
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_32_101' SLOT OF RIA_image$glrlm
dim(DICOM$glrlm$ep_32)
#> [1] 32 16

As discussed in the first-order case, the image wished to be analyzed may be set using the use_orig, use_slot and save_name parameters. RIA looks at the name of the provided image, if numbers are present in it, the it will set the dimensions and the resulting name of the GLRLM based-on these values. If no numbers are present, then it will the automatic name generator of RIA to figure out the name of the last image manipulation. If it does not succeed, then it will calculate how many different gray levels there are in the image to set the dimensions of GLRLM matrix and the name of the statistic. However, it might occur for example that the data was discretized to 32 equally sized bins, and then one of the bins does not contain any data. In these cases the GLRLM will only be 31 x max(run length)!

Batch calculation of GLRLM

The glrlm function also support batch calculations on discretized images. Therefore, if you wish to calculate a given GLRLM for all discretizations all you have to do is:

DICOM = glrlm(RIA_data_in = DICOM, use_type = "discretized",
             off_right = 1, off_down = 0, off_z = 1)
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_2_101' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_2_101' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_4_101' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_8_101' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_16_101' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_32_101' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_4_101' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_8_101' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_16_101' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_32_101' SLOT OF RIA_image$glrlm
names(DICOM$glrlm)
#>  [1] "ep_32_101" "es_2_101"  "ep_2_101"  "es_4_101"  "es_8_101" 
#>  [6] "es_16_101" "es_32_101" "ep_4_101"  "ep_8_101"  "ep_16_101"

Statistics on GLRLM matrices

The main purpose of calculating GLRLMs, is to derive statistics from them. GLRLM statistics can be calculated using the glrlm_stat function. Overall, RIA can calculate 11 different GLRLM statistics. As previous functions, glrlm_stat can process single and multiple GLRLMs at once. For single data processing, one can use the use_slot parameter to calculate GLRLM statistics on a specific GLRLM

DICOM = glrlm_stat(DICOM, use_type = "single", use_slot = "glrlm$ep_2_101")
#> GLRLM STATISTICS WAS SUCCESSFULLY ADDED TO 'ep_2_101' SLOT OF RIA_image$stat_glrlm

The results as all statistical calculations, are saved to a “stat_” slot of the RIA_image, specifically to the RIA_image$stat_glrlm slot. The name is automatically generated based on the supplied GLRLM name. However it may be changed by the save_name input if desired.

Batch calculation of GLRLM statistics

The glrlm_stat function also support batch calculations. Therefore, if you wish to calculate statistics for all calculated GLRLMs the you can achieve this by one line of code:

DICOM = glrlm_stat(DICOM, use_type = "glrlm")
#> GLRLM STATISTICS WAS SUCCESSFULLY ADDED TO 'ep_32_101' SLOT OF RIA_image$stat_glrlm
#> GLRLM STATISTICS WAS SUCCESSFULLY ADDED TO 'es_2_101' SLOT OF RIA_image$stat_glrlm
#> GLRLM STATISTICS WAS SUCCESSFULLY ADDED TO 'ep_2_101' SLOT OF RIA_image$stat_glrlm
#> GLRLM STATISTICS WAS SUCCESSFULLY ADDED TO 'es_4_101' SLOT OF RIA_image$stat_glrlm
#> GLRLM STATISTICS WAS SUCCESSFULLY ADDED TO 'es_8_101' SLOT OF RIA_image$stat_glrlm
#> GLRLM STATISTICS WAS SUCCESSFULLY ADDED TO 'es_16_101' SLOT OF RIA_image$stat_glrlm
#> GLRLM STATISTICS WAS SUCCESSFULLY ADDED TO 'es_32_101' SLOT OF RIA_image$stat_glrlm
#> GLRLM STATISTICS WAS SUCCESSFULLY ADDED TO 'ep_4_101' SLOT OF RIA_image$stat_glrlm
#> GLRLM STATISTICS WAS SUCCESSFULLY ADDED TO 'ep_8_101' SLOT OF RIA_image$stat_glrlm
#> GLRLM STATISTICS WAS SUCCESSFULLY ADDED TO 'ep_16_101' SLOT OF RIA_image$stat_glrlm
names(DICOM$stat_glrlm)
#>  [1] "ep_2_101"  "ep_32_101" "es_2_101"  "es_4_101"  "es_8_101" 
#>  [6] "es_16_101" "es_32_101" "ep_4_101"  "ep_8_101"  "ep_16_101"

The names of the outputs can also be specified. Be aware of providing the same number of names as there are GLRLMs being processed. Failing to do so will throw an error.

Batch calculation of GLRLM matrices in all directions

To achieve rotationally invariant results, usually GLRLM matrices are calculated in all directions. Using RIA, with one line of code you can calulate the GLRLMs in all the different directions simply by calling:

DICOM = glrlm_all(DICOM, use_type = "single")
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_32_100' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_32_010' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_32_110' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_32_1-10' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_32_101' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_32_011' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_32_111' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_32_1-11' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_32_10-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_32_01-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_32_11-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_32_1-1-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_32_001' SLOT OF RIA_image$glrlm
names(DICOM$glrlm)
#>  [1] "ep_32_101"   "es_2_101"    "ep_2_101"    "es_4_101"    "es_8_101"   
#>  [6] "es_16_101"   "es_32_101"   "ep_4_101"    "ep_8_101"    "ep_16_101"  
#> [11] "ep_32_100"   "ep_32_010"   "ep_32_110"   "ep_32_1-10"  "ep_32_011"  
#> [16] "ep_32_111"   "ep_32_1-11"  "ep_32_10-1"  "ep_32_01-1"  "ep_32_11-1" 
#> [21] "ep_32_1-1-1" "ep_32_001"

This uses the image stored in the DICOM$data$modif. This can be changed similarly to all other functions using the use_orig, use_slot and save_name parameters. RIA can also calculate all the different GLRLMs on all modified images just by simply calling:

DICOM = glrlm_all(DICOM, use_type = "discretized")
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_2_100' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_2_100' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_4_100' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_8_100' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_16_100' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_32_100' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_4_100' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_8_100' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_16_100' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_32_100' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_2_010' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_2_010' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_4_010' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_8_010' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_16_010' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_32_010' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_4_010' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_8_010' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_16_010' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_32_010' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_2_110' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_2_110' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_4_110' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_8_110' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_16_110' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_32_110' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_4_110' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_8_110' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_16_110' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_32_110' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_2_1-10' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_2_1-10' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_4_1-10' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_8_1-10' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_16_1-10' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_32_1-10' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_4_1-10' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_8_1-10' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_16_1-10' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_32_1-10' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_2_101' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_2_101' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_4_101' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_8_101' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_16_101' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_32_101' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_4_101' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_8_101' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_16_101' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_32_101' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_2_011' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_2_011' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_4_011' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_8_011' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_16_011' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_32_011' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_4_011' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_8_011' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_16_011' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_32_011' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_2_111' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_2_111' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_4_111' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_8_111' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_16_111' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_32_111' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_4_111' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_8_111' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_16_111' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_32_111' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_2_1-11' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_2_1-11' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_4_1-11' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_8_1-11' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_16_1-11' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_32_1-11' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_4_1-11' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_8_1-11' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_16_1-11' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_32_1-11' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_2_10-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_2_10-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_4_10-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_8_10-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_16_10-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_32_10-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_4_10-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_8_10-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_16_10-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_32_10-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_2_01-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_2_01-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_4_01-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_8_01-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_16_01-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_32_01-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_4_01-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_8_01-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_16_01-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_32_01-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_2_11-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_2_11-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_4_11-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_8_11-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_16_11-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_32_11-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_4_11-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_8_11-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_16_11-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_32_11-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_2_1-1-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_2_1-1-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_4_1-1-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_8_1-1-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_16_1-1-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_32_1-1-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_4_1-1-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_8_1-1-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_16_1-1-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_32_1-1-1' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_2_001' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_2_001' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_4_001' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_8_001' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_16_001' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'es_32_001' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_4_001' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_8_001' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_16_001' SLOT OF RIA_image$glrlm
#> GLRLM WAS SUCCESSFULLY ADDED TO 'ep_32_001' SLOT OF RIA_image$glrlm
names(DICOM$glrlm)
#>   [1] "ep_32_101"   "es_2_101"    "ep_2_101"    "es_4_101"    "es_8_101"   
#>   [6] "es_16_101"   "es_32_101"   "ep_4_101"    "ep_8_101"    "ep_16_101"  
#>  [11] "ep_32_100"   "ep_32_010"   "ep_32_110"   "ep_32_1-10"  "ep_32_011"  
#>  [16] "ep_32_111"   "ep_32_1-11"  "ep_32_10-1"  "ep_32_01-1"  "ep_32_11-1" 
#>  [21] "ep_32_1-1-1" "ep_32_001"   "es_2_100"    "ep_2_100"    "es_4_100"   
#>  [26] "es_8_100"    "es_16_100"   "es_32_100"   "ep_4_100"    "ep_8_100"   
#>  [31] "ep_16_100"   "es_2_010"    "ep_2_010"    "es_4_010"    "es_8_010"   
#>  [36] "es_16_010"   "es_32_010"   "ep_4_010"    "ep_8_010"    "ep_16_010"  
#>  [41] "es_2_110"    "ep_2_110"    "es_4_110"    "es_8_110"    "es_16_110"  
#>  [46] "es_32_110"   "ep_4_110"    "ep_8_110"    "ep_16_110"   "es_2_1-10"  
#>  [51] "ep_2_1-10"   "es_4_1-10"   "es_8_1-10"   "es_16_1-10"  "es_32_1-10" 
#>  [56] "ep_4_1-10"   "ep_8_1-10"   "ep_16_1-10"  "es_2_011"    "ep_2_011"   
#>  [61] "es_4_011"    "es_8_011"    "es_16_011"   "es_32_011"   "ep_4_011"   
#>  [66] "ep_8_011"    "ep_16_011"   "es_2_111"    "ep_2_111"    "es_4_111"   
#>  [71] "es_8_111"    "es_16_111"   "es_32_111"   "ep_4_111"    "ep_8_111"   
#>  [76] "ep_16_111"   "es_2_1-11"   "ep_2_1-11"   "es_4_1-11"   "es_8_1-11"  
#>  [81] "es_16_1-11"  "es_32_1-11"  "ep_4_1-11"   "ep_8_1-11"   "ep_16_1-11" 
#>  [86] "es_2_10-1"   "ep_2_10-1"   "es_4_10-1"   "es_8_10-1"   "es_16_10-1" 
#>  [91] "es_32_10-1"  "ep_4_10-1"   "ep_8_10-1"   "ep_16_10-1"  "es_2_01-1"  
#>  [96] "ep_2_01-1"   "es_4_01-1"   "es_8_01-1"   "es_16_01-1"  "es_32_01-1" 
#> [101] "ep_4_01-1"   "ep_8_01-1"   "ep_16_01-1"  "es_2_11-1"   "ep_2_11-1"  
#> [106] "es_4_11-1"   "es_8_11-1"   "es_16_11-1"  "es_32_11-1"  "ep_4_11-1"  
#> [111] "ep_8_11-1"   "ep_16_11-1"  "es_2_1-1-1"  "ep_2_1-1-1"  "es_4_1-1-1" 
#> [116] "es_8_1-1-1"  "es_16_1-1-1" "es_32_1-1-1" "ep_4_1-1-1"  "ep_8_1-1-1" 
#> [121] "ep_16_1-1-1" "es_2_001"    "ep_2_001"    "es_4_001"    "es_8_001"   
#> [126] "es_16_001"   "es_32_001"   "ep_4_001"    "ep_8_001"    "ep_16_001"

In the near future RIA will have functions capable of calculating statistics and deriving aggregated statistics in a similar fashion.

Geometry-based statistics

Several statistics have been derived to evaluate different geometrical properties of objects. RIA calculates 9 conventional geometrical parameters and 3 fractal dimensions. Geometrical statistics can be calculated both on the original image:

DICOM = geometry(RIA_data_in = DICOM, use_orig = TRUE, calc_sub = FALSE)
#> GEOMETRY-BASED STATISTICS WAS SUCCESSFULLY ADDED TO 'orig' SLOT OF RIA_image$stat_geometry
RIA:::list_to_df(DICOM$stat_geometry$orig)
#>                        Values
#> volume           117.30811157
#> v_ratio_to_all     1.00000000
#> surface          492.88000000
#> s_ratio_to_all     1.00000000
#> surface_volume_r   4.20158498
#> compactness1       1.06069937
#> compactness2       0.01299825
#> spher_dis          4.25309460
#> spher              0.23512292
#> fractal_bc_d       1.89130618
#> fractal_i_d        1.93411435
#> fractal_c_d        1.92374602

and also on discretized images. Similarly as previous functions, if the desired image is stored in RIA_image$data$modif, then by setting the use_orig parameter to FALSE the function will run on the modified image. Using the use_slot parameter a specific image can also be set. The output is automatically named, but can be changed using the save_name parameter. The main reason to run geometry-based statistics on discretized images is to evaluate the geometrical features of the different sub-components. To calculate statistics on all sub-components of an image the calc_sub parameter has to be set to TRUE, which is the default:

DICOM = geometry(RIA_data_in = DICOM, use_slot = "discretized$es_2")
#> GEOMETRY-BASED STATISTICS WAS SUCCESSFULLY ADDED TO 'es_2' SLOT OF RIA_image$stat_geometry
RIA:::list_to_df(DICOM$stat_geometry$es_2)
#>                        Values            NA
#> volume           102.53243408  14.775677490
#> v_ratio_to_all     0.87404386   0.125956145
#> surface          441.22750000 168.643125000
#> s_ratio_to_all     0.89520269   0.342158588
#> surface_volume_r   4.30329684  11.413562939
#> compactness1       0.99810895   0.273103148
#> compactness2       0.01384163   0.005148032
#> spher_dis          4.16489704   5.791435820
#> spher              0.24010197   0.172668753
#> fractal_bc_d       1.85349246   1.416819995
#> fractal_i_d        1.90390391   1.421835255
#> fractal_c_d        1.88899493   1.412545053

Additional input parameters of geometry function

Further inputs can be specified:

Batch calculation of geometry-based statistics

The geometry function also support batch calculations. Therefore, if you wish to calculate statistics for all discretizations, then all you have to do is:

DICOM = geometry(DICOM, use_type = "discretized")
#> GEOMETRY-BASED STATISTICS WAS SUCCESSFULLY ADDED TO 'es_2' SLOT OF RIA_image$stat_geometry
#> GEOMETRY-BASED STATISTICS WAS SUCCESSFULLY ADDED TO 'ep_2' SLOT OF RIA_image$stat_geometry
#> GEOMETRY-BASED STATISTICS WAS SUCCESSFULLY ADDED TO 'es_4' SLOT OF RIA_image$stat_geometry
#> GEOMETRY-BASED STATISTICS WAS SUCCESSFULLY ADDED TO 'es_8' SLOT OF RIA_image$stat_geometry
#> GEOMETRY-BASED STATISTICS WAS SUCCESSFULLY ADDED TO 'es_16' SLOT OF RIA_image$stat_geometry
#> GEOMETRY-BASED STATISTICS WAS SUCCESSFULLY ADDED TO 'es_32' SLOT OF RIA_image$stat_geometry
#> GEOMETRY-BASED STATISTICS WAS SUCCESSFULLY ADDED TO 'ep_4' SLOT OF RIA_image$stat_geometry
#> GEOMETRY-BASED STATISTICS WAS SUCCESSFULLY ADDED TO 'ep_8' SLOT OF RIA_image$stat_geometry
#> GEOMETRY-BASED STATISTICS WAS SUCCESSFULLY ADDED TO 'ep_16' SLOT OF RIA_image$stat_geometry
#> GEOMETRY-BASED STATISTICS WAS SUCCESSFULLY ADDED TO 'ep_32' SLOT OF RIA_image$stat_geometry
names(DICOM$stat_geometry)
#>  [1] "orig"  "es_2"  "ep_2"  "es_4"  "es_8"  "es_16" "es_32" "ep_4" 
#>  [9] "ep_8"  "ep_16" "ep_32"

Conclsions

RIA package for R is a fast, versatile and user-friendly way to calculate radiomic statistics using only a few lines of code. One can calculate several hundreds of different statistics on various versions of an image. RIA is regularly updated with new features that further help radiomic analyses.