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.