Howdy, Stranger!

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

Supported by

Image in Background (Sketchpad)

Hi all,

I'm trying to create an experiment with a mouse response on ROI. My ROI are rect which change position on the sketchpad. Now I want to include an image in the background and make my ROI transparent, so it looks like the participants are clicking on the background image but are actually clicking on my ROI. Anyhow when I put the image in the background I am not able to click on my ROI and get a correct response, even when I put the image in the background (z_index=1) it still does not except clicks on the ROI.

How can I put an image in the background that is not clickable but just there (for every trial)?


Thanks in advance!

Comments

  • Hi Igotta,

    I am not sure what ROI means, but maybe it is not that important.

    If you creat a canvas in an inline_script you may set an image at the background.

    Then you can put additional things (text, rectangles) onto the image. I am not sure whether you can set it transparant, but if your background image is white at these parts you can add a white rectangle.

    Then you can define that only the rectangle is clickable.

    Hope this helps

    Stephan

  • Hi Stephan,

    thank you for your quick response. I'm trying to draw the picture on my canvas using an inline script before my sketchpad

    prepare:

    my_canvas = Canvas ()

    path = exp.pool[u'Dringend.png']

    my_canvas.image(path)


    run:

    my_canvas.show ()


    but the picture only appears for one millisecond.

    Also is it possible to combine a sketchpad and an inline script in a way that the inline script only adds the image to the existing sketchpad or do I need to build everything in the script?


    Thanks for your help

    Charlotte

  • Ok.Now I managed to combine sketchpad and image. What I can't manage is to put the image in the background. I tried z_index=1 but it's not working. Here is my script so far:


    prepare (after sketchpad):

    my_canvas = items['new_sketchpad'].canvas


    run:

    bgroung_image = exp.get_file('Dringend.png')

    my_canvas.image(bgroung_image, True, -100, -300 )

    my_canvas.show()


    Can anyone help to put the bground_image in the background?

    Thanks and cheers!

  • I haven't followed the complete discussion, but if you have a sketchpad that is being executed (run_if statement is set to always, or evaluates to True), and there is no delay between the inline_script and the sketchpad, the sketchpad will override the canvas within 1-2 frame flips. This is because right after you show your canvas in the prepare phase, the sketchpad is being executed in the run phase. Do you see?

    To check whether this is really what happens, you can add a delay after my_canvas.show(). So for example, clock.sleep(3000) timeouts for 3 seconds.

    If you want to get the image onto your sketchpad, you have then reverse the assignment: items['new_sketchpad'].canvas = my_canvas. But honestly, I don't really get why you would do that. Why don't just use inline_scripts or just use sketchpads? Why combining them?

    Eduard

    Buy Me A Coffee

  • Hi Eduard,

    I'm combining inline_script and sketchpad simply because i could't figure out how to do this only in sketchpad. If there is a way to do that that would be great.

    In the beginning of this discussion I described my issue a little more detailed. Do you have an idea how to put an image in the background of my sketchpad so when the ROI on top of it are clicked the mouse still collects a response? z_index does not work unfortunately.

    Charlotte

  • Never mind,

    solved it :) Thanks for the help anyway!

Sign In or Register to comment.