Howdy, Stranger!

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

Supported by

[solved] logging using information at the end of experiment

edited February 2012 in OpenSesame

Hi Sebastiaan, I have an experiment in which I use some similarity ratings at the end of the experiment to calculate some differences between the stimuli that are compared at the beginning of the experiment. I would like to use the values of the similarity ratings to calculate some things that make data analysis easier like ratios (e.g. bigger/smaller). If I understand how the logger works correctly, I would not be able to write in each row of the log file with the information collected at the end of the experiment because the logger would have already wrote all the information while the experiment is running. Is there any way to make the logger go back and calculate for each presented pair of stimuli a bigger/smaller ratio with the similarity ratings collected at the end of the experiment?

Comments

  • edited 3:53PM

    Hi Frank.

    Yes, your understanding is correct: The logger writes one line at a time and there is no way to go back and change what has been written. If you want to do some processing at the end of the experiment, you'd have to implement a simple logger yourself, using a bit of inline code.

    For example, first initialize an empty list in an inline_script at the start of the experiment:

    global my_log
    # Initialize an empty list
    my_log = []

    At the end of each trial, store the relevant variables as a dictionary in the list (so my_log is a list of dictionaries):

    global my_log
    # Create a dictionary with trial variables
    my_trial = {}
    my_trial["my_var1"] = 10.
    my_trial["my_var2"] = 20.
    # And store it
    my_log.append(my_trial)

    At the end of the experiment, calculate whatever you want to calculate and write my_log to a file:

    global my_log
    # Calculate some new variable
    for my_trial in my_log:
        my_trial["my_ratio"] = my_trial["my_var1"]/my_trial["my_var2"]  
    # Write the logfile
    f = open("my_log.csv", "w")
    # First the header
    f.write(",".join(my_log[0].keys()))
    f.write(chr(10)) # = newline
    # Then the trial data
    for my_trial in my_log: 
        f.write(",".join([str(s) for s in my_trial.values()]))
        f.write(chr(10))
    f.close()

    I would do this in addition to a regular logger, because by writing the data at the end you will lose everything if the experiments crashes or is aborted halfway.

    Hope this helps!

    Cheers,
    Sebastiaan

  • edited 3:53PM

    Hi Sebastiaan.

    I am enjoying openSesame, it is an excelent program for experiment design. Thank you a lot. Now I need to present stimuli of 20 msec of duration (subliminal), but when I run the experiment I still can see the stimuli. I think this is because the refresh of the screen, but I tried this with other program for experiment design (using the same computer) and I did not see the stimuli. I radically prefer openSesame, but I need a 20 msec stimulus presentation; the goal is that my subject can´t report something presented on the screen. How can I achieve this?

    Thank you Sebastiann.
    My best wishes.

  • edited 3:53PM

    Hi Ciria,

    The duration should indeed be possible given the refresh rate of the monitor, but in your case that should be fine: 20ms will be round up to two frames of 16.7ms (if you have a 60Hz monitor). One reason that participants might be able to see the stimulus is because it is not masked (or is it?). Without masking or making the stimuli extremely dim participants are likely to see them.

    But it might also be an issue of incorrect timing, of course. You can investigate the time_[item name] variables to see if the timing is as you expect it to be. You can also find some tips on proper timing here: http://osdoc.cogsci.nl/miscellaneous/timing

    Good luck!

    Regards,
    Sebastiaan

    PS. In the future, could you perhaps open a new topic when posting a new question? Thanks!

  • edited February 2012

    Thanks Sebastiaan, a couple of questions though:
    1. How do I get the number of the subject for the log so that the file is called 'my_log_Sub1'?
    2. Just to confirm, the trial inline should be in the 'run' tab right?
    3. In a related but different question... using the regular loggers, I have the logger inserted at the end of the trial loop. However, I want to log some information at the end of the experiment (that is asked outside the trial loop). Where do I put the second logger to include this information? Should it be the same logger twice, or do I have to use different loggers?

    Frank

  • edited 3:53PM

    Hi Frank,

    The subject number is available as subject_nr. So something like the following should give you what you want:

    f = open("my_log_%d.csv" % self.get("subject_nr"), "w")

    For more such variables, see http://osdoc.cogsci.nl/usage/variables-and-conditional-qifq-statements

    Regarding the use of loggers. You can use either the same logger in two different positions, or create a new logger. Either way will work fine, but your logfile will probably look a bit less chaotic if you stick to a single logger. Make sure to enable the Use NA ... setting in the logger, otherwise the variables will be ignored if they are not yet available when the logger is first called.

    And, yes, the run phase is the place to put the script!

    Good luck!

    Cheers,
    Sebastiaan

  • edited February 2012

    Hi Sebastiaan, I am trying to debug the script that nuclides your suggestion but the experiment was done originally on a PC and I don't have access to a PC just now and when I try to run it on a mac it crashes completely and I cannot even get a debug window to figure out what is wrong with it... Can you help me with this?

  • edited 3:53PM

    Hi Frank,

    I'm afraid that, as it says on the download page, Mac OS support is experimental. On some systems it works quite well, on some it doesn't. I don't have a clear picture of when and why the Mac OS packages crash. The issues go deeper than the OpenSesame code: There are hard crashes in the underlying modules, which is why they are not intercepted by the OpenSesame debug window.

    However, you may want to try selecting a different back-end. There's a good chance that one of the back-ends will work.

    I don't have a mac myself, so I'm mostly dependent on others for testing and creating Mac OS packages. That's why Mac OS support still lags behind, unfortunately.

    Good luck!
    Sebastiaan

  • edited 3:53PM

    Hi Sebastiaan,

    the main problem with the script is that the f = open("my_log.csv", "w") only works if you type the complete path name. If it is not included it complaints that I do not have permission to write on the file. I tried to get the pathname with path = os.getcwd(), but if I replace the full path with the variable 'path' it complains again. Do you have any insight on how to solve this so that the experiment can be run in multiple computers without having to change the pathname individually on each computer?

    Thanks!

  • edited 3:53PM

    Hi Frank,

    Right, I think I misunderstood. I thought the entire program crashed, but it's just an innocent little path-error?

    For your purposes, the easiest way is probably to store the custom logfile in the file pool. This is just a temporary folder somewhere, and you're guaranteed to have write access there (you may not have write access in the working directory). So you could do something like this:

    f = open(os.path.join(self.experiment.pool_folder, "my_log_%d.csv" % self.get("subject_nr")), "w")

    After the experiment you can refresh the pool folder (or maybe that's done automatically) and you will see your logfile. Be sure to use the .opensesame.tar.gz format, otherwise the pool will not be saved!

    Cheers,
    Sebastiaan

  • edited 3:53PM

    Hi Sebastiaan, actually in mac the entire program actually crashes, this bug was probably one of the reasons that caused it to crash but I only received this message when I tried my experiment on the windows side.

  • edited 3:53PM

    Hi Sebastiaan, the fix worked well. 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