Tracking of mouse nose.

534 views
Skip to first unread message

Joan Esteve Agraz

unread,
May 22, 2018, 4:45:20 PM5/22/18
to Bonsai Users
Hey everyone,
I see that Bonsai is growing fast, cool!

I want to ask something related to a previous old question:

https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/bonsai-users/03LAQjhG24I/fWAeMlOwBQAJ;context-place=searchin/bonsai-users/zebrafish$20heading

I'm just focusing on tracking (in a reliable and stable way) the nose of a mouse in this open arena. The field is pretty small, and the conditions are pretty nice.
Therefore, I can get a nice tracking, however, the coordinate that I'm interested in (nose) sometimes do the thing so-called 'faceass' (the ExpressionTransform node after the BinaryRegionExtremes one), so it 'jumps' from one side of the animal to the other in a frame.
So the main question that I'd like to know is:

- Is there any python transform that can avoid the jumping in the coordinates that happens in one frame-based. Don't know really how to tell Python that X and Y coordinates should not change more than 'n' number of pixels in 1 frame change. It could also keep a memory of the previous coordinates to find the closer one. 

- Or any other idea how to keep the nose coordinates stable, I would really appreciate it. 

Attached is the Bonsai file, this link leads to the video: https://drive.google.com/file/d/1uZzaCnwSIIGj5Ga92Y-TdPJFJ6A0gdlW/view?usp=sharing

Best,

Joan
mouse-track.bonsai

Gonçalo Lopes

unread,
May 23, 2018, 8:27:02 PM5/23/18
to Joan Esteve Agraz, Bonsai Users
Hi Joan,

Good to see things are working again. I believe you will find this old post very useful:

Basically I believe the last answer describes what you are looking for, a script that memorizes the previous position and uses it to keep track of the correct points. It should be possible to adapt the memorization criteria so that you adjust for fast movements.

Hope this helps!

--
You received this message because you are subscribed to the Google Groups "Bonsai Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bonsai-users+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/bonsai-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/bonsai-users/e1804ef5-cf6a-4f6c-9eab-8a6210dc6835%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Joan Esteve Agraz

unread,
May 24, 2018, 12:53:30 PM5/24/18
to Bonsai Users
Hey,

I checked it already and I've been trying, but the jumps still occur.

Let me be more clear:

 - With the expression transform node I get a much more stable nose point, which still is jumping, but much less than the point extracted from the binary region extremes one. 
    So I was thinking if there is a way to set a max range of pixels for both x and y coordinates of that point that can jump. For example:

          - So if x coordinate is in 245, next frame it changes less than 40 pixels, lets say; then it is a possible change. However, if the change of pixels is bigger than 40, then do not allow it, and by keeping the memory of the previous frames, then it can go to the closest location of the last pixel. 

I think this makes sense, and by checking the different movements from the animal and jumpings of the point, and I realized that this 40 pixels change is more or less normal. A bigger change means that the point is not in the nose anymore.  In this way, I also think that can be more easily done, since it is only focusing in one point (the one extracted from the expression transform), and only needs to take into account its coordinates, and not both points. 


Let me know if this makes sense and if can be implemented, 

Thanks so much!

Best,

Joan


El jueves, 24 de mayo de 2018, 2:27:02 (UTC+2), goncaloclopes escribió:
Hi Joan,

Good to see things are working again. I believe you will find this old post very useful:

Basically I believe the last answer describes what you are looking for, a script that memorizes the previous position and uses it to keep track of the correct points. It should be possible to adapt the memorization criteria so that you adjust for fast movements.

Hope this helps!
On 22 May 2018 at 21:45, Joan Esteve Agraz <joan.est...@gmail.com> wrote:
Hey everyone,
I see that Bonsai is growing fast, cool!

I want to ask something related to a previous old question:

https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/bonsai-users/03LAQjhG24I/fWAeMlOwBQAJ;context-place=searchin/bonsai-users/zebrafish$20heading

I'm just focusing on tracking (in a reliable and stable way) the nose of a mouse in this open arena. The field is pretty small, and the conditions are pretty nice.
Therefore, I can get a nice tracking, however, the coordinate that I'm interested in (nose) sometimes do the thing so-called 'faceass' (the ExpressionTransform node after the BinaryRegionExtremes one), so it 'jumps' from one side of the animal to the other in a frame.
So the main question that I'd like to know is:

- Is there any python transform that can avoid the jumping in the coordinates that happens in one frame-based. Don't know really how to tell Python that X and Y coordinates should not change more than 'n' number of pixels in 1 frame change. It could also keep a memory of the previous coordinates to find the closer one. 

- Or any other idea how to keep the nose coordinates stable, I would really appreciate it. 

Attached is the Bonsai file, this link leads to the video: https://drive.google.com/file/d/1uZzaCnwSIIGj5Ga92Y-TdPJFJ6A0gdlW/view?usp=sharing

Best,

Joan

--
You received this message because you are subscribed to the Google Groups "Bonsai Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bonsai-users...@googlegroups.com.

Gonçalo Lopes

unread,
Jul 7, 2018, 6:29:12 PM7/7/18
to Joan Esteve Agraz, Bonsai Users
Hi Joan,

Sorry I wasn't able to reply sooner. Any updates on this? You should be able to adapt the python script in the previous post to achieve the desired behavior. That script already picks the closest point to the previous two points. If you add on top of that an extra condition to check whether distancesquared is smaller than 40 for the closest point, it should work. In case the point is not smaller, you simply don't update the memory.

Hope this helps.

To unsubscribe from this group and stop receiving emails from it, send an email to bonsai-users+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages