esmraldi.fusion

Module for the joint statistical analysis of images

Module Contents

Functions

clustering_affinity(X_r)

Clustering by affinity propagation

clustering_kmeans(X_r)

Clustering by kmeans

flatten(image_maldi[, is_spectral])

Preprocess for reduction : flattens

pca(image[, n])

Performs PCA on image array.

nmf(image[, n])

Performs NMF on image array.

post_processing(pca_maldi, pca_mri)

Computes t-SNE from dimension reduction data.

weighted_distance(X, weights)

Weighted euclidean distance

select_images(images, point_mri, centers, weights, ...)

Sort the (MALDI) images according to their proximity to

extract_ratio_images(image, mzs)

Extracts ratio images : image_n / image_{n-x}, x > 0

get_score(model, data[, scorer])

Estimate performance of the model on the data

reconstruct_image_from_components(components, weights)

Synthetic image from a vector and components

closest_pixels_cosine(image1, image2)

Find closest pixels using cosine measure

cosine_neighborhood(image1, image2, r)

Cosine similarity taking a neighborhood into account

explaining_eigenvector(image_eigenvectors, ...)

Finding the most contributing eigenvector

closest_reconstruction(image, image1, image2, ...[, ...])

Find proximities based on the similarity between projection images.

remove_indices(image)

Utility function to remove images

roc_indices(mask, shape[, norm_img])

region_to_bool(regions, indices_ravel, shape)

weighted_roc_curve(y_true, y_score, *[, pos_label, ...])

roc_curve_projection(fpr, tpr, thresholds)

auc_roc(y_true, y_score[, sample_weight, max_fpr, ...])

roc_curve(y_true, y_score, *[, pos_label, ...])

single_roc_auc(image, indices, region_bool[, ...])

single_roc_cutoff(image, indices, region_bool, fn[, ...])

cutoff_distance2(fpr, tpr, thresholds[, nb_zeros, ...])

cutoff_distance(fpr, tpr, thresholds[, nb_zeros, ...])

cutoff_half_tpr(fpr, tpr, thresholds[, nb_zeros, ...])

cutoff_generalized_youden(fpr, tpr, thresholds, ...[, ...])

cutoff_efficiency(fpr, tpr, thresholds, nb_zeros, nb_ones)

roc_auc_analysis(images, indices, region_bool[, ...])

single_measure(current_image, indices, region_bool[, fn])

measures_per_region(images, indices, region_bool[, fn])

roc_cutoff_analysis(images, indices, region_bool[, ...])

image_to_thresholded_variants(image[, n])

esmraldi.fusion.clustering_affinity(X_r)

Clustering by affinity propagation

Based on scikit module

Parameters
X_r: np.ndarray

fitted data (e.g. by PCA)

Returns
np.ndarray

clustered data

esmraldi.fusion.clustering_kmeans(X_r)

Clustering by kmeans

Based on scikit module

Parameters
X_r: np.ndarray

fitted data (e.g. by PCA)

Returns
np.ndarray

clustered data

esmraldi.fusion.flatten(image_maldi, is_spectral=False)

Preprocess for reduction : flattens a stack image with OpenCV

Parameters
image_maldi: numpy.ndarray

input image

Returns
numpy.ndarray

normalized image

esmraldi.fusion.pca(image, n=5)

Performs PCA on image array.

Each image is represented as a point after fitting.

Based on scikit module

Parameters
image: np.ndarray

collection of images

n: int

number of components

Returns
sklearn.decomposition.PCA

pca object

esmraldi.fusion.nmf(image, n=5)

Performs NMF on image array.

Each image is represented as a point after fitting.

Based on scikit module

Parameters
image: np.ndarray

collection of images

n: int

number of components

Returns
sklearn.decomposition.NMF

nmf object

esmraldi.fusion.post_processing(pca_maldi, pca_mri)

Computes t-SNE from dimension reduction data.

Based on scikit module

Parameters
pca_maldi: np.ndarray

PCA coordinates for the MALDI images

pca_mri: np.ndarray

PCA coordinates for the MRI image

Returns
np.ndarray

tSNE coordinates for MALDI

np.ndarray

tSNE coordinates for MRI

esmraldi.fusion.weighted_distance(X, weights)

Weighted euclidean distance for similarity measure

Parameters
X: np.ndarray

coordinates

weights: list

weights for each coordinate

esmraldi.fusion.select_images(images, point_mri, centers, weights, mzs, labels, top=1)

Sort the (MALDI) images according to their proximity to the MRI image

Parameters
images: np.ndarray

MALDI images

centers: np.ndarray

MALDI images (reduced)

point_mri: np.ndarray

MRI image (reduced)

weights: list

weights for each coordinate

mzs: list

m/z ratios

labels: np.ndarray

clustering labels (optional)

top: int

