Creating pynetstation plug-in for OpenSesame
Hey developers,
I've been developing a fairly complex experiment using OpenSesame for the past few months and having a blast. The experiment includes use of EGI's EEG equipment, which I was going to use pynetstation(https://code.google.com/p/pynetstation/) in multiple inline_script items to communicate with Netstation--EGI's recording software.
Unfortunately, I got excited about making OpenSesame a permanent tool in our lab's software and decided to make a plug-in for pynetstation. The only problem is that I can't seem to get communications to work properly since I put the pynetstation code into various .py files as opposed to including the code in various inline_script files. I have a feeling the issue is that my module (or object from the module) isn't being dispersed across all the plug-in files and therefor causing problems, as I've noticed in inline_scripts modules and variables(in this case an object) are shared across all other inline_scripts. Is there a secret line of code I'm missing in your source files in order to share a single module/object? I tried to base a majority of my plug-in on your newer yaml format, but there is code mixed into the qt'plug-in' class from the pygaze, which was all json formatted, not sure if that matters.
Attached is a copy of the plug-in as it stands(some messiness at the moment due to troubleshooting/debuggin).
Thanks for any thoughts or advice you might have.
Also, with your help, i'll be able to send the pynetstation plug-in to you for distribution with future copies so everyone can make use of it.
Best,
Josh
Comments
Hi Josh,
Do I understand correctly that you would like to create variables (or modules, etc.) in your plug-in that are available as
global
s ininline_script
s? There are two ways you can do this:You can add properties to the
experiment
object. So if you doself.experiment.my_var = 10
in your plug-in, people will be able to useexp.my_var
ininline_script
items. This is the typical way.You can add something to the Python workspace that is used by
inline_script
items, like so:self.experiment.python_workspace['my_var'] = 10
. If you do that,my_var
will become aglobal
ininline_script
items.It might be a good idea to create a GitHub repository for the plug-in?
Hope this helps!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Thanks Sebastiaan,
I was able to correct my problem after reading your response. It turned out I wasn't referencing my object properly within the
self.experiment
object. It's all working now with bells and whistles. I set up a repository for it on my github:https://github.com/imnotamember/Pynetstation-Plug-In
One more thing I was curious about is working in some more advanced GUI interface into one of my plug-in items. It is pynetstation_send_tags, and the item takes user input for variables and data to send to the EEG software as timestamped-tags. Currently, it just has 5 text fields where the user inputs the variables or literals they want to send for each tag, and I'd rather allow the user to add as many variables or literals as they wish for each tag (up to 255 as that's the limitation) and potentially have a list view of the variable inspector that they could just drag and drop variable names from to avoid the headaches of human error in typing. I looked into Pyqt 4 and Qt 4 and I see the potential, but I don't know how to take advantage of Pyqt within the confines of my plug-in's widget. Any thoughts?
Thanks in advance for your continued support!
That's great. Once you feel that the plug-in is ready for general use, feel free to update the documentation so that it includes a reference to it. Maybe as an additional page under External devices?
If you want to use PyQt4 directly, you mainly need to know that you can use
self.add_widget()
to add an arbitraryQWidget
to the plug-in controls. After that, you're pretty much on your own, in terms of connecting signals to make sure that all changes are applied, etc.If you want to understand the structure of plug-in controls in more detail, you can take a look at
libqtopensesame.qtitem.qtitem.init_edit_widget()
. That's probably not necessary though.Cheers!
Check out SigmundAI.eu for our OpenSesame AI assistant!
Dear all,
I was trying to add the Pynestation plugins to OS as usually, adding egi,pynetstation_begin_trial, etc... (8 folders from https://github.com/imnotamember/Pynetstation-Plug-In) .Path enviroment var modified to recognize egi folder, ok.
but when i was trying to add the pynetstation_init i got an error (Failed to load plug-in pynetstation_init). Here the result from the debug window:
Plug-in error
line: 80
exception message: Failed to load plugin 'pynetstation_init'
exception type: osexception
Traceback:
File "dist\libqtopensesame\widgets\tree_overview.py", line 498, in drop_event_item_new
File "dist\libqtopensesame\misc\qtitem_store.py", line 78, in new
File "dist\libopensesame\item_store.py", line 80, in new
osexception:
Failed to load plugin 'pynetstation_init'
code: u'You should only have one instance of 'pynetstation_init' in your experiment')
line: 59
exception message:
exception type: SyntaxError
Traceback:
File "dist\libopensesame\item_store.py", line 77, in new
File "dist\libopensesame\plugins.py", line 331, in load_plugin
File "dist\libopensesame\plugins.py", line 303, in import_plugin
File "C:\Program Files (x86)\OpenSesame\plugins\pynetstation_init\pynetstation_init.py", line 59
u'You should only have one instance of 'pynetstation_init' in your experiment')
^
SyntaxError: invalid syntax
Do you have some suggestion for this ?
i'm grateful in advance for your reply, Pietro
Hey Pietro,
I've just updated the pynetstation_init/pynetstation_init.py file. Replace the one you currently have with the updated file on github. Let me know if you have more issues.
I made this plugin months ago and since data collection ended I stopped working on it for other projects. I fully intend to make it completely functional but haven't had a motivation yet (or time) to finish this. I will say that I ended up scrapping this on my own project as it became too complex to simply run through a plugin and I ended up just hard-coding the signals to Netstation. If you need any assistance getting this to work I'd be happy to use it as a means for updating the plug in.
What operating system are you using? I've had terrible luck trying to get plugins working on Mac's(even though you can use them to send Netstation signals). Also, what version of Netstation are you using? I've had trouble getting Netstation 5 to work with this, but am working on it with EGI.
Best,
Josh
Dear Josh,
pynetstation_init.py replacement was successful, i'm grateful for your help. My platform is win7 64bit, Netstation 4.1.1 on OSX. I'm developing some templates for our EEG labs, OS/python seems me an optimal development choice, I'll let you know: i agree about hard coding,so i will keep you informed if there are relevant developments.
All the best, Pietro