Biomarkers

BatchExtractor

class MEDimage.biomarkers.BatchExtractor.BatchExtractor(path_read: str | Path, path_csv: str | Path, path_params: str | Path, path_save: str | Path, n_batch: int = 4)[source]

Bases: object

Organizes all the patients/scans in batches to extract all the radiomic features

__init__(path_read: str | Path, path_csv: str | Path, path_params: str | Path, path_save: str | Path, n_batch: int = 4) None[source]

constructor of the BatchExtractor class

compute_radiomics(create_tables: bool = True) None[source]

Compute all radiomic features for all scans in the CSV file (set in initialization) and organize it in JSON and CSV files

Parameters:

create_tables (bool) – True to create CSV tables for the extracted features and not save it in JSON only.

Returns:

None.

diagnostics

MEDimage.biomarkers.diagnostics.extract_all(vol_obj: ndarray, roi_obj_int: ndarray, roi_obj_morph: ndarray, im_type: str) Dict[source]

Computes diagnostic features

The diagnostic features help identify issues with the implementation of the image processing sequence.

Parameters:
  • vol_obj (ndarray) – Imaging data.

  • roi_obj_int (ndarray) – Intensity mask data.

  • roi_obj_morph (ndarray) – Morphological mask data.

  • im_type (str) –

    Image processing step.

    • ’reSeg’: Computes Diagnostic features right after the re-segmentaion step.

    • ’interp’ or any other arg: Computes Diagnostic features for any processing step other than re-segmentation.

Returns:

Dictionnary containing the computed features.

Return type:

Dict

get_oriented_bound_box

MEDimage.biomarkers.get_oriented_bound_box.rot_matrix(theta: float, dim: int = 2, rot_axis: int = -1) ndarray[source]

Creates a 2d or 3d rotation matrix

Parameters:
  • theta (float) – angle in radian

  • dim (int, optional) – dimension size. Defaults to 2.

  • rot_axis (int, optional) – rotation axis value. Defaults to -1.

Returns:

rotation matrix

Return type:

ndarray

MEDimage.biomarkers.get_oriented_bound_box.sig_proc_find_peaks(x: float, ddir: str = 'pos') DataFrame[source]

Determines peak positions in array of values

Parameters:
  • x (float) – value

  • ddir (str, optional) – positive or negative value. Defaults to “pos”.

Returns:

peak positions in array of values

Return type:

pd.DataFrame

MEDimage.biomarkers.get_oriented_bound_box.sig_proc_segmentise(x: List) List[source]

Produces a list of segments from input x with values (0,1)

Parameters:

x (List) – list of values

Returns:

list of segments from input x with values (0,1)

Return type:

List

glcm

class MEDimage.biomarkers.glcm.CooccurrenceMatrix(distance: int, direction: ndarray, direction_id: int, spatial_method: str, img_slice: ndarray | None = None, merge_method: str | None = None, matrix: DataFrame | None = None, n_v: int | None = None)[source]

Bases: object

Class that contains a single co-occurrence matrix.

Note

Code was adapted from the in-house radiomics software created at OncoRay, Dresden, Germany.

distance

Chebyshev distance.

Type:

int

direction

Direction along which neighbouring voxels are found.

Type:

ndarray

direction_id

Direction index to identify unique direction vectors.

Type:

int

spatial_method

Spatial method used to calculate the co-occurrence matrix: “2d”, “2.5d” or “3d”.

Type:

str

img_slice

Corresponding slice index (only if the co-occurrence matrix corresponds to a 2d image slice).

Type:

ndarray

merge_method

Method for merging the co-occurrence matrix with other co-occurrence matrices.

Type:

str

matrix

The actual co-occurrence matrix in sparse format (row, column, count).

Type:

pandas.DataFrame

n_v

The number of voxels in the volume.

Type:

int

__init__(distance: int, direction: ndarray, direction_id: int, spatial_method: str, img_slice: ndarray | None = None, merge_method: str | None = None, matrix: DataFrame | None = None, n_v: int | None = None) None[source]

Constructor of the CooccurrenceMatrix class

Parameters:
  • distance (int) – Chebyshev distance.

  • direction (ndarray) – Direction along which neighbouring voxels are found.

  • direction_id (int) – Direction index to identify unique direction vectors.

  • spatial_method (str) – Spatial method used to calculate the co-occurrence matrix: “2d”, “2.5d” or “3d”.

  • img_slice (ndarray, optional) – Corresponding slice index (only if the co-occurrence matrix corresponds to a 2d image slice).

  • merge_method (str, optional) – Method for merging the co-occurrence matrix with other co-occurrence matrices.

  • matrix (pandas.DataFrame, optional) – The actual co-occurrence matrix in sparse format (row, column, count).

  • n_v (int, optional) – The number of voxels in the volume.

Returns:

None.

_copy()[source]

Returns a copy of the co-occurrence matrix object.

_parse_names() str[source]

“Adds additional settings-related identifiers to each feature. Not used currently, as the use of different settings for the co-occurrence matrix is not supported.

Returns:

String of the features indetifier.

Return type:

str

calculate_cm_features(intensity_range: ndarray) DataFrame[source]

Wrapper to json.dump function.

Parameters:

intensity_range (np.ndarray) – Range of potential discretised intensities, provided as a list: [minimal discretised intensity, maximal discretised intensity]. If one or both values are unknown,replace the respective values with np.nan.

Returns:

Data frame with values for each feature.

Return type:

pandas.DataFrame

calculate_cm_matrix(df_img: DataFrame, img_dims: ndarray, dist_weight_norm: str) None[source]

Function that calculates a co-occurrence matrix for the settings provided during initialisation and the input image.

Parameters:
  • df_img (pandas.DataFrame) – Data table containing image intensities, x, y and z coordinates, and mask labels corresponding to voxels in the volume.

  • img_dims (ndarray, List[float]) – Dimensions of the image volume.

  • dist_weight_norm (str) – Norm for distance weighting. Weighting is only performed if this parameter is either “manhattan”, “euclidean” or “chebyshev”.

Returns:

None. Assigns the created image table (cm matrix) to the matrix attribute.

Raises:

ValueError – If self.spatial_method is not “2d”, “2.5d” or “3d”. Also, if dist_weight_norm is not “manhattan”, “euclidean” or “chebyshev”.

get_cm_data(intensity_range: ndarray)[source]

Computes the probability distribution for the elements of the GLCM (diagonal probability, cross-diagonal probability…) and number of gray-levels.

Parameters:

intensity_range (ndarray) – Range of potential discretised intensities, provided as a list: [minimal discretised intensity, maximal discretised intensity]. If one or both values are unknown,replace the respective values with np.nan.

Returns:

  • Occurence data frame

  • Diagonal probabilty

  • Cross-diagonal probabilty

  • Number of gray levels

Return type:

Typle[pd.DataFrame, pd.DataFrame, pd.DataFrame, float]

MEDimage.biomarkers.glcm.auto_corr(glcm_dict: Dict) float | List[float][source]

Computes autocorrelation features. This feature refers to “Fcm_auto_corr” (ID = QWB0) in the IBSI1 reference manual.

Parameters:

glcm_dict (Dict) – dictionary with glcm matrices, generated using get_glcm_matrices()

Returns:

the autocorrelation features

Return type:

Union[float, List[float]]

MEDimage.biomarkers.glcm.clust_prom(glcm_dict: Dict) float | List[float][source]

Computes cluster prominence features. This feature refers to “Fcm_clust_prom” (ID = AE86) in the IBSI1 reference manual.

Parameters:

glcm_dict (Dict) – dictionary with glcm matrices, generated using get_glcm_matrices()

Returns:

the cluster prominence features

Return type:

Union[float, List[float]]

MEDimage.biomarkers.glcm.clust_shade(glcm_dict: Dict) float | List[float][source]

Computes cluster shade features. This feature refers to “Fcm_clust_shade” (ID = 7NFM) in the IBSI1 reference manual.

Parameters:

glcm_dict (Dict) – dictionary with glcm matrices, generated using get_glcm_matrices()

Returns:

the cluster shade features

Return type:

Union[float, List[float]]

MEDimage.biomarkers.glcm.clust_tend(glcm_dict: Dict) float | List[float][source]

Computes cluster tendency features. This feature refers to “Fcm_clust_tend” (ID = DG8W) in the IBSI1 reference manual.

Parameters:

glcm_dict (Dict) – dictionary with glcm matrices, generated using get_glcm_matrices()

Returns:

the cluster tendency features

Return type:

Union[float, List[float]]

MEDimage.biomarkers.glcm.combine_matrices(glcm_list: List, merge_method: str, spatial_method: str) List[source]

Merges co-occurrence matrices prior to feature calculation.

Note

This code was adapted from the in-house radiomics software created at OncoRay, Dresden, Germany.

Parameters:
  • glcm_list (List) – List of CooccurrenceMatrix objects.

  • merge_method (str) – Merging method which determines how features are calculated. One of “average”, “slice_merge”, “dir_merge” and “vol_merge”. Note that not all combinations of spatial and merge method are valid.

  • spatial_method (str) – spatial method which determines the way co-occurrence matrices are calculated and how features are determined. One of “2d”, “2.5d” or “3d”.

Returns:

list of one or more merged CooccurrenceMatrix objects.

Return type:

List[CooccurrenceMatrix]

MEDimage.biomarkers.glcm.contrast(glcm_dict: Dict) float | List[float][source]

Computes constrast features. This feature refers to “Fcm_contrast” (ID = ACUI) in the IBSI1 reference manual.

Parameters:

glcm_dict (Dict) – dictionary with glcm matrices, generated using get_glcm_matrices()

Returns:

the contrast features

Return type:

Union[float, List[float]]

MEDimage.biomarkers.glcm.corr(glcm_dict: Dict) float | List[float][source]

Computes correlation features. This feature refers to “Fcm_corr” (ID = NI2N) in the IBSI1 reference manual.

Parameters:

glcm_dict (Dict) – dictionary with glcm matrices, generated using get_glcm_matrices()

Returns:

the correlation features

Return type:

Union[float, List[float]]

MEDimage.biomarkers.glcm.diff_avg(glcm_dict: Dict) float | List[float][source]

Computes difference average features. This feature refers to “Fcm_diff_avg” (ID = TF7R) in the IBSI1 reference manual.

Parameters:

glcm_dict (Dict) – dictionary with glcm matrices, generated using get_glcm_matrices()

Returns:

the difference average features

Return type:

Union[float, List[float]]

MEDimage.biomarkers.glcm.diff_entr(glcm_dict: Dict) float | List[float][source]

Computes difference entropy features. This feature refers to “Fcm_diff_entr” (ID = NTRS) in the IBSI1 reference manual.

Parameters:

glcm_dict (Dict) – dictionary with glcm matrices, generated using get_glcm_matrices()

Returns:

the difference entropy features

Return type:

Union[float, List[float]]

MEDimage.biomarkers.glcm.diff_var(glcm_dict: Dict) float | List[float][source]

Computes difference variance features. This feature refers to “Fcm_diff_var” (ID = D3YU) in the IBSI1 reference manual.

Parameters:

glcm_dict (Dict) – dictionary with glcm matrices, generated using get_glcm_matrices()

Returns:

the difference variance features

Return type:

Union[float, List[float]]

MEDimage.biomarkers.glcm.dissimilarity(glcm_dict: Dict) float | List[float][source]

Computes dissimilarity features. This feature refers to “Fcm_dissimilarity” (ID = 8S9J) in the IBSI1 reference manual.

Parameters:

glcm_dict (Dict) – dictionary with glcm matrices, generated using get_glcm_matrices()

Returns:

the dissimilarity features

Return type:

Union[float, List[float]]

MEDimage.biomarkers.glcm.energy(glcm_dict: Dict) float | List[float][source]

Computes angular second moment features. This feature refers to “Fcm_energy” (ID = 8ZQL) in the IBSI1 reference manual.

Parameters:

glcm_dict (Dict) – dictionary with glcm matrices, generated using get_glcm_matrices()

Returns:

the angular second moment features

Return type:

Union[float, List[float]]

MEDimage.biomarkers.glcm.extract_all(vol, dist_correction=None, merge_method='vol_merge') Dict[source]

Computes glcm features. This features refer to Glcm family in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, isotropically resampled, quantized (e.g. n_g = 32, levels = [1, …, n_g]), with NaNs outside the region of interest.

  • dist_correction (Union[bool, str], optional) – Set this variable to true in order to use discretization length difference corrections as used by the Institute of Physics and Engineering in Medicine. Set this variable to false to replicate IBSI results. Or use string and specify the norm for distance weighting. Weighting is only performed if this argument is “manhattan”, “euclidean” or “chebyshev”.

  • merge_method (str, optional) – merging method which determines how features are calculated. One of “average”, “slice_merge”, “dir_merge” and “vol_merge”. Note that not all combinations of spatial and merge method are valid.

  • method (str, optional) – Either ‘old’ (deprecated) or ‘new’ (faster) method.

Returns:

Dict of the glcm features.

Return type:

Dict

Raises:

ValueError – If method is not ‘old’ or ‘new’.

Todo

  • Enable calculation of CM features using different spatial methods (2d, 2.5d, 3d)

  • Enable calculation of CM features using different CM distance settings

  • Enable calculation of CM features for different merge methods (“average”, “slice_merge”, “dir_merge” and “vol_merge”)

  • Provide the range of discretised intensities from a calling function and pass to get_cm_features().

  • Test if dist_correction works as expected.

MEDimage.biomarkers.glcm.get_cm_features(vol, intensity_range, glcm_spatial_method='3d', glcm_dist=1.0, merge_method='vol_merge', dist_weight_norm=None) Dict[source]

Extracts co-occurrence matrix-based features from the intensity roi mask.

Note

This code was adapted from the in-house radiomics software created at OncoRay, Dresden, Germany.

Parameters:
  • vol (ndarray) – volume with discretised intensities as 3D numpy array (x, y, z).

  • intensity_range (ndarray) – range of potential discretised intensities, provided as a list: [minimal discretised intensity, maximal discretised intensity]. If one or both values are unknown, replace the respective values with np.nan.

  • glcm_spatial_method (str, optional) – spatial method which determines the way co-occurrence matrices are calculated and how features are determined. MUST BE “2d”, “2.5d” or “3d”.

  • glcm_dist (float, optional) – chebyshev distance for comparison between neighbouring voxels.

  • merge_method (str, optional) – merging method which determines how features are calculated. One of “average”, “slice_merge”, “dir_merge” and “vol_merge”. Note that not all combinations of spatial and merge method are valid.

  • dist_weight_norm (Union[bool, str], optional) – norm for distance weighting. Weighting is only performed if this argument is either “manhattan”, “euclidean”, “chebyshev” or bool.

Returns:

Dict of the glcm features.

Return type:

Dict

Raises:

ValueError – If glcm_spatial_method is not “2d”, “2.5d” or “3d”.

MEDimage.biomarkers.glcm.get_glcm_matrices(vol, glcm_spatial_method='3d', glcm_dist=1.0, merge_method='vol_merge', dist_weight_norm=None) Dict[source]

Extracts co-occurrence matrices from the intensity roi mask prior to features extraction.

Note

This code was adapted from the in-house radiomics software created at OncoRay, Dresden, Germany.

Parameters:
  • vol (ndarray) – volume with discretised intensities as 3D numpy array (x, y, z).

  • intensity_range (ndarray) – range of potential discretised intensities,provided as a list: [minimal discretised intensity, maximal discretised intensity]. If one or both values are unknown, replace the respective values with np.nan.

  • glcm_spatial_method (str, optional) – spatial method which determines the way co-occurrence matrices are calculated and how features are determined. Must be “2d”, “2.5d” or “3d”.

  • glcm_dist (float, optional) – Chebyshev distance for comparison between neighboring voxels.

  • merge_method (str, optional) – merging method which determines how features are calculated. One of “average”, “slice_merge”, “dir_merge” and “vol_merge”. Note that not all combinations of spatial and merge method are valid.

  • dist_weight_norm (Union[bool, str], optional) – norm for distance weighting. Weighting is only performed if this argument is either “manhattan”,”euclidean”, “chebyshev” or bool.

Returns:

Dict of co-occurrence matrices.

Return type:

Dict

Raises:

ValueError – If glcm_spatial_method is not “2d”, “2.5d” or “3d”.

MEDimage.biomarkers.glcm.get_matrix(roi_only: ndarray, levels: ndarray | List, dist_correction=True) ndarray[source]

This function computes the Gray-Level Co-occurence Matrix (GLCM) of the region of interest (ROI) of an input volume. The input volume is assumed to be isotropically resampled. Only one GLCM is computed per scan, simultaneously recording (i.e. adding up) the neighboring properties of the 26-connected neighbors of all voxels in the ROI. To account for discretization length differences, neighbors at a distance of \(\sqrt{3}\) voxels around a center voxel increment the GLCM by a value of \(\sqrt{3}\), neighbors at a distance of \(\sqrt{2}\) voxels around a center voxel increment the GLCM by a value of \(\sqrt{2}\), and neighbors at a distance of 1 voxels around a center voxel increment the GLCM by a value of 1. This matrix refers to “Grey level co-occurrence based features” (ID = LFYI) in the IBSI1 reference manual.

Parameters:
  • roi_only (ndarray) – Smallest box containing the ROI, with the imaging data ready for texture analysis computations. Voxels outside the ROI are set to NaNs.

  • levels (ndarray or List) – Vector containing the quantized gray-levels in the tumor region (or reconstruction levels of quantization).

  • dist_correction (bool, optional) – Set this variable to true in order to use discretization length difference corrections as used by the Institute of Physics and Engineering in Medicine. Set this variable to false to replicate IBSI results.

Returns:

Gray-Level Co-occurence Matrix of roi_only.

Return type:

ndarray

References

[1] Haralick, R. M., Shanmugam, K., & Dinstein, I. (1973). Textural features for image classification. IEEE Transactions on Systems, Man and Cybernetics, smc 3(6), 610–621.

MEDimage.biomarkers.glcm.info_corr1(glcm_dict: Dict) float | List[float][source]

Computes information correlation 1 features. This feature refers to “Fcm_info_corr1” (ID = R8DG) in the IBSI1 reference manual.

Parameters:

glcm_dict (Dict) – dictionary with glcm matrices, generated using get_glcm_matrices()

Returns:

the information correlation 1 features

Return type:

Union[float, List[float]]

MEDimage.biomarkers.glcm.info_corr2(glcm_dict: Dict) float | List[float][source]

Computes information correlation 2 features - Note: iteration over combinations of i and j This feature refers to “Fcm_info_corr2” (ID = JN9H) in the IBSI1 reference manual.

Parameters:

glcm_dict (Dict) – dictionary with glcm matrices, generated using get_glcm_matrices()

Returns:

the information correlation 2 features

Return type:

Union[float, List[float]]

MEDimage.biomarkers.glcm.inv_diff(glcm_dict: Dict) float | List[float][source]

Computes inverse difference features. This feature refers to “Fcm_inv_diff” (ID = IB1Z) in the IBSI1 reference manual.

Parameters:

glcm_dict (Dict) – dictionary with glcm matrices, generated using get_glcm_matrices()

Returns:

the inverse difference features

Return type:

Union[float, List[float]]

MEDimage.biomarkers.glcm.inv_diff_mom(glcm_dict: Dict) float | List[float][source]

Computes inverse difference moment features. This feature refers to “Fcm_inv_diff_mom” (ID = WF0Z) in the IBSI1 reference manual.

Parameters:

glcm_dict (Dict) – dictionary with glcm matrices, generated using get_glcm_matrices()

Returns:

the inverse difference moment features

Return type:

Union[float, List[float]]

MEDimage.biomarkers.glcm.inv_diff_mom_norm(glcm_dict: Dict) float | List[float][source]

Computes inverse difference moment normalized features. This feature refers to “Fcm_inv_diff_mom_norm” (ID = 1QCO) in the IBSI1 reference manual.

Parameters:

glcm_dict (Dict) – dictionary with glcm matrices, generated using get_glcm_matrices()

Returns:

the inverse difference moment normalized features

Return type:

Union[float, List[float]]

MEDimage.biomarkers.glcm.inv_diff_norm(glcm_dict: Dict) float | List[float][source]

Computes inverse difference normalized features. This feature refers to “Fcm_inv_diff_norm” (ID = NDRX) in the IBSI1 reference manual.

Parameters:

glcm_dict (Dict) – dictionary with glcm matrices, generated using get_glcm_matrices()

Returns:

the inverse difference normalized features

Return type:

Union[float, List[float]]

MEDimage.biomarkers.glcm.inv_var(glcm_dict: Dict) float | List[float][source]

Computes inverse variance features. This feature refers to “Fcm_inv_var” (ID = E8JP) in the IBSI1 reference manual.

Parameters:

glcm_dict (Dict) – dictionary with glcm matrices, generated using get_glcm_matrices()

Returns:

the inverse variance features

Return type:

Union[float, List[float]]

MEDimage.biomarkers.glcm.joint_avg(glcm_dict: Dict) float | List[float][source]

Computes joint average features. This feature refers to “Fcm_joint_avg” (ID = 60VM) in the IBSI1 reference manual.

Parameters:

glcm_dict (Dict) – dictionary with glcm matrices, generated using get_glcm_matrices()

Returns:

Union[float, List[float]]:: List or float of the joint average feature(s)

MEDimage.biomarkers.glcm.joint_entr(glcm_dict: Dict) float | List[float][source]

Computes joint entropy features. This feature refers to “Fcm_joint_entr” (ID = TU9B) in the IBSI1 reference manual.

Parameters:

glcm_dict (Dict) – dictionary with glcm matrices, generated using get_glcm_matrices()

Returns:

the joint entropy features

Return type:

Union[float, List[float]]

MEDimage.biomarkers.glcm.joint_max(glcm_dict: Dict) float | List[float][source]

Computes joint maximum features. This feature refers to “Fcm_joint_max” (ID = GYBY) in the IBSI1 reference manual.

Parameters:

glcm_dict (Dict) – dictionary with glcm matrices, generated using get_glcm_matrices()

Returns:

Union[float, List[float]]:: List or float of the joint maximum feature(s)

MEDimage.biomarkers.glcm.joint_var(glcm_dict: Dict) float | List[float][source]

Computes joint variance features. This feature refers to “Fcm_var” (ID = UR99) in the IBSI1 reference manual.

Parameters:

glcm_dict (Dict) – dictionary with glcm matrices, generated using get_glcm_matrices()

Returns:

List or float of the joint variance feature(s)

Return type:

Union[float, List[float]]

MEDimage.biomarkers.glcm.sum_avg(glcm_dict: Dict) float | List[float][source]

Computes sum average features. This feature refers to “Fcm_sum_avg” (ID = ZGXS) in the IBSI1 reference manual.

Parameters:

glcm_dict (Dict) – dictionary with glcm matrices, generated using get_glcm_matrices()

Returns:

the sum average features

Return type:

Union[float, List[float]]

MEDimage.biomarkers.glcm.sum_entr(glcm_dict: Dict) float | List[float][source]

Computes sum entropy features. This feature refers to “Fcm_sum_entr” (ID = P6QZ) in the IBSI1 reference manual.

Parameters:

glcm_dict (Dict) – dictionary with glcm matrices, generated using get_glcm_matrices()

Returns:

the sum entropy features

Return type:

Union[float, List[float]]

MEDimage.biomarkers.glcm.sum_var(glcm_dict: Dict) float | List[float][source]

Computes sum variance features. This feature refers to “Fcm_sum_var” (ID = OEEB) in the IBSI1 reference manual.

Parameters:

glcm_dict (Dict) – dictionary with glcm matrices, generated using get_glcm_matrices()

Returns:

the sum variance features

Return type:

Union[float, List[float]]

gldzm

MEDimage.biomarkers.gldzm.extract_all(vol_int: ndarray, mask_morph: ndarray, gldzm: ndarray | None = None) Dict[source]

Computes gldzm features. This feature refers to “Grey level distance zone based features” (ID = VMDZ) in the IBSI1 reference manual.

Parameters:
  • vol_int (np.ndarray) – 3D volume, isotropically resampled, quantized (e.g. n_g = 32, levels = [1, …, n_g]),

  • interest. (with NaNs outside the region of)

  • mask_morph (np.ndarray) – Morphological ROI mask.

  • gldzm (np.ndarray, optional) – array of the gray level distance zone matrix. Defaults to None.

Returns:

dict of gldzm features

Return type:

Dict

MEDimage.biomarkers.gldzm.get_matrix(roi_only_int: ndarray, mask: ndarray, levels: ndarray | List) ndarray[source]

Computes Grey level distance zone matrix. This matrix refers to “Grey level distance zone based features” (ID = VMDZ) in the IBSI1 reference manual.

Parameters:
  • roi_only_int (ndarray) – 3D volume, isotropically resampled, quantized (e.g. n_g = 32, levels = [1, …, n_g]), with NaNs outside the region of interest.

  • mask (ndarray) – Morphological ROI mask.

  • levels (ndarray or List) – Vector containing the quantized gray-levels in the tumor region (or reconstruction levels of quantization).

Returns:

Grey level distance zone Matrix.

Return type:

ndarray

Todo

levels should be removed at some point, no longer needed if we always quantize our volume such that levels = 1,2,3,4,...,max(quantized Volume). So simply calculate levels = 1:max(roi_only(~isnan(roi_only(:)))) directly in this function.

MEDimage.biomarkers.gldzm.get_single_matrix(vol_int: ndarray, mask_morph: ndarray) ndarray[source]

Computes gray level distance zone matrix in order to compute the single features.

Parameters:
  • vol_int (ndarray) – 3D volume, isotropically resampled, quantized (e.g. n_g = 32, levels = [1, …, n_g]), with NaNs outside the region of interest.

  • mask_morph (ndarray) – Morphological ROI mask.

Returns:

gldzm features.

Return type:

ndarray

MEDimage.biomarkers.gldzm.gl_var(gldzm: ndarray) float[source]

Computes grey level variance This feature refers to “Fdzm_gl_var” (ID = QK93) in the IBSI1 reference manual.

Parameters:

gldzm (ndarray) – array of the gray level distance zone matrix

Returns:

the grey level variance feature

Return type:

float

MEDimage.biomarkers.gldzm.glnu(gldzm: ndarray) float[source]

Computes distance zone matrix gray level non-uniformity This feature refers to “Fdzm_glnu” (ID = VFT7) in the IBSI1 reference manual.

Parameters:

gldzm (ndarray) – array of the gray level distance zone matrix

Returns:

the gray level non-uniformity feature

Return type:

float

MEDimage.biomarkers.gldzm.glnu_norm(gldzm: ndarray) float[source]

Computes distance zone matrix gray level non-uniformity normalised This feature refers to “Fdzm_glnu_norm” (ID = 7HP3) in the IBSI1 reference manual.

Parameters:

gldzm (ndarray) – array of the gray level distance zone matrix

Returns:

the gray level non-uniformity normalised feature

Return type:

float

MEDimage.biomarkers.gldzm.hgze(gldzm: ndarray) float[source]

Computes distance matrix high grey level zone emphasis feature. This feature refers to “Fdzm_hgze” (ID = K26C) in the IBSI1 reference manual.

Parameters:

gldzm (ndarray) – array of the gray level distance zone matrix

Returns:

the high grey level zone emphasis feature

Return type:

float

MEDimage.biomarkers.gldzm.lde(gldzm: ndarray) float[source]

Computes large distance emphasis feature. This feature refers to “Fdzm_lde” (ID = MB4I) in the IBSI1 reference manual.

Parameters:

gldzm (ndarray) – array of the gray level distance zone matrix

Returns:

the large distance emphasis feature

Return type:

float

MEDimage.biomarkers.gldzm.ldhge(gldzm: ndarray) float[source]

Computes large distance high grey level emphasis feature. This feature refers to “Fdzm_ldhge” (ID = KLTH) in the IBSI1 reference manual.

Parameters:

gldzm (ndarray) – array of the gray level distance zone matrix

Returns:

the high grey level emphasis feature

Return type:

float

MEDimage.biomarkers.gldzm.ldlge(gldzm: ndarray) float[source]

Computes large distance low grey level emphasis feature. This feature refers to “Fdzm_ldlge” (ID = A7WM) in the IBSI1 reference manual.

Parameters:

gldzm (ndarray) – array of the gray level distance zone matrix

Returns:

the low grey level emphasis feature

Return type:

float

MEDimage.biomarkers.gldzm.lgze(gldzm: ndarray) float[source]

Computes distance matrix low grey level zone emphasis feature. This feature refers to “Fdzm_lgze” (ID = S1RA) in the IBSI1 reference manual.

Parameters:

gldzm (ndarray) – array of the gray level distance zone matrix

Returns:

the low grey level zone emphasis feature

Return type:

float

