Howdy, Stranger!

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

Supported by

[solved] Easy way to use a lot of photos?

edited September 2014 in OpenSesame

Hi,
I already posted this question a couple of days ago but I can't find the discussion anymore.
I am making an experiment which uses a lot of photos (over 2000). The way I understand it, the only way to use these photos is to drag them to the file pool, but to use them in a loop you have to enter each file name manually. I was wondering, is there a way to just direct openSesame to a folder outside of the openSesame environment and program something like 'for this loop, use random photos from this folder'? That would help me a lot.
Thanks,
Floor

Comments

  • I have exactly the same request :)
    We have a set of 3500 fractals, and a lot of variation of the code.
    The hard drive is quite full... :p

  • edited 9:38AM

    Hi, I already posted this question a couple of days ago but I can't find the discussion anymore.

    Technical issues, sorry. But we're back online now!

    Yes, you can certainly read images from a folder. OpenSesame doesn't just accept files from the file pool, it also looks in the experiment folder, and accepts relative and absolute paths.

    In your case, what you could do is build a list of images at the start of your experiment. Something like this:

    import os
    import random
    # Specify the folder with your images
    my_image_folder = '/home/sebastiaan/Pictures'
    # Walk through all files in this folder ...
    my_image_list = []
    for fname in os.listdir(my_image_folder):
        # ... but only take those that end with .png. Change this to .jpg,
        # .bmp, etc. as required.
        if fname.endswith('.png'):
            # Add the full path (i.e. including the folder) of the image to
            # a list.
            path = os.path.join(my_image_folder, fname)
            my_image_list.append(path)
    # Shuffle the list
    random.shuffle(my_image_list)
    # Print it out so we can see in the debug window. This way you can check
    # if things work as expected.
    print my_image_list
    

    Once you have this list (my_image_list), you can simply take one item from the top at the beginning of every trial. Like so (in the prepare phase on an inline_script):

    # Take the last image from the list ('pop').
    image = my_image_list.pop()
    # And set it as an experimental variable.
    exp.set('image', image)
    

    Because you've set image as an experimental variable, you can log it, use it in a sketchpad, etc.

    See? Not that hard, really.

    Cheers!
    Sebastiaan

  • Thank's a lot :) I'll try as soon as possible

  • edited 9:38AM

    Yes, thank you! This helps a lot.
    However, with each photo, there is also a correct keyboard response. Is there a way to link a correct keyboard response to a particular picture this way?

  • edited 9:38AM

    so, to clarify: can I implement something that says "if the filename ends with 3.jpg the correct keybord response is 3"?

  • edited 9:38AM

    Nevermind, I found a way which works! (after a little bit of testing).
    for those who are interested:
    after
    exp.set('image', image)
    write: if image.endswith('3.JPG'):
    exp.set("correct_answer", 3)

    Thanks again for your help Sebastiaan, you saved me a lot of work! :D

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