Howdy, Stranger!

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

Supported by

Randomization

Hi,

I am designing an experiment that has 3 IVs : Incongruent vs. Congruent shapes, Audio (Silence, 120 bpm, 240 bpm), and Angle of rotation of the shapes (0, 50, 100, 150), giving me 24 unique trials. I have a total of 96 different images that account for 4 unique sets of the visual IVs. I would like to present all 96 of these stimuli in random order, but I also want each image to be randomly paired with one level of the Audio variable, so that no two participants experience the same trial order and paired image and sound combination. I am sort of stuck trying to figure out if this level of randomization is doable using the block loops, or if this would require changes to the script, addition of blocks, etc... Any assistance would be great. Thank you. I can definitely provide more information, if needed.

Comments

  • Hi @Tpatrick,

    I'm not sure I understand your description.

    You seem to have a 2 x 3 x 4 design, yielded 24 trial types that you want to present 4 timees each, leadiong to a total of 96 trials. You have 96 pictures that you want to allocate randomly to these 96 trials, Is that correct?

    If so, my recommendation would be to build your loop with the 96 trials, coding all three IVs as you want them to ensure full orthogonality (and setting the loop to select rows randoly).

    Regarding the pictures, you'd need to use some coding to create an array containing the 96 picture file names, shuffle that array (all of this before the loop). Then, in your trial sequence, set up a variable that counts the trials and use it to pull individual elements from the array to indicate to the task which picture to show. That would result in a random allocation of the pictures to the 96 trials, different every time the task runs.

    Hope this helps,

    Fabrice.

    Buy Me A Coffee

  • Hi Fab,

    Yes. That is correct.

    Does this code look correct?

    Additionally,

    I am trying to evenly distribute 3 audio files throughout the 96 images. So each audio file is paired with 32 trials (randomly). I am having some trouble getting the audio track to stop when a key is pressed. Does this require code to halt the audio and move onto the next trial when a response is provided?


    Thank you for your response.

  • This is the code I attempted to use to get the audio to stop when either the i or c key is pressed. I am getting the following error message:

     Inline script, line 5, in <module>

    AttributeError: 'str' object has no attribute 'start'

  • Hi @Tpatrick,

    I'm still not clear as to what you're trying to achieve exactly (I don't really follow your design). In any case, print screens of code don't really allow me to comment. Your first screen shot shows arrays but I'm not sure what you do with this later in the task. Doesn't look like you're actually storing the images in an array that you shuffle. I'd still recommend the method I described earlier (though again, I'm not sure what you're actually trying to do; but in case, you'll need to do some coding to resolve it).

    As for the sound, I don't typically use Python code for this, so I can't really comment. But the error seem to suggest that you haven't defined the sound object.

    Best of luck,

    Fabrice.

    Buy Me A Coffee

  • Hi Fabrice,

    I apologize, allow me to explain more clearly. I am creating a classic mental rotation task. The images are 1/2 incongruent (48) and 1/2 congruent (48) and within each set they are made up 12: 0 degree difference, 12: 50 degree difference, 12: 100 degree difference, and 12: 150 degree difference. My other IV is audio made up of: Silence, 120 bpm ticks, and 240 bpm ticks.

    My hope was to randomly present the different images, but also randomly (but evenly) pair them with the different levels of the audio. I want to present the image and the audio together and have the participants press either 'C' for congruent or 'I' for incongruent. I am trying to set it up so that the trial ends (both the audio and image stop) and moves on to the next trial (new image and new audio) when a key is pressed.

    Where I am running into difficulty is 1) figuring out how to randomly present the images and randomly pair the images with the audio and 2) getting the complete trials to end when the appropriate key(s) are pressed.

    I am going to continue chipping away at it, but to be honest I have little experience coding, so its an uphill battle right now. Any guidance would be much appreciated.

    Thanks again!

  • Hi @Tpatrick,

    Your description seems to fit my prior understanding. You have 4 times (2 x 4 x 3) = 96 trials and you want to allocate 96 images to these 96 trials in a random manner.

    So, the method is that I described earlier: creating an array with the 96 file names, shuffle it, then pull out elements one by one as your trials run. One simple method is to implement a counter, increment it in every trial, and use it to pull the nth element of the array.

    As for starting a sound and stopping it when a key is pressed, I'd run the following code in the trial sequence:

    # Prepare the script
    import pygame
    
    # Initialize the mixer module in pygame
    pygame.mixer.init()
    
    # Load the sound file from the file pool
    sound_file = pool[sound_file]
    sound = pygame.mixer.Sound(sound_file)
    
    # Play the sound in the background
    sound.play() 
    

    For this to work, you must have a variable called sound_file in your loop and it must contain the name of the sound file (which must be present in the pool).

    Then I'd insert the sketchpad with the stimulus you want to show (duration=0), a keyboard object, and right after the keyboard object, I'd run the follwing code to stop the sound:

    # Stop the sound when a key is pressed
    pygame.mixer.stop()
    

    Hope this helps,

    Fabrice.

    Buy Me A Coffee

  • Hi Fabrice,

    Thank you. This is definitely moving me in the right direction. Does this still apply if I have 3 different sound files that I will be selecting randomly? I created the variable sound_file in the loop and within that variable are the file names contained in my pool (0.wav, 120.wav, 240.wav) In the sampler under sound file I have [sound_file].wav to indicate that I want to call these different files. After entering the code above in the prepare and run phases, respectively, I am getting an error saying "sound_file is not defined". I am not sure what is off. I am going to continue toying with it but currently this is my issue.

  • I've tried using the inline script to randomly call both the images and files throughout the actual experiment. But its telling me that none of the images in my pool exist. I know there is a disconnect somewhere, but I can tell I am spinning my wheels trying to make sense of the most minor errors.


    Just to reiterate, in the experiment, I would like each image to be shown in random order, but only once. I would also like each image to be randomly paired with 1 of the .wav files. I would like the audio and the image to go away once a key press is made, recording the response time. This seems like a basic design, but I am struggling. Would you mind looking at what I have so far? I think that would help clarify any ambiguity that exists from trying to put this into words. Any guidance would be great. Please don't do it for me, but if you have any insight into what is wrong with the script or general setup that would be so helpful.

    Thank you

  • Hi @Tpatrick,

    If you get the message that the picture is not in the pool, print to the console the actual content of the variable you're using to retrieve a specific picture and check that it is correct. If the string OS uses to retrieve the picture is correct, then it must be that you did not include the picture in the pool.

    As for the presentation of the images paires with sound files, it's a matter of setting up your loop and if needed populating it in real time from an array (which requires coding as explained earlier, or some variation of it, depending on what exactly you want to do).

    To stop the sound and image when a key press has been registered, you simply need to insert the next code stopping the sound right after the keyboard event, as well as whatever sketchpad you want to appear after a key press.

    Good luck,

    Fabrice.

    Buy Me A Coffee

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