Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Forming a 5*5 grid of already randomised elements

I will really appreciateand thankful if anyone help me forming a 5*5 matrix for the distractions (it's a visual search task ). Shapes have been already randomised. Simply need to align them. I am a beginner .I couldn't figure this out.Please do check attached script.


  • Hi,

    griddim= 5 # 5 by 5
    width = 500
    height = 500
    # if height and width are different you need to do this separately for cell width and cell height
    cell_size = width/griddim
    center_cell= cell_size/2
    # draw grid in center
    xc =0
    yc =0
    # top left corner of grid
    start_x = xc-0.5*width
    start_y = yc-0.5*height
    # calculate positions
    positions = []
    for xI in range(griddim):
        for yI in range(griddim):
            x = start_x+ center_cell+ xI*cell_size
            y = start_y+ center_cell+ yI*cell_size
    # next: loop over positions and assign a stimulus to that position (or vice versa)

    Hope this code helps.


  • Thank you so much sir.

Sign In or Register to comment.