Skip to content

Commit

Permalink
angle wrt cords
Browse files Browse the repository at this point in the history
  • Loading branch information
kapoorlab committed Apr 6, 2024
1 parent c03668f commit 9ec1a1f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 53 deletions.
54 changes: 3 additions & 51 deletions src/napatrackmater/Trackmate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2401,21 +2401,15 @@ def _dict_update(

unique_id = str(track_id) + str(generation_id) + str(tracklet_id)

vec_mask = [
float(self.unique_spot_properties[int(cell_id)][self.maskcentroid_x_key]),
float(self.unique_spot_properties[int(cell_id)][self.maskcentroid_y_key]),
float(self.unique_spot_properties[int(cell_id)][self.maskcentroid_z_key]),
]

vec_cell = [
float(self.unique_spot_properties[int(cell_id)][self.xposid_key]),
float(self.unique_spot_properties[int(cell_id)][self.yposid_key]),
float(self.unique_spot_properties[int(cell_id)][self.zposid_key]),
]

angle_x = angular_change_x(vec_mask, vec_cell)
angle_y = angular_change_y(vec_mask, vec_cell)
angle_z = angular_change_z(vec_mask, vec_cell)
angle_x = cell_angular_change_x(vec_cell)
angle_y = cell_angular_change_y(vec_cell)
angle_z = cell_angular_change_z(vec_cell)

self.unique_spot_properties[int(cell_id)].update(
{self.radial_angle_x_key: angle_x}
Expand Down Expand Up @@ -3108,20 +3102,6 @@ def prob_sigmoid(x):
return 1 - math.exp(-x)


def angular_change_z(vec_mask, vec_cell):

vec = np.asarray(vec_cell) - np.asarray(vec_mask)
vec = vec / np.linalg.norm(vec)
num_dims = len(vec)
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_z(vec_cell):

vec = np.asarray(vec_cell)
Expand All @@ -3136,20 +3116,6 @@ def cell_angular_change_z(vec_cell):
return angle


def angular_change_y(vec_mask, vec_cell):

vec = np.asarray(vec_cell) - np.asarray(vec_mask)
vec = vec / np.linalg.norm(vec)
num_dims = len(vec)
unit_vector = np.zeros(num_dims)
unit_vector[-2] = 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_y(vec_cell):

vec = np.asarray(vec_cell)
Expand All @@ -3164,20 +3130,6 @@ def cell_angular_change_y(vec_cell):
return angle


def angular_change_x(vec_mask, vec_cell):

vec = np.asarray(vec_cell) - np.asarray(vec_mask)
vec = vec / np.linalg.norm(vec)
num_dims = len(vec)
unit_vector = np.zeros(num_dims)
unit_vector[0] = 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_x(vec_cell):

vec = np.asarray(vec_cell)
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 = "5.0.9"
__version_tuple__ = version_tuple = (5, 0, 9)
__version__ = version = "5.1.0"
__version_tuple__ = version_tuple = (5, 1, 0)

0 comments on commit 9ec1a1f

Please sign in to comment.