Howdy, Stranger!

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

Supported by

[open] Custom Logging/Output

edited March 2014 in OpenSesame

I will be using OpenSesame as part of a cognitive training study (starting April 1), which involves subjects coming in for multiple sessions. I currently record and log Subject # and Session variables, but every time the same subject # is used, the logging file (e.g., subject-1.csv) is overwritten.

I could have the subject runners manually name the output files, but that introduces a lot of room for human error, especially with the amount of data that will be collected (hundreds of subjects completing 16 sessions each).

I would like to be able to either name the log file (sub_session_task.csv) or create a new custom output file from an inline script within the experiment. I've tried out a few commands that work from a Python terminal, but I haven't been able to create a text file from within OpenSesame using the Droid back-end on a Nexus 10. Any ideas?

Comments

  • edited March 2014

    You'll want to take a look at this discussion, which describes how you can choose custom logfile locations from within an inline_script:

    In your case, the idea should be the same, but you'll have to make sure that you choose a writable location for the logfile, for example in the /sdcard/ folder (but it's somewhat device dependent). So ...

    path = '%d-%d.csv' % (self.get('subject_nr'), session_nr)
    

    ... might become ...

    path = '/sdcard/%d-%d.csv' % (self.get('subject_nr'), session_nr)
    

    Cheers!

  • edited 8:08PM

    Thanks! I was able to get it to work based on the previous discussion and your suggested path. Here's the code that ended up working for me:

    #Imports modules for modifying filenames and getting a timestamp
    import os
    import time
    import datetime
    
    # Closes the current logfile
    exp._log.close()
    
    #Creates a timestamp
    rawtimestamp = time.time()
    timestamp =
    #Formats the timestamp into YYYYMMDDHHSS
    datetime.datetime.fromtimestamp(rawtimestamp).strftime('%Y%m%d%H%M%S')
    
    #Version 1 = colored Ps
    #Re-defines the name of the log file as Sub_Sess_TaskVers#_Timestamp.csv
    path = '/sdcard/ChangeDetectionData/Sub' + str(self.get('subject_nr')) + '_Sess' + str(self.get('Session')) + '_ChangeDetectionVers1_' + str(timestamp) + '.csv'
    exp.logfile = path
    
    # Reopens the logfile
    exp._log = None
    exp.init_log()
    
    

    It's working perfectly. I'm curious about something, though. I have a folder with all my stimulus images called TaskImages. In my stimulus display inline, I have the following code.

    Targets=['BA.bmp','BB.bmp']
    #Randomizes which image is first
    shuffle(Targets)
    #Defines the target as the first image (now shuffled)
    trialtarg=Targets[0]
    #Defines the path to the image
    trialtargpath='./TaskImages/'+ trialtarg
    

    But when I try to use a comparable command to define the output folder with a relative path, I get an error.

    path = './VisualSearchData/Sub' + str(self.get('subject_nr')) + '_Sess' + str(self.get('Session')) + '_VisualSearchVers1_' + str(timestamp) + '.csv'
    

    outputs this error in the debug file:
    "IOError: [Errno 2] No such file or directory: './VisualSearchData/Sub0_Sess4_VisualSearchVers1_20140317175935.csv'

    The script currently works great with the original script I attached at the top, so it's not critical, but I'm curious why './VisualSearchData' doesn't work.

  • edited 8:08PM

    The ./ indicates that the path is relative to the current directory, which (under Android) is the app directory that you don't (usually) have write access to. So it's simply a permissions issue.

    Cheers!

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