echiappe / BonsaiClub

Repository with materials for Chiappe Lab's Bonsai Club
0 stars 0 forks source link

Orientation tracking algorithm #2

Open bruno-f-cruz opened 1 year ago

bruno-f-cruz commented 1 year ago

Currently, we are using an algorithm identical to the one previously suggested by Goncalo.

Since the lab already appeared to have a better working solution it would be good to have access to that piece of code and try to implement it in the current workflow.

miguel-paco commented 1 year ago

I am summarizing here the orientation tracking algorithm.

1st: check the major axis orientation vs the previous orientation. if it is flipped, correct it to follow the same direction as the previous tracking point. 2nd: check the cosine similarity between the orientation vector (centroid to head) and the motion vector (centroid to previous centroids). if cosine similarity > 0 then we save a 1 into an array. if cosine similarity < 0 then we save a -1 into an array. if the motion vector is smaller then a threshold, we save a 0 into an array. 3rd: Sum the array over a specific amount of frames (last 9 frames). if the sum of the array is < 0, then it flips the orientation vector and resets all the array values to 0 to reset the algorithm.

Could you show me how to implement a similar algorithm or an alternative that does the same calculations in bonsai.

Tell me if there are any questions?

miguel-paco commented 1 year ago

Could you place here the bonsai code that was done by gonçalo during the last bonsaiclub where this issue was addressed?