Howdy, Stranger!

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

Supported by

need some ideas for the programming part of the experiment

edited December 2016 in OpenSesame

Hi
i 'm beginner in programing and i would like to ask if someone have some ideas to share with me about the programing part of my experiment :
in my expriment participants have to read short stories, one sentence at a time. knowing that, there are 6 target stories and 6 control stories that will appear randomly.

  • Each target story ends with three different end type (end type 1, end type 2, or end type 3), knowing that each target story have his own three possible end type (type 1, type 2, type 3)
    i would like that during experiment each participant read two target stories with end type 1, two target stories with end type 2, and two target stories with end type 3
    -Control stories ends with only one neutral end.

so i create a script, just for the end part, below, the problem is that the end doesn't displayed during the experiment :smiley:

import random

# a list that would allow to define the end type to choose for each target story throughout the experiment:
aList = [1,2,3, 1,2,3]

random.shuffle(aList)

def index () :
    yield aList [0]
    yield aList [1]
    yield aList [2]
    yield aList [3]
    yield aList [4]
    yield aList [5]

recup_index = index()

#specify the end type to choose for target stories and for control stories 
#specify for target stories the end type to choose:

if var.category == "target":
    recup_index.next()
    if recup_index == 1 :
        var.end = var.end_type_1
    elif recup_index == 2 :
        var.end = var.end_type_2
    elif recup_index == 3 :
        var.end = var.end_type_3
else :
    var.end = var.end_neutral