number of images to extract

Returns
np.ndarray

sorted MALDI images based on proximity to RI

np.ndarray

sorted mzs based on proximity to MRI

np.ndarray

metric values used to sort MALDI

esmraldi.fusion.extract_ratio_images(image, mzs)

Extracts ratio images : image_n / image_{n-x}, x > 0

Computing (n**2-n)/2 images

Parameters
image: np.ndarray

array of input images

mzs: list

associated labels (e.g. m/z ratios)

esmraldi.fusion.get_score(model, data, scorer=metrics.explained_variance_score)

Estimate performance of the model on the data

Parameters
model: sklearn.decomposition

matrix-factorization technique

data: np.ndarray

matrix used to estimate performance

scorer: sklearn.metrics

metric

Returns
float

performance metric

esmraldi.fusion.reconstruct_image_from_components(components, weights)

Synthetic image from a vector and components from a dimension reduction method

Parameters
components: np.ndarray

Component images

weights: np.ndarray

point

Returns
np.ndarray

synthetic image

esmraldi.fusion.closest_pixels_cosine(image1, image2)

Find closest pixels using cosine measure Spatial localization

Parameters
image1: np.ndarray

image 1

image2: np.ndarray

image 2

Returns
np.ndarray

indices of pixels ordered by similarity

esmraldi.fusion.cosine_neighborhood(image1, image2, r)

Cosine similarity taking a neighborhood into account

Parameters
image1: np.ndarray

image 1

image2: np.ndarray

image 2

r: int

radius of neighborhood

Returns
float

local cosine similarity

esmraldi.fusion.explaining_eigenvector(image_eigenvectors, weights_target, weights_reference)

Finding the most contributing eigenvector (or component image) in the target

Parameters
image_eigenvectors: np.ndarray

component images

weights_target: np.ndarray

weight vector of target (NMF coordinates)

weights_reference: np.ndarray

weight vector of reference (NMF coordinates)

Returns
np.ndarray

the component image which explains target w.r.t reference

esmraldi.fusion.closest_reconstruction(image, image1, image2, image_eigenvectors, image_eigenvectors_2=None)

Find proximities based on the similarity between projection images.

Parameters
image: np.ndarray

None

image1: np.ndarray

reference image

image2: np.ndarray

target image

image_eigenvectors: np.ndarray

component images associated to image 1

image_eigenvectors_2: np.ndarray

component images associated to image 2, if different

Returns
np.ndarray

average differences between reconstructions for each image

esmraldi.fusion.remove_indices(image)

Utility function to remove images with only 0 intensities of if the median value is the maximum value

Parameters
image: np.ndarray

image

Returns
list

indices to remove

esmraldi.fusion.roc_indices(mask, shape, norm_img=None)
esmraldi.fusion.region_to_bool(regions, indices_ravel, shape)
esmraldi.fusion.weighted_roc_curve(y_true, y_score, *, pos_label=None, sample_weight=None, drop_intermediate=True)
esmraldi.fusion.roc_curve_projection(fpr, tpr, thresholds)
esmraldi.fusion.auc_roc(y_true, y_score, sample_weight=None, max_fpr=None, is_weighted=False, is_projection=False)
esmraldi.fusion.roc_curve(y_true, y_score, *, pos_label=None, sample_weight=None, drop_intermediate=True, is_weighted=False, is_projection=False)
esmraldi.fusion.single_roc_auc(image, indices, region_bool, is_weighted=False, is_projection=False)
esmraldi.fusion.single_roc_cutoff(image, indices, region_bool, fn, is_weighted=False)
esmraldi.fusion.cutoff_distance2(fpr, tpr, thresholds, nb_zeros=0, nb_ones=0, return_index=False)
esmraldi.fusion.cutoff_distance(fpr, tpr, thresholds, nb_zeros=0, nb_ones=0, return_index=False)
esmraldi.fusion.cutoff_half_tpr(fpr, tpr, thresholds, nb_zeros=0, nb_ones=0, return_index=False)
esmraldi.fusion.cutoff_generalized_youden(fpr, tpr, thresholds, nb_zeros, nb_ones, return_index=False)
esmraldi.fusion.cutoff_efficiency(fpr, tpr, thresholds, nb_zeros, nb_ones, return_index=False)
esmraldi.fusion.roc_auc_analysis(images, indices, region_bool, norm_img=None, thresholded_variants=False, is_weighted=False, is_projection=False)
esmraldi.fusion.single_measure(current_image, indices, region_bool, fn=np.mean)
esmraldi.fusion.measures_per_region(images, indices, region_bool, fn=np.mean)
esmraldi.fusion.roc_cutoff_analysis(images, indices, region_bool, is_weighted=False, fn=cutoff_distance)
esmraldi.fusion.image_to_thresholded_variants(image, n=3)