Random angle for DrawGratings

153 views
Skip to first unread message

RMojica

unread,
Nov 23, 2021, 5:27:13 PM11/23/21
to Bonsai Users
Hi all,
I'm trying to feed random angles to the DrawGratings Bonvision node, so that every presentation occurs in a different direction (in multiples of 45 degs). To achieve this, I create a ParameterRange from -224to +224, use a PythonTransform to convert the continuous range to steps of 45 degrees (-180 to +180), and then use the Permutation node to shuffle this range. Then, I feed this into the Observable DirectionalGrating, where the angle is fed to Stim1 and finally goes into DrawGratings.

However, I am seeing unexpected behavior... The angle the is displayed is not the correct one, and in fact, if I stop the workflow, I can see that the angles presented are in the order of thousands. For example, when the random angle is 45 degs, the Angle property of DrawGratings takes the value -7734.93; when it's 180, the Angle property is 10313.24, etc.

I have tried using the Angle Bonvision node, as well as experimenting with data types in my PythonTransform and downstream, but nothing seems to fix the behavior.

Any idea why this is happening?
Screenshot 2021-11-23 165618.png
drifting_gratings.bonsai

Aman Saleem

unread,
Nov 24, 2021, 3:34:00 AM11/24/21
to RMojica, Bonsai Users
Hello,
I noticed a couple of issues with the workflow. 
- You don't need a python transfer after ParameterRange. If you choose the right count and range you can get the distribution you want. In this case Count:8; Range:45 to 360. If you want more repeats, you can add a Repeat/RepeatCount node later.
- While the angle is displayed in degrees, it actually uses radians as an input. So, you need a add a DegreeToRadian node between somewhere.

Here is a screenshot where things work as you wanted them to. 

Hope this helps,
Aman

image.png

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/bonsai-users/753a6d18-b371-418d-b377-c970e0b63bfen%40googlegroups.com.


--
Aman Saleem
University College London
London, UK



RMojica

unread,
Nov 24, 2021, 4:12:29 PM11/24/21
to Bonsai Users
Hi Aman,

Thank you so much for your input! I suspected it had something to do with degrees vs radians, but the Angle property being in degrees threw me off. It now works as expected.
Your other suggestion works like a charm as well, and makes the workflow more elegant (and the Bonsai equivalent of pythonic).

With gratitude,
Raul
Reply all
Reply to author
Forward
0 new messages