From 6aeb09f5a977e5ebab2b45d23680f0301b310364 Mon Sep 17 00:00:00 2001 From: kapoorlab Date: Mon, 25 Mar 2024 10:00:49 +0000 Subject: [PATCH] angles --- src/napatrackmater/Trackmate.py | 43 +++++++++++---------------------- src/napatrackmater/_version.py | 4 +-- 2 files changed, 16 insertions(+), 31 deletions(-) diff --git a/src/napatrackmater/Trackmate.py b/src/napatrackmater/Trackmate.py index 8cd9e25a..fb1789f8 100644 --- a/src/napatrackmater/Trackmate.py +++ b/src/napatrackmater/Trackmate.py @@ -1899,24 +1899,8 @@ def _assign_cluster_class(self): closest_centroid[2], ) closest_cell_id = self.unique_spot_centroid[frame_spot_centroid] - mask_vector = [ - float( - self.unique_spot_properties[int(closest_cell_id)][ - self.maskcentroid_x_key - ] - ), - float( - self.unique_spot_properties[int(closest_cell_id)][ - self.maskcentroid_y_key - ] - ), - float( - self.unique_spot_properties[int(closest_cell_id)][ - self.maskcentroid_z_key - ] - ), - ] - cell_axis_mask = cell_angular_change( cell_axis) + + cell_axis_mask = cell_angular_change(cell_axis) self.unique_spot_properties[int(closest_cell_id)].update( {self.cellaxis_mask_key: cell_axis_mask} @@ -2912,28 +2896,29 @@ def prob_sigmoid(x): def angular_change(vec_mask, vec_cell): vec = np.asarray(vec_cell) - np.asarray(vec_mask) - vec = vec/np.linalg.norm(vec) + vec = vec / np.linalg.norm(vec) num_dims = len(vec) - unit_vector = np.ones(num_dims) - unit_vector[-1] = 0 - unit_vector = unit_vector/np.linalg.norm(unit_vector) - theta = np.arccos(np.clip(np.dot(vec,unit_vector), -1.0, 1.0)) + unit_vector = np.zeros(num_dims) + unit_vector[-1] = 1 + unit_vector = unit_vector / np.linalg.norm(unit_vector) + theta = np.arccos(np.clip(np.dot(vec, unit_vector), -1.0, 1.0)) angle = np.rad2deg(theta) return angle -def cell_angular_change( vec_cell): + +def cell_angular_change(vec_cell): vec = np.asarray(vec_cell) - vec = vec/np.linalg.norm(vec) + vec = vec / np.linalg.norm(vec) num_dims = len(vec) unit_vector = np.ones(num_dims) unit_vector[-1] = 0 - unit_vector = unit_vector/np.linalg.norm(unit_vector) - theta = np.arccos(np.clip(np.dot(vec,unit_vector), -1.0, 1.0)) + unit_vector = unit_vector / np.linalg.norm(unit_vector) + theta = np.arccos(np.clip(np.dot(vec, unit_vector), -1.0, 1.0)) angle = np.rad2deg(theta) - - return angle + + return angle def check_and_update_mask(mask, image): diff --git a/src/napatrackmater/_version.py b/src/napatrackmater/_version.py index 56d63dc9..20d0a1e9 100644 --- a/src/napatrackmater/_version.py +++ b/src/napatrackmater/_version.py @@ -1,2 +1,2 @@ -__version__ = version = "4.9.9" -__version_tuple__ = version_tuple = (4, 9, 9) +__version__ = version = "5.0.0" +__version_tuple__ = version_tuple = (5, 0, 0)