Howdy, Stranger!

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

Supported by

[solved] Pseudorandom with Lexical Decision

edited April 2013 in OpenSesame

Hi,

Thank you for this great software !

In a lexical decision experiment, I'd like to create a trial sequence that is random but has the restriction that a word or a nonword should not been shown more than 3 times in immediate succession.
How could I do that (from the lexical decision example script for instance) ?

Best regards,

Boris

Comments

  • Hi Boris,

    Welcome to the forum!

    Such pseudorandomisation functionality is not (yet) implemented in OpenSesame. Perhaps you could try Mix (only for Windows, unfortunately), a program that allows you to generate trial orders according to a wide range of constraints. The minimal distance restriction you mention will be very easy to apply with this software.

    It can be downloaded here:

    And the reference is:

        Van Casteren, M., & Davis, M. H. (2006). Mix, a program for pseudorandomization. Behavior research methods, 38(4), 584–589.

    I hope this helps.

    Best wishes,

    Lotje

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

  • edited 8:49PM

    Thank you for your answer !

    I know Mix and Shuffle (also for linux or mac) but this forces me to use pre-made lists for each subject.

    Isn't it possible to do this with a Python inline ?

    Best regards,

    Boris

  • edited February 2013

    Hi Boris,

    It's possible to use an inline, but you'll need to build your experiment a bit different from the usual way.

    Normally you would fill out a list item with all of your stimulus words and set the list order to random. For pseudorandom options, you'll have to do the randomization yourself. You could still predefine all your stimulus words up front, in a variable or a text document (in a. tsv-like lay-out).

    Lets say you did this in the way you prefer and created a list variable containing all the words in the beginning of your experiment. After the inline_script in which you do this, add some more code:

    inline_script_1

    global biglist
    
    import random
    
    # stimuli
    stimlist = [...] # read from. txt or enter manually
    
    # constants
    REPEATS = 5 # number of times you would want to present each stimulus
    
    # create one big list
    biglist = []
    repcount = 0
    prevstim = ''
    while len(biglist) < len(stimlist)*REPEATS:
        newstim = random.choice(stimlist)
        if biglist.count(newstim) == REPEATS:
            stimlist.pop(stimlist.index(newstim))
        else:
            if newstim == prevstim:
                if repcount < 2:
                    repcount += 1
                    biglist.append(newstim)
            else:
                repcount = 0
                biglist.append(newstim)
        prevstim = newstim[:]
    self.experiment.set("trialnr", 0)
    

    Add the following to your sequence in an empty list with repeats = trials

    global biglist
    self.experiment.set("stimword", biglist[self.get("trailnr")])
    self.experiment.set("trialnr", self.get("trialnr") + 1)
    

    Now you can use the variable stimword in OpenSesame items used to present your stimulus like so: [stimword]

    Good luck!

  • edited 8:49PM

    Hi Edwin,

    Thank you very much for your code but I'm not sure that I understand everything.

    The point is that, I have difficulties to see how your inline identify the column defining words and pseudowords (the one where I do not want more than x repetitions)

    For instance, for the moment, my stimulus list is the following:


    Target Prime Type TypeCible CorrectAnswer
    GARAGE garage 1 Mot l
    FUYARD funets 1 Mot l
    TRUITE moutre 1 Mot l
    AVERSE averse 1 Mot l
    PROFIT parile 1 Mot l
    MISÈRE ronfel 1 Mot l
    PUDEUR gavise 1 Mot l
    MOUTON mouton 1 Mot l
    CHANTIER jurame 1 Mot l
    ANGINE angine 1 Mot l
    BILOGE biloge 2 Pseudomot q
    ÉTATIN étatin 2 Pseudomot q
    GLARON glaron 2 Pseudomot q
    GORARD gorard 2 Pseudomot q
    LOIPÉE laurin 2 Pseudomot q
    PALIPE rofame 2 Pseudomot q
    INCOTE onfele 2 Pseudomot q
    INRONE anrige 2 Pseudomot q
    JANCIN pinrol 2 Pseudomot q
    NOFFAT gumert 2 Pseudomot q

    Here the column that should not repeat are columns 3 ("Type") or 4 ("TypeCible"). But I need to have the other columns in my result file...

    Best,

    Boris

  • edited February 2013

    I also tried your code with a simple list ("1" would code for words and "2" for nonwords) like


    stimlist = ['1', '1', '1','1', '1', '1','1', '1', '1','2', '2', '2', '2','2', '2', '2','2', '2', '2','2']

    But when I print stimlist it gives:
    ['1', '2']

    Which is not what I was waiting for.
    I was waiting for something like: (for no more than 3 repetitions)
    ['2', '2', '2', '1', '1', '2', '1', '2', '2', '1', '2', '2', '2', '1', '1', '1', '2', '1', '1', '1']

    And I think that stimlist should be a multi-dimensional array on which I could do the randomization on a particular column...

    I found this discussion on this question but I am unfortunately not able to apply it to my problem:
    http://stackoverflow.com/questions/4630723/using-python-for-quasi-randomization

  • edited September 2013

    Hi Boris,

    I think that Lotje's suggestion to use Mix is the most pragmatic. But since you appear to be quite keen to use Python code, here's another example. The idea is the same as the script that Edwin provided, but it indeed uses a multidimensional array. At the start of the experiment, add an inline_script item with the following code:

    import numpy as np
    
    repeatCheck = 3 # # How many repeats are not *allowed*
    column = 3 # Which column should be checked for repeats
    src = 'stimlist.csv' # A tab separated text file in the file pool
    
    # Load the conditions into a NumPy array
    a = np.loadtxt(exp.get_file(src), delimiter='\t', dtype=str)
    
    # Go into a 'shuffle loop'
    while True:
        # Shuffle the array
        np.random.shuffle(a)
    
        # Loop from trial 0 to (number-of-trials - repeatCheck).
        shuffleAgain = False
        for i in range(len(a)-repeatCheck):
            # Get a slice out of the condition matrix that goes from i to
            # i+repeatCheck, including only the specified column
            slice = a[i:i+repeatCheck, column]
            # If the length of the list of unique items in that slice is 1
            # (i.e. if they are all the same), we need to shuffle the
            # list again
            if len(np.unique(slice)) == 1:
                shuffleAgain = True
        # If we don't need to shuffle again, exit the 'shuffle loop'
        if not shuffleAgain:
            break
    # Store the array as exp.stimlist, so we can access it later on
    exp.stimlist = a
    

    This will read in a text file that specifies all the conditions. For this example I assumed that the conditions are as you described in your previous post. The text file should be tab-separated, not contain column headers, and be placed in the file pool. (If you want to do it differently, take a look at numpy.loadtxt().)

    Next, you add an inline_script to the start of each trial sequence with the following in the prepare phase:

    # Get the trial id using the trial_sequence counter, and use that to get the
    # correct row from the stimlist
    trialId = self.get('count_trial_sequence')
    trialCond = exp.stimlist[trialId]
    # Use the columns from the stimlist to set the experimental variables
    exp.set('Target', trialCond[0])
    exp.set('Prime', trialCond[1])
    exp.set('Type', trialCond[2])
    exp.set('TypeCible', trialCond[3])
    exp.set('CorrectAnswer', trialCond[4])
    

    This will walk through the trial list that was loaded and randomized at the start of the experiment, and store the values from the columns as experimental variables that you can use in sketchpads etc.

    Randomizing with constraints is not the easiest thing in the world! You may want to take a look at NumPy, which is great library for numeric stuff:

    Cheers,
    Sebastiaan

  • edited 8:49PM

    Hi Sebastiaan,

    Thank you very much !!
    Unfortunately, I tried your code and had the following error


    Error: Inline script error
    In: inline_script (run phase)
    File "dist\libopensesame\inline_script.py", line 106, in prepare Python traceback:
    TypeError: compile() expected string without null bytes Full traceback in debug window

    My script is there if it can help:
    https://docs.google.com/file/d/0B-sE9ac1ksCAbXRfd0ljdklkWFk/edit?usp=sharing

    I also wanted to know what I should write in the "block_loop"

    Finally I think that the strategy to shuffle again may probably fail with many items. (I think I experienced that with Eprime)

    Ideally I would like to shuffle a first time and then verify the items and when an item is repeated more than 3 times ( 1 1 1 1), switch it with the next other item (2).
    For instance
    1 1 1 1 2 1 2 2 2 2
    would give in a first time (there is still a problem at the end but we loop on the beginning of the table until a solution is found)
    1 1 1 2 1 1 2 2 2 2
    which would give
    2 1 1 2 1 1 2 2 2 1

    Best,

    Boris

  • edited February 2013

    Hi Boris,

    I understood you did not want to have the same word appear over two successive times, but I now see you meant the type of word. In this case my script won't work indeed! It assumes the original stimlist is a list containing your stimulus words.

    Another suggestion:

    inline_script_1 (at start of experiment)

    global stimuli, header
    
    # open textfile
    stimfile = open('PATHTOFILE/stimuli.txt')
    
    # load content
    stimuli = stimfile.readlines()
    
    # close file again
    stimfile.close()
    
    # parse content
    for line in range(0, len(stimuli)):
        stimuli[line] = stimuli[line].replace("\n", "") # remove returns
        stimuli[line] = stimuli[line].split('\t') # split based on tab separator
    
    # remove header
    header = stimuli[0]
    stimuli.pop(0)
    
    # variables to keep track of stuff
    exp.set("reps", 0) # number of repeats
    exp.set("prevtype", '') # previous stimulus type
    

    inline_script_2 (at start of trial, in prepare phase)

    global stimuli, header
    import random
    
    stop = False
    while not stop:
        # pick a random stimulus
        newstim = random.choice(stimuli)
        # check if this is ok
        if newstim[header.index('Type')] == exp.get("prevtype"):
            if exp.get("reps") #SMALLER THAN SIGN#= exp.get("maxreps"):
                exp.set("reps", exp.get("reps") + 1)
                stop = True
        else:
            exp.set("reps", 0)
            stop = True
    
    # set previous type
    exp.set("prevtype", newstim[header.index('Type')])
    
    # set new stimulus
    for var in header:
        exp.set(var, newstim[header.index(var)])
    
    # PLEASE DO NOTE: all numerical values are now stored as strings!
    # workaround:
    exp.set('Type', int(exp.get('Type')))
    

    stimuli.txt

    Target  Prime   Type    TypeCible   CorrectAnswer
    GARAGE  garage  1   Mot l
    FUYARD  funets  1   Mot l
    TRUITE  moutre  1   Mot l
    AVERSE  averse  1   Mot l
    PROFIT  parile  1   Mot l
    MISÈRE  ronfel  1   Mot l
    PUDEUR  gavise  1   Mot l
    MOUTON  mouton  1   Mot l
    CHANTIER    jurame  1   Mot l
    ANGINE  angine  1   Mot l
    BILOGE  biloge  2   Pseudomot   q
    ÉTATIN  étatin  2   Pseudomot   q
    GLARON  glaron  2   Pseudomot   q
    GORARD  gorard  2   Pseudomot   q
    LOIPÉE  laurin  2   Pseudomot   q
    PALIPE  rofame  2   Pseudomot   q
    INCOTE  onfele  2   Pseudomot   q
    INRONE  anrige  2   Pseudomot   q
    JANCIN  pinrol  2   Pseudomot   q
    NOFFAT  gumert  2   Pseudomot   q
    

    ================================

    WORKAROUND, DUE TO \n ERROR IN INLINE_SCRIPT:

    inline_script_1 (at start of experiment)

    global stimuli, header
    
    # open textfile
    stimfile = open('PATHTOFILE/stimuli.txt')
    
    # load content
    stimuli = stimfile.readlines()
    
    # close file again
    stimfile.close()
    
    # parse content
    for line in range(0, len(stimuli)):
        stimuli[line] = stimuli[line].split('\t') # split based on tab separator
        stimuli[line].pop(len(stimuli[line])-1)
    
    # remove header
    header = stimuli[0]
    stimuli.pop(0)
    
    # variables to keep track of stuff
    exp.set("reps", 0) # number of repeats
    exp.set("prevtype", '') # previous stimulus type
    

    stimuli.txt

    Target  Prime   Type    TypeCible   CorrectAnswer   dummy
    GARAGE  garage  1   Mot l   dummy
    FUYARD  funets  1   Mot l   dummy
    TRUITE  moutre  1   Mot l   dummy
    AVERSE  averse  1   Mot l   dummy
    PROFIT  parile  1   Mot l   dummy
    MISÈRE  ronfel  1   Mot l   dummy
    PUDEUR  gavise  1   Mot l   dummy
    MOUTON  mouton  1   Mot l   dummy
    CHANTIER    jurame  1   Mot l   dummy
    ANGINE  angine  1   Mot l   dummy
    BILOGE  biloge  2   Pseudomot   q   dummy
    ÉTATIN  étatin  2   Pseudomot   q   dummy
    GLARON  glaron  2   Pseudomot   q   dummy
    GORARD  gorard  2   Pseudomot   q   dummy
    LOIPÉE  laurin  2   Pseudomot   q   dummy
    PALIPE  rofame  2   Pseudomot   q   dummy
    INCOTE  onfele  2   Pseudomot   q   dummy
    INRONE  anrige  2   Pseudomot   q   dummy
    JANCIN  pinrol  2   Pseudomot   q   dummy
    NOFFAT  gumert  2   Pseudomot   q   dummy
    
  • edited February 2013

    For some reason, inline_script_2 isn't shown full. Retry: (see above)

    EDIT: bleep, same problem. In two pieces, but do put 'em in the same inline!
    EDIT #13415313: got it, there is a 'smaller than' sign that looks like the start of some html-bit. Just replace #SMALLER THAN SIGN# by <

    Now you can use the variables with the names they have in stimuli.txt (in our case: [Target], [Prime], [Type], [TypeCibele] and [CorrectAnswer]).

    OpenSesame file: http://dl.dropbox.com/u/95377477/Sem.opensesame

    Good luck!

    EDIT: BUG REPORT!
    Sebastiaan, when I tried to run above code, OpenSesame crashes because of the use of '\n' in an inline_script. It seems to think '\n' represents a return within the inline_script, instead of a part of the code (win7, 0.27 run from source).

    Boris: temporary workaround, see above.

  • edited February 2013

    Hi Edwin,

    I ran your opensesame script (from the dropbox).

    I converted the stimuli.txt file to UTF8

    I emptied the "block_loop" object in OS

    It runs but:

    -it did not respect the constraint of 2 or 3 max successive items

    -some items are repeating themselves in the 20 trials... (and consequently some items are missing)

    So I added the line in the first inline: (because I did not find where you define the maximum number of repetitions [but I am not sure of this])

    exp.set("maxreps", 2)

    But this did not change the above problems...
    Here is the final script

    https://docs.google.com/file/d/0B-sE9ac1ksCAU1B6aUpVTjB2Y1U/edit?usp=sharing

  • edited February 2013

    Hi Sebastiaan,

    Finally I found that the problem I had with your script concerned the path (space and/or accentuated characters)

    Now it's working nicely.

    The only problem remaining is that it crashes with 120 items or more...

    Here is the script for 120 items:

    https://docs.google.com/file/d/0B-sE9ac1ksCAc0s3NlktaERRUW8/edit?usp=sharing
    And the stimuli:

    https://docs.google.com/file/d/0B-sE9ac1ksCAWktYc1NvbV9qY3c/edit?usp=sharing

  • edited February 2013

    Hi Boris,

    Ah, yes, you are right! A variable that should have been a string turned out to be an integer (seems to be automatically converted by OpenSesame). Therefore the comparison always turned out False (i.e.: '1' == 1 is False indeed).

    On the matter of the maximum repetitions: somewhere it got lost (although I can distinctly remember to have written it... spooky!). It's in where it's supposed to be now.

    For the repetition of certain words: you're right again! I forgot to include that in the new script. Now it should be fixed.

    Finally, concerning the converting to UTF-8: this is because of the accents, right? Didn't quite spot those since just now ;)

    Anyhow, the correct OpenSesame script, the stimuli.txt that I used and a sample output file are in the Dropbox (https://www.dropbox.com/sh/amjj3gsou22b5cn/XCnTnr7aAt).

    Hope it's fixed now!

  • edited 8:49PM

    Hi Edwin,

    I tested your code and it works nicely now.

    More interesting it's working in "extreme conditions" with 240 items and only 2 repetitions.

    So I'll check everything tomorrow but it looks like a problem solved ! (interestingly people from Eprime support never found a proper solution to this problem)

    Thank you very very much !

  • edited 8:49PM

    Nice! No problem, glad to help out. Especially if we did better than E-Prime's support :p

  • edited February 2013

    Hi Edwin,

    I think that another solution than the dummy column for the "\n" is to do a rstrip


    for line in range(0, len(stimuli)):
    stimuli[line] = stimuli[line].rstrip()
    stimuli[line] = stimuli[line].split(' ') # split based on tab separator
    stimuli[line].append(0) # add counter

    Best,
  • edited February 2013

    Hi,

    Unfortunately, I was too enthusiastic.
    The script is often crashing when running the experiment at the end of the 240 items (for instance after 235).

    The problem is if, arriving on item 235, all the words have already been selected for example, then it is looping endlessly.

    Here is the script and the stimuli:
    https://docs.google.com/folder/d/0B-sE9ac1ksCAeVJWUGFlRE5RdWc/edit?usp=sharing

    Best,

  • edited February 2013

    Hi Boris,

    Do I understand correctly that all of the single-word repeats have 'run out' for all words? Wouldn't that mean that all of the trials are already run? (basically meaning that you cannot possibly run 240 trials, unles you heighten the variable for the number of repeats for unique stimuli)

    EDIT: if you are using the original 20 items posted here, than 240 should be possible indeed. I'll look into it.

    Best,
    Edwin

  • edited February 2013

    Do I understand correctly that all of the single-word repeats have 'run out' for all words?

    Yes

     Wouldn't that mean that all of the trials are already run?

    No because there are still some pseudowords to display...

    I'm not using the 20 items but 240 different ones

    A strategy would be to randomize items and switch problematic items with the next good one (restarting with the beginning of the items if there is a problem at the end of the list) but I don't success in implementing that in python.

  • edited February 2013

    Hi Edwin,

    I think that I found a partial solution to the problem.
    This new script is doing well to randomize my table "stimuli". (I tested it in a Python interpreter and it was working)

    So at the end in my result file, I have no "1" or "2" (column "Type") more than 3 times which is good.

    But I still the big following problem:

    -during the experiment I have quite often more than 4 words following. At the end in my csv file, I notice that my French word VAURIEN is transformed in a "2" (nonword) during the experiment while in the stimuli.txt file it is marked as "1" (word)

    Script & Stimuli
    https://docs.google.com/folder/d/0B-sE9ac1ksCALVhvdTVUUXY0dG8/edit?usp=sharing

    Best regards,

  • edited February 2013

    Finally I found the solution !

    This code should work whatever the size of your stimulus list and whatever the max number of consecutive trials you want (you can adapt the script easily)

    Put this inline in the beginning of the script:

    global stimuli, header, CountTrial
    
    import random
    CountTrial = 0
    
    # open textfile
    #file_path = exp.get_file('stimuli.txt')
    #stimfile = open(file_path)
    
    stimfile = open('W:\stimuli.txt')
    
    # load content
    stimuli = stimfile.readlines()
    
    # close file again
    stimfile.close()
    
    # parse content
    for line in range(0, len(stimuli)):
        stimuli[line] = stimuli[line].rstrip()
        stimuli[line] = stimuli[line].split('   ') # split based on tab separator
    
    # remove header
    header = stimuli[0]
    stimuli.pop(0)
    
    # Shuffle the table with the stimuli
    random.shuffle(stimuli)
    
    for k in range(0,len(stimuli)):
        print stimuli[k][2]
    
    repeatCheck=3 #(2 or 3 but see comment below to put bigger numbers)
    Solution = 0
    BigSolution = 0
    i=0
    repet = 0
    column = 2 # Which column should be checked for repeats (starting from 0)
    
    while(BigSolution == 0):
        if (i == len(stimuli)-(repeatCheck+1)):
            # if there was no repetition in the latest check, a solution for the experiment has been found, it's finished
            if (repet == 0):
                BigSolution = 1
            # if not it does a loop again
            # i is the index we're checking
            i = 0
            repet = 0
        # Detect repetition
        # Change the following line if you want bigger repeatCheck (4, 5, etc)
        if (stimuli[i][column] == stimuli[i+repeatCheck-3][column] == stimuli[i+repeatCheck-2][column] == stimuli[i+repeatCheck-1][column] ==  stimuli[i+repeatCheck][column]):
            repet = 1
            Solution = 0
            k=i+3 # k will be the cue that will look for a different item to swap
            # Look for next different item to swap
            while Solution == 0:
                # If there we do not find a solution at the end of the table, we look for a solution from the beginning of the table
                if (k >= len(stimuli)):
                    k = 0
                if (stimuli[k][column] <> stimuli[i+repeatCheck][column]):
                    # Swap the lines
                    stimuli[i+repeatCheck],stimuli[k] = stimuli[k],stimuli[i+repeatCheck]
                    # Found the solution
                    Solution = 1
                else:
                    k += 1
        i += 1
    
    

    and this one at the beginning of your "trial_sequence"

    global stimuli, header, CountTrial
    import random
    
    # Get the trial id using CountTrial counter, and use that to get the
    # correct row from the stimlist
    
    newstim = stimuli[CountTrial]
    CountTrial += 1
    
    for var in header:
        exp.set(var, newstim[header.index(var)])
    
    # PLEASE DO NOTE: all numerical values are now stored as strings!
    # SECOND NOTE: turns out this isn't quite true, as OpenSesame's exp.set seems to convert to int automatically
    # workaround:
    exp.set('Type', int(exp.get('Type')))
    

    The script and stimuli are here:
    https://docs.google.com/folder/d/0B-sE9ac1ksCALVhvdTVUUXY0dG8/edit?usp=sharing

    I hope this code will be useful to other users !

  • edited 8:49PM

    Hi Boris,

    Great that you've found a solution! I like the french commenting, it's always nice to pick up a few more words in a different language.

    Good luck with the testing!

  • edited 8:49PM

    Sorry for my French but I'm a lazy English user... (always cost more energy to write/say something in English ) :P

  • edited March 2016

    Hi, I find myself in a similar situation that I am finding easier to solve with Sebastiaan's code (it crashes, but I feel like I'm close to it..) and I would prefer not to write a predefined list per subject.
    I have a list of possible conditions (24) and 5 columns. To make things easier I've coded all values in numbers (integers). In the last column I have values 0 or 1 like this:

    2 2 10 1 1
    2 1 10 1 1
    2 2 10 1 0
    2 1 10 1 0

    I want to pseudorandomize the order of conditions according to the last column so that (ideally) if on one trial the condition has a value 1 in the last column, the next trial has to have a value 0, but when I used the shuffle it was taking too much time (now I'm only using a list of 24 possible trials but they will be more) so instead I set number of maximum repetitions=2

    I have created a txt file tab delimited with no header.
    At the beginning of the experiment I created an inline script with in run phase:

    import numpy as np

    repeatCheck = 3 # # How many repeats are not allowed
    column = 4 # Which column should be checked for repeats
    src = 'C:\Users\act\Desktop\stim.txt' # A tab separated text file in the file pool

    Load the conditions into a NumPy array

    a = np.loadtxt(exp.get_file(src), delimiter='\t', dtype='str')

    Go into a 'shuffle loop'

    while True:
    # Shuffle the array
    np.random.shuffle(a)

    # Loop from trial 0 to (number-of-trials - repeatCheck).
    shuffleAgain = False
    for i in range(len(a)-repeatCheck):
        # Get a slice out of the condition matrix that goes from i to
        # i+repeatCheck, including only the specified column
        slice = a[i:i+repeatCheck, column]
        # If the length of the list of unique items in that slice is 1
        # (i.e. if they are all the same), we need to shuffle the
        # list again
        if len(np.unique(slice)) == 1:
            shuffleAgain = True
    # If we don't need to shuffle again, exit the 'shuffle loop'
    if not shuffleAgain:
        break
    

    Store the array as exp.stimlist, so we can access it later on

    exp.set("stimlist", a)

    if I print a I get a nicely shuffles list. So that works now I just want for each trial to read the list in a sequential manner and use the info in it. In my loop item now empty (right?) I only set number of repetitions of each cycle to 1, inside I have a trial sequence which calls another inline script with all my experiment written. at the beginning in the prepare phase I put:

    Get the trial id using the trial_sequence counter, and use that to get the

    correct row from the stimlist

    trialId = self.get('count_trial_sequence')
    trialCond = exp.stimlist[trialId]

    Use the columns from the stimlist to set the experimental variables

    exp.set('correct_response', trialCond[0])
    exp.set('target_pos', trialCond[1])
    exp.set('target_letter', trialCond[2])
    exp.set('warning_signal', trialCond[3])
    exp.set('cue_validity', trialCond[4])

    but it crashes with this error

    exception message: string index out of range
    exception type: IndexError

    Traceback (also in debug window):
    File "dist\libopensesame\inline_script.py", line 150, in prepare
    File "dist\libopensesame\python_workspace.py", line 111, in _exec
    File "", line 8, in
    IndexError: string index out of range

    I think it doesn't correctly creates the object stimlist, I have tried when loading the txt to put object instead of string but it doesn't work. Also, if I try to print stimlist at the end of the first inline script it doesn't work. Instead if I print "a" it works, why?
    thank you for your help
    Stefania

  • I know this is a pretty old thread, but if you're still using this forum, Boris, I have a question for you! I very much like your script and think I will use it (thanks for that!), but I wanted to clarify a potential problem I see.

    My question is in regard to this part of your script:

         while Solution == 0:
                    # If there we do not find a solution at the end of the table, we look for a solution from the beginning of the table
                    if (k >= len(stimuli)):
                        k = 0
                    if (stimuli[k][column] <> stimuli[i+repeatCheck][column]):
                        # Swap the lines
                        stimuli[i+repeatCheck],stimuli[k] = stimuli[k],stimuli[i+repeatCheck]
                        # Found the solution
                        Solution = 1
                    else:
                        k += 1
    

    Doesn't looking for a solution from the beginning of the table potentially lead to "undoing" the previous work? For example, if you had the following sequence of item types:

    2 2 2 1 2 2 1 1 2 1 1 2 2 1 1 1 2 2 2 2

    and on i = 16 (the 17th item), you find that the following three items are of the same type, but you're at the end of your list, so you loop back around to find an item to "swap" and the first available one you come by is at k = 3 (the fourth item). By swapping the fourth and 17th items, you've now created a run of 5 "2's" at the start of your list.

    Perhaps I'm missing something?

    Thanks in advance!

    -Jonathan

  • Ohhhh wait I get it. You continue to cycle through the list until you do a whole pass without finding any unwanted repetitions (so repet remains set to 0 and BigSolution can be set to 1).

    Sorry for the unnecessary question! Hopefully it will help someone who misunderstands as I did :)

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