Skip to content
Snippets Groups Projects
Commit 176aa03f authored by Alán Muñoz's avatar Alán Muñoz
Browse files

remove(ext): delete faiss and k2_major_median

parent 802996f6
No related branches found
No related tags found
No related merge requests found
...@@ -13,7 +13,6 @@ import math ...@@ -13,7 +13,6 @@ import math
import typing as t import typing as t
import bottleneck as bn import bottleneck as bn
import faiss
import numpy as np import numpy as np
from scipy import ndimage from scipy import ndimage
...@@ -121,37 +120,6 @@ def std(cell_mask, trap_image): ...@@ -121,37 +120,6 @@ def std(cell_mask, trap_image):
return np.std(trap_image[cell_mask]) return np.std(trap_image[cell_mask])
def k2_major_median(cell_mask, trap_image):
"""
Finds the medians of the major cluster after clustering the pixels in the cell into two clusters.
Parameters
----------
cell_mask: 2d array
Segmentation mask for the cell
trap_image: 2d array
Returns
-------
median: float
The median of the major cluster of two clusters
"""
if bn.anynan(trap_image):
cell_mask[np.isnan(trap_image)] = False
X = trap_image[cell_mask].reshape(-1, 1).astype(np.float32)
# cluster pixels in cell into two clusters
indices = faiss.IndexFlatL2(X.shape[1])
# (n_clusters=2, random_state=0).fit(X)
_, indices = indices.search(X, k=2)
high_indices = np.argmax(indices, axis=1).astype(bool)
# find the median of pixels in the largest cluster
# high_masks = np.logical_xor( # Use casting to obtain masks
# high_indices.reshape(-1, 1), np.tile((0, 1), X.shape[0]).reshape(-1, 2)
# )
major_median = bn.median(X[high_indices])
return major_median
def volume(cell_mask) -> float: def volume(cell_mask) -> float:
""" """
Estimates the volume of the cell assuming it is an ellipsoid with the mask providing a cross-section through the median plane of the ellipsoid. Estimates the volume of the cell assuming it is an ellipsoid with the mask providing a cross-section through the median plane of the ellipsoid.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment