Skip to content

Commit

Permalink
angles
Browse files Browse the repository at this point in the history
  • Loading branch information
kapoorlab committed Mar 25, 2024
1 parent d1e5a7d commit 6aeb09f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 31 deletions.
43 changes: 14 additions & 29 deletions src/napatrackmater/Trackmate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions src/napatrackmater/_version.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 6aeb09f

Please sign in to comment.