4/14/2023 0 Comments Psychopy draw rectangleHowever, vertices are (x,y) coordinates, so we need to convert these degrees. So how do we create these vertices? Since a circle consists of 360°, we will first say that we will sample the circumference after each 1° (this is the step_size). We will create a circle by manually specifying the vertices and then create a ShapeStim based on those vertices. These vertices are connected by straight lines, but because you have so many of them (and because each single one is very tiny), you have the impression of a round object. Although we say that a circle is round, the drawing process on a computer involves defining a lot of vertices on the circumference of that circle. The actual rectangle is then rendered by drawing a line through those points. For example, a rectangle can be defined by four vertices. So what are vertices? They are basically the points, or (x,y) coordinates, that define a figure. They just have their vertices preset so that we don’t need to bother about that. In fact, some of the objects that you can use (such as Rect, Circle, Polygon, …) are examples of a ShapeStim. This allows you to create a shape by defining an arbitrary set of vertices. For that we can use the ShapeStim object. Getting started: The ShapeStimīecause this stimulus is not part of the PsychoPy toolbox, we need to create it ourselves. ![]() However, here we will take the point that you do need that flexibility. In this case, I would argue that if you do not need the flexibly change your stimulus during the course of the experiment, it is best to stick with the image. This is always a good consideration to make before you start coding, as an elegant solution does not necessarily mean you have to write code. ![]() After all, if you already have the image, why not just render the image itself in PsychoPy? Before we do that, we first need to ask the question if it is really necessary to take that approach. In this post I will demonstrate how you can create the figure below in PsychoPy using the ShapeStim object. In fact, most cases where I had to actually ‘use’ mathematics in my research involved just that. ![]() However, I do think that some basic trigonometry knowledge should be part of your toolbox. If you are not planning on writing your own machine learning algorithms I would say no. People often wonder if you need to be good at mathematics to be a good programmer.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |