Howdy, Stranger!

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

Supported by

How Collect RF Pulse (Collecting Keyboard Responses Anytime)

I'm trying to build an experiment that collects responses in fMRI environment. However, I also do need to collect the pulses from the MRI machine itself. The machine will send a keyboard input every 2 seconds and I need to be able to collect it and write it to a log file. I am kind of clueless in this regard.

Comments

  • Hi @Xeonen ,

    In principle there's no difference between recording keyboard responses from the fMRI machine and those that come from the participant. They will (at least on most systems) simply be exposed as key presses to the software. How and whether to deal with this depends on the details of the experiment though.

    Are these 'pulse' key presses simply emitted every 2 s as a steady pulse? In that case, you could consider only registering the timestamp of the first pulse, because that's all the information you need. (In fact, this is exactly what's often done in fMRI experiments.) Or do the 'pulse' key presses actually convey important timing information, for example because they indicate the onset of something in a way that is not fully predictable?

    There's no general purpose solution here; the details matter! And so you'll have to provide a lot more information! I would also ask the lab technician (or experienced lab members) how they usually do this (even if they use other software). Labs tend to have their idiosyncratic ways of implementing these kinds of things, and it makes sense to stick to that, at least if you're just starting out.

    — Sebastiaan

  • Hello there @sebastiaan !

    Yes, the pulse key presses are emitted every 2 seconds as a steady pulse. However, if machine "hicks-up" the delay will change. These keypresses will be used to sync the actual timing with the images produced by the machine.

    In general, there is an experiment running on the background. Participant will be shown stimuli and they will grade the stimuli using a mouse. In this regard, there will be other keypresses and mouse clicks. What confused me is that OpenSesame records keypresses once for each keypress object, logger also logs them only when it runs. (timeline passes over the logger). I don't have a clue on how to add a logger and keypress object that will write to a separate csv file each time that pulse "key" is pressed.

    I tried to upload the experiment but I got 413 error. I will be sharing the Google Drive link.

    Lastly, thanks a lot for the reply. I was losing hope when I posted on the forum.

    Kind regards,

    Salih Fırat Canpolat

    https://drive.google.com/file/d/1C1n6hwk-2FBDqth4CWYfoDpE0ydMMcE5/view?usp=sharing

  • Hi @Xeonen ,

    It sounds like you want OpenSesame to behave normally, except that in the background the program is also continuously monitoring for, and responding to, presses of a specific key that is used to send pulses. That's a bit unusual, but it's possible.

    The easiest way to do this is by applying a so-called decorator to the function that PsychoPy uses to capture key presses (event._onPygletKey). Below you see a script that does this; this script should be in the prepare phase of an inline_script at the very start of the experiment. You can watch these videos if you want to know more about decorators, but the general logic is that a function (_onPygletKey in this case) is replaced with another function that adds some functionality, in this case printing out a message to the console whenever the k is pressed. Of course, in your case you want to change this so that a timestamp is written to a file whenever the key is pressed that the fMRI devices uses to signal pulses.

    Hope this helps!

    — Sebastiaan

    from psychopy import event
    
    
    def capture(fnc):
    
        def inner(symbol, modifiers, emulated=False):
            if symbol == 107:  # ASCII code for k
                print('The k was pressed')
            return fnc(symbol, modifiers, emulated=emulated)
    
        return inner
    
    
    event._onPygletKey = capture(event._onPygletKey)
    

    PS. Sorry for the slow response. I hope the issue is still relevant.

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