nyxus.Nyxus

class Nyxus(features, neighbor_distance=5.0, pixels_per_micron=1.0, coarse_gray_depth=256, n_feature_calc_threads=4, n_loader_threads=1, using_gpu=-1)

Bases: object

Nyxus image feature extraction library

Scalably extracts features from images.

Parameters
  • features (list[str]) –

    List of features to be calculated. Individual features can be provided or pre-specified feature groups. Valid groups include:

    ALL ALL_INTENSITY ALL_MORPHOLOGY BASIC_MORPHOLOGY ALL_GLCM ALL_GLRM ALL_GLSZM ALL_GLDM ALL_NGTDM ALL_BUT_GABOR ALL_BUT_GLCM

    Both individual features and feature groups are case sensitive.

  • neighbor_distance (float (optional, default 5.0)) – Any two objects separated by a Euclidean distance (pixel units) greater than this value will not be be considered neighbors. This cutoff is used by all features which rely on neighbor identification.

  • pixels_per_micron (float (optional, default 1.0)) – Specify the image resolution in terms of pixels per micron for unit conversion of non-unitless features.

  • coarse_gray_depth (int (optional, default 256)) – Custom number of levels in grayscale denoising used in texture features.

  • n_feature_calc_threads (int (optional, default 4)) – Number of threads to use for feature calculation parallelization purposes.

  • n_loader_threads (int (optional, default 1)) – Number of threads to use for loading image tiles from disk. Note: image loading multithreading is very memory intensive. You should consider optimizing n_feature_calc_threads before increasing n_loader_threads.

  • using_gpu (int (optional, default -1)) – Id of the gpu to use. To find available gpus along with ids, using nyxus.get_gpu_properties(). The default value of -1 uses cpu calculations. Note that the gpu features only support a single thread for feature calculation.

__init__(features, neighbor_distance=5.0, pixels_per_micron=1.0, coarse_gray_depth=256, n_feature_calc_threads=4, n_loader_threads=1, using_gpu=-1)
Parameters
  • features (List[str]) –

  • neighbor_distance (float) –

  • pixels_per_micron (float) –

  • coarse_gray_depth (int) –

  • n_feature_calc_threads (int) –

  • n_loader_threads (int) –

  • using_gpu (int) –

Methods

__init__(features[, neighbor_distance, ...])

featurize(intensity_files, mask_files)

Extract features from image file pairs passed as lists

featurize_directory(intensity_dir[, ...])

Extract features from all the images satisfying the file pattern of provided image directories.

using_gpu(gpu_on)

featurize(intensity_files, mask_files)

Extract features from image file pairs passed as lists

Extracts all the requested features _at the image level_ from the intensity images present in list intensity_files with respect to region of interest masks presented in list mask_files. Multiple

Parameters
  • intensity_files (list of intensity image file paths) –

  • mask_files (list of mask image file paths) –

Returns

df – Pandas DataFrame containing the requested features with one row per label per image.

Return type

pd.DataFrame

featurize_directory(intensity_dir, label_dir=None, file_pattern='.*')

Extract features from all the images satisfying the file pattern of provided image directories.

Extracts all the requested features _at the image level_ from the images present in intensity_dir. If label_dir is specified, features will be extracted for each unique label present in the label images. The file names of the label images are expected to match those of the intensity images.

Parameters
  • intensity_dir (str) – Path to directory containing intensity images.

  • label_dir (str (optional, default None)) – Path to directory containing label images.

  • file_pattern (str (optional, default ".*")) – Regular expression used to filter the images present in both intensity_dir and label_dir

Returns

df – Pandas DataFrame containing the requested features with one row per label per image.

Return type

pd.DataFrame