Howdy, Stranger!

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

Supported by

How looping pictures stimulus

I am programming my cognitive-emotion recognition experiment. But I had some difficulties concerned how to looping the image using "expyriment.stimuli.Picture()". I had 5 major emotion and i want to present in 2 blocks and 5 trials. Here some my code :
n_trials_block = 5
n_blocks = 2
emo_stimuli = ["G:/Py/Imej/Anger.jpg", "G:/Py/Imej/Contempt.jpg", "G:/Py/Imej/Disgust.jpg", "G:/Py/Imej/Happy.jpg"]
exp = expyriment.design.Experiment(name="Emotion_Recognition")
expyriment.control.initialize(exp)

for block in range(n_blocks):
my_block = expyriment.design.Block(name=str(block + 1))
for trial in range(n_trials_block):
now_stimuli = emo_stimuli[trial]
emot_stim = expyriment.stimuli.Picture(emo_stimuli)
emot_trial = expyriment.design.Trial()
emot_trial.add_stimulus(emot_stim)
my_block.add_trial(emot_trial)

my_block.Shuffle_trials()
exp.add_block(my_block)

Comments

  • Hi Tanto,

    I am not sure I understand what it exactly it is you want to achieve. Could you maybe be a bit more specific?

    Best,
    Florian

  • My apologies, I am new in Python and all the stuff scripting language. My research is to distinguish ERA (Emotional Response Ability) with Positive Emotion and Negative Emotion. In positive emotion I have happy and joy, in negative emotion there are sad and anger. To present this image I need some ability to looping the image, otherwise I just write it down in very tidy ways :

    block = 2
    n_trial_block = 5
    expyriment.io.defaults.outputfile_time_stamp = False
    exp = expyriment.design.Experiment(name="Visual_Emotion_Recognition")
    expyriment.control.initialize(exp)

    block_one = expyriment.design.Block(name="1")
    trial_one = expyriment.design.Trial()
    stim = expyriment.stimuli.Picture("G:/Py/Imej/Anger.jpg")
    stim.preload()
    trial_one.add_stimulus(stim)
    trial_two = expyriment.design.Trial()
    stim = expyriment.stimuli.Picture("G:/Py/Imej/Sad.jpg")
    trial_two.add_stimulus(stim)
    trial_three = expyriment.design.Trial()
    stim = expyriment.stimuli.Picture("G:/Py/Imej/Sad.jpg")
    trial_three.add_stimulus(stim)
    trial_four = expyriment.design.Trial()
    stim = expyriment.stimuli.Picture("G:/Py/Imej/Anger.jpg")
    trial_four.add_stimulus(stim)
    trial_five = expyriment.design.Trial()
    stim = expyriment.stimuli.Picture("G:/Py/Imej/Sad.jpg")
    trial_five.add_stimulus(stim)
    block_one.add_trial(trial_one)
    block_one.add_trial(trial_two)
    block_one.add_trial(trial_three)
    block_one.add_trial(trial_four)
    block_one.add_trial(trial_five)
    block_one.shuffle_trials()
    exp.add_block(block_one)

    block_two = expyriment.design.Block(name="2")
    trial_one = expyriment.design.Trial()
    stim = expyriment.stimuli.Picture("G:/Py/Imej/Fear.jpg")
    stim.preload()
    trial_one.add_stimulus(stim)
    trial_two = expyriment.design.Trial()
    stim = expyriment.stimuli.Picture("G:/Py/Imej/Sad.jpg")
    trial_two.add_stimulus(stim)
    trial_three = expyriment.design.Trial()
    stim = expyriment.stimuli.Picture("G:/Py/Imej/Sad.jpg")
    trial_three.add_stimulus(stim)
    trial_four = expyriment.design.Trial()
    stim = expyriment.stimuli.Picture("G:/Py/Imej/Fear.jpg")
    trial_four.add_stimulus(stim)
    trial_five = expyriment.design.Trial()
    stim = expyriment.stimuli.Picture("G:/Py/Imej/Fear.jpg")
    trial_five.add_stimulus(stim)
    block_two.add_trial(trial_one)
    block_two.add_trial(trial_two)
    block_two.add_trial(trial_three)
    block_two.add_trial(trial_four)
    block_two.add_trial(trial_five)
    block_two.shuffle_trials()
    exp.add_block(block_two)

    block_three = expyriment.design.Block(name="3")
    trial_one = expyriment.design.Trial()
    stim = expyriment.stimuli.Picture("G:/Py/Imej/Happy.jpg")
    stim.preload()
    trial_one.add_stimulus(stim)
    trial_two = expyriment.design.Trial()
    stim = expyriment.stimuli.Picture("G:/Py/Imej/Joy.jpg")
    trial_two.add_stimulus(stim)
    trial_three = expyriment.design.Trial()
    stim = expyriment.stimuli.Picture("G:/Py/Imej/Happy.jpg")
    trial_three.add_stimulus(stim)
    trial_four = expyriment.design.Trial()
    stim = expyriment.stimuli.Picture("G:/Py/Imej/Happy.jpg")
    trial_four.add_stimulus(stim)
    trial_five = expyriment.design.Trial()
    stim = expyriment.stimuli.Picture("G:/Py/Imej/Joy.jpg")
    trial_five.add_stimulus(stim)
    block_three.add_trial(trial_one)
    block_three.add_trial(trial_two)
    block_three.add_trial(trial_three)
    block_three.add_trial(trial_four)
    block_three.add_trial(trial_five)
    block_three.shuffle_trials()
    exp.add_block(block_three)

    and so on..I just want to looping this three blocks. Its easier if the stimuli like textline to be presented that i can use list but if i do, there is some error that said "list cannot decode". After all..thanksssss for your support!!!

  • Assuming your question is how to get two different block types (one negative, one positive emotion), where each has 5 trials that are randomly(?) drawn from two possible pictures, something along the lines of this should work:

    import expyriment as xpy
    
    
    pictures = {"anger": xpy.stimuli.Picture("G:/Py/Imej/Anger.jpg"),
                "sad": xpy.stimuli.Picture("G:/Py/Imej/Sad.jpg"),
                "happy": xpy.stimuli.Picture("G:/Py/Imej/Happy.jpg"),
                "joy": xpy.stimuli.Picture("G:/Py/Imej/Joy.jpg")}
    for picture in pictures:
        pictures[picture].preload()
    
    exp = xpy.design.Experiment("Emotion Regulation")
    
    for emotion_type, emotions in {"negative": ["anger", "sad"], "positive": ["happy", "joy"]}.items():   # use iteritems() in Python 2
        block = xpy.design.Block()
        block.set_factor("EmotionType", emotion_type)
        for trial_repetition in range(5):
            trial = xpy.design.Trial()
            emotion = xpy.design.randomize.rand_elem(emotions)
            trial.set_factor("Emotion", emotion)
            trial.add_stimulus(pictures[emotion])
        exp.add_block(block)
    
  • Hi Florian
    Thank you very much! the basic is combine with tuple with every stimuli. I'll work for the rest (correct response in certain emotion).

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