Howdy, Stranger!

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

Supported by

selecting randomization lists in Latin Squared designs

Hi there!

most experiments are Latin Squared. Suppose you have a 2x2 within subject design, you will have a total of 4 lists that you wish to rotate between subjects (and therefore obtain that each item was seen in all conditions across 4 subjects).

Therefore, I was wondering is there an easy way to select such list directly from the start of the experiment? So, you input the name of the subject AND select the randomization lists? I guess it might be possible to do so by specifying a variable in the dataframe for the trial sequence that you could call and subset the part of the dataframe needed, but I am not quite sure how to do that. Otherwise, for a 2x2 design, I would end up with four different versions of the experiment, which does not sound right.

I am using OpenSesame 3.0.7 because I need to record speech.

thanks a lot for your kind help!

Moreno

Comments

  • edited October 2016

    mmm ... as it seems I was unsuccessful, let me try again, perhaps, I will be clearer this time.
    So, suppose you have 24 items in a 2x2 (within subject) Latin Squared design.

    The only way you have to present 24 items (without repetition) in all four conditions, is to divide them into 4 lists (a, b, c, d), and then have 4 subjects each seeing only 1 list. It is quite a classic problem I believe.

    I am using OpenSesame 3.0.7, and I have found a workaround solution to select such lists (without having to duplicate the experiment 4 times).
    (http://www.chrislongmore.co.uk/screencasts/html/counterbalance-opensesame.html)

    What I do thought (as explained in the tutorial linked above), it is literally to copy the block sequence 4 times (one for each list) and then have a variable (e.g., called rblock), which I input at the beginning of the experiment using a text form, that I use to select the block to run in the experiment sequence. I mean, this solution works, but if you have 12 different conditions (because of counterbalancing other co-variates) plus a division into blocks (e.g., easy and hard), you end up with 24 copies of the block sequences, which makes a ridiculously redundant experiment.

    This solution is admittedly quite ugly, so I hope someone could suggest me something better and more elegant by using in line scripts.

    I believe, but I might be wrong, that I should be able to have just a single block sequence (or perhaps two at the most -- if the experiment is divided into an easy and a hard block) with all trials for all the lists in it (or to be read from a .csv file), and then use the variable (rblock) that I input at the beginning of the exp., to select only the relevant part of the dataframe (i.e., the randomization list) to display my stimuli.

    I have been looking around the internet and in the forum, and although, there are some solutions, I am not quite sure I have really fully understood them. So, I truly appreciate a very concrete, simple (working) example, something like this that I found for psychopy (https://groups.google.com/forum/#!topic/psychopy-users/3tbsPRvb9WY) but applied to opensesame.

    If that's not possible, no problem. I will live with my ugly solution for now ...

    thanks a lot for any time you would ever spend thinking about this!

  • Hi Moreno,

    Depending on the details of your experiment, it could work for you if you had only one generic loop, in which you present condition 1 through 4. In the beginning of your experiment you could have your lists hard coded and use the subject number (var.subject_nr) as identifier as for which element of a list you want to use for this particular subject. Once selected, you could proceed to your trial sequence and present the stimuli that fit the first chosen condition (not necessarily the first condition in your terminology), so for example, if you have four conditions A, B, C and D, you set the order of them in the beginning of the script and assign the respective identifier (A,B,C or D) to variables you will use in the experiment (cond1, cond2,cond3, cond4) . Importantly, in your main trial/block loop, you use latter variable. So that regardless of the order of conditions (a,b,c,d) you can code the blocks generically. Of course this requires that the conditions are comparable to some extent. Presenting words in own condition and pictures in another, might be a little tricky (though far from impossible).

    Hope this helped.

    Eduard

    Buy Me A Coffee

  • Hi Eduard,

    thanks for your response. I am not completely sure I really understood what you are suggesting.

    Let's do this... let's work on a very simple example together, if you | anyone else would be so kind to help out.

    I have attached a very simple 'experiment' called latin square, which simply present words selected from two lists (1,2). I modeled it on the basis of what I understood from your response, as well as, following this other post.

    http://forum.cogsci.nl/index.php?p=/discussion/814/open-nested-lists-functionality

    It does not do really what I want, and also again, I do not think this is an elegant solution. It still implies repeating the same block of code for every randomization list we might have, so a 2x2 Latin Square Design will have 4 blocks of identical code, a 2x2x2 would have 12, and so on. This is in essence, identical to the solution posted above.

    I am trying instead to imagine a solution where you really have only one structure of your experiment, and then you feed only the list of items you want a subject to see. It would be great to have a mock up experiment that does this, as latin squaring, it is really a very common thing to do.

    thanks a lot!!

  • Hi Moreno,

    I hope I haven't misunderstood you.
    Attached you can find an example of the structure that I had in mind.

    Let me know whether you like it or not (and sorry for the late response).

    Eduard

    Buy Me A Coffee

  • Hi Eduard,

    Thanks and sorry for the late response. I have been working on it, and now I have a final solution.
    I wanted a solution that was somewhat more general than what you have proposed.

    I simply wanted to choose a subset e/o block of stimuli from a .csv dataset.
    Such dataset should already be organized by the researcher outside of OpenSesame, with whichever randomization Latin Squaring etc. he/she wants, and he/she accesses the randomization list wished to be presented, at the start of the experiment.

    I have attached the final product, which does what I want. You can choose between two lists (1,2).

    A couple of caveats for whoever may end up using this code:

    a) I have used pandas and numpy to extract and process the .csv.
    However, very often the versions available are in conflict (at least that's what happened to me). So make sure they are compatible.

    b) You need to change the file path to load your .csv data from the inline called (define_list_practice, line 16)

    I hope somebody else would benefit by this ...

    Moreno

  • Dear developers,

    I have used this solution with OpenSesame 3.0.7. I knew that it was a hack, but it worked. I have another experiment running fine on it.

    Now, I am designing another experiment, and I would like to move to the latest versions of OpenSesame, and I have tried it with the last one 3.1.6.

    This solution does not work any longer. The problem is that OpenSesame does not accept the way I input and subset the dataset, which is by loading and subsetting it through an in_line script. It always default back to the one specified in the block loop. No matter what I do, it would always consider that dataframe.

    Guys, seriously, I believe this is a straightforward not so strange thing to do (read above), but to reiterate, I want to input the dataset only once, then have a variable in it, where I specify the randomization list I am interested. I want to use such variable to subset the dataset ONLY to the list I want to run.
    Why it looks so difficult? What am I doing wrong?

    NB, now also the bulky solution (http://www.chrislongmore.co.uk/screencasts/html/counterbalance-opensesame.html) that seemed to work, it is not working any longer either.

    I have honestly spent two solid days reading all around, but: (a) I do not understand how I can use datamatrix (or pandas) within in_line script to do this, (b) I am not sure I understand the difference between dm and live.dm, and how can I manipulate either of the two (perhaps i do not understand where is the dataframe stored ... but especially how can I access it), but I could not find documentation that guides a user to get from a dataset containing all possible randomized lists of material, just a subset (i.e., the list I want to present to a specific subject), and run the experiment fine.

    I believe that if this problem is clearly solved once, it would be very beneficial to many users, and not just me. I cannot believe I am the only one creating his randomization lists outside of opensesame, and simply wanting to subset the one to run without having to duplicate the experiment code.

    Forgive me if the solution is somewhat trivial, but I am completely lost now.

    Thanks for your time and kind help,

    Moreno

    PS @sebastiaan (please help me :-))

  • Hi Moreno,

    It's a long discussion (which I haven't read entirely), but there are few fairly straightforward ways to implement counterbalancing. Both options below require OpenSesame ≥ 3.1.

    Selecting a source file based on subject number

    In the loop you can select a source file. Say that you have created three stimulus lists for counterbalancing (list0.csv, list1.csv, and list2.csv), then you could rotate these lists across participants by entering the following in the File input:

    list[=var.subject_nr % 3].csv
    

    So you're embedding a short Python statement that takes the modulo 3 of the subject number. See also:

    Selecting rows from the loop table based on subject_nr

    Alternatively, you could create a loop table that has the information in it for all participants, and then select a subset of rows from this table. Say that you have a column called counterbalancing that again goes from 0 to 2, then you could select the relevant rows like so:

    items['block_loop'].dm = items['block_loop'].dm.counterbalancing == var.subject % 3
    

    This would go into the Prepare phase of an inline_script that preceded block_loop. This changes the original DataMatrix (before randomization, repeating, etc) so that it contains only those rows where the counterbalancing column matches subject_nr modulo 3. (To clarify: the live_dm is the DataMatrix after randomization, repeating, and other loop operations.)

    In most cases, Option 1 seems easier to me.

    Cheers!
    Sebastiaan

  • yes! indeed. exactly, a simple solution for a simple problem! it worked like charm. thank you so much!
    p.s. I prefer to use an external variable list rather than subject nr.

    Moreno

  • Sorry to revive an old thread but I have been attempting to implement the solution given above but trying to extract trials from file rather than hardcoding everything into the loop? Is there a way to do this?

  • @jspayne You'll have to be a bit more specific. What exactly are you trying to do, what have you tried so far, and in what sense doesn't this work as you'd like it to?

  • @moreno would you mind sharing the final result?
    I'm trying to use "option 2".
    @sebastiaan , I guess you mean to load the csv file in the practice_loop, and experimental_loop, and then under this loop to have the inline script, right?
    In a case like this, the order of the practice/experimental loop should be sequential, and then the block loop should do the randomization, right?

  • @bruno_nicenboim I have actually used the first solution. I have created my Latin Square lists outside using R, uploaded them in the file pool (e.g., list1.csv, list2.csv, etc.), and then called them as sebastiaan suggested me within the sequence loop. Instead of using the subject.nr though, I have chosen the list number using a text-input box at the beginning of the experiment. In this way, I could administer the lists I wanted independently of the subject nr. I hope this helps!

  • ah, ok. Thanks!

  • edited December 2018

    Reviving this old thread for a second time...
    @sebastiaan , I am trying to apply the solution 2 "Selecting rows from the loop table based on subject_nr" "from the post that you made in April of 2017. The solution is only working for me if I use the inbuilt table of OpenSesame but not with an external .csv file. Onexp is able to read the file (it shows correctly in the preview) and the experiment does not crash... however, it shows all the items on the list, without filtering out the relevant rows. This doesn't happen with the inbuilt table (the column name by which I am "naming" the lists is the same for the csv).
    I have encoded the csv as specified here: https://osdoc.cogsci.nl/3.1/manual/structure/loop/#reading-independent-variables-from-file (see attachment).
    Did this happen to anybody here? Anything very basic that I'm missing?

    This is the code I am using: items['loop'].dm = items['loop'].dm.listnr == var.subject_nr % 3 (in an inline script that directly precedes the relevant loop, for a loop called "loop" and to distribute participants across "listnr" (the title of the relevant column)).
    The csv file is attached.

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