Triggering TMS machine with labjack

379 views
Skip to first unread message

rwa...@gmail.com

unread,
Mar 4, 2015, 8:53:52 AM3/4/15
to psychop...@googlegroups.com
I'm trying to use labjack to trigger stimulation from our TMS machine. I'm failing at almost the first hurdle. 

I'm running OS X 10.8.5 and PsychoPy 1.81.03 (and also 1.82.01). 
I've installed the LabJackPython drivers and libusb packages. 

Within a python session from the terminal (Python 2.7.2), I can
import u3
d=u3.U3()
and then do some of the reading and configuring,

Within psychopy coder view, I have been trying what's recommended in the help docs:
from labjack import u3

But I get the error: 
ImportError: cannot import name u3

If I just try to import u3 directly, I'm unable to, presumably PsychoPy is looking elsewhere for the module?

A search of labjack within the group turned up a similar unanswered question. If anyone has suggestions, that would be much appreciated!

rwa...@gmail.com

unread,
Mar 4, 2015, 9:12:28 AM3/4/15
to psychop...@googlegroups.com
One correction and one additional point
Correction what fails in the coder view is 
from labjacks import u3

Also tried to use a parallel out port in Builder view and get a similar error. The offending lines:
from psychopy.hardware import labjacks
p_port = labjacks.U3()

    import u3
ImportError: No module named u3

Jared Roberts

unread,
Mar 4, 2015, 11:56:25 AM3/4/15
to psychop...@googlegroups.com
Hello,

Are you using the standalone install of psychopy?  If so, it keeps its own registry of python libraries separate from the system's python install.  I don't know about labjack in particular, but I've had success before in copying python libraries from the system's site-packages folder into the standalone app's Contents/Resources/lib folder.  That's kind of a hack though, and may not work with all packages.  Probably the correct way to deal with something like this is to install psychopy and its dependencies to your system python interpreter.  You can find more info here: http://www.psychopy.org/installation.html

-Jared

--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/psychopy-users/8c4d90ef-edfc-470b-be93-a63941a39b28%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Jared Roberts
Graduate Student
Neuroscience of Memory, Aging and Dementia Lab
Department of Neurobiology and Behavior
University of California, Irvine
"A lost cause can be as spiritually satisfying as a victory." - Robert Heinlein

Jeremy Gray

unread,
Mar 4, 2015, 3:14:13 PM3/4/15
to psychop...@googlegroups.com
You can also add libraries to a list in preferences > general > paths

--Jeremy

r.w...@bangor.ac.uk

unread,
Mar 5, 2015, 5:34:00 AM3/5/15
to psychop...@googlegroups.com
Thanks Jared and Jeremy for the replies
I don't know much about the nitty-gritty of library installation. Is there an easy way to find out from where a module has been imported? I mean, if I say:
import u3
Is there a way for me to find out where on my computer python pulled the u3 module?

Axel Kohler

unread,
Mar 5, 2015, 5:48:32 AM3/5/15
to psychop...@googlegroups.com

If the import was successfull, you can get a hint with:

u3.__file__

If you are even unsure about which Python you are using at the moment, you can also do the following from within Python:

import sys
sys
.executable

Cheers,

Axel

Jonathan Peirce

unread,
Mar 5, 2015, 10:45:55 AM3/5/15
to psychop...@googlegroups.com
If you use the standalone distribution of psychopy then you need to do either:
    from labjack import u3
    dev = u3.U3()
If you have your own python installation then you need to do:
    import u3
    dev = u3.U3()

The reason is that labjack's install method dumps its files not in a folder but individually into python site-packages folder. I can't distribute it that way for technical reasons (py2app) and because it offends me ;-)

BUT if you do the following then psychopy should check for either type of install and work correctly:
    from psychopy.hardware import labjacks
    device = labjacks.U3()
This also adds an extra method called setData() to the device that labjcak didn't provide and I prefer.

So if that isn't working then we need to know more about how you created your python installation.

