Howdy, Stranger!

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

Supported by

[open] TMS parallel port managing delays

edited September 2015 in OpenSesame

Dear all,

I am running a visual behavioral experiment where subjects must make a size judgment one 2 elements presented on a picture (which one is larger) and then press left or right. Experiment works fine using psychopy back-end but now i want to add TMS on it.

In the experiment I present the picture during 200 ms. and I want to use 5 different delays (0-50-100-150-200 ms) in the TMS pulse. in order to "send" the pulse instruction to the TMS i just need to send a "1" pulse through the parallel port and then come back to "0" state.

So I have two problems at the moment:

1- On one side I can't use the parrallel_port plugin because the parallel port of the computer is an external card whose number is E010 ... what means it is the port number 57360 in decimal values, and this number in not covered by the port plugin. is there anyway to overcome this issue?

2- In the case I could use the plugin, is there any way to "tell" the plugging to "wait" for an x amount of time before sending the pulse?

I think that both problems could be solved using inline code , but looking in the forum I just found the posibility to use something like:

from ctypes import windll
port = 889 
dev = windll.inpout32 
val = dev.Inp32(port) 
print "Read %d from port %d" % (val, port)

but when I tried OpensSesame launches an error saying that there is no module ctypes (I alreaddy installed inpout32.dll).

I am using OpenSesame is 2.9.7 Hesitant Heisenberg on a Windows 7 machine.

Any ideas? Recomendations?

Thanks in advance.

Felipe

Comments

  • edited 9:28PM

    Hi Felipe,

    Let's begin with the ctypes issue. This module is part of the Python standard library, so it should always be available. What script did you try exactly, and what is the exact error message?

    Cheers,
    Sebastiaan

  • edited September 2015

    Hi Sebastiaan,

    Thanks a lot for your fast answer...

    So far I have the code line like this:

    from psychopy import core
    from psychopy.visual  import GratingStim, SimpleImageStim, TextStim, Circle
    import numpy as np
    from ctypes import windll
    
    im.draw()  # im is a picture previosuly load in the prepare phase
    myStimB.draw() # these mystim variables are different size elements ###
    myStim2B.draw() 
    myStim.draw()
    myStim2.draw()
    fixcross.draw()
    
    foto_nr= (float(trigger)) # trigger is the delay for the TMS pulse (0-50-100 ms)
    
    if trigger==0:
        port = 57360 # Port nr to read from. Names like COM1 etc do not appear to work
        dev = windll.inpout32 # Init the device
        val = dev.Inp32(port) # Read a value
        print "Read %d from port %d" % (val, port)
        win.flip()
        core.wait(0.1) #stimumus presented 100 ms
    elif trigger==50:
        win.flip()
        core.wait(0.05)
        port = 57360 # Port nr to read from. Names like COM1 etc do not appear to work
        dev = windll.inpout32 # Init the device
        val = dev.Inp32(port) # Read a value
        print "Read %d from port %d" % (val, port)
        core.wait(0.05)
    elif trigger==100:
        win.flip()
        core.wait(0.1)
        port = 57360 # Port nr to read from. Names like COM1 etc do not appear to work
        dev = windll.inpout32 # Init the device
        val = dev.Inp32(port) # Read a value
        print "Read %d from port %d" % (val, port)
    else:
        win.flip()
        core.wait(0.1)
    

    Using this code I get the following error message in the debug window:

    Error while executing inline script

    phase: run
    item: Stimulus
    line: 365
    exception message: 
    exception type: WindowsError
    
    Traceback:
      File "dist\libopensesame\inline_script.py", line 155, in run
      File "<string>", line 87, in <module>
      File "ctypes\__init__.pyo", line 435, in __getattr__
      File "ctypes\__init__.pyo", line 365, in __init__
    WindowsError: [Error 193] %1 nest pas une application Win32 valide
    

    Could you help me here on what is wrong in the code in order to activate the parallel port? Is there any "easier" way to activate the port in between of the stimulus presentation?

    Thanks again

    Felipe

  • edited 9:28PM

    Hi Felipe,

    It's a bit unclear where exactly this error message comes from. Could you upload the entire experiment script, for example to http://pastebin.com?

    And are you running 32 bit or 64 bit Windows 7? It kind of looks like a compatibility issue, but I'm not sure.

    Could you help me here on what is wrong in the code in order to activate the parallel port? Is there any "easier" way to activate the port in between of the stimulus presentation?

    I'm afraid not. The parallel port is very outdated, pretty much only still used by EEG researchers. It's always a bit of a problem to activate it under Windows. (But it can be done.)

    Cheers,
    Sebastiaan

  • edited 9:28PM

    Hi Sebastiaan,
    Thanks for your answer.
    There are two ways toa ccess the TMS serial or parallel port. The parallel seems to be much easier since you just need to sens a "1" to open the port and activate the tms pulse and a "0" to close it again.
    Of course, as I tried to explain before, this is not really straight foward with OpenSesame when i need to use different time delays after a picture presentation.
    I let you the code I have written here:

    http://pastebin.com/JCxAD00X

    I am running it on a Windows 7 Profesisonal 32 bits machine.

    Thanks a lot for your help

    Felipe

  • edited 9:28PM

    Hi there,

    It seems that my pastebin link expired so I reupload in case somebody is interested to give me some help on this issue.

    http://pastebin.com/AxDgLAqc

    Thanks in advance for any idea or help to deal with this problem.

    Felipe

  • edited 9:28PM

    Hi Felipe,

    Could you clarify a bit what exactly you're trying to do? From your description it sounds like you want to send triggers via the parallel port, but in your script you're reading from the parallel port.

    Then we have the inpout32.dll error, which is quite mysterious. Is inpout32.dll actually present in the OpenSesame folder?

    As an alternative, you could use dlportio.dll instead, either through a script or the parallel_port_trigger plugin? This is explained on this page:

    Cheers,
    Sebastiaan

  • edited 9:28PM

    Hi Sebastiaan,
    Thanks for your reply.

    You re totally right with the issue inpout32.dll ... I want to send a "1" and not to read the port.

    I need to present a picture and send a "1" to the parallel port either 0-100-150-200 ms after the picture presentation, and inmediately after close the port. (The "1" triggers the TMS pulse) .

    The pluggin does not work because the parallel port of the computer is an external card whose number is E010 ... what means it is the port number 57360 in decimal values, and this number in not covered by the port plugin. Is there anyway to overcome this issue? Solving this problem would be the easiest way.

    Then , the inline code of dlportio.dll would be the only option. Still, the problem is how to delay 0-100-150-200 ms to send the trigger.
    Any idea how to overcome this issue with the inline code?

    Thanks again.
    Felipe.

  • edited 9:28PM

    Hi Felipe, did you solve the problem? I am facing something smilar right now with the need to trigger TMS and a too large parallel port number. Thanks! Luigi

  • edited 9:28PM

    Hi Luigi,

    Unfortunately I never found a solution . So I moved to another stimulus presentation software.

    I hoipe you got better luck!

    Cheers

    F.

  • edited 9:28PM

    Hi Luigi,

    Managed to get this working with port = 0xD010 by downloading the Binaries only from http://www.highrez.co.uk/downloads/inpout32

    Unpacking the Win32 folder.

    Running InstallDriver.exe as Admin

    Copy the file inpout32.dll from Win32 to c:\Windows\SysWOW64\ and rename it to dlportio.dll

    Best,
    Jarik

    I tested this on Windows 7 64 bit with OpenSesame 3.0.7 using inline script: http://osdoc.cogsci.nl/devices/triggers/#using-dportiodll-in-a-python-inline-script-windows-only

    with port = 0xD010 instead of port = 0x378

    I used a StartTech PEX1PLP (PCI Express Parallel port card)

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