Usage

Start by importing Advanced Radiomics.

import advanced_radiomics

Module Extract

This module is used to generate random images/mask (for research), open files, transform images (reduce the size, create image with bins) and extract features for one segmentation or multiples segmentations (multiVOI).

advanced_radiomics.extract.generateRandomImage(size, lims=[0, 255])[source]

Create random image with numpy.random.random.

Parameters

size : tuple

Shape of image.

lims : list

Min and Max values of the image.

Returns

image : SimpleITK.Image

Random image created.

Examples

>>> import SimpleITK as sitk
>>> image = generateRandomImage((2,3,4))
>>> print(sitk.GetArrayFromImage(image))
[[[ 10 208  58 210]
  [253 142  92 100]
  [240  12  31 244]]
 [[ 50 119 103 103]
  [225 130  85  60]
  [ 63 121 226 239]]]
advanced_radiomics.extract.generateRandomMask(size, p=0.5)[source]

Create random mask with numpy.random.random.

Parameters

size : tuple

Shape of image.

p : float

Percentual of values equal to 0 in mask.

Returns

mask : SimpleITK.Image

Random mask created.

Examples

>>> import SimpleITK as sitk
>>> mask = generateRandomMask((2,3,4))
>>> print(sitk.GetArrayFromImage(mask))
[[[0 0 1 1]
  [0 1 0 0]
  [1 1 0 1]]
 [[1 1 1 0]
  [1 1 0 0]
  [0 1 1 0]]]
advanced_radiomics.extract.generateBoth(size, lims=[0, 255], p=0.5)[source]

Create random both image and mask with numpy.random.random.

Parameters

size : tuple

Shape of image.

p : float

Percentual of values equal to 0 in mask.

lims : list

Min and Max values of the image.

Returns

image : SimpleITK.Image

Random image created.

mask : SimpleITK.Image

Random mask created.

Examples

>>> import SimpleITK as sitk
>>> image, mask = generateBoth((2,3,4))
>>> print(sitk.GetArrayFromImage(image))
[[[222 221  50 176]
  [186 217  82  16]
  [160 133  53   4]]
 [[ 16 162 157 206]
  [ 24 130 228 136]
  [ 24  78  50 180]]]
>>> print(sitk.GetArrayFromImage(mask))
[[[1 1 0 0]
  [0 0 0 1]
  [0 0 0 0]]
 [[1 1 1 1]
  [1 0 0 1]
  [0 0 0 1]]]
advanced_radiomics.extract.openFile(path_name)[source]

Create an image object of SimpleITK given the file/directory name.

Parameters

path_name : string

Path to file/diretory

Returns

image : SimpleITK.Image

Image opened.

Examples

>>> image = openFile("image.nrrd")
advanced_radiomics.extract.filterStatistical(image_object, filter_type='prewitt', sigma=1)[source]

Filter the image input. Supports 4 types of filters.

Parameters

image_object : SimpleITK.Image

Image to filter.

filter_type : str, optional (default=”prewitt”)

Type of filter. The filters are “prewitt”, “sobel”, “laplace”, “LoG”.

sigma : int, optional (default=1)

Sigma of LoG. Only works if filter_type is equal to “LoG”.

Returns

image_filt_object : SimplITK.Image

Image filtered.

advanced_radiomics.extract.reduceSize(image_object, mask_object)[source]

Reduce the size of both image and mask, where is the VOI.

Parameters

image_object : SimpleITK.Image

Image Object with the original image.

mask_object : SimpleITK.Image

Image Object with the mask.

Returns

red_image_object : SimpleITK.Image

Image Object with the image reduced.

red_mask_object : SimpleITK.Image

Image Object with the mask reduced.

Examples

>>> image = openFile("image.nrrd")
>>> mask = openFile("mask.nrrd")
>>> im, mk = reduceSize(image, mask)
advanced_radiomics.extract.createBin(image_object, num=8)[source]

Create image with ‘num’ bins.

Parameters

image_object : SimpleITK.Image

Original image.

num : int

Number of bins, default = 8.

Returns

image_object_bin : SimpleITK.Image

Image with ‘num’ bins.

advanced_radiomics.extract.extractFeatures(image, mask, name, binCount=8, features='all')[source]

Extract the features by type.

Parameters

image : SimpleITK.Image

Original image.

mask : SimpleITK.Image

Image’s mask.

name : str

Identifier.

binCount : int, optional (default=8)

Number of bins.

features : str or list, optional (default=”all”)

If “all”, calculate all features. If list, must contain at least one of these strings: * “FO” -> First Order * “S3D” -> Shap * “GLCM” -> GLCM * “GLSZM” -> GLSZM * “GLRLM” -> GLRLM * “NGTDM” -> NGTDM * “GLDM” -> GLDM

Returns

df -> pandas.DataFrame

Dataframe with features calculated.

advanced_radiomics.extract.extractFilterStatistics(image, mask, name, filter_type='prewitt', sigma=1, binCount=8)[source]

Extract First Order feature’s of the filtered image.

Parameters

image : SimpleITK.Image

Original image.

mask : SimpleITK.Image

Image’s mask.

name : str

Identifier.

filter_type : str, optional (default=”prewitt”)

Type of filter. The filters are “prewitt”, “sobel”, “laplace”, “LoG”.

binCount : int, optional (default=8)

Number of bins.

sigma : int, optional (default=1)

Sigma of LoG. Only works if filter_type is equal to “LoG”.

Returns

features : pandas.DataFrame

Dataframe with features.

advanced_radiomics.extract.multiVOI(image_object, mask_object, name, binCount=8)[source]

Separate VOI’s.

Parameters

image_object : SimpleITK.Image

Original image.

mask_object : SimpleITK.Image

Mask image.

name : string

Identifier.

binCount : int

Number of bins.

Returns

dados : pandas.DataFrame

DataFrame with features per VOI.

Module Analysis

This module is for calculate statistics and other informations about the data.

advanced_radiomics.analysis.separateFeatures(data)[source]

Separates feature by type (First Order, Shape, GLCM…).

Parameters

data : pandas.DataFrame

Data with features calculated.

Returns

columns_dict : dict

Dict with keys as feature’s type.

Examples

>>> c_dict = separateFeatures(data)
>>> c_dict['GLCM']
  Autocorrelation_GLCM ClusterProminence_GLCM  ...      SumEntropy_GLCM    SumSquares_GLCM
0   19.291666666666668    0.01707175925925927  ...  0.23978697925681078  5.822048611111111

Module Visualization

This module is used to visualizate the data and to visualizate some informations, like PCA.

advanced_radiomics.visualization.showImageMask(image_object, mask_object)[source]

Show image and mask side by side.

Parameters

image_object : SimpleITK.Image

Image object of original image.

mask_object : SimpleITK.Image

Image object of the mask.

advanced_radiomics.visualization.plotPCA(data, target, normalize=False)[source]

Plot the first and second Principal Components of PCA and Separate Points by a class.

Parameters

data : numpy.array or pandas.DataFrame

Data with values.

target : numpy.array, pandas.Series or str

If the class is in the data, target must be the Column’s name of the class.