Howdy, Stranger!

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

Supported by

[solved] Text/Image position independent of resolution?

edited April 2014 in OpenSesame

Hey!
I'm trying to set up an experimental paradigm on OpenSesame that is going to be used on multiple different systems. Since display resolutions might differ, I'm looking for a way to define stimulus positions based on percentage of the display rather than pixels. Right now I'm thinking about using an inline script to calculate the positions. I was wondering, however, if there is an easier way to change coordinates in opensesame.

Thanks in advance,
Jannis

Comments

  • edited April 2014

    Hi Jannis.

    The inline_script option is the easiest way to go, as OpenSesame does not support other coordinate units than pixels, and arithmetic operations in sketchpad's aren't supported. This doesn't mean that it has to be difficult to find a solution, though!

    Let's say you define the x and y coordinate of a stimulus in a loop item, as a percentage of the display size. Let's call the variables xpos and ypos. To recalculate this to pixels based on the display resolution, place the following code in the Prepare phase of an inline_script at the start of the trial sequence:

    # calculate the pixel values
    xpos = int(self.get("xpos") * self.get("width"))
    ypos = int(self.get("ypos") * self.get("height"))
    
    # overwrite the percentage values
    exp.set("xpos", xpos)
    exp.set("ypos", ypos)
    

    Now in a sketchpad, you can use [xpos] and [xpos] to define the stimulus coordinates.

    Good luck!

  • edited 11:57AM

    Hey Edwin,
    thanks for your help, works perfectly!

    cheers

  • edited April 2016

    Hi there Jannis,

    I'm trying to use the same inline script to get my images to fit my screen for an MRI experiment since some images are a bit on the large side. However I keep getting an error relating to my int. value I think. Any advice?

    image

    EDIT: More specifically, is there a way to scale in image to match the screen resolution/size

    Thank you!

  • edited April 2016

    Hi,

    The error that you are posting is related to some type conflict. As it seems you are trying to convert something to an integer (maybe even implicitly), which cannot be an integer. To say for sure, I would have to see the piece of code that produced this error.

    EDIT: More specifically, is there a way to scale in image to match the screen resolution/size

    var.width and var.height represent the dimensions of the screen. If you normalize your images based on these to values, you will get a scaling factor, that you have to apply to your images, so that your images will fit the screen. Something like that:

    image_width = 1680
    image_height = 1050
    
    # var.width = 800
    # var.height = 600
    
    scaling_x = var.width / float(image_width)
    scaling_y = var.height / float(image_height)
    
    # later when you draw your canvas, something like that
    canvas.image(image, scale = scaling_?) # if you wanna keep the ratio, use the
    # smaller of scaling_x, or scaling_y, respectively
    
    

    Does this help?

    Eduard

    Buy Me A Coffee

  • edited 11:57AM

    Hi Eduard,

    The images I have vary in dimension, some are 22501250, while others maintain a 800600 dimension. I opted for manually editing the images and scaling them with a locked aspect ration. Not the most elegant or efficient solution, but Occams razor.

    Thanks for the quick reply though. (y)

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games