Howdy, Stranger!

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

Supported by

Define Color in Javascript

Hi,

I want to create an attentional blink task. The two targets will be colored with red. Since the stream sequence is random, that is the target position is randomly assigned.

Using the above codes, I have successfully defined these target colors. However, when trying to display the targets in sketchpad, it reports that the result_color is not defined.

I also attached my experiment code, in case I didn't explain it clearly.


Could you please check and tell me what happened.

Best,

Lorraine

Comments

  • Hi @Lorraine ,

    You're defining the colors in the run phase of the target_color item. The sketchpad items are prepared in advance, during the prepare phase, and at this time the color variables aren't yet defined. The solution would be to move the code to the prepare phase of the target_color item.

    You can read more about this here:

    -- Sebastiaan

  • Hi,

    Thanks, but it still suggests me that the color variable is not defined after I moved the code to the prepare phase.


  • edited April 2021

    Hi @Lorraine ,


    I think you should embed the letter string in an additional loop-sequence within the trial sequence and use the square-bracket method to define the current stimulus:



    Next, you can compare the current stimulus to T1 and T2 with only a few lines of javascript like so:


    // Default is white:
    vars.result_color = "white"
    
    // Except when the current stimulus is T1....
    if (vars.stimulus == vars.T1){
    vars.result_color = "red"}
    
    // Or T2
    if (vars.stimulus == vars.T2){
    vars.result_color = "red"}
    


    Now you only need one sketchpad item, where you can refer to the current letter like so:


    draw textline center=1 color="[result_color]" font_bold=no font_family=mono font_italic=no font_size=64 html=yes show_if=always text="[stimulus]" x=0 y=0 z_index=0
    


    I attached a modified script. (I modified the practice phase only.)

    Good luck with your experiment!


    Cheers,


    Lotje


    Did you like my answer? Feel free to Buy Me A Coffee :)

  • HI,


    Thanks, it works. However, one side effect is that when target displaying, there are some delays. I mean, I wish the stimuli could display 100 ms, without between stimulus intervals. When I run your example experiment, I found the stream doesn't display smoothly. Could you please let me know whether this problem could be fixed?

    Best,

    Lorraine

  • Hi @Lorraine ,


    Oops, I must have accidentally changed the duration of the sketchpad from 100 ms to 200 ms. So you could just change it back.


    Cheers,


    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • Hi,


    Yes, I noticed that and after changing it back, it still has the delay. As you can see from the console, it seems like not all canvas has been displayed (which should be 14 canvas as there are 14 stimuli.)

    Best,

    Lorraine

  • Hi Lorraine,

    I haven't followed the entire discussion, but the stimulus_loop only shows 13 items, because it has only 13 lines in the loop table. If you need 14, you have to add one more.

    The warnings that you see in the console are not really good, but they shouldn't cause the problem.

    (sorry if this is missing the point).

    Eduard

    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