[trackingdata] implementation of bendedness
This commit is contained in:
parent
bf7c37eb46
commit
6d288aace1
@ -175,12 +175,11 @@ class TrackingData(QObject):
|
|||||||
bodyaxis = [0, 1, 2, 5]
|
bodyaxis = [0, 1, 2, 5]
|
||||||
bodycoords = self.coordinates()[:, bodyaxis, :]
|
bodycoords = self.coordinates()[:, bodyaxis, :]
|
||||||
head_tail_vector = bodycoords[:, -1, :] - bodycoords[:, 0, :]
|
head_tail_vector = bodycoords[:, -1, :] - bodycoords[:, 0, :]
|
||||||
head_tail_length = np.linalg.norm(head_tail_vector, axis=1, keepdims=True)
|
head_tail_vector = head_tail_vector[:, np.newaxis ,:] # cross-product only defined in space, not in 2D
|
||||||
normalized_head_tail_vector = head_tail_vector / head_tail_length
|
head_tail_length = np.linalg.norm(head_tail_vector, axis=1, keepdims=True) # pythagoras, length of head- tail connection
|
||||||
|
point_axis_vectors = bodycoords - head_tail_vector
|
||||||
projections = np.einsum('ijk,ij->ik', bodycoords - bodycoords[:, 0, np.newaxis, :], normalized_head_tail_vector)
|
deviations = np.cross(head_tail_vector, point_axis_vectors)/head_tail_length
|
||||||
distances = np.linalg.norm(bodycoords - (bodycoords[:, 0, np.newaxis, :] + projections[:, :, np.newaxis] * normalized_head_tail_vector[:, np.newaxis, :]), axis=2)
|
deviation = np.mean(deviations, axis=1)
|
||||||
deviation = np.mean(distances, axis=1)
|
|
||||||
return deviation
|
return deviation
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
@ -237,7 +236,8 @@ def main():
|
|||||||
lengths = data.animalLength()
|
lengths = data.animalLength()
|
||||||
frames = data["frame"]
|
frames = data["frame"]
|
||||||
tracks = data["track"]
|
tracks = data["track"]
|
||||||
bendedness = data.bendedness()
|
|
||||||
|
# bendedness = data.bendedness()
|
||||||
|
|
||||||
embed()
|
embed()
|
||||||
tracks = data["track"]
|
tracks = data["track"]
|
||||||
|
Loading…
Reference in New Issue
Block a user