Comments

  • Hi,

    Well, if the presentation of the stimuli doesn't work, why don't you share that part with us, instead of the part where you select the endings?

    Btw. Here is your code a little shorther:

    import random
    
    # a list that would allow to define the end type to choose for each target story throughout the experiment:
    aList = [var.end_type_1,var.end_type_1,var.end_type_2, var.end_type_2,var.end_type_3,var.end_type_3]
    
    random.shuffle(aList)
    if var.category == "target":
        var.end = aList.pop()
    else:
        var.end = var.end_neutral
    

    Edaurd

    Buy Me A Coffee

  • thank you for your answer,
    i'm not sure to understand your question,
    this is just the part when the end must be displayed that doesn't work. that's why i share the part where i select the endings.
    i use sketchpad for the others parts of the stories

  • Hi,

    What I mean, is that in your code you don't do anything to actually present the endings. The only thing you do, is selecting which ending to present. If you say that you present your stories in sketchpads then this is where you have to add the endings. For example, if you're story is saved in the variable var.story. Then you could add the ending and create variable complete story (var.complete_story = var.story + var.ending). In your sketchpad you present then var.complete_story instead of var.story and you should be set.

    Does this make sense?

    Eduard

    Buy Me A Coffee

  • yes i understand,
    but i need to record the reading time for each sentence of each stories and to know, on the data, which type of end was read.
    So i use a sketchpad to display each sentence of the stories, and one for the end type. I know that it is not really efficient but i don't know other possible way to do that.

  • Sounds fine to me. So what is the problem? :)

    Buy Me A Coffee

  • the problem is that, there is no var.story in which the entire story is saved,
    there is a variable "category"
    a variable "story name"
    a variable "sentence1"
    a variable "sentence2"
    a variable "sentence 3"
    ...
    a variable "end_type_1"
    a variable "end_type_2"
    a variable "end_type_3"

    so i can't create var.complete_story = var.story + var.ending
    what i need is to do is when aList.pop () return var.end_type_1 in the script, the sketchpad that is dedicated to the end of the story display var.end_type_1 that i'have already create: that's the problem

  • Well, couldn't you create this variable then?

    Something along the lines of var.story = sentence1 + sentence2 + sentence3 + var.end_type1?
    You could do this once before the trial, or right after every sentence is presented.

    Eduard

    Buy Me A Coffee

  • thanks for your help,
    sorry for this late answer,
    i have tried something, that do not require inline-script :
    in one sketchpad i've set three text line and set in if statement for each text line :
    end type_1 : [count_sequence]%3 = 0
    end_type_2 : [count_sequence]%3 = 1
    end_type_3 : [count_sequence]%3 = 2
    and apparently it works

    but i face with a new problem :
    the display of some sentences, that are quite long, doesn't fit with screen size so they are cut at the beginning and at the end, so i've try search on forum similar problem but i've don't see anything that can help me to override this problem.

    Oriane.

  • edited February 2017

    Hi,

    When you define your sentences, you can add hard coded linebreaks. Not sure whether this is still compatible with your design, but that's how I can deal with very long lines. See example:

    string1 = " This is a very long string that would probably not fit on the screen if you present it without a linebreak character because it has so many words in it that, frankly, do not convey much meaning but blow up the sentence length quite tremendously"
    string2 = " This is a very long string that would probably not fit on the screen if you present it without a linebreak character \n because it has so many words in it that, frankly, do not convey much meaning but blow up the sentence length quite tremendously. \n\n However, adding a line break has helped!"
    kb = keyboard()
    cv,cv2  = canvas(),canvas()
    cv.text(string1)
    cv2.text2(string2)
    cv.show()
    kb.get_key()
    cv2.show()
    kb.get_key()
    

    Does this make sense?

    Eduard

    Buy Me A Coffee

  • i'm not sure to understand...
    because all sentences are already set in the loop table in var.sentence1, var.sentence2 ...
    and the newline character "\n" directly insert in sentence in the loop table doesn't work

    Oriane

  • Hi Oriane,

    I see. Indeed, adding these characters to the loop table does not solve the issue. Instead you can modify the strings to include the manual line break characters, just before you present them. For example, you can add an inline_script before your sketchpad and put this code into there:

    # First find the index in your string at which you want to break the line. 
    # For simplicity, I just use the middle
    index =len(var.sentence1)/2 
    # then you create a new variable that consists of the two (or more) parts of the original string, separated
    by the '\n' character
    var.NewSentence1 = var.sentence1[:index] + '\n' + var.sentence1[index:]
    
    # now you only need to make sure that your `sketchpad` is presenting the new sentence, and you should be done
    

    Eduard

    Buy Me A Coffee

  • Hi,

    Thank you so much ! it works perfectly !

    I would like to ask to you two more things :
    first : when i execute the experiment with subject number.. i've seen, sometimes but not each time, a white screen appeared instead of the end sentence.. and i've search some answer in forum and i don't see why this occur ?

    second : regardless of using xpyriment backend or legacy backend, there is an inter-trial time delay that is quite long, so i need to press two times the key space to pass to the end sentence (when finish to read) to the next story trial. I know that it is due the the number of sketchpad that are used for each trial, but because i record the reading time, i need some temporal precision, especially for the end sentence.
    Have you some advice for this ?

    Oriane

  • Hi ,

    first : when i execute the experiment with subject number.. i've seen, sometimes but not each time, a white screen appeared instead of the end sentence.. and i've search some answer in forum and i don't see why this occur ?

    I've never seen/heard such a thing. No idea, what could be the reason. Could you upload your experiment so that we can have a look?

    so i need to press two times the key space

    Irrespective of inter trial delay, if you have to press twice, that you are waiting for two keypresses somewhere. It is hard to tell what exactly happens, again, if you upload your experiment we can have a look and see what happens.

    Eduard

    Buy Me A Coffee

  • Hi,
    sure, here it is,

    Oriane

  • Hi Oriane,

    As I said, you are sampling two key presses. Depending on what you want to accomplish you either remove your keyboard_response, or you set the duration of the last sketchpad to 0. I tried either, and the experiment seems to run very smoothly.

    Also, once you think you're done, check the log file to see whether all variables are stored in the way you expect it.

    Eduard

    Buy Me A Coffee

  • indeed, it is better know ! i believed that the keyboard item must always be placed at the end of sequence.

    Thank you !

    what about the white screen ? when i run the experiment to verify, as you said, whether all variable are stored, again, a white screen instead of the end sentence for the second trial appeared.

    Oriane

  • There is no white screen for me. Neither with the expyriment, nor with the legacy backend. What system and version of Opensesame do you use? maybe someone else (@Sebastiaan) can reproduce the problem. Unfortunately, I can't.

    Eduard

    Buy Me A Coffee

  • i have macOS sierra 10.12.3 , and the last version of open sesame 3.1.6, and the problem occasionally occurred either for xpyriment and legacy backends.

    Anyway, thanks for your help !

  • Hi,

    I didn't thoroughly read this discussion, but at first glance it looks like the white-screen issue described here:

    Essentially, Mac OS sometimes shows white screens when running an experiment for the second time. I don't know why it happens, but it can be fixed by selecting the multiprocess runner under Tools → Preferences.

    Does that resolve the issue?

    Cheers,
    Sebastiaan

  • Hi,
    Yes, it works perfectly !
    Thanks !

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