cheers
Jon
--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/psychopy-users/8c4d90ef-edfc-470b-be93-a63941a39b28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
Jonathan Peirce
Nottingham Visual Neuroscience

http://www.peirce.org.uk


This message and any attachment are intended solely for the addressee
and may contain confidential information. If you have received this
message in error, please send it back to me, and immediately delete it. 

Please do not use, copy or disclose the information contained in this
message or in any attachment.  Any views or opinions expressed by the
author of this email do not necessarily reflect the views of the
University of Nottingham.

This message has been checked for viruses but the contents of an
attachment may still contain software viruses which could damage your
computer system, you are advised to perform your own checks. Email
communications with the University of Nottingham may be monitored as
permitted by UK legislation.

r.w...@bangor.ac.uk

unread,
Mar 6, 2015, 7:40:04 AM3/6/15
to psychop...@googlegroups.com
Someone took the labjack last night, so a sliiiiiight delay while I track it down.

r.w...@bangor.ac.uk

unread,
Mar 9, 2015, 5:31:47 AM3/9/15
to psychop...@googlegroups.com
OK Jonathan, to follow up your suggestions.

From the terminal I am running python 2.7.2 (from /usr/bin/python)
From there I can reach the labjack, e.g.
import u3; d=u3.U3(); d.getFIOState(4)


In the coder view 1.81.03 (sys.executable = /Applications/PsychoPy2.app/Contents/MacOS/python):
if I try 
import u3
I get ImportError: No module named u3

If I try either
from psychopy.hardware import labjacks
or
from labjack import u3

Then I get another error related to a driver, appended below. I had to compile the libusb myself. I don't know how it works for one python and not the other?

Rob

Traceback (most recent call last):
  File "/Volumes/OLD/Users/pss143/Dropbox/Rob/Active/faces/tms/untitled.py", line 4, in <module>
    from labjack import u3
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/labjack/__init__.py", line 1, in <module>
    import u3, u6, u12, ue9, skymote, Modbus
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/labjack/u12.py", line 378, in <module>
    raise U12Exception("Could not load the Exodriver driver. Ethernet connectivity only.\n\nCheck that the Exodriver is installed, and the permissions are set correctly.\nThe error message was: %s" % e)
labjack.u12.U12Exception: Could not load the Exodriver driver. Ethernet connectivity only.

Check that the Exodriver is installed, and the permissions are set correctly.
The error message was: dlopen(liblabjackusb.dylib, 6): Library not loaded: /usr/local/lib/libusb-1.0.0.dylib
  Referenced from: /usr/local/lib/liblabjackusb.dylib
  Reason: no suitable image found.  Did find:
/usr/local/lib/libusb-1.0.0.dylib: mach-o, but wrong architecture
/usr/local/lib/libusb-1.0.0.dylib: mach-o, but wrong architecture




On Thursday, March 5, 2015 at 3:45:55 PM UTC, Jon wrote:

r.w...@bangor.ac.uk

unread,
Mar 9, 2015, 5:46:56 AM3/9/15
to psychop...@googlegroups.com
Thanks everyone for your help. THe issue I was having with "mach-o wrong architecture" is addressed at the labjack site. There are step-by-step instructions for installing dual-architecture libusb and liblabjackusb libraries. So I can now set and get FIO states in psychopy (as well as the python command line).

One reason I'm working on this in psychopy is to try to make it easier for people to use the TMS stimulator. If there are any suggestions on how to easily install the correct libraries I'd be interested to hear. Currently the first step of the procedure will be (1) install XCODE!

Jonathan Peirce

unread,
Mar 9, 2015, 4:50:14 PM3/9/15
to psychop...@googlegroups.com

On 09/03/2015 09:46, r.w...@bangor.ac.uk wrote:
> Then I get another error related to a driver, appended below. I had to
> compile the libusb myself. I don't know how it works for one python
> and not the other?
If the driver was 64bit then it would have worked from Mac's built-in
(64bit) python but not from the 32bit python that we use for PsychoPy.

Jon
Reply all
Reply to author
Forward
0 new messages