Welcome! Log In Create A New Profile

Advanced

How to draw a gray ring stimulus using MonkeyLogic Version 2?

Posted by mengcheng 
How to draw a gray ring stimulus using MonkeyLogic Version 2?
June 15, 2025 01:19PM
Hi Jaewon,

I'm trying to draw a gray ring stimulus in MonkeyLogic Version 2 using PolygonGraphic, but I haven't been able to get it to render correctly.

Stimulus specs:
Outer diameter: 0.6 degrees
Inner diameter: 0.5 degrees (i.e., it should be a ring, not a filled disk)
Color: Gray [0.5 0.5 0.5]

I attempted to use the PolygonGraphic class to create this annulus shape by subtracting two concentric circles or by drawing a shape with a hole, but I couldn't find a way to make it work. The documentation and examples I found focus mostly on filled shapes.

My question:
Is there a recommended way to draw a ring (annulus) stimulus with an inner hole using MonkeyLogic V2? Should I use PolygonGraphic, or is there a better approach?

Any help or example code would be much appreciated!

Thanks in advance!

MengCheng
Re: How to draw a gray ring stimulus using MonkeyLogic Version 2?
June 16, 2025 03:48PM
Use CircleGraphic.
crc = CircleGraphic(null_);
crc.List = { [1 0 0], [1 0 0], [0.5 0.5], [0 0]; ...
        [0.5 0.5 0.5], [0.5 0.5 0.5], [0.6 0.6], [0 0] };
tc = TimeCounter(crc);
tc.Duration = 5000;

scene = create_scene(tc);
run_scene(scene);
Re: How to draw a gray ring stimulus using MonkeyLogic Version 2?
June 29, 2025 01:18PM
Hi Jaewon,

Thank you very much for your suggestion and for sharing the sample code using CircleGraphic.

I tested it on my setup, but unfortunately, the ring doesn’t appear smooth when using smaller diameters. The shape looks uneven, and the edges are quite jagged—please see the attached image for reference. It seems the annulus isn't rendering with clean contours or proper anti-aliasing.

Interestingly, when I set the inner and outer diameters to 2 and 3, the ring appears smooth and uniform. However, when I set the diameters to 0.5 and 0.6—as in my intended stimulus parameters—the ring becomes jagged and distorted, as shown in the photo. It seems this issue may be related to resolution or rendering at small scales.

Is there any way to improve the appearance of the ring at smaller sizes, or would you recommend a different approach for rendering a clean annulus stimulus?

I truly appreciate your help and any further guidance you can offer.

Best regards,
Mengcheng
Attachments:
open | download - attached image.jpg (1.38 MB)
Re: How to draw a gray ring stimulus using MonkeyLogic Version 2?
June 30, 2025 03:14PM
It is natural that small circles get pixelated. In addition, CircleGraphic does not do anti-aliasing, for fast graphic updates (e.g., animation).

The pixelation may occur only on the control screen. Your subject screen is probably larger and you may not see it there.

You do not have to use CircleGraphic. You can create the stimuli as CRC TaskObjects, which do anti-aliasing, and present them with create_scene().

The National Institute of Mental Health (NIMH) is part of the National Institutes of Health (NIH), a component of the U.S. Department of Health and Human Services.