[open] Adding random number to Draw Textline?
I have made a visual stimuli that consists of a series of numbers spaced apart in varying ways ( see below)
Each of the numbers is positioned using the draw text line feature with specific coordinates. I was wondering if there is anyway I can use a random number generator to add a random number in the text line, keeping the same format as I already have ( but changing the numbers shown), so that I can create a collection of the stimuli above automatically? I have a number of other test cards with varying degrees of spacing that I will apply the method too as well.
Thank you in advance,
Tyler
Comments
Hi Tyler,
Do you want to change the numbers, after you have already created such a display, or is it also fine, if you create it with random numbers right from the beginning?
The exact way of doing it depends on what it is that you need. In any case, you have to have control over which type of stimulus (line vs. number) is shown at which position. So, while creating the displays, you need to keep track of the positions, e.g. in a
listthat either saves the coordinates, or only the indices of them, if the coordinates are evenly spaced.Later, you can use this
listas a boolean array like way of accessing the content at every position and manipulate it in any way you like.Does this make sense? If you need more help, just say so.
Good luck,
Eduard
Hi eduard,
Thank you for your response. It is not necessary that I create the random number array later, but it is important that the coordinates of the numbers and the lines remain the same. If it is not too much trouble, could you give me an example of how I might use 'list' to save the coordinates?
This is sort of what I had in mind:
@ [-480, -384] = output is some random number; @ [-224, -384] = output is some random number, etc
In my mind, the idea is to set up the coordinate array and have it propagated with random numbers automatically. This is to say that once the list has been created for the coordinates, I want a function to take the coordinates and give a random number output. If this makes since.
Thank you for your help,
Tyler
Hi Tyler,
I assume, that your display has a grid-like structure, that is, it consists of a certain number of cells in horizontal and vertical dimension, which are evenly spaced. Is this correct?
If so, you could split the creation of this display into two functions. First, for creating the grid and assigning every position to the respective category (line vs. number). Second, adding random numbers and put them at the proper positions. So, pretty much like you already thought.
The first function could look like this:
If you want to make sure that there is at least a certain numbers of positions assigned to lines/numbers you can wrap a
whileloop around this function and run it until the requirements are fulfilled, e.g.:After you have the indices of every position in your display, you can loop over each of it, check to which group it belongs and draw the corresponding stimulus. Here, you also have to translate the position indices into real coordinates, which is not really difficult. The general idea is to divide the total space your display should cover, by the number of elements per dimension.
This should help you getting started, right? Let us know if you need more help.
Good luck,
Eduard