[trackingdata] avoid div by zero on center of gravity estimation
This commit is contained in:
parent
64e75ba4b0
commit
765d381c5d
@ -199,8 +199,11 @@ class TrackingData(QObject):
|
|||||||
scores[:, np.setdiff1d(np.arange(scores.shape[1]), nodes)] = 0.0
|
scores[:, np.setdiff1d(np.arange(scores.shape[1]), nodes)] = 0.0
|
||||||
weighted_coords = self.coordinates(selection=selection) * scores[:, :, np.newaxis]
|
weighted_coords = self.coordinates(selection=selection) * scores[:, :, np.newaxis]
|
||||||
sum_scores = np.sum(scores, axis=1, keepdims=True)
|
sum_scores = np.sum(scores, axis=1, keepdims=True)
|
||||||
center_of_gravity = np.sum(weighted_coords, axis=1) / sum_scores
|
|
||||||
return center_of_gravity
|
cogs = np.zeros((weighted_coords.shape[0], 2))
|
||||||
|
val_ids = np.where(sum_scores > 0.0)[0]
|
||||||
|
cogs[val_ids] = np.sum(weighted_coords[val_ids], axis=1) / sum_scores[val_ids]
|
||||||
|
return cogs
|
||||||
|
|
||||||
def animalLength(self, bodyaxis=None):
|
def animalLength(self, bodyaxis=None):
|
||||||
if bodyaxis is None:
|
if bodyaxis is None:
|
||||||
|
Loading…
Reference in New Issue
Block a user