psychopy.org | Reference | Downloads | Github

Trigger TMS via MacBook Pro USB port via LabJack U3-LV to TTL in


#1

Hi All,

My aim is to trigger a transcranial magnetic stimulation pulse (TMS) using PsychoPy running on a MacBook Pro via a LabJack U3-LV. The MacBook Pro is connected to the TMS machine via the USB port, which is connected to the LabJack U3-LV. The LabJack U3-LV is then connected to the TMS via TTL.

I’m trying to run stuff that is on this webpage here: http://www.psychopy.org/api/hardware/labjack.html

The first line from psychopy.hardware.labjacks import U3 seems to be working ok. However, the next line is confusing me: U3.init(debug = False, autoOpen = True, **openArgs)

I’m inputting the code below to implement this (which is probably wrong):

U3.init(debug = False, autoOpen = True, firstFound = True, localID = None, devNumber = None, handleOnly = False, LJSocket = None)

However, I’m getting the following error:

TypeError: unbound method init() must be called with U3 instance as first argument (got nothing instead)

Please could somebody explain this error to me? Please could somebody explain the U3.init(debug = False, autoOpen = True, **openArgs) to me as well? In particular, could the format of specifying the openArgs be explained? I know it recommends looking at u3.open() but I’ve looked at this and I don’t understand.

Thanks,
Rory


Receiving TTL triggers
#2

You should probably create it like this:

labjack = u3.U3() # I guess supply the arguments as above

i.e. you want to create an actual object (here called labjack but you can name it what you want) which you can interact with afterwards. The relevant init method should get called implicitly for you, passing that object along to act as the first argument (in Python terms, the function needs a self reference to a particular object). At the moment you’re trying to directly call the init method of the library but not actually creating an object that will get initialised. That may not make sense, but don’t worry.

Afterwards, the labjack variable provides a reference to a persistent object to send your triggers to and whatever else you need. e.g.

labjack.setData(0) # send a zero byte on the default address

#3

Hello Micheal,

I hope this finds you well!

I have recently been trying to get a labjack U3-LV to run with PsychoPy. I have been able to send a high/lo’s to each of FIO pins (set to digital out), though for the life of me cannot seem to get setData function to work.

This is what I have so far…

Code Start

from psychopy.hardware.labjacks import u3

lb = u3.U3()

cal_data = lb.getCalibrationData()
if lb.getFIOState(0) == 1:
lb.setFIOState(0,0)

lb.setFIOState(X,0) # This is what I have been using to change the values of different outputs.

End Code

I have tried to use

lb.setData(), but get the following error: u3 object has no attribute ‘setData’

If I look in the hardware folder of the psychopy installation, I find a .py file called labjacks.py with what appears to be the setData function within it.

If you could point me in the direction I need to get this to work, that would be amazing!!!

Thank you so much and please let me know if you need anything else from me.

Best,

Reza

p.s. Using standalone version 1.85.4 (psychopy)


#4

Is the capitalisation of u3 in that message correct? If so, it looks like you are trying to setData() on the u3 library rather than a U3 object.


Psychopy lagging when connecting with Labjack
#5

Micheal,

It is actually capitalized. Sorry for that mistake!

It reads: AttributeError: ‘U3’ object has no attribute ‘setData’

I’m pretty much a newbie when it comes to python, though someone told me to run dir() on the various objects that I was creating, and I have found that when I run it on my ‘lb’ object, I can see the functions that work (e.g. setFIOState()), though not setData().

Not sure if that helps at all, and as always any help is most appreciated!!

Best,

Reza


#6

OK, that sounds like you are importing the standard labjack library, and not the extended one that PsychoPy provides, which adds the setData() method:
http://www.psychopy.org/api/hardware/labjack.html

So make sure the import looks like this, with the capital U:

from psychopy.hardware.labjacks import U3

then:

lb = U3.U3()

I’m flying blind here, though, as I don’t have a labjack so can’t test.


#7

Micheal,

That worked like a charm!!

Thank you so much!!

Reza