Howdy, Stranger!

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

Supported by

Sync paradigma with MRI scanner

Dear All,

Currently i'm investigating possibilities for paradigma presentation in fMRI experiments. The initial idea was to use Cogent, but due to stability / development issues we are investigating the alternative ways.

So far i was able to reproduce the core of the paradigma in OpenSesame, but currently i'm stuck on the synchronization.

The pulse from GE MRI scanner comes to the SyncBox from NordicNeuroLabs and is transmitted to the computer via RS-232 - USB connection. We must use the RS-232 communication, as the other software - nordicActia requires this.

The SyncBox transmits 's' symbol at the beginning of every slice. an we are to start the timing just on the slice.

The generic idea is to make blocking port read on the serial port while the 's' (or any other predefined character) is received. As OpenSesame already has 'srbox' plugin, i thought it will be trivial to create 'syncbox' plugin. Up to the moment

inputbyte1 = ord(inputchar)

As nothing is received on the port, it kills tre paradigma with
TypeError: ord() expected a character, but string of length 0 found

I'm quite new to Python and suppose something wrong is at the lines (see the libsrbox.py):

if inputchar == '':
continue

Any clue for this? How should i denote empty line is Pyton3.5 ?

Comments

  • Hi,

    Python 3 makes a distinction between bytes and str text. (These roughly correspond to str and unicode in Python 2. Confusingly, Python 2 str maps onto Python 3 bytes.)

    I suspect that you get a bytes object when reading from the serial port, and so you need to compare it to a bytes object, otherwise the comparison will always be False. An empty bytes is not identical to an empty str. In other words, the correct comparison would be:

    if inputchar == b'':
    

    However, even better would be to use the fact that empty things are also False, and not assume any particular object type:

    if not inputchar:
    

    Does that make sense?

    In general, I would first read up on how text is handled in Python 3, so that you fully understand the difference between str and bytes. Otherwise you're likely to get stuck or, if you don't, to write code that is likely to break!

    Cheers,
    Sebastiaan

  • Hi Sebastiaan,

    Thank You for the response. It seems to be not so trivial task for me.
    Currently if not inputchar: is not triggered by empty read from the serial port and i'm not sure why.
    I feel like a complete dummy in Python as i'm still unable to print a debug string :)

    BTW: to free the MRI scanner and its interface i've created an Arduino based hardware simulation box. Anyone interested in it?

  • Well, it seems now i can sync the paradigmas using the external signal.
    I've copypasted the new toolbox, called 'syncbox' for this. It holds up the presentation up to a sync character is received on the serial port.

  • edited December 2016

    Hi ejs,

    Thank you for sharing this.

    BTW: to free the MRI scanner and its interface i've created an Arduino based hardware simulation box. Anyone interested in it?

    I'm not interested at this point but if you could upload your files here (assuming they aren't very big) or share a link to them, others can benefit if they stumble upon this discussion in the future.

    Best,
    Jarik

  • Here's the Gihub link to the 'syncbox' plugin and the the fMRI Parrot, an off-scanner sync trigger generator. The last one does not contain the schematics, but the connection and key definitions are obvious from the Arduino sketch.

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