acryo.classification package

Submodules

acryo.classification.pca module

class acryo.classification.pca.PcaClassifier(image_stack: NDArray[np.float32] | da.Array, mask_image: NDArray[np.float32] | None = None, n_components: int = 2, n_clusters: int = 2, seed: int | None = 0)[source]

Bases: object

A PCA (Principal component analysis) and k-means based image classifier.

get_bases() numpy.ndarray[source]

Get base images (principal axes) as image stack.

Returns

Same axes as input image stack, while the axis “p” corresponds to the identifier of bases.

Return type

np.ndarray

get_transform(labels: Iterable[int] | None = None) NDArray[np.float32][source]

Get the transformed vectors from the input images.

Returns

Transormed vectors. If input image stack P images, then (P, n_components) array will be returned.

Return type

da.Array

property kmeans: KMeans

The k-means object.

property labels: NDArray[np.int32] | None
property pca: PCA

The PCA object.

plot_transform(labels: Iterable[int] | None = None, bases: tuple[int, int] = (0, 1), ax: Axes | None = None) Axes[source]
predict(input: da.Array) NDArray[np.int32][source]

Predict which labels the input images belong to.

run() Self[source]

Run PCA and k-means clustering.

split_clusters() list[dask.array.core.Array][source]

Split input image stack into list of image stacks according to the labels.

This method must be called after k-means clustering is conducted, otherwise only one cluster will be returned. If input image stack has "pzyx" axes, list of "pzyx" images will be returned.

transform(input: da.Array, mask: bool = True) NDArray[np.float32][source]

Transform the input image into the principal component space.

Module contents

class acryo.classification.PcaClassifier(image_stack: NDArray[np.float32] | da.Array, mask_image: NDArray[np.float32] | None = None, n_components: int = 2, n_clusters: int = 2, seed: int | None = 0)[source]

Bases: object

A PCA (Principal component analysis) and k-means based image classifier.

get_bases() numpy.ndarray[source]

Get base images (principal axes) as image stack.

Returns

Same axes as input image stack, while the axis “p” corresponds to the identifier of bases.

Return type

np.ndarray

get_transform(labels: Iterable[int] | None = None) NDArray[np.float32][source]

Get the transformed vectors from the input images.

Returns

Transormed vectors. If input image stack P images, then (P, n_components) array will be returned.

Return type

da.Array

property kmeans: KMeans

The k-means object.

property labels: NDArray[np.int32] | None
property pca: PCA

The PCA object.

plot_transform(labels: Iterable[int] | None = None, bases: tuple[int, int] = (0, 1), ax: Axes | None = None) Axes[source]
predict(input: da.Array) NDArray[np.int32][source]

Predict which labels the input images belong to.

run() Self[source]

Run PCA and k-means clustering.

split_clusters() list[dask.array.core.Array][source]

Split input image stack into list of image stacks according to the labels.

This method must be called after k-means clustering is conducted, otherwise only one cluster will be returned. If input image stack has "pzyx" axes, list of "pzyx" images will be returned.

transform(input: da.Array, mask: bool = True) NDArray[np.float32][source]

Transform the input image into the principal component space.