MEDimage.biomarkers.gldzm.sde(gldzm: ndarray) float[source]

Computes small distance emphasis feature. This feature refers to “Fdzm_sde” (ID = 0GBI) in the IBSI1 reference manual.

Parameters:

gldzm (ndarray) – array of the gray level distance zone matrix

Returns:

the small distance emphasis feature

Return type:

float

MEDimage.biomarkers.gldzm.sdhge(gldzm: ndarray) float[source]

Computes small distance high grey level emphasis feature. This feature refers to “Fdzm_sdhge” (ID = DKNJ) in the IBSI1 reference manual.

Parameters:

gldzm (ndarray) – array of the gray level distance zone matrix

Returns:

the distance high grey level emphasis feature

Return type:

float

MEDimage.biomarkers.gldzm.sdlge(gldzm: ndarray) float[source]

Computes small distance low grey level emphasis feature. This feature refers to “Fdzm_sdlge” (ID = RUVG) in the IBSI1 reference manual.

Parameters:

gldzm (ndarray) – array of the gray level distance zone matrix

Returns:

the low grey level emphasis feature

Return type:

float

MEDimage.biomarkers.gldzm.z_perc(gldzm, vol_int)[source]

Computes zone percentage This feature refers to “Fdzm_z_perc” (ID = VIWW) in the IBSI1 reference manual.

Parameters:

gldzm (ndarray) – array of the gray level distance zone matrix

Returns:

the zone percentage feature

Return type:

float

MEDimage.biomarkers.gldzm.zd_entr(gldzm: ndarray) float[source]

Computes zone distance entropy This feature refers to “Fdzm_zd_entr” (ID = GBDU) in the IBSI1 reference manual.

Parameters:

gldzm (ndarray) – array of the gray level distance zone matrix

Returns:

the zone distance entropy feature

Return type:

float

MEDimage.biomarkers.gldzm.zd_var(gldzm: ndarray) float[source]

Computes zone distance variance This feature refers to “Fdzm_zd_var” (ID = 7WT1) in the IBSI1 reference manual.

Parameters:

gldzm (ndarray) – array of the gray level distance zone matrix

Returns:

the zone distance variance feature

Return type:

float

MEDimage.biomarkers.gldzm.zdnu(gldzm: ndarray) float[source]

Computes zone distance non-uniformity This feature refers to “Fdzm_zdnu” (ID = V294) in the IBSI1 reference manual.

Parameters:

gldzm (ndarray) – array of the gray level distance zone matrix

Returns:

the zone distance non-uniformity feature

Return type:

float

MEDimage.biomarkers.gldzm.zdnu_norm(gldzm: ndarray) float[source]

Computes zone distance non-uniformity normalised This feature refers to “Fdzm_zdnu_norm” (ID = IATH) in the IBSI1 reference manual.

Parameters:

gldzm (ndarray) – array of the gray level distance zone matrix

Returns:

the zone distance non-uniformity normalised feature

Return type:

float

glrlm

class MEDimage.biomarkers.glrlm.RunLengthMatrix(direction: ndarray, direction_id: int, spatial_method: str, img_slice: ndarray | None = None, merge_method: str | None = None, matrix: DataFrame | None = None, n_v: int | None = None)[source]

Bases: object

Class that contains a single run length matrix.

Note

This code was adapted from the in-house radiomics software created at OncoRay, Dresden, Germany.

Parameters:
  • direction (ndarray) – Direction along which neighbouring voxels are found.

  • direction_id (int) – Direction index to identify unique direction vectors.

  • spatial_method (str) – Spatial method used to calculate the co-occurrence matrix: “2d”, “2.5d” or “3d”.

  • img_slice (ndarray, optional) – Corresponding slice index (only if the co-occurrence matrix corresponds to a 2d image slice).

  • merge_method (str, optional) – Method for merging the co-occurrence matrix with other co-occurrence matrices.

  • matrix (pandas.DataFrame, optional) – The actual co-occurrence matrix in sparse format (row, column, count).

  • n_v (int, optional) – The number of voxels in the volume.

direction

Direction along which neighbouring voxels are found.

Type:

ndarray

direction_id

Direction index to identify unique direction vectors.

Type:

int

spatial_method

Spatial method used to calculate the co-occurrence matrix: “2d”, “2.5d” or “3d”.

Type:

str

img_slice

Corresponding slice index (only if the co-occurrence matrix corresponds to a 2d image slice).

Type:

ndarray

merge_method

Method for merging the co-occurrence matrix with other co-occurrence matrices.

Type:

str

matrix

The actual co-occurrence matrix in sparse format (row, column, count).

Type:

pandas.DataFrame

n_v

The number of voxels in the volume.

Type:

int

__init__(direction: ndarray, direction_id: int, spatial_method: str, img_slice: ndarray | None = None, merge_method: str | None = None, matrix: DataFrame | None = None, n_v: int | None = None) None[source]

Initialising function for a new run length matrix

_copy()[source]

Returns a copy of the RunLengthMatrix object.

_parse_feature_names() str[source]

“Adds additional settings-related identifiers to each feature. Not used currently, as the use of different settings for the run length matrix is not supported.

_set_empty()[source]

Creates an empty RunLengthMatrix

calculate_feature(name: str) DataFrame[source]

Computes run length matrix features for the current run length matrix.

Returns:

Value of feature given as parameter

Return type:

ndarray

calculate_rlm_features() DataFrame[source]

Computes run length matrix features for the current run length matrix.

Returns:

Data frame with values for each feature.

Return type:

pandas.DataFrame

calculate_rlm_matrix(df_img: DataFrame, img_dims: ndarray, dist_weight_norm: str) None[source]

Function that calculates a run length matrix for the settings provided during initialisation and the input image.

Parameters:
  • df_img (pandas.DataFrame) – Data table containing image intensities, x, y and z coordinates, and mask labels corresponding to voxels in the volume.

  • img_dims (ndarray, List[float]) – Dimensions of the image volume.

  • dist_weight_norm (str) – Norm for distance weighting. Weighting is only performed if this parameter is either “manhattan”, “euclidean” or “chebyshev”.

Returns:

None. Assigns the created image table (rlm matrix) to the matrix attribute.

Raises:

ValueError – If self.spatial_method is not “2d”, “2.5d” or “3d”. Also, if dist_weight_norm is not “manhattan”, “euclidean” or “chebyshev”.

MEDimage.biomarkers.glrlm.combine_rlm_matrices(rlm_list: list, merge_method: str, spatial_method: str) List[source]

Merges run length matrices prior to feature calculation.

Note

This code was adapted from the in-house radiomics software created at OncoRay, Dresden, Germany.

Parameters:
  • rlm_list (List) – List of RunLengthMatrix objects.

  • merge_method (str) – Merging method which determines how features are calculated. One of “average”, “slice_merge”, “dir_merge” and “vol_merge”. Note that not all combinations of spatial and merge method are valid.

  • spatial_method (str) – Spatial method which determines the way co-occurrence matrices are calculated and how features are determined. One of “2d”, “2.5d” or “3d”.

Returns:

List of one or more merged RunLengthMatrix objects.

Return type:

List[CooccurrenceMatrix]

MEDimage.biomarkers.glrlm.extract_all(vol: ndarray, dist_correction: bool | str | None = None, merge_method: str = 'vol_merge') Dict[source]

Computes glrlm features. This features refer to Grey Level Run Length Matrix family in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, isotropically resampled, quantized (e.g. n_g = 32, levels = [1, …, n_g]), with NaNs outside the region of interest.

  • dist_correction (Union[bool, str], optional) – Set this variable to true in order to use discretization length difference corrections as used by the Institute of Physics and Engineering in Medicine. Set this variable to false to replicate IBSI results. Or use string and specify the norm for distance weighting. Weighting is only performed if this argument is “manhattan”, “euclidean” or “chebyshev”.

  • merge_method (str, optional) – merging method which determines how features are calculated. One of “average”, “slice_merge”, “dir_merge” and “vol_merge”. Note that not all combinations of spatial and merge method are valid.

  • method (str, optional) – Either ‘old’ (deprecated) or ‘new’ (faster) method.

Returns:

Dict of the glrlm features.

Return type:

Dict

Raises:

ValueError – If method is not ‘old’ or ‘new’.

Todo

  • Enable calculation of RLM features using different spatial methods (2d, 2.5d, 3d)

  • Enable calculation of RLM features using different RLM distance settings

  • Enable calculation of RLM features for different merge methods (average, slice_merge, dir_merge, vol_merge)

  • Provide the range of discretised intensities from a calling function and pass to get_rlm_features.

  • Test if dist_correction works as expected.

MEDimage.biomarkers.glrlm.get_matrix(vol: ndarray, glrlm_spatial_method: str = '3d', merge_method: str = 'vol_merge', dist_weight_norm: bool | str | None = None) ndarray[source]

Extract run length matrix-based features from the intensity roi mask.

Note

This code was adapted from the in-house radiomics software created at OncoRay, Dresden, Germany.

Parameters:
  • vol (ndarray) – volume with discretised intensities as 3D numpy array (x, y, z).

  • glrlm_spatial_method (str, optional) – spatial method which determines the way co-occurrence matrices are calculated and how features are determined. must be “2d”, “2.5d” or “3d”.

  • merge_method (str, optional) – merging method which determines how features are calculated. One of “average”, “slice_merge”, “dir_merge” and “vol_merge”. Note that not all combinations of spatial and merge method are valid.

  • dist_weight_norm (Union[bool, str], optional) – norm for distance weighting. Weighting is only performed if this argument is either “manhattan”, “euclidean”, “chebyshev” or bool.

Returns:

Dict of the length matrix features.

Return type:

ndarray

MEDimage.biomarkers.glrlm.get_rlm_features(vol: ndarray, glrlm_spatial_method: str = '3d', merge_method: str = 'vol_merge', dist_weight_norm: bool | str | None = None) Dict[source]

Extract run length matrix-based features from the intensity roi mask.

Note

This code was adapted from the in-house radiomics software created at OncoRay, Dresden, Germany.

Parameters:
  • vol (ndarray) – volume with discretised intensities as 3D numpy array (x, y, z).

  • glrlm_spatial_method (str, optional) – spatial method which determines the way co-occurrence matrices are calculated and how features are determined. must be “2d”, “2.5d” or “3d”.

  • merge_method (str, optional) – merging method which determines how features are calculated. One of “average”, “slice_merge”, “dir_merge” and “vol_merge”. Note that not all combinations of spatial and merge method are valid.

  • dist_weight_norm (Union[bool, str], optional) – norm for distance weighting. Weighting is only performed if this argument is either “manhattan”, “euclidean”, “chebyshev” or bool.

Returns:

Dict of the length matrix features.

Return type:

Dict

MEDimage.biomarkers.glrlm.gl_var(upd_list: ndarray) float[source]

Compute Grey level variance feature from the run length matrices list. This feature refers to “Frlm_gl_var” (ID = 8CE5) in the IBSI1 reference manual.

Parameters:

upd_list (ndarray) – Run length matrices computed and merged according given method.

Returns:

Dict of the Grey level variance feature.

Return type:

float

MEDimage.biomarkers.glrlm.glnu(upd_list: ndarray) float[source]

Compute Grey level non-uniformity feature from the run length matrices list. This feature refers to “Frlm_glnu” (ID = R5YN) in the IBSI1 reference manual.

Parameters:

upd_list (ndarray) – Run length matrices computed and merged according given method.

Returns:

Dict of the Grey level non-uniformity feature.

Return type:

float

MEDimage.biomarkers.glrlm.glnu_norm(upd_list: ndarray) float[source]

Compute Grey level non-uniformity normalised feature from the run length matrices list. This feature refers to “Frlm_glnu_norm” (ID = OVBL) in the IBSI1 reference manual.

Parameters:

upd_list (ndarray) – Run length matrices computed and merged according given method.

Returns:

Dict of the Grey level non-uniformity normalised feature.

Return type:

float

MEDimage.biomarkers.glrlm.hgre(upd_list: ndarray) float[source]

Compute High grey level run emphasis feature from the run length matrices list. This feature refers to “Frlm_hgre” (ID = G3QZ) in the IBSI1 reference manual.

Parameters:

upd_list (ndarray) – Run length matrices computed and merged according given method.

Returns:

Dict of the High grey level run emphasis feature.

Return type:

float

MEDimage.biomarkers.glrlm.lgre(upd_list: ndarray) float[source]

Compute Low grey level run emphasis feature from the run length matrices list. This feature refers to “Frlm_lgre” (ID = V3SW) in the IBSI1 reference manual.

Parameters:

upd_list (ndarray) – Run length matrices computed and merged according given method.

Returns:

Dict of the Low grey level run emphasis feature.

Return type:

float

MEDimage.biomarkers.glrlm.lre(upd_list: ndarray) float[source]

Compute Long runs emphasis feature from the run length matrices list. This feature refers to “Frlm_lre” (ID = W4KF) in the IBSI1 reference manual.

Parameters:

upd_list (ndarray) – Run length matrices computed and merged according given method.

Returns:

Dict of the Long runs emphasis feature.

Return type:

float

MEDimage.biomarkers.glrlm.lrhge(upd_list: ndarray) float[source]

Compute Long run high grey level emphasisfeature from the run length matrices list. This feature refers to “Frlm_lrhge” (ID = 3KUM) in the IBSI1 reference manual.

Parameters:

upd_list (ndarray) – Run length matrices computed and merged according given method.

Returns:

Dict of the Long run high grey level emphasis feature.

Return type:

float

MEDimage.biomarkers.glrlm.lrlge(upd_list: ndarray) float[source]

Compute Long run low grey level emphasis feature from the run length matrices list. This feature refers to “Frlm_lrlge” (ID = IVPO) in the IBSI1 reference manual.

Parameters:

upd_list (ndarray) – Run length matrices computed and merged according given method.

Returns:

Dict of the Long run low grey level emphasis feature.

Return type:

float

MEDimage.biomarkers.glrlm.merge_feature(feat_list: ndarray) float[source]

Merge feature tables into a single dictionary.

Parameters:

feat_list (ndarray) – volume with discretised intensities as 3D numpy array (x, y, z).

Returns:

Dict of the length matrix feature.

Return type:

float

MEDimage.biomarkers.glrlm.r_perc(upd_list: ndarray) float[source]

Compute Run percentage feature from the run length matrices list. This feature refers to “Frlm_r_perc” (ID = 9ZK5) in the IBSI1 reference manual.

Parameters:

upd_list (ndarray) – Run length matrices computed and merged according given method.

Returns:

Dict of the Run percentage feature.

