Equal distribution of dot stimulus (DotStim) over aperture with long dot life: (how) can I use this GitHub code?

OSX Mojave
PsychoPy v3.0.7 (standalone)

I want to create a dot stimulus with dots that have an infinite dot life time and a 100% coherent motion direction, though with the concentration of dots over the aperture to be homogeneous at any time in the stimulus duration. It is known that this is not the case when using the default DotStim settings in the Builder and only altering coherence to 1.0 and dot life time to -1 (infinite).

I found this GitHub code that exactly describes this problem and, I think, offers a solution:
Link to GitHub

It is unclear to me if this is an earlier version of the DotStim code? Because it is also called “dot.py”? Is it is an alteration? And, if so, how could I implement this code when using the builder? Should I store this file at the appropriate folder in the PsychoPy application folder instead of the “dot.py” file that came with the installation?

Is any of you familiar with this code on GitHub and does it indeed provide a solution for my problem?

Hi @Myjulo, the link is to a current version of PsychoPy, but it may seem confusing becuase of the commit history for dot.py was last updated for version 1.90.2. This means that the dot.py code has not been updated since PsychoPy version 1.90.2, but is still the most recent version available.

To implement this code in Builder, you would use the Dots: Random Dot Kinematogram (RDK) component in the Stimuli category in Builder. See DotStim API documentation and also the DotStim RDK for Builder documentation

Hi @dvbridges,

Thank you for the clarification! I have an additional question though. In the code in the link at line 13, there is a comment stating that the dot stimulus can be programmed such that new dots do not appear randomly in the aperture but at the opposite edge of where they are moving to, so that the density of dots over the aperture stays homogeneous. This homogeneity issue is well known for the dot stimulus when using an infinite dot life time and a 100% coherent motion direction. Is there indeed a solution provided in the dot.py code?

Hi, I am running into the same problem. Has this been resolved? Any suggestion how to fix?

Thanks

Hello, I am running into the same issue and am not able to resolve it. Could you please provide addition information?

Much appreciated!

Hi there! I fixed it in a somewhat unelegant way. But what I do is make the dotstimulus larger than I intend it to be and then paste a circular aperture over the dotstimulus to make it smaller. If you now coordinate the speed of the dots and the duation of the trial to the ratio of the dotstimulus and aperture size, you should have homogeneous dots every trial during the whole trial.

1 Like

@dizzie I actually have to add something. I remembered I also use this code in the “Begin Routine” section in a Builder code element:

dots._verticesBase = dots._newDotsXY(400)

where ‘dots’ is the name of the dotstimulus and 400 stands for the number of dots used for that stimulus.

I’ve made a couple of edits to the github code to make things work for my purposes.
Let me know if you’d like a copy of my version.
(I’m not enough of a programmer to post things on github, but happy to share.)

@aseydell Yes, I would love to have a peak at your code! Thanks!!

Sure thing! I’m not sure whether you can get an email attachment via PsychoPy - I’ll try. If it doesn’t come through, please give me your email address and I’ll send the code directly.

For this to work, you’ll first have to find the place on your computer where the original dot.py file is stored.

On my PC, I could get there by right-clicking on the PsychoPy icon, then choosing “open file location”, and navigating to PsychoPy3\Lib\site-packages\psychopy\visual.

On my Mac, I navigated to PsychoPy in the Applications folder, right-clicked, and chose “Show Package Contents”, then found the files under Applications/PsychoPy3/Contents/Resources/lib/python3.6/psychopy/visual.

I’d then copy the dot.py file that’s in there (you’ll probably need admin privileges) to some other location for safekeeping.

Then re-name the attached file to dot.py and put it into the “visual” folder (again, you’ll probably need admin privileges).

Any call to DotStim will then use this code - and hopefully work without dot density inhomogeneities.

(As you can see above, I’m using PsychoPy3.6 - no clue whether it works with earlier versions.

I left pretty extensive comments in the code to mark my edits - look towards the end of the file if you’re curious.)

Good luck!

dotpy_for_sharing.py (28.4 KB)