Howdy, Stranger!

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

Supported by

Logging dynamic variables

Hi everyone,


I am currently struggling with creating a well-structured logfile for my experiment. Since I need to log a few variables per task, I created dynamic variables, "reaction_time" for instance:

var.set('reaction_time_{}'.format(n_tasks), reaction_time)

Checking the variable inspector after a test-run, everything seemed to have worked just fine, as in logging reaction_time_1, reaction_time_2, ..., etc., but importing the *.csv to Excel results in only one column named "reaction_time" and value "NA".


Is there anything I missed out here to make dynamic variables be written properly to the logfile?

Comments

  • Hi,


    If you call your variable "reaction_time_1" you have to look for this one in file. Opensesame writes a number of variables automatically, even if they are undefined. Can you find this variable in your list?


    Eduard

    Buy Me A Coffee

  • Hi Eduard,


    thanks for your reply. I do see them in the variable inspector in OpenSesame after an experimental run:


    However, they do not appear in the *.csv-logfile, unless I manually add custom variables to the logger item and call them "reaction_time_1", "reaction_time_2", "reaction_time_3" and so on. But then again, it wouldn't make any sense to create dynamic variables if I still have to manually add each one to be logged + I don't know how many will be needed as they differ from participant to participant.

    In my experiment, participants are given a reaction task every 7-10 seconds and I need to log the reaction time for each task. Depending on how much time participants take on the primary task, the number of reaction tasks (secondary tasks) will vary individually (as will the number of reaction times respectively).


    So basically, I am looking for a way to add a dynamic variable such as "reaction_time_{}.format(n_tasks)" to the logger item, instead of having to add one for each task not knowing how many tasks will be performed.

  • Hi Mr. Fugbaum,

    why don't you just log different variables using long format?

    For example:

    var.RT = yourresponsetime

    var.N_task = yourNofTheTask

    You can later switch this easily and automatically to wide format using tidyr package in R (does not work in Excel).

    Just an idea ;)

    Stephan

  • Hi Stephan,

    thanks for your reply. What is the default logging format in OpenSesame and how do I change it from wide to long or vice versa? Using your example only results in the last response time & last task being logged instead of response time 1 + task 1, response time 2 + task 2, and so on in long format. That is why I thought it was necessary to create dynamic variables in the first place, I just need to find a way to log them and apparently I must be missing the crucial point on how to do that.


    Simply put:

    "var.RT = reaction_time" only logs one value, that is the last value of the variable reaction_time.

    "var.set('reaction_time_{}'.format(n_tasks), reaction_time)" shows reaction_time_X per task X in the variable inspector, but does not write it to the logfile.

  • edited October 2019

    Okay nevermind, I finally managed to find a workaround creating my own logfile using the following code:


    import csv
    
    with open(logger, "a") as logfile :
    	output = csv.writer(logfile, delimiter=";",lineterminator='\n')
    	output.writerow(['subject_id', 'task_id','trials', 'target', 'position', 'correct_response','reaction_time'])
            output.writerow([subject_id, n_tasks, n_trials, letter, position, correct_response, reaction_time])	
    


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