Return type:

float

MEDimage.biomarkers.glrlm.rl_entr(upd_list: ndarray) float[source]

Compute Zone size entropy feature from the run length matrices list. This feature refers to “Frlm_rl_entr” (ID = HJ9O) in the IBSI1 reference manual.

Parameters:

upd_list (ndarray) – Run length matrices computed and merged according given method.

Returns:

Dict of the Zone size entropy feature.

Return type:

float

MEDimage.biomarkers.glrlm.rl_var(upd_list: ndarray) float[source]

Compute Run length variancefeature from the run length matrices list. This feature refers to “Frlm_rl_var” (ID = SXLW) in the IBSI1 reference manual.

Parameters:

upd_list (ndarray) – Run length matrices computed and merged according given method.

Returns:

Dict of the Run length variance feature.

Return type:

float

MEDimage.biomarkers.glrlm.rlnu(upd_list: ndarray) float[source]

Compute Run length non-uniformity feature from the run length matrices list. This feature refers to “Frlm_rlnu” (ID = W92Y) in the IBSI1 reference manual.

Parameters:

upd_list (ndarray) – Run length matrices computed and merged according given method.

Returns:

Dict of the Run length non-uniformity feature.

Return type:

float

MEDimage.biomarkers.glrlm.rlnu_norm(upd_list: ndarray) float[source]

Compute Run length non-uniformity normalised feature from the run length matrices list. This feature refers to “Frlm_rlnu_norm” (ID = IC23) in the IBSI1 reference manual.

Parameters:

upd_list (ndarray) – Run length matrices computed and merged according given method.

Returns:

Dict of the Run length non-uniformity normalised feature.

Return type:

float

MEDimage.biomarkers.glrlm.sre(upd_list: ndarray) float[source]

Compute Short runs emphasis feature from the run length matrices list. This feature refers to “Frlm_sre” (ID = 22OV) in the IBSI1 reference manual.

Parameters:

upd_list (ndarray) – Run length matrices computed and merged according given method.

Returns:

Dict of the Short runs emphasis feature.

Return type:

float

MEDimage.biomarkers.glrlm.srhge(upd_list: ndarray) float[source]

Compute Short run high grey level emphasis feature from the run length matrices list. This feature refers to “Frlm_srhge” (ID = GD3A) in the IBSI1 reference manual.

Parameters:

upd_list (ndarray) – Run length matrices computed and merged according given method.

Returns:

Dict of the Short run high grey level emphasis feature.

Return type:

float

MEDimage.biomarkers.glrlm.srlge(upd_list: ndarray) float[source]

Compute Short run low grey level emphasis feature from the run length matrices list. This feature refers to “Frlm_srlge” (ID = HTZT) in the IBSI1 reference manual.

Parameters:

upd_list (ndarray) – Run length matrices computed and merged according given method.

Returns:

Dict of the Short run low grey level emphasis feature.

Return type:

float

glszm

MEDimage.biomarkers.glszm.extract_all(vol: ndarray, glszm: ndarray | None = None) Dict[source]

Computes glszm features. These features refer to “Grey level size zone based features” (ID = 9SAK) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, isotropically resampled, quantized (e.g. n_g = 32, levels = [1, …, n_g]), with NaNs outside the region of interest.

Returns:

Dict of glszm features.

Return type:

Dict

MEDimage.biomarkers.glszm.get_matrix(roi_only: ndarray, levels: ndarray | List) Dict[source]

This function computes the Gray-Level Size Zone Matrix (GLSZM) of the region of interest (ROI) of an input volume. The input volume is assumed to be isotropically resampled. The zones of different sizes are computed using 26-voxel connectivity. This matrix refers to “Grey level size zone based features” (ID = 9SAK) in the IBSI1 reference manual.

Note

This function is compatible with 2D analysis (language not adapted in the text).

Parameters:
  • roi_only_int (ndarray) – Smallest box containing the ROI, with the imaging data ready for texture analysis computations. Voxels outside the ROI are set to NaNs.

  • levels (ndarray or List) – Vector containing the quantized gray-levels in the tumor region (or reconstruction levels of quantization).

Returns:

Array of Gray-Level Size Zone Matrix of roi_only.

Return type:

ndarray

References

[1] Thibault, G., Fertil, B., Navarro, C., Pereira, S., Cau, P., Levy, N., Mari, J.-L. (2009). Texture Indexes and Gray Level Size Zone Matrix. Application to Cell Nuclei Classification. In Pattern Recognition and Information Processing (PRIP) (pp. 140–145).

MEDimage.biomarkers.glszm.get_single_matrix(vol: ndarray) ndarray[source]

Computes gray level size zone matrix in order to compute the single features.

Parameters:
  • vol_int – 3D volume, isotropically resampled, quantized (e.g. n_g = 32, levels = [1, …, n_g]), with NaNs outside the region of interest.

  • levels – Vector containing the quantized gray-levels in the tumor region (or reconstruction levels of quantization).

Returns:

Array of Gray-Level Size Zone Matrix of ‘vol’.

Return type:

ndarray

MEDimage.biomarkers.glszm.gl_var(glszm: ndarray) float[source]

Computes grey level variance This feature refers to “Fszm_gl_var” (ID = BYLV) in the IBSI1 reference manual.

Parameters:

glszm (ndarray) – array of the gray level size zone matrix

Returns:

the grey level variance feature

Return type:

float

MEDimage.biomarkers.glszm.glnu(glszm: ndarray) float[source]

Computes grey level non-uniformity feature. This feature refers to “Fszm_glnu” (ID = JNSA) in the IBSI1 reference manual.

Parameters:

glszm (ndarray) – array of the gray level size zone matrix

Returns:

the grey level non-uniformity feature

Return type:

float

MEDimage.biomarkers.glszm.glnu_norm(glszm: ndarray) float[source]

Computes grey level non-uniformity normalised This feature refers to “Fszm_glnu_norm” (ID = Y1RO) in the IBSI1 reference manual.

Parameters:

glszm (ndarray) – array of the gray level size zone matrix

Returns:

the grey level non-uniformity normalised feature

Return type:

float

MEDimage.biomarkers.glszm.hgze(glszm: ndarray) float[source]

Computes high grey zone emphasis feature. This feature refers to “Fszm_hgze” (ID = 5GN9) in the IBSI1 reference manual.

Parameters:

glszm (ndarray) – array of the gray level size zone matrix

Returns:

the high grey zone emphasis

Return type:

float

MEDimage.biomarkers.glszm.lgze(glszm: ndarray) float[source]

Computes low grey zone emphasis feature. This feature refers to “Fszm_lgze” (ID = XMSY) in the IBSI1 reference manual.

Parameters:

glszm (ndarray) – array of the gray level size zone matrix

Returns:

the low grey zone emphasis

Return type:

float

MEDimage.biomarkers.glszm.lze(glszm: ndarray) float[source]

Computes large zone emphasis feature. This feature refers to “Fszm_lze” (ID = 48P8) in the IBSI1 reference manual.

Parameters:

glszm (ndarray) – array of the gray level size zone matrix

Returns:

the large zone emphasis

Return type:

float

MEDimage.biomarkers.glszm.lzhge(glszm: ndarray) float[source]

Computes large zone high grey level emphasis feature. This feature refers to “Fszm_lzhge” (ID = J17V) in the IBSI1 reference manual.

Parameters:

glszm (ndarray) – array of the gray level size zone matrix

Returns:

the large zone high grey level emphasis

Return type:

float

MEDimage.biomarkers.glszm.lzlge(glszm: ndarray) float[source]

Computes large zone low grey level emphasis feature. This feature refers to “Fszm_lzlge” (ID = YH51) in the IBSI1 reference manual.

Parameters:

glszm (ndarray) – array of the gray level size zone matrix

Returns:

the large zone low grey level emphasis

Return type:

float

MEDimage.biomarkers.glszm.sze(glszm: ndarray) float[source]

Computes small zone emphasis feature. This feature refers to “Fszm_sze” (ID = 5QRC) in the IBSI1 reference manual.

Parameters:

glszm (ndarray) – array of the gray level size zone matrix

Returns:

the small zone emphasis

Return type:

float

MEDimage.biomarkers.glszm.szhge(glszm: ndarray) float[source]

Computes small zone high grey level emphasis feature. This feature refers to “Fszm_szhge” (ID = HW1V) in the IBSI1 reference manual.

Parameters:

glszm (ndarray) – array of the gray level size zone matrix

Returns:

the small zone high grey level emphasis

Return type:

float

MEDimage.biomarkers.glszm.szlge(glszm: ndarray) float[source]

Computes small zone low grey level emphasis feature. This feature refers to “Fszm_szlge” (ID = 5RAI) in the IBSI1 reference manual.

Parameters:

glszm (ndarray) – array of the gray level size zone matrix

Returns:

the small zone low grey level emphasis

Return type:

float

MEDimage.biomarkers.glszm.z_perc(glszm: ndarray) float[source]

Computes zone percentage This feature refers to “Fszm_z_perc” (ID = P30P) in the IBSI1 reference manual.

Parameters:

glszm (ndarray) – array of the gray level size zone matrix

Returns:

the zone percentage feature

Return type:

float

MEDimage.biomarkers.glszm.zs_entr(glszm: ndarray) float[source]

Computes zone size entropy This feature refers to “Fszm_zs_entr” (ID = GU8N) in the IBSI1 reference manual.

Parameters:

glszm (ndarray) – array of the gray level size zone matrix

Returns:

the zone size entropy feature

Return type:

float

MEDimage.biomarkers.glszm.zs_var(glszm: ndarray) float[source]

Computes zone size variance This feature refers to “Fszm_zs_var” (ID = 3NSA) in the IBSI1 reference manual.

Parameters:

glszm (ndarray) – array of the gray level size zone matrix

Returns:

the zone size variance feature

Return type:

float

MEDimage.biomarkers.glszm.zsnu(glszm: ndarray) float[source]

Computes zone size non-uniformity This feature refers to “Fszm_zsnu” (ID = 4JP3) in the IBSI1 reference manual.

Parameters:

glszm (ndarray) – array of the gray level size zone matrix

Returns:

the zone size non-uniformity feature

Return type:

float

MEDimage.biomarkers.glszm.zsnu_norm(glszm: ndarray) float[source]

Computes zone size non-uniformity normalised This feature refers to “Fszm_zsnu_norm” (ID = VB3A) in the IBSI1 reference manual.

Parameters:

glszm (ndarray) – array of the gray level size zone matrix

Returns:

the zone size non-uniformity normalised feature

Return type:

float

int_vol_hist

MEDimage.biomarkers.int_vol_hist.auc(vol: ndarray, vol_int_re: ndarray, wd: int, ivh: Dict | None = None, im_range: ndarray | None = None, medscan: MEDscan | None = None) float[source]

Computes Area under IVH curve. This feature refers to “Fivh_auc” (ID = 9CMM) in the IBSI1 reference manual.

Note

For the input volume:

  • Naturally discretised volume can be kept as it is (e.g. HU values of CT scans)

  • All other volumes with continuous intensity distribution should be quantized (e.g., nBins = 100), with levels = [min, …, max]

Parameters:
  • vol (ndarray) – 3D volume, QUANTIZED, with NaNs outside the region of interest

  • vol_int_re (ndarray) – 3D volume, with NaNs outside the region of interest

  • wd (int) – Discretisation width.

  • ivh (Dict, optional) – Dict of the Intensity-volume Histogram parameters (Discretization algo and value).

  • im_range (ndarray, optional) – The intensity range.

  • medscan (MEDscan, optional) – MEDscan instance containing processing parameters.

Returns:

Area under IVH curve feature.

Return type:

float

MEDimage.biomarkers.int_vol_hist.extract_all(vol: ndarray, vol_int_re: ndarray, wd: int, ivh: Dict | None = None, im_range: ndarray | None = None, medscan: MEDscan | None = None) Dict[source]

Computes Intensity-volume Histogram Features. This features refer to Intensity-volume histogram family in the IBSI1 reference manual.

Note

For the input volume, naturally discretised volume can be kept as it is (e.g. HU values of CT scans). All other volumes with continuous intensity distribution should be quantized (e.g., nBins = 100), with levels = [min, …, max]

Parameters:
  • vol (ndarray) – 3D volume, QUANTIZED, with NaNs outside the region of interest

  • vol_int_re (ndarray) – 3D volume, with NaNs outside the region of interest

  • wd (int) – Discretisation width.

  • ivh (Dict, optional) – Dict of the Intensity-volume Histogram parameters (Discretization algo and value).

  • im_range (ndarray, optional) – The intensity range.

  • medscan (MEDscan, optional) – MEDscan instance containing processing parameters.

Returns:

Dict of the Intensity Histogram Features.

Return type:

Dict

MEDimage.biomarkers.int_vol_hist.i10(vol: ndarray, vol_int_re: ndarray, wd: int, ivh: Dict | None = None, im_range: ndarray | None = None, medscan: MEDscan | None = None) float[source]

Computes Intensity at volume fraction 10 feature. This feature refers to “Fivh_I10” (ID = GBPN) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, QUANTIZED, with NaNs outside the region of interest

  • vol_int_re (ndarray) – 3D volume, with NaNs outside the region of interest

  • wd (int) – Discretisation width.

  • ivh (Dict, optional) – Dict of the Intensity-volume Histogram parameters (Discretization algo and value).

  • im_range (ndarray, optional) – The intensity range.

  • medscan (MEDscan, optional) – MEDscan instance containing processing parameters.

Returns:

Intensity at volume fraction 10 feature.

Return type:

float

MEDimage.biomarkers.int_vol_hist.i10_minus_i90(vol: ndarray, vol_int_re: ndarray, wd: int, ivh: Dict | None = None, im_range: ndarray | None = None, medscan: MEDscan | None = None) float[source]

Computes Intensity at volume fraction difference i10-i90 This feature refers to “Fivh_I10minusI90” (ID = CNV2) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, QUANTIZED, with NaNs outside the region of interest

  • vol_int_re (ndarray) – 3D volume, with NaNs outside the region of interest

  • wd (int) – Discretisation width.

  • ivh (Dict, optional) – Dict of the Intensity-volume Histogram parameters (Discretization algo and value).

  • im_range (ndarray, optional) – The intensity range.

  • medscan (MEDscan, optional) – MEDscan instance containing processing parameters.

Returns:

Intensity at volume fraction difference i10-i90 feature.

Return type:

float

MEDimage.biomarkers.int_vol_hist.i90(vol: ndarray, vol_int_re: ndarray, wd: int, ivh: Dict | None = None, im_range: ndarray | None = None, medscan: MEDscan | None = None) float[source]

Computes Intensity at volume fraction 90 feature. This feature refers to “Fivh_I90” (ID = GBPN) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, QUANTIZED, with NaNs outside the region of interest

  • vol_int_re (ndarray) – 3D volume, with NaNs outside the region of interest

  • wd (int) – Discretisation width.

  • ivh (Dict, optional) – Dict of the Intensity-volume Histogram parameters (Discretization algo and value).

  • im_range (ndarray, optional) – The intensity range.

  • medscan (MEDscan, optional) – MEDscan instance containing processing parameters.

Returns:

Intensity at volume fraction 90 feature.

Return type:

float

MEDimage.biomarkers.int_vol_hist.init_ivh(vol: ndarray, vol_int_re: ndarray, wd: int, ivh: Dict | None = None, im_range: ndarray | None = None, medscan: MEDscan | None = None) Tuple[ndarray, ndarray, int, int][source]

Computes Intensity-volume Histogram Features.

Note

For the input volume:

  • Naturally discretised volume can be kept as it is (e.g. HU values of CT scans)

  • All other volumes with continuous intensity distribution should be quantized (e.g., nBins = 100), with levels = [min, …, max]

Parameters:
  • vol (ndarray) – 3D volume, QUANTIZED, with NaNs outside the region of interest

  • vol_int_re (ndarray) – 3D volume, with NaNs outside the region of interest

  • wd (int) – Discretisation width.

  • ivh (Dict, optional) – Dict of the Intensity-volume Histogram parameters (Discretization algo and value).

  • im_range (ndarray, optional) – The intensity range.

  • medscan (MEDscan, optional) – MEDscan instance containing processing parameters.

Returns:

Dict of the Intensity Histogram Features.

Return type:

Dict

MEDimage.biomarkers.int_vol_hist.v10(vol: ndarray, vol_int_re: ndarray, wd: int, ivh: Dict | None = None, im_range: ndarray | None = None, medscan: MEDscan | None = None) float[source]

Computes Volume at intensity fraction 10 feature. This feature refers to “Fivh_V10” (ID = BC2M) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, QUANTIZED, with NaNs outside the region of interest

  • vol_int_re (ndarray) – 3D volume, with NaNs outside the region of interest

  • wd (int) – Discretisation width.

  • ivh (Dict, optional) – Dict of the Intensity-volume Histogram parameters (Discretization algo and value).

  • im_range (ndarray, optional) – The intensity range.

  • medscan (MEDscan, optional) – MEDscan instance containing processing parameters.

Returns:

Volume at intensity fraction 10 feature.

Return type:

float

MEDimage.biomarkers.int_vol_hist.v10_minus_v90(vol: ndarray, vol_int_re: ndarray, wd: int, ivh: Dict | None = None, im_range: ndarray | None = None, medscan: MEDscan | None = None) float[source]

Computes Volume at intensity fraction difference v10-v90 This feature refers to “Fivh_V10minusV90” (ID = DDTU) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, QUANTIZED, with NaNs outside the region of interest

  • vol_int_re (ndarray) – 3D volume, with NaNs outside the region of interest

  • wd (int) – Discretisation width.

  • ivh (Dict, optional) – Dict of the Intensity-volume Histogram parameters (Discretization algo and value).

  • im_range (ndarray, optional) – The intensity range.

  • medscan (MEDscan, optional) – MEDscan instance containing processing parameters.

Returns:

Volume at intensity fraction difference v10-v90 feature.

Return type:

float

MEDimage.biomarkers.int_vol_hist.v90(vol: ndarray, vol_int_re: ndarray, wd: int, ivh: Dict | None = None, im_range: ndarray | None = None, medscan: MEDscan | None = None) float[source]

Computes Volume at intensity fraction 90 feature. This feature refers to “Fivh_V90” (ID = BC2M) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, QUANTIZED, with NaNs outside the region of interest

  • vol_int_re (ndarray) – 3D volume, with NaNs outside the region of interest

  • wd (int) – Discretisation width.

  • ivh (Dict, optional) – Dict of the Intensity-volume Histogram parameters (Discretization algo and value).

  • im_range (ndarray, optional) – The intensity range.

  • medscan (MEDscan, optional) – MEDscan instance containing processing parameters.

Returns:

Volume at intensity fraction 90 feature.

Return type:

float

intensity_histogram

MEDimage.biomarkers.intensity_histogram.cov(vol: ndarray) float[source]

Compute Intensity histogram coefficient of variation feature of the input dataset (3D Array). This feature refers to “Fih_cov” (ID = CWYJ) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

Intensity histogram coefficient of variation feature.

Return type:

float

MEDimage.biomarkers.intensity_histogram.entropy(vol: ndarray) float[source]

Compute Intensity histogram entropy feature of the input dataset (3D Array). This feature refers to “Fih_entropy” (ID = TLU2) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

Intensity histogram entropy feature.

Return type:

float

MEDimage.biomarkers.intensity_histogram.extract_all(vol: ndarray) Dict[source]

Computes Intensity Histogram Features. These features refer to Intensity histogram family in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, QUANTIZED (e.g. nBins = 100, levels = [1, …, max]), with NaNs outside the region of interest.

Returns:

Dict of the Intensity Histogram Features.

Return type:

Dict

MEDimage.biomarkers.intensity_histogram.hist_grad_calc(vol: ndarray) ndarray[source]

Calculation of histogram gradient. This feature refers to “Fih_hist_grad_calc” (ID = 12CE) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

Histogram gradient

Return type:

ndarray

MEDimage.biomarkers.intensity_histogram.init_IH(vol: ndarray) Tuple[ndarray, ndarray, int, ndarray, ndarray][source]

Initialize Intensity Histogram Features.

Parameters:

vol (ndarray) – 3D volume, QUANTIZED (e.g. nBins = 100, levels = [1, …, max]), with NaNs outside the region of interest.

Returns:

Dict of the Intensity Histogram Features.

Return type:

Dict

MEDimage.biomarkers.intensity_histogram.iqrange(vol: ndarray) float[source]

Compute Intensity histogram interquantile range feature of the input dataset (3D Array). This feature refers to “Fih_iqr” (ID = WR0O) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

Interquartile range. If \(axis ≠ None\) , the output data-type is the same as that of the input. Since x goes from \(1:max(x)\) , all with integer values, the result is an integer.

Return type:

float

MEDimage.biomarkers.intensity_histogram.kurt(vol: ndarray) float[source]

Compute Intensity histogram kurtosis feature of the input dataset (3D Array). This feature refers to “Fih_kurt” (ID = C3I7) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

The Intensity histogram kurtosis feature

Return type:

float

MEDimage.biomarkers.intensity_histogram.mad(vol: ndarray) float[source]

Compute Intensity histogram mean absolute deviation feature of the input dataset (3D Array). This feature refers to “Fih_mad” (ID = D2ZX) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

Intensity histogram mean absolute deviation feature.

Return type:

float

MEDimage.biomarkers.intensity_histogram.max(vol: ndarray) float[source]

Compute Intensity histogram maximum grey level feature of the input dataset (3D Array). This feature refers to “Fih_max” (ID = 3NCY) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

Intensity histogram maximum grey level feature.

Return type:

float

MEDimage.biomarkers.intensity_histogram.max_grad(vol: ndarray) float[source]

Calculation of Maximum histogram gradient feature. This feature refers to “Fih_max_grad” (ID = 12CE) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

Maximum histogram gradient feature.

Return type:

float

MEDimage.biomarkers.intensity_histogram.max_grad_gl(vol: ndarray) float[source]

Calculation of Maximum histogram gradient grey level feature. This feature refers to “Fih_max_grad_gl” (ID = 8E6O) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

Maximum histogram gradient grey level feature.

Return type:

float

MEDimage.biomarkers.intensity_histogram.mean(vol: ndarray) float[source]

Compute Intensity histogram mean feature of the input dataset (3D Array). This feature refers to “Fih_mean” (ID = X6K6) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

Intensity histogram mean

Return type:

float

MEDimage.biomarkers.intensity_histogram.medad(vol: ndarray) float[source]

Intensity histogram median absolute deviation feature of the input dataset (3D Array). This feature refers to “Fih_medad” (ID = 4RNL) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

Intensity histogram median absolute deviation feature.

Return type:

float

MEDimage.biomarkers.intensity_histogram.median(vol: ndarray) float[source]

Compute Intensity histogram median feature along the specified axis of the input dataset (3D Array). This feature refers to “Fih_median” (ID = WIFQ) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

Intensity histogram median feature.

Return type:

float

MEDimage.biomarkers.intensity_histogram.min(vol: ndarray) float[source]

Compute Intensity histogram minimum grey level feature of the input dataset (3D Array). This feature refers to “Fih_min” (ID = 1PR8) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

Intensity histogram minimum grey level feature.

Return type:

float

MEDimage.biomarkers.intensity_histogram.min_grad(vol: ndarray) float[source]

Calculation of Minimum histogram gradient feature. This feature refers to “Fih_min_grad” (ID = VQB3) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

Minimum histogram gradient feature.

Return type:

float

MEDimage.biomarkers.intensity_histogram.min_grad_gl(vol: ndarray) float[source]

Calculation of Minimum histogram gradient grey level feature. This feature refers to “Fih_min_grad_gl” (ID = RHQZ) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

Minimum histogram gradient grey level feature.

Return type:

float

MEDimage.biomarkers.intensity_histogram.mode(vol: ndarray) int[source]

Compute Intensity histogram mode feature of the input dataset (3D Array). This feature refers to “Fih_mode” (ID = AMMC) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

Intensity histogram mode. levels = 1:max(x), so the index of the ith bin of h is the same as i

Return type:

integer

MEDimage.biomarkers.intensity_histogram.p10(vol: ndarray) float[source]

Compute Intensity histogram 10th percentile feature of the input dataset (3D Array). This feature refers to “Fih_P10” (ID = GPMT) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

Intensity histogram 10th percentile feature.

Return type:

float

MEDimage.biomarkers.intensity_histogram.p90(vol: ndarray) float[source]

Compute Intensity histogram 90th percentile feature of the input dataset (3D Array). This feature refers to “Fih_P90” (ID = OZ0C) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

Intensity histogram 90th percentile feature.

Return type:

float

MEDimage.biomarkers.intensity_histogram.qcod(vol: ndarray) float[source]

Compute the quartile coefficient of dispersion feature of the input dataset (3D Array). This feature refers to “Fih_qcod” (ID = SLWD) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

A new array holding the quartile coefficient of dispersion feature.

Return type:

ndarray

MEDimage.biomarkers.intensity_histogram.range(vol: ndarray) float[source]

Compute Intensity histogram range of values (maximum - minimum) feature of the input dataset (3D Array). This feature refers to “Fih_range” (ID = 5Z3W) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

Intensity histogram range.

Return type:

float

MEDimage.biomarkers.intensity_histogram.rmad(vol: ndarray) float[source]

Compute Intensity histogram robust mean absolute deviation feature of the input dataset (3D Array). This feature refers to “Fih_rmad” (ID = WRZB) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

  • P10 (ndarray) – Score at 10th percentil.

  • P90 (ndarray) – Score at 90th percentil.

Returns:

Intensity histogram robust mean absolute deviation

Return type:

float

MEDimage.biomarkers.intensity_histogram.skewness(vol: ndarray) float[source]

Compute Intensity histogram skewness feature of the input dataset (3D Array). This feature refers to “Fih_skew” (ID = 88K1) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

Intensity histogram skewness.

Return type:

float

MEDimage.biomarkers.intensity_histogram.uniformity(vol: ndarray) float[source]

Compute Intensity histogram uniformity feature of the input dataset (3D Array). This feature refers to “Fih_uniformity” (ID = BJ5W) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

Intensity histogram uniformity feature.

Return type:

float

MEDimage.biomarkers.intensity_histogram.var(vol: ndarray) float[source]

Compute Intensity histogram variance feature of the input dataset (3D Array). This feature refers to “Fih_var” (ID = CH89) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

Intensity histogram variance

Return type:

float

local_intensity

MEDimage.biomarkers.local_intensity.extract_all(img_obj: ndarray, roi_obj: ndarray, res: ndarray, intensity_type: str, compute_global: bool = False) Dict[source]

Compute Local Intensity Features. This features refer to Local Intensity family in the IBSI1 reference manual.

Parameters:
  • img_obj (ndarray) – Continuous image intensity distribution, with no NaNs outside the ROI.

  • roi_obj (ndarray) – Array of the mask defining the ROI.

  • res (List[float]) – [a,b,c] vector specifying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

  • intensity_type (str) – Type of intensity to compute. Can be “arbitrary”, “definite” or “filtered”. Will compute features only for “definite” intensity type.

  • compute_global (bool, optional) – If True, will compute global intensity peak, we recommend you don’t set it to True if not necessary in your study or analysis as it takes too much time for calculation. Default: False.

Returns:

Dict of the Local Intensity Features.

Return type:

Dict

Raises:

ValueError – If intensity_type is not “arbitrary”, “definite” or “filtered”.

MEDimage.biomarkers.local_intensity.peak_global(img_obj: ndarray, roi_obj: ndarray, res: ndarray) float[source]

Computes global intensity peak. This feature refers to “Floc_peak_global” (ID = 0F91) in the IBSI1 reference manual.

Parameters:
  • img_obj (ndarray) – Continuous image intensity distribution, with no NaNs outside the ROI.

  • roi_obj (ndarray) – Array of the mask defining the ROI.

  • res (List[float]) – [a,b,c] vector specifying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Global intensity peak.

Return type:

float

MEDimage.biomarkers.local_intensity.peak_local(img_obj: ndarray, roi_obj: ndarray, res: ndarray) float[source]

Computes local intensity peak. This feature refers to “Floc_peak_local” (ID = VJGA) in the IBSI1 reference manual.

Parameters:
  • img_obj (ndarray) – Continuous image intensity distribution, with no NaNs outside the ROI.

  • roi_obj (ndarray) – Array of the mask defining the ROI.

  • res (List[float]) – [a,b,c] vector specifying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Local intensity peak.

Return type:

float

morph

MEDimage.biomarkers.morph.a_dens_aabb(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray) float[source]

Computes Area density - axis-aligned bounding box feature. This feature refers to “Fmorph_a_dens_aabb” (ID = R59B) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the Area density - axis-aligned bounding box feature.

Return type:

float

MEDimage.biomarkers.morph.a_dens_aee(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray) float[source]

Computes Area density - approximate enclosing ellipsoid feature. This feature refers to “Fmorph_a_dens_aee” (ID = RDD2) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the Area density - approximate enclosing ellipsoid feature.

Return type:

float

MEDimage.biomarkers.morph.a_dens_conv_hull(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray) float[source]

Computes Area density - convex hull feature. This feature refers to “Fmorph_a_dens_conv_hull” (ID = 7T7F) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the Area density - convex hull feature.

Return type:

float

MEDimage.biomarkers.morph.a_dens_mvee(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray) float[source]

Computes Area density - minimum volume enclosing ellipsoid feature. Subsequent singular value decomposition of matrix A and and taking the inverse of the square root of the diagonal of the sigma matrix will produce respective semi-axis lengths. Subsequent singular value decomposition of matrix A and taking the inverse of the square root of the diagonal of the sigma matrix will produce respective semi-axis lengths. This feature refers to “Fmorph_a_dens_mvee” (ID = BRI8) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the Area density - minimum volume enclosing ellipsoid feature.

Return type:

float

MEDimage.biomarkers.morph.a_dens_ombb(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray) float[source]

Computes Area density - oriented minimum bounding box feature. Implementation of Chan and Tan’s algorithm (C.K. Chan, S.T. Tan. Determination of the minimum bounding box of an arbitrary solid: an iterative approach. This feature refers to “Fmorph_a_dens_ombb” (ID = IQYR) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the Area density - oriented minimum bounding box feature.

Return type:

float

MEDimage.biomarkers.morph.approx_vol(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray) float[source]

Computes morphological approximate volume feature. This feature refers to “Fmorph_approx_vol” (ID = YEKZ) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the morphological approximate volume feature.

Return type:

float

MEDimage.biomarkers.morph.area(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray) float[source]

Computes Surface area feature. This feature refers to “Fmorph_area” (ID = COJJK) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the surface area feature.

Return type:

float

MEDimage.biomarkers.morph.asphericity(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray) float[source]

Computes Asphericity feature. This feature refers to “Fmorph_asphericity” (ID = 25C) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the Asphericity feature.

Return type:

float

MEDimage.biomarkers.morph.av(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray) float[source]

Computes Surface to volume ratio feature. This feature refers to “Fmorph_av” (ID = 2PR5) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the Surface to volume ratio feature.

Return type:

float

MEDimage.biomarkers.morph.com(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray) float[source]

Computes Centre of mass shift feature. This feature refers to “Fmorph_com” (ID = KLM) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the Centre of mass shift feature.

Return type:

float

MEDimage.biomarkers.morph.comp_1(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray) float[source]

Computes Compactness 1 feature. This feature refers to “Fmorph_comp_1” (ID = SKGS) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the Compactness 1 feature.

Return type:

float

MEDimage.biomarkers.morph.comp_2(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray) float[source]

Computes Compactness 2 feature. This feature refers to “Fmorph_comp_2” (ID = BQWJ) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the Compactness 2 feature.

Return type:

float

MEDimage.biomarkers.morph.diam(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray) float[source]

Computes Maximum 3D diameter feature. This feature refers to “Fmorph_diam” (ID = L0JK) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the Maximum 3D diameter feature.

Return type:

float

MEDimage.biomarkers.morph.extract_all(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray, intensity_type: str, compute_moran_i: bool = False, compute_geary_c: bool = False) Dict[source]

Compute Morphological Features. This features refer to Morphological family in the IBSI1 reference manual.

Note

Moran’s Index and Geary’s C measure takes so much computation time. Please use compute_moran_i compute_geary_c carefully.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

  • intensity_type (str) – Type of intensity to compute. Can be “arbitrary”, “definite” or “filtered”. Will compute all features for “definite” intensity type and all but intergrated intensity for “arbitrary” intensity type.

  • compute_moran_i (bool, optional) – True to compute Moran’s Index.

  • compute_geary_c (bool, optional) – True to compute Geary’s C measure.

Raises:

ValueError – If intensity_type is not “arbitrary”, “definite” or “filtered”.

MEDimage.biomarkers.morph.geary_c(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray, compute_geary_c: bool = False) float[source]

Computes Geary’s C measure feature. This feature refers to “Fmorph_geary_c” (ID = NPT7) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

  • compute_geary_c (bool, optional) – True to compute Geary’s C measure.

Returns:

Value of the Geary’s C measure feature.

Return type:

float

MEDimage.biomarkers.morph.get_area_dens_approx(a: float, b: float, c: float, n: float) float[source]

Computes area density - minimum volume enclosing ellipsoid

Parameters:
  • a (float) – Major semi-axis length.

  • b (float) – Minor semi-axis length.

  • c (float) – Least semi-axis length.

  • n (int) – Number of iterations.

Returns:

Area density - minimum volume enclosing ellipsoid.

Return type:

float

MEDimage.biomarkers.morph.get_axis_lengths(xyz: ndarray) Tuple[float, float, float][source]

Computes AxisLengths.

Parameters:

xyz (ndarray) – Array of three column vectors, defining the [X,Y,Z] positions of the points in the ROI (1’s) of the mask volume. In mm.

Returns:

Array of three column vectors [Major axis lengths, Minor axis lengths, Least axis lengths].

Return type:

Tuple[float, float, float]

MEDimage.biomarkers.morph.get_com(xgl_int: ndarray, xgl_morph: ndarray, xyz_int: ndarray, xyz_morph: ndarray) float | ndarray[source]

Calculates center of mass shift (in mm, since resolution is in mm).

Note

Row positions of “x_gl” and “xyz” must correspond for each point.

Parameters:
  • xgl_int (ndarray) – Vector of intensity values in the volume to analyze (only values in the intensity mask).

  • xgl_morph (ndarray) – Vector of intensity values in the volume to analyze (only values in the morphological mask).

  • xyz_int (ndarray) – [n_points X 3] matrix of three column vectors, defining the [X,Y,Z] positions of the points in the ROI (1’s) of the mask volume (In mm). (Mesh-based volume calculated from the ROI intensity mesh)

  • xyz_morph (ndarray) – [n_points X 3] matrix of three column vectors, defining the [X,Y,Z] positions of the points in the ROI (1’s) of the mask volume (In mm). (Mesh-based volume calculated from the ROI morphological mesh)

Returns:

The ROI volume centre of mass.

Return type:

Union[float, np.ndarray]

MEDimage.biomarkers.morph.get_geary_c(vol: ndarray, res: ndarray) float[source]

Computes Geary’C measure (Assesses intensity differences between voxels). This feature refers to “Geary’s C measure” (ID = NPT7) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm.

Returns:

computes value of Geary’C measure.

Return type:

float

MEDimage.biomarkers.morph.get_mesh(mask: ndarray, res: ndarray | List) Tuple[ndarray, ndarray, ndarray][source]

Compute Mesh.

Note

Make sure the mask is padded with a layer of 0’s in all dimensions to reduce potential isosurface computation errors.

Parameters:
  • mask (ndarray) – Contains only 0’s and 1’s.

  • res (ndarray or List) – [a,b,c] vector specifying the resolution of the volume in mm. xyz resolution (world), or JIK resolution (intrinsic matlab).

Returns:

  • Array of the [X,Y,Z] positions of the ROI.

  • Array of the spatial coordinates for mask unique mesh vertices.

  • Array of triangular faces via referencing vertex indices from vertices.

Return type:

Tuple[np.ndarray, np.ndarray, np.ndarray]

MEDimage.biomarkers.morph.get_mesh_area(faces: ndarray, vertices: ndarray) float[source]

Computes the surface area (mesh) feature from the ROI mesh by summing over the triangular face surface areas. This feature refers to “Surface area (mesh)” (ID = C0JK) in the IBSI1 reference manual.

Parameters:
  • faces (np.ndarray) – matrix of three column vectors, defining the [X,Y,Z] positions of the faces of the isosurface or convex hull of the mask (output from “isosurface.m” or “convhull.m” functions of MATLAB). –> These are more precisely indexes to vertices

  • vertices (np.ndarray) – matrix of three column vectors, defining the [X,Y,Z] positions of the vertices of the isosurface of the mask (output from “isosurface.m” function of MATLAB). –> In mm.

Returns:

Mesh area.

Return type:

float

MEDimage.biomarkers.morph.get_mesh_volume(faces: ndarray, vertices: ndarray) float[source]

Computes MeshVolume feature. This feature refers to “Volume (mesh)” (ID = RNU0) in the IBSI1 reference manual.

Parameters:
  • faces (np.ndarray) – matrix of three column vectors, defining the [X,Y,Z] positions of the faces of the isosurface or convex hull of the mask (output from “isosurface.m” or “convhull.m” functions of MATLAB). –> These are more precisely indexes to vertices

  • vertices (np.ndarray) – matrix of three column vectors, defining the [X,Y,Z] positions of the vertices of the isosurface of the mask (output from “isosurface.m” function of MATLAB). –> In mm.

Returns:

Mesh volume

Return type:

float

MEDimage.biomarkers.morph.get_moran_i(vol: ndarray, res: List[float]) float[source]

Computes Moran’s Index. This feature refers to “Moran’s I index” (ID = N365) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • res (List[float]) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world) or JIK resolution (intrinsic matlab).

Returns:

Value of Moran’s Index.

Return type:

float

MEDimage.biomarkers.morph.get_variables(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray) Tuple[ndarray, ndarray, ndarray, ndarray, ndarray, ndarray, ndarray][source]

Compute variables usefull to calculate morphological features.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Variables usefull to calculate morphological features.

Return type:

tuple of 7 ndarray

MEDimage.biomarkers.morph.integ_int(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray) float[source]

Computes Integrated intensity feature. This feature refers to “Fmorph_integ_int” (ID = 99N0) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the Integrated intensity feature.

Return type:

float

MEDimage.biomarkers.morph.min_oriented_bound_box(pos_mat: ndarray) ndarray[source]

Computes the minimum bounding box of an arbitrary solid: an iterative approach. This feature refers to “Volume density (oriented minimum bounding box)” (ID = ZH1A) in the IBSI1 reference manual.

Parameters:

pos_mat (ndarray) – matrix position

Returns:

return bounding box dimensions

Return type:

ndarray

MEDimage.biomarkers.morph.min_vol_ellipse(P: ndarray, tolerance: ndarray) Tuple[ndarray, ndarray][source]

Computes min_vol_ellipse.

Finds the minimum volume enclsing ellipsoid (MVEE) of a set of data points stored in matrix P. The following optimization problem is solved:

minimize $$log(det(A))$$ subject to $$(P_i - c)’ * A * (P_i - c) <= 1$$

in variables A and c, where P_i is the i-th column of the matrix P. The solver is based on Khachiyan Algorithm, and the final solution is different from the optimal value by the pre-spesified amount of tolerance.

Note

Adapted from MATLAB code of Nima Moshtagh (nima@seas.upenn.edu) University of Pennsylvania.

Parameters:
  • P (ndarray) – (d x N) dimnesional matrix containing N points in R^d.

  • tolerance (ndarray) – error in the solution with respect to the optimal value.

Returns:

2-element tuple containing

  • A: (d x d) matrix of the ellipse equation in the ‘center form’: $$(x-c)’ * A * (x-c) = 1$$ where d is shape of P along 0-axis.

  • c: d-dimensional vector as the center of the ellipse.

Examples

>>>P = rand(5,100)

>>>[A, c] = min_vol_ellipse(P, .01)()

To reduce the computation time, work with the boundary points only:

>>>K = convhulln(P)()

>>>K = unique(K(:))()

>>>Q = P(:,K)()

>>>[A, c] = min_vol_ellipse(Q, .01)()

MEDimage.biomarkers.morph.moran_i(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray, compute_moran_i: bool = False) float[source]

Computes Moran’s I index feature. This feature refers to “Fmorph_moran_i” (ID = N365) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

  • compute_moran_i (bool, optional) – True to compute Moran’s Index.

Returns:

Value of the Moran’s I index feature.

Return type:

float

MEDimage.biomarkers.morph.padding(vol: ndarray, mask_int: ndarray, mask_morph: ndarray) Tuple[ndarray, ndarray, ndarray][source]

Padding the volume and masks.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

Returns:

Volume and masks after padding.

Return type:

tuple of 3 ndarray

MEDimage.biomarkers.morph.pca_elongation(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray) float[source]

Computes Elongation feature. This feature refers to “Fmorph_pca_elongation” (ID = Q3CK) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the Elongation feature.

Return type:

float

MEDimage.biomarkers.morph.pca_flatness(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray) float[source]

Computes Flatness feature. This feature refers to “Fmorph_pca_flatness” (ID = N17B) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the Flatness feature.

Return type:

float

MEDimage.biomarkers.morph.pca_least(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray) float[source]

Computes Least axis length feature. This feature refers to “Fmorph_pca_least” (ID = 7J51) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the Least axis length feature.

Return type:

float

MEDimage.biomarkers.morph.pca_major(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray) float[source]

Computes Major axis length feature. This feature refers to “Fmorph_pca_major” (ID = TDIC) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the Major axis length feature.

Return type:

float

MEDimage.biomarkers.morph.pca_minor(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray) float[source]

Computes Minor axis length feature. This feature refers to “Fmorph_pca_minor” (ID = P9VJ) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the Minor axis length feature.

Return type:

float

MEDimage.biomarkers.morph.sph_dispr(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray) float[source]

Computes Spherical disproportion feature. This feature refers to “Fmorph_sph_dispr” (ID = KRCK) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the Spherical disproportion feature.

Return type:

float

MEDimage.biomarkers.morph.sphericity(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray) float[source]

Computes Sphericity feature. This feature refers to “Fmorph_sphericity” (ID = QCFX) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the Sphericity feature.

Return type:

float

MEDimage.biomarkers.morph.v_dens_aabb(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray) float[source]

Computes Volume density - axis-aligned bounding box feature. This feature refers to “Fmorph_v_dens_aabb” (ID = PBX1) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the Volume density - axis-aligned bounding box feature.

Return type:

float

MEDimage.biomarkers.morph.v_dens_aee(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray) float[source]

Computes Volume density - approximate enclosing ellipsoid feature. This feature refers to “Fmorph_v_dens_aee” (ID = 6BDE) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the Volume density - approximate enclosing ellipsoid feature.

Return type:

float

MEDimage.biomarkers.morph.v_dens_conv_hull(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray) float[source]

Computes Volume density - convex hull feature. This feature refers to “Fmorph_v_dens_conv_hull” (ID = R3ER) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the Volume density - convex hull feature.

Return type:

float

MEDimage.biomarkers.morph.v_dens_mvee(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray) float[source]

Computes Volume density - minimum volume enclosing ellipsoid feature. Subsequent singular value decomposition of matrix A and and taking the inverse of the square root of the diagonal of the sigma matrix will produce respective semi-axis lengths. Subsequent singular value decomposition of matrix A and taking the inverse of the square root of the diagonal of the sigma matrix will produce respective semi-axis lengths. This feature refers to “Fmorph_v_dens_mvee” (ID = SWZ1) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the Volume density - minimum volume enclosing ellipsoid feature.

Return type:

float

MEDimage.biomarkers.morph.v_dens_ombb(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray) float[source]

Computes Volume density - oriented minimum bounding box feature. Implementation of Chan and Tan’s algorithm (C.K. Chan, S.T. Tan. Determination of the minimum bounding box of an arbitrary solid: an iterative approach. Comp Struc 79 (2001) 1433-1449. This feature refers to “Fmorph_v_dens_ombb” (ID = ZH1A) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the Volume density - oriented minimum bounding box feature.

Return type:

float

MEDimage.biomarkers.morph.vol(vol: ndarray, mask_int: ndarray, mask_morph: ndarray, res: ndarray) float[source]

Computes morphological volume feature. This feature refers to “Fmorph_vol” (ID = RNUO) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, continous imaging intensity distribution.

  • mask_int (ndarray) – Intensity mask.

  • mask_morph (ndarray) – Morphological mask.

  • res (ndarray) – [a,b,c] vector specfying the resolution of the volume in mm. XYZ resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the morphological volume feature.

Return type:

float

ngldm

class MEDimage.biomarkers.ngldm.GreyLevelDependenceMatrix(distance: float, diff_lvl: float, spatial_method: str, img_slice: ndarray | None = None, matrix: ndarray | None = None, n_v: float | None = None)[source]

Bases: object

__init__(distance: float, diff_lvl: float, spatial_method: str, img_slice: ndarray | None = None, matrix: ndarray | None = None, n_v: float | None = None) None[source]

Initialising function for a new neighbouring grey level dependence matrix.

Parameters:
  • distance (float) – chebyshev distance used to determine the local neighbourhood.

  • diff_lvl (float) – coarseness parameter which determines which intensities are considered similar.

  • spatial_method (str) – spatial method used to calculate the ngldm: 2d, 2.5d or 3d

  • img_slice (ndarray) – corresponding slice index (only if the ngldm corresponds to a 2d image slice)

  • matrix (ndarray) – the actual ngldm in sparse format (row, column, count)

  • n_v (float) – the number of voxels in the volume

calculate_ngldm_matrix(df_img: DataFrame, img_dims: int)[source]

Function that calculates an ngldm for the settings provided during initialisation and the input image.

Parameters:
  • df_img (pd.DataFrame) – data table containing image intensities, x, y and z coordinates, and mask labels corresponding to voxels in the volume.

  • img_dims (int) – dimensions of the image volume

compute_ngldm_features() DataFrame[source]

Computes neighbouring grey level dependence matrix features for the current neighbouring grey level dependence matrix.

Returns:

with values for each feature.

Return type:

pandas data frame

copy()[source]

Returns a copy of the GreyLevelDependenceMatrix object.

parse_feature_names()[source]

Adds additional settings-related identifiers to each feature. Not used currently, as the use of different settings for the neighbouring grey level dependence matrix is not supported.

set_empty()[source]

Creates an empty GreyLevelDependenceMatrix

MEDimage.biomarkers.ngldm.combine_ngldm_matrices(ngldm_list: List, spatial_method: str) List[source]

Function to merge neighbouring grey level dependence matrices prior to feature calculation.

Parameters:
  • ngldm_list (List) – list of GreyLevelDependenceMatrix objects.

  • spatial_method (str) – spatial method which determines the way neighbouring grey level dependence matrices are calculated and how features are determined. One of “2d”, “2.5d” or “3d”.

Returns:

list of one or more merged GreyLevelDependenceMatrix objects.

Return type:

List

MEDimage.biomarkers.ngldm.dc_energy(ngldm_dict: ndarray) float[source]

Computes dependence count energy feature. This feature refers to “Fngl_dc_energy” (ID = CAS9) in the IBSI1 reference manual.

Parameters:

ngldm (ndarray) – array of neighbouring grey level dependence matrix

Returns:

dependence count energy value

Return type:

float

MEDimage.biomarkers.ngldm.dc_entr(ngldm_dict: ndarray) float[source]

Computes dependence count entropy feature. This feature refers to “Fngl_dc_entr” (ID = FCBV) in the IBSI1 reference manual.

Parameters:

ngldm (ndarray) – array of neighbouring grey level dependence matrix

Returns:

dependence count entropy value

Return type:

float

MEDimage.biomarkers.ngldm.dc_var(ngldm_dict: ndarray) float[source]

Computes dependence count variance feature. This feature refers to “Fngl_dc_var” (ID = DNX2) in the IBSI1 reference manual.

Parameters:

ngldm (ndarray) – array of neighbouring grey level dependence matrix

Returns:

dependence count variance value

Return type:

float

MEDimage.biomarkers.ngldm.dcnu(ngldm_dict: ndarray) float[source]

Computes dependence count non-uniformity feature. This feature refers to “Fngl_dcnu” (ID = Z87G) in the IBSI1 reference manual.

Parameters:

ngldm (ndarray) – array of neighbouring grey level dependence matrix

Returns:

dependence count non-uniformity value

Return type:

float

MEDimage.biomarkers.ngldm.dcnu_norm(ngldm_dict: ndarray) float[source]

Computes dependence count non-uniformity normalised feature. This feature refers to “Fngl_dcnu_norm” (ID = OKJI) in the IBSI1 reference manual.

Parameters:

ngldm (ndarray) – array of neighbouring grey level dependence matrix

Returns:

dependence count non-uniformity normalised value

Return type:

float

MEDimage.biomarkers.ngldm.extract_all(vol: ndarray) Dict[source]

Compute NGLDM features

Parameters:
  • vol (np.ndarray) – volume with discretised intensities as 3D numpy array (x, y, z)

  • method (str, optional) – Either ‘old’ (deprecated) or ‘new’ (faster) method.

Raises:

ValueError – Ngldm should either be calculated using the faster “new” method, or the slow “old” method.

Returns:

Dictionary of NGTDM features.

Return type:

dict

MEDimage.biomarkers.ngldm.get_dict(vol: ndarray) dict[source]

Extract neighbouring grey level dependence matrix-based features from the intensity roi mask.

Parameters:

vol (ndarray) – volume with discretised intensities as 3D numpy array (x, y, z)

Returns:

dictionary with feature values

Return type:

dict

MEDimage.biomarkers.ngldm.get_matrix(roi_only: array, levels: ndarray) float[source]

Computes Neighbouring grey level dependence matrix. This matrix refers to “Neighbouring grey level dependence based features” (ID = REK0) in the IBSI1 reference manual.

Parameters:
  • roi_only_int (ndarray) – Smallest box containing the ROI, with the imaging data ready for texture analysis computations. Voxels outside the ROI are set to NaNs.

  • levels (ndarray or List) – Vector containing the quantized gray-levels in the tumor region (or reconstruction levels of quantization).

Returns:

Array of neighbouring grey level dependence matrix of roi_only.

Return type:

ndarray

MEDimage.biomarkers.ngldm.get_ngldm_features(vol: ndarray, ngldm_spatial_method: str = '3d', ngldm_diff_lvl: float = 0.0, ngldm_dist: float = 1.0) Dict[source]

Extract neighbouring grey level dependence matrix-based features from the intensity roi mask. These features refer to “Neighbouring grey level dependence based features” (ID = REK0) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – volume with discretised intensities as 3D numpy array (x, y, z).

  • intensity_range (ndarray) – range of potential discretised intensities, provided as a list: [minimal discretised intensity, maximal discretised intensity]. If one or both values are unknown, replace the respective values with np.nan.

  • ngldm_spatial_method (str) – spatial method which determines the way neighbouring grey level dependence matrices are calculated and how features are determined. One of “2d”, “2.5d” or “3d”.

  • ngldm_diff_lvl (float) – also called coarseness. Coarseness determines which intensity differences are allowed for intensities to be considered similar. Typically 0, and changing discretisation levels may have the same effect as increasing the coarseness parameter.

  • ngldm_dist (float) – the chebyshev distance that forms a local neighbourhood around a center voxel.

Returns:

dictionary with feature values.

Return type:

dict

MEDimage.biomarkers.ngldm.gl_var(ngldm_dict: ndarray) float[source]

Computes grey level variance feature. This feature refers to “Fngl_gl_var” (ID = 1PFV) in the IBSI1 reference manual.

Parameters:

ngldm (ndarray) – array of neighbouring grey level dependence matrix

Returns:

grey level variance value

Return type:

float

MEDimage.biomarkers.ngldm.glnu(ngldm_dict: ndarray) float[source]

Computes grey level non-uniformity feature. This feature refers to “Fngl_glnu” (ID = FP8K) in the IBSI1 reference manual.

Parameters:

ngldm (ndarray) – array of neighbouring grey level dependence matrix

Returns:

grey level non-uniformity value

Return type:

float

MEDimage.biomarkers.ngldm.glnu_norm(ngldm_dict: ndarray) float[source]

Computes grey level non-uniformity normalised feature. This feature refers to “Fngl_glnu_norm” (ID = 5SPA) in the IBSI1 reference manual.

Parameters:

ngldm (ndarray) – array of neighbouring grey level dependence matrix

Returns:

grey level non-uniformity normalised value

Return type:

float

MEDimage.biomarkers.ngldm.hde(ngldm_dict: ndarray) float[source]

Computes high dependence emphasis feature. This feature refers to “Fngl_hde” (ID = IMOQ) in the IBSI1 reference manual.

Parameters:

ngldm (ndarray) – array of neighbouring grey level dependence matrix

Returns:

high depence emphasis value

Return type:

float

MEDimage.biomarkers.ngldm.hdhge(ngldm_dict: ndarray) float[source]

Computes high dependence high grey level emphasis feature. This feature refers to “Fngl_hdhge” (ID = 9QMG) in the IBSI1 reference manual.

Parameters:

ngldm (ndarray) – array of neighbouring grey level dependence matrix

Returns:

high dependence high grey level emphasis value

Return type:

float

MEDimage.biomarkers.ngldm.hdlge(ngldm_dict: ndarray) float[source]

Computes high dependence low grey level emphasis feature. This feature refers to “Fngl_hdlge” (ID = NBZI) in the IBSI1 reference manual.

Parameters:

ngldm (ndarray) – array of neighbouring grey level dependence matrix

Returns:

high dependence low grey level emphasis value

Return type:

float

MEDimage.biomarkers.ngldm.hgce(ngldm_dict: ndarray) float[source]

Computes high grey level count emphasis feature. This feature refers to “Fngl_hgce” (ID = OAE7) in the IBSI1 reference manual.

Parameters:

ngldm (ndarray) – array of neighbouring grey level dependence matrix

Returns:

high grey level count emphasis value

Return type:

float

MEDimage.biomarkers.ngldm.lde(ngldm_dict: ndarray) float[source]

Computes low dependence emphasis feature. This feature refers to “Fngl_lde” (ID = SODN) in the IBSI1 reference manual.

Parameters:

ngldm (ndarray) – array of neighbouring grey level dependence matrix

Returns:

low depence emphasis value

Return type:

float

MEDimage.biomarkers.ngldm.ldhge(ngldm_dict: ndarray) float[source]

Computes low dependence high grey level emphasis feature. This feature refers to “Fngl_ldhge” (ID = JA6D) in the IBSI1 reference manual.

Parameters:

ngldm (ndarray) – array of neighbouring grey level dependence matrix

Returns:

low dependence high grey level emphasis value

Return type:

float

MEDimage.biomarkers.ngldm.ldlge(ngldm_dict: ndarray) float[source]

Computes low dependence low grey level emphasis feature. This feature refers to “Fngl_ldlge” (ID = EQ3F) in the IBSI1 reference manual.

Parameters:

ngldm (ndarray) – array of neighbouring grey level dependence matrix

Returns:

low dependence low grey level emphasis value

Return type:

float

MEDimage.biomarkers.ngldm.lgce(ngldm_dict: ndarray) float[source]

Computes low grey level count emphasis feature. This feature refers to “Fngl_lgce” (ID = TL9H) in the IBSI1 reference manual.

Parameters:

ngldm (ndarray) – array of neighbouring grey level dependence matrix

Returns:

low grey level count emphasis value

Return type:

float

ngtdm

MEDimage.biomarkers.ngtdm.busyness(ngtdm: ndarray, count_valid: ndarray) float[source]

Computes busyness feature. This feature refers to “Busyness” (ID = NQ30) in the IBSI1 reference manual.

Parameters:

ngtdm (ndarray) – array of neighbourhood grey tone difference matrix

Returns:

busyness value

Return type:

float

MEDimage.biomarkers.ngtdm.coarseness(ngtdm: ndarray, count_valid: ndarray) float[source]

Computes coarseness feature. This feature refers to “Coarseness” (ID = QCDE) in the IBSI1 reference manual.

Parameters:

ngtdm (ndarray) – array of neighbourhood grey tone difference matrix

Returns:

coarseness value

Return type:

float

MEDimage.biomarkers.ngtdm.complexity(ngtdm: ndarray, count_valid: ndarray) float[source]

Computes complexity feature. This feature refers to “Complexity” (ID = HDEZ) in the IBSI1 reference manual.

Parameters:

ngtdm (ndarray) – array of neighbourhood grey tone difference matrix

Returns:

complexity value

Return type:

float

MEDimage.biomarkers.ngtdm.contrast(ngtdm: ndarray, count_valid: ndarray) float[source]

Computes contrast feature. This feature refers to “Contrast” (ID = 65HE) in the IBSI1 reference manual.

Parameters:

ngtdm (ndarray) – array of neighbourhood grey tone difference matrix

Returns:

contrast value

Return type:

float

MEDimage.biomarkers.ngtdm.extract_all(vol: ndarray, dist_correction: bool | str | None = None) Dict[source]

Compute Neighbourhood grey tone difference based features. These features refer to “Neighbourhood grey tone difference based features” (ID = IPET) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, isotropically resampled, quantized (e.g. n_g = 32, levels = [1, …, n_g]), with NaNs outside the region of interest.

  • dist_correction (Union[bool, str], optional) – Set this variable to true in order to use discretization length difference corrections as used by the Institute of Physics and Engineering in Medicine. Set this variable to false to replicate IBSI results. Or use string and specify the norm for distance weighting. Weighting is only performed if this argument is “manhattan”, “euclidean” or “chebyshev”.

Returns:

Dict of Neighbourhood grey tone difference based features.

Return type:

Dict

MEDimage.biomarkers.ngtdm.get_matrix(roi_only: ndarray, levels: ndarray, dist_correction: bool = False) Tuple[ndarray, ndarray][source]

This function computes the Neighborhood Gray-Tone Difference Matrix (NGTDM) of the region of interest (ROI) of an input volume. The input volume is assumed to be isotropically resampled. The ngtdm is computed using 26-voxel connectivity. To account for discretization length differences, all averages around a center voxel are performed such that the neighbours at a distance of \(\sqrt{3}\) voxels are given a weight of \(\sqrt{3}\), and the neighbours at a distance of \(\sqrt{2}\) voxels are given a weight of \(\sqrt{2}\). This matrix refers to “Neighbourhood grey tone difference based features” (ID = IPET) in the IBSI1 reference manual.

Note

This function is compatible with 2D analysis (language not adapted in the text)

Parameters:
  • roi_only (ndarray) – Smallest box containing the ROI, with the imaging data ready for texture analysis computations. Voxels outside the ROI are set to NaNs.

  • levels (ndarray) – Vector containing the quantized gray-levels in the tumor region (or reconstruction levels of quantization).

  • dist_correction (bool, optional) –

    Set this variable to true in order to use discretization length difference corrections as used by the Institute of Physics and Engineering in Medicine. Set this variable to false to replicate IBSI results.

Returns:

  • ngtdm: Neighborhood Gray-Tone Difference Matrix of roi_only'.

  • count_valid: Array of number of valid voxels used in the ngtdm computation.

Return type:

Tuple[np.ndarray, np.ndarray]

References

[1] Amadasun, M., & King, R. (1989). Textural Features Corresponding to Textural Properties. IEEE Transactions on Systems Man and Cybernetics, 19(5), 1264–1274.

MEDimage.biomarkers.ngtdm.get_single_matrix(vol: ndarray, dist_correction=None) Tuple[ndarray, ndarray][source]

Compute neighbourhood grey tone difference matrix in order to compute the single features.

Parameters:
  • vol (ndarray) – 3D volume, isotropically resampled, quantized (e.g. n_g = 32, levels = [1, …, n_g]), with NaNs outside the region of interest.

  • dist_correction (Union[bool, str], optional) – Set this variable to true in order to use discretization length difference corrections as used by the Institute of Physics and Engineering in Medicine. Set this variable to false to replicate IBSI results. Or use string and specify the norm for distance weighting. Weighting is only performed if this argument is “manhattan”, “euclidean” or “chebyshev”.

Returns:

array of neighbourhood grey tone difference matrix

Return type:

np.ndarray

MEDimage.biomarkers.ngtdm.strength(ngtdm: ndarray, count_valid: ndarray) float[source]

Computes strength feature. This feature refers to “Strength” (ID = 1X9X) in the IBSI1 reference manual.

Parameters:

ngtdm (ndarray) – array of neighbourhood grey tone difference matrix

Returns:

strength value

Return type:

float

stats

MEDimage.biomarkers.stats.cov(vol: ndarray) float[source]

Computes the coefficient of variation feature of the input dataset (3D Array). This feature refers to “Fstat_cov” (ID = 7TET) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

A new array holding the coefficient of variation feature.

Return type:

float

MEDimage.biomarkers.stats.energy(vol: ndarray) float[source]

Computes the energy feature of the input dataset (3D Array). This feature refers to “Fstat_energy” (ID = N8CA) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

A new array holding the energy feature.

Return type:

float

MEDimage.biomarkers.stats.extract_all(vol: ndarray, intensity_type: str) dict[source]

Computes Intensity-based statistical features. These features refer to “Intensity-based statistical features” (ID = UHIW) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution).

  • intensity_type (str) – Type of intensity to compute. Can be “arbitrary”, “definite” or “filtered”. Will compute features only for “definite” intensity type.

Returns:

Dictionnary containing all stats features.

Return type:

dict

Raises:

ValueError – If intensity_type is not “arbitrary”, “definite” or “filtered”.

MEDimage.biomarkers.stats.iqrange(vol: ndarray) float[source]

Computes the interquartile range feature of the input dataset (3D Array). This feature refers to “Fstat_iqr” (ID = SALO) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

Interquartile range. If axis != None, the output data-type is the same as that of the input.

Return type:

float

MEDimage.biomarkers.stats.kurt(vol: ndarray) float[source]

Computes the kurtosis (Fisher or Pearson) feature of the input dataset (3D Array). This feature refers to “Fstat_kurt” (ID = IPH6) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

The kurtosis feature of values along an axis. If all values are equal, return -3 for Fisher’s definition and 0 for Pearson’s definition.

Return type:

float

MEDimage.biomarkers.stats.mad(vol: ndarray) float[source]

Mean absolute deviation feature of the input dataset (3D Array). This feature refers to “Fstat_mad” (ID = 4FUA) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

A new array holding mean absolute deviation feature.

Return type:

float

MEDimage.biomarkers.stats.max(vol: ndarray) float[source]

Computes the maximum grey level feature of the input dataset (3D Array). This feature refers to “Fstat_max” (ID = 84IY) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

The maximum grey level feature of the array elements.

Return type:

float

MEDimage.biomarkers.stats.mean(vol: ndarray) float[source]

Computes statistical mean feature of the input dataset (3D Array). This feature refers to “Fstat_mean” (ID = Q4LE) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

Statistical mean feature

Return type:

float

MEDimage.biomarkers.stats.medad(vol: ndarray) float[source]

Median absolute deviation feature of the input dataset (3D Array). This feature refers to “Fstat_medad” (ID = N72L) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

A new array holding the median absolute deviation feature.

Return type:

float

MEDimage.biomarkers.stats.median(vol: ndarray) float[source]

Computes the median feature along the specified axis of the input dataset (3D Array). This feature refers to “Fstat_median” (ID = Y12H) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

The median feature of the array elements.

Return type:

float

MEDimage.biomarkers.stats.min(vol: ndarray) float[source]

Computes the minimum grey level feature of the input dataset (3D Array). This feature refers to “Fstat_min” (ID = 1GSF) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

The minimum grey level feature of the array elements.

Return type:

float

MEDimage.biomarkers.stats.p10(vol: ndarray) float[source]

Computes the score at the 10th percentile feature of the input dataset (3D Array). This feature refers to “Fstat_P10” (ID = QG58) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

Score at 10th percentil.

Return type:

float

MEDimage.biomarkers.stats.p90(vol: ndarray) float[source]

Computes the score at the 90th percentile feature of the input dataset (3D Array). This feature refers to “Fstat_P90” (ID = 8DWT) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

Score at 90th percentil.

Return type:

float

MEDimage.biomarkers.stats.qcod(vol: ndarray) float[source]

Computes the quartile coefficient of dispersion feature of the input dataset (3D Array). This feature refers to “Fstat_qcod” (ID = 9S40) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

A new array holding the quartile coefficient of dispersion feature.

Return type:

float

MEDimage.biomarkers.stats.range(vol: ndarray) float[source]

Range of values (maximum - minimum) feature along an axis of the input dataset (3D Array). This feature refers to “Fstat_range” (ID = 2OJQ) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

A new array holding the range of values, unless out was specified, in which case a reference to out is returned.

Return type:

float

MEDimage.biomarkers.stats.rmad(vol: ndarray) float[source]

Robust mean absolute deviation feature of the input dataset (3D Array). This feature refers to “Fstat_rmad” (ID = 1128) in the IBSI1 reference manual.

Parameters:
  • vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

  • P10 (ndarray) – Score at 10th percentil.

  • P90 (ndarray) – Score at 90th percentil.

Returns:

A new array holding the robust mean absolute deviation.

Return type:

float

MEDimage.biomarkers.stats.rms(vol: ndarray) float[source]

Computes the root mean square feature of the input dataset (3D Array). This feature refers to “Fstat_rms” (ID = 5ZWQ) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

A new array holding the root mean square feature.

Return type:

float

MEDimage.biomarkers.stats.skewness(vol: ndarray) float[source]

Computes the sample skewness feature of the input dataset (3D Array). This feature refers to “Fstat_skew” (ID = KE2A) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

The skewness feature of values along an axis. Returning 0 where all values are equal.

Return type:

float

MEDimage.biomarkers.stats.var(vol: ndarray) float[source]

Computes statistical variance feature of the input dataset (3D Array). This feature refers to “Fstat_var” (ID = ECT3) in the IBSI1 reference manual.

Parameters:

vol (ndarray) – 3D volume, NON-QUANTIZED, with NaNs outside the region of interest (continuous imaging intensity distribution)

Returns:

Statistical variance feature

Return type:

float

utils

MEDimage.biomarkers.utils.find_i_x(levels: ndarray, fract_vol: ndarray, x: float) ndarray[source]

Computes intensity at volume fraction.

Parameters:
  • levels (ndarray) – COMPLETE INTEGER grey-levels.

  • fract_vol (ndarray) – Fractional volume.

  • x (float) – Fraction percentage, between 0 and 100.

Returns:

Array of minimum discretised intensity present in at most \(x\) % of the volume.

Return type:

ndarray

MEDimage.biomarkers.utils.find_v_x(fract_int: ndarray, fract_vol: ndarray, x: float) ndarray[source]

Computes volume at intensity fraction.

Parameters:
  • fract_int (ndarray) – Intensity fraction.

  • fract_vol (ndarray) – Fractional volume.

  • x (float) – Fraction percentage, between 0 and 100.

Returns:

Array of largest volume fraction fract_vol that has an intensity fraction fract_int of at least \(x\) %.

Return type:

ndarray

MEDimage.biomarkers.utils.get_area_dens_approx(a: float, b: float, c: float, n: float) float[source]

Computes area density - minimum volume enclosing ellipsoid

Parameters:
  • a (float) – Major semi-axis length.

  • b (float) – Minor semi-axis length.

  • c (float) – Least semi-axis length.

  • n (int) – Number of iterations.

Returns:

Area density - minimum volume enclosing ellipsoid.

Return type:

float

MEDimage.biomarkers.utils.get_axis_lengths(xyz: ndarray) Tuple[float, float, float][source]

Computes AxisLengths.

Parameters:

xyz (ndarray) – Array of three column vectors, defining the [X,Y,Z] positions of the points in the ROI (1’s) of the mask volume. In mm.

Returns:

Array of three column vectors

[Major axis lengths, Minor axis lengths, Least axis lengths].

Return type:

Tuple[float, float, float]

MEDimage.biomarkers.utils.get_com(xgl_int: ndarray, xgl_morph: ndarray, xyz_int: ndarray, xyz_morph: ndarray) float | ndarray[source]

Calculates center of mass shift (in mm, since resolution is in mm).

Note

Row positions of “x_gl” and “xyz” must correspond for each point.

Parameters:
  • xgl_int (ndarray) – Vector of intensity values in the volume to analyze (only values in the intensity mask).

  • xgl_morph (ndarray) – Vector of intensity values in the volume to analyze (only values in the morphological mask).

  • xyz_int (ndarray) – [n_points X 3] matrix of three column vectors, defining the [X,Y,Z] positions of the points in the ROI (1’s) of the mask volume (In mm). (Mesh-based volume calculated from the ROI intensity mesh)

  • xyz_morph (ndarray) – [n_points X 3] matrix of three column vectors, defining the [X,Y,Z] positions of the points in the ROI (1’s) of the mask volume (In mm). (Mesh-based volume calculated from the ROI morphological mesh)

Returns:

The ROI volume centre of mass.

Return type:

Union[float, np.ndarray]

MEDimage.biomarkers.utils.get_glcm_cross_diag_prob(p_ij: ndarray) ndarray[source]

Computes cross diagonal probabilities.

Parameters:

p_ij (ndarray) – Joint probability of grey levels i and j occurring in neighboring voxels. (Elements of the probability distribution for grey level co-occurrences).

Returns:

Array of the cross diagonal probability.

Return type:

ndarray

MEDimage.biomarkers.utils.get_glcm_diag_prob(p_ij: ndarray) ndarray[source]

Computes diagonal probabilities.

Parameters:

p_ij (ndarray) – Joint probability of grey levels i and j occurring in neighboring voxels. (Elements of the probability distribution for grey level co-occurrences).

Returns:

Array of the diagonal probability.

Return type:

ndarray

MEDimage.biomarkers.utils.get_glob_peak(img_obj: ndarray, roi_obj: ndarray, res: ndarray) float[source]

Computes Global intensity peak.

Note

This works only in 3D for now.

Parameters:
  • img_obj (ndarray) – Continuos image intensity distribution, with no NaNs outside the ROI.

  • roi_obj (ndarray) – Array of the mask defining the ROI.

  • res (List[float]) – [a,b,c] vector specifying the resolution of the volume in mm. xyz resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the global intensity peak.

Return type:

float

MEDimage.biomarkers.utils.get_loc_peak(img_obj: ndarray, roi_obj: ndarray, res: ndarray) float[source]

Computes Local intensity peak.

Note

This works only in 3D for now.

Parameters:
  • img_obj (ndarray) – Continuos image intensity distribution, with no NaNs outside the ROI.

  • roi_obj (ndarray) – Array of the mask defining the ROI.

  • res (List[float]) – [a,b,c] vector specifying the resolution of the volume in mm. xyz resolution (world), or JIK resolution (intrinsic matlab).

Returns:

Value of the local intensity peak.

Return type:

float

MEDimage.biomarkers.utils.get_mesh(mask: ndarray, res: ndarray | List) Tuple[ndarray, ndarray, ndarray][source]

Compute Mesh.

Note

Make sure the mask is padded with a layer of 0’s in all dimensions to reduce potential isosurface computation errors.

Parameters:
  • mask (ndarray) – Contains only 0’s and 1’s.

  • res (ndarray or List) – [a,b,c] vector specifying the resolution of the volume in mm. xyz resolution (world), or JIK resolution (intrinsic matlab).

Returns:

  • Array of the [X,Y,Z] positions of the ROI.

  • Array of the spatial coordinates for mask unique mesh vertices.

  • Array of triangular faces via referencing vertex indices from vertices.

Return type:

Tuple[np.ndarray, np.ndarray, np.ndarray]