Running online experiments with psychopy

1,803 views
Skip to first unread message

Alexandre Blondin Massé

unread,
Aug 9, 2010, 10:13:14 AM8/9/10
to psychopy-users, olivier...@gmail.com
Hello, everyone !

Having been a Sage and Python user for the last year, I was really
happy to fall on psychopy. I'm interested in running a simple
experiment and would gladly code it in Python, but there is a big
problem: If possible, I would like the experiment to be done online
from our server. Is it possible ? And what would be the best way to do
it ?

I know that there exists a hybrid language called Jython that allows
one to create applets in Python, but I don't know if it works well
with psychopy.

Thank you in advance for the answers !

Alexandre Blondin Massé
Ph.D. student, UQAM

Jonathan Peirce

unread,
Aug 9, 2010, 10:46:52 AM8/9/10
to psychop...@googlegroups.com, olivier...@gmail.com
Sorry Alexandre, PsychoPy really isn't designed for that. To get the
performance needed PsychoPy makes use of a variety of low-level graphics
(OpenGL) commands and these can't be run via the web. I suppose you
could do something yourself using VNC windows, but it would have
horrible performance.

Jon

> Alexandre Blondin Mass�
> Ph.D. student, UQAM
>

--
Dr. Jonathan Peirce
Nottingham Visual Neuroscience

http://www.peirce.org.uk/

Alexandre Blondin Massé

unread,
Aug 9, 2010, 2:04:08 PM8/9/10
to psychopy-users
Hi, Jonathan !

Thank you for the quick reply. This is what I thought, but I wanted to
make sure there was nothing I was missing.

da...@davebritton.com

unread,
Aug 11, 2010, 10:07:15 AM8/11/10
to psychop...@googlegroups.com, olivier...@gmail.com
Alexandre,
It would be conceivable to do this by having the end user (the
subject) run a local copy of a psychopy application instead of a web
browser. Inside the local psychopy application you would use python's
web httplib library to communicate from the local copy to the web
server, to send and receive data that would tell the server what the
user is doing and let the server tell the application what to do. On
the server you would have a python cgi or wsgi application that
answers the end user application's http request at some url. This
would require that your end users download and install your psychopy
app, perhaps as a standalone, packaged so as to be self-installing.
That could be a lot of work, but possibly worth it. What are you
thinking about that would require doing it online?
-Dave Britton

Quoting Jonathan Peirce <jon.p...@gmail.com>:

> Sorry Alexandre, PsychoPy really isn't designed for that. To get the
> performance needed PsychoPy makes use of a variety of low-level
> graphics (OpenGL) commands and these can't be run via the web. I
> suppose you could do something yourself using VNC windows, but it would
> have horrible performance.
>
> Jon
>

> On 09/08/2010 15:13, Alexandre Blondin Massé wrote:
>> Hello, everyone !
>>
>> Having been a Sage and Python user for the last year, I was really
>> happy to fall on psychopy. I'm interested in running a simple
>> experiment and would gladly code it in Python, but there is a big
>> problem: If possible, I would like the experiment to be done online
>> from our server. Is it possible ? And what would be the best way to do
>> it ?
>>
>> I know that there exists a hybrid language called Jython that allows
>> one to create applets in Python, but I don't know if it works well
>> with psychopy.
>>
>> Thank you in advance for the answers !
>>

>> Alexandre Blondin Massé


>> Ph.D. student, UQAM
>>
>
> --
> Dr. Jonathan Peirce
> Nottingham Visual Neuroscience
>
> http://www.peirce.org.uk/
>

> --
> You received this message because you are subscribed to the Google
> Groups "psychopy-users" group.
> To post to this group, send email to psychop...@googlegroups.com.
> To unsubscribe from this group, send email to
> psychopy-user...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/psychopy-users?hl=en.

Alexandre Blondin Massé

unread,
Aug 12, 2010, 8:53:28 AM8/12/10
to psychopy-users
Hello, Dave !

This is indeed a possible solution that's worth thinking about... I
guess we would have to resolve firewall problems... and check if the
experiment runs ok on different platform.

The reason why we would like it to be online is that it is going to be
very long for each subject (maybe 20 hours), but we don't need to have
very precise data related to the chronometrical features or that it be
done in a very controlled environment. Basically, we only need the
data produced by the subject, and they can do it on a long period of
time if they want to. Maybe it is not necessary to use psychopy, in
fact...

I don't know, I'll keep you posted about our choice. Thank you for the
answer anyway !

Alex

On 11 août, 10:07, d...@davebritton.com wrote:
> Alexandre,
> It would be conceivable to do this by having the end user (the  
> subject) run a local copy of a psychopy application instead of a web  
> browser. Inside the local psychopy application you would use python's  
> web httplib library to communicate from the local copy to the web  
> server, to send and receive data that would tell the server what the  
> user is doing and let the server tell the application what to do. On  
> the server you would have a python cgi or wsgi application that  
> answers the end user application's http request at some url. This  
> would require that your end users download and install your psychopy  
> app, perhaps as a standalone, packaged so as to be self-installing.
>     That could be a lot of work, but possibly worth it. What are you  
> thinking about that would require doing it online?
> -Dave Britton
>

Jeremy Gray

unread,
Aug 12, 2010, 9:52:02 AM8/12/10
to psychop...@googlegroups.com
if timing etc is not that important, I wonder if a psychopy experiment running inside a google app engine could work for this? it looks like something might be possible, although might require things beyond PsychoPy. from http://code.google.com/appengine/docs/python/gettingstarted/ 

"Google App Engine supports any framework written in pure Python that speaks CGI (and any WSGI-compliant framework using a CGI adaptor), including Django, CherryPy, Pylons, and web.py. You can bundle a framework of your choosing with your application code by copying its code into your application directory."

--Jeremy

Alexandre Blondin Massé

unread,
Aug 12, 2010, 8:37:32 PM8/12/10
to psychopy-users
Thank you, Jeremy ! This is another very interesting idea. I'll look
into it...
Alex

On 12 août, 09:52, Jeremy Gray <jrg...@gmail.com> wrote:
> if timing etc is not that important, I wonder if a psychopy experiment
> running inside a google app engine could work for this? it looks like
> something might be possible, although might require things beyond PsychoPy.
> fromhttp://code.google.com/appengine/docs/python/gettingstarted/
>
> "Google App Engine supports any framework written in pure Python that speaks
> CGI (and any WSGI <http://www.python.org/dev/peps/pep-0333/>-compliant
> framework using a CGI adaptor), including
> Django<http://www.djangoproject.com/>,
> CherryPy <http://www.cherrypy.org/>, Pylons <http://pylonshq.com/>, and
> web.py <http://webpy.org/>. You can bundle a framework of your choosing with
> your application code by copying its code into your application directory."
>
> --Jeremy
>
> On Thu, Aug 12, 2010 at 8:53 AM, Alexandre Blondin Massé <
>
> > > > psychopy-user...@googlegroups.com<psychopy-users%2Bunsu...@googlegroups.com>
> > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/psychopy-users?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "psychopy-users" group.
> > To post to this group, send email to psychop...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > psychopy-user...@googlegroups.com<psychopy-users%2Bunsu...@googlegroups.com>
> > .

Jonathan Peirce

unread,
Aug 13, 2010, 3:55:31 AM8/13/10
to psychop...@googlegroups.com
I guess the key part of the snippet below is that the app engine will
run any *pure python* framework, but pyglet, pygame, pyOpenGL, wx,
numpy, and scipy are not pure python - they make calls either to system
libraries via c-types or c libraries compiled by the module, neither of
which will be accessible to a web browser. And without them PsychoPy is
totally crippled.

Sorry to be a downer, but I really don't see it working without a huge
effort (that would amount to starting from scratch). An app engine
solution for running experiments that dont require high temporal
precision is a really interesting idea, but I don't honestly think
psychopy is the starting point for it.

Jon

On 13/08/2010 01:37, Alexandre Blondin Mass� wrote:
> Thank you, Jeremy ! This is another very interesting idea. I'll look
> into it...
> Alex
>

> On 12 ao�t, 09:52, Jeremy Gray<jrg...@gmail.com> wrote:
>> if timing etc is not that important, I wonder if a psychopy experiment
>> running inside a google app engine could work for this? it looks like
>> something might be possible, although might require things beyond PsychoPy.
>> fromhttp://code.google.com/appengine/docs/python/gettingstarted/
>>
>> "Google App Engine supports any framework written in pure Python that speaks
>> CGI (and any WSGI<http://www.python.org/dev/peps/pep-0333/>-compliant
>> framework using a CGI adaptor), including
>> Django<http://www.djangoproject.com/>,
>> CherryPy<http://www.cherrypy.org/>, Pylons<http://pylonshq.com/>, and
>> web.py<http://webpy.org/>. You can bundle a framework of your choosing with
>> your application code by copying its code into your application directory."
>>
>> --Jeremy
>>

>> On Thu, Aug 12, 2010 at 8:53 AM, Alexandre Blondin Mass�<


>>
>> alexandre.blondin.ma...@gmail.com> wrote:
>>> Hello, Dave !
>>> This is indeed a possible solution that's worth thinking about... I
>>> guess we would have to resolve firewall problems... and check if the
>>> experiment runs ok on different platform.
>>> The reason why we would like it to be online is that it is going to be
>>> very long for each subject (maybe 20 hours), but we don't need to have
>>> very precise data related to the chronometrical features or that it be
>>> done in a very controlled environment. Basically, we only need the
>>> data produced by the subject, and they can do it on a long period of
>>> time if they want to. Maybe it is not necessary to use psychopy, in
>>> fact...
>>> I don't know, I'll keep you posted about our choice. Thank you for the
>>> answer anyway !
>>> Alex

>>> On 11 ao�t, 10:07, d...@davebritton.com wrote:
>>>> Alexandre,
>>>> It would be conceivable to do this by having the end user (the
>>>> subject) run a local copy of a psychopy application instead of a web
>>>> browser. Inside the local psychopy application you would use python's
>>>> web httplib library to communicate from the local copy to the web
>>>> server, to send and receive data that would tell the server what the
>>>> user is doing and let the server tell the application what to do. On
>>>> the server you would have a python cgi or wsgi application that
>>>> answers the end user application's http request at some url. This
>>>> would require that your end users download and install your psychopy
>>>> app, perhaps as a standalone, packaged so as to be self-installing.
>>>> That could be a lot of work, but possibly worth it. What are you
>>>> thinking about that would require doing it online?
>>>> -Dave Britton
>>>> Quoting Jonathan Peirce<jon.pei...@gmail.com>:
>>>>> Sorry Alexandre, PsychoPy really isn't designed for that. To get the
>>>>> performance needed PsychoPy makes use of a variety of low-level
>>>>> graphics (OpenGL) commands and these can't be run via the web. I
>>>>> suppose you could do something yourself using VNC windows, but it would
>>>>> have horrible performance.
>>>>> Jon

>>>>> On 09/08/2010 15:13, Alexandre Blondin Mass� wrote:
>>>>>> Hello, everyone !
>>>>>> Having been a Sage and Python user for the last year, I was really
>>>>>> happy to fall on psychopy. I'm interested in running a simple
>>>>>> experiment and would gladly code it in Python, but there is a big
>>>>>> problem: If possible, I would like the experiment to be done online
>>>>>> from our server. Is it possible ? And what would be the best way to do
>>>>>> it ?
>>>>>> I know that there exists a hybrid language called Jython that allows
>>>>>> one to create applets in Python, but I don't know if it works well
>>>>>> with psychopy.
>>>>>> Thank you in advance for the answers !

>>>>>> Alexandre Blondin Mass�

Jason Locklin

unread,
Aug 13, 2010, 11:11:48 AM8/13/10
to psychop...@googlegroups.com
> >>>>> On 09/08/2010 15:13, Alexandre Blondin Massé wrote:
> >>>>>> .... I'm interested in

> >>>>>> running a simple experiment and would gladly code it in
> >>>>>> Python, but there is a big problem: If possible, I would
> >>>>>> like the experiment to be done online from our server. Is
> >>>>>> it possible ? And what would be the best way to do it ?...

> >>>>>> Alexandre Blondin Massé
> >>>>>> Ph.D. student, UQAM

On Friday 13 August 2010 3:55:31 am Jonathan Peirce wrote:
> Sorry to be a downer, but I really don't see it working without a
> huge effort (that would amount to starting from scratch). An app
> engine solution for running experiments that dont require high
> temporal precision is a really interesting idea, but I don't
> honestly think psychopy is the starting point for it.
>
> Jon
>

A few years ago I looked into this in general. Obviously, the easiest
way to run simple experiments over the web is with standard web
languages, i.e., html driven by a server-side scripting language like
php, python, or perl. Unfortunately, that gives very little control
over the way the experiment is presented (it will always be inside a
browser for one thing, and you have zero control over timing). Html5
and modern javascript give excellent control over display, but
unfortunately are not yet reliably consistent across different web
browsers. I have seen Adobe Flash based experiments done. Most
computers have flash and it allows full-screen displays, but is an
expensive and proprietary programming language, and rules out some
operating systems (and has speed issues on others).

I ended up writing a rough full-screen questionnaire-type experiment
engine using Java a few years back for a course. If the user has
Java, you can run your experiment with either Java WebStart or by
downloading and doubleclicking on a Jar file. Using Java allows the
user to simply click a link to run your experiment, and does not
require any installation of software. Java is more difficult to
program than Python, but is free, has opensource implementations for
nearly all operating systems, and gives access to all operating
system resources with "reasonable" timing. Stay away from java
applets though.

Just my 2 cents.
Jason Locklin


Alexandre Blondin Massé

unread,
Aug 13, 2010, 6:31:40 PM8/13/10
to psychopy-users
I'm glad for all the propositions everyone has suggested...

After discussing the matter with the groupe I'm working with, we think
that it would be good to have two versions of the experiment : one
online and one installed somewhere in our lab computers. The best
solution I see so far would be to program it in Python (which is my
current favorite language, I prefer to avoid Java as much as I can)
for the lab computer version, and to create an extension of it for the
online version. People would have to install it on their computer (not
via a browser) and I would try using the packages dealing with http
protocols in Python to communicate with the server to store the
answers from the subject. I'll still continue to discuss it with my
colleagues and think about it, but it seems to be the best answer up
to date for our needs.

Thank you again everyone!

Alex

Jeremy Gray

unread,
Aug 13, 2010, 9:58:30 PM8/13/10
to psychop...@googlegroups.com
I have a couple short code bits that I'm happy to share. the first is taken right from http://docs.python.org/library/httplib.html, and sends data via POST to a server (eg, the data from an experiment run outside of a lab is sent back to a lab). the other (actually two small php scripts and directories) sits on a web server (eg, in your lab), receives the data, and dumps it to a file and adds a line about the IP address it came from. I'll share "as is" -- I can't provide troubleshooting or other support. to use securely, there's more than just using the scripts, you'd need to a web server with proper .htaccess, ideally https, a non-standard port, etc. let me know if interested and I'll send directly (not to the list).

--Jeremy


--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To post to this group, send email to psychop...@googlegroups.com.
To unsubscribe from this group, send email to psychopy-user...@googlegroups.com.

Horea Christian

unread,
Sep 14, 2013, 11:26:08 PM9/14/13
to psychop...@googlegroups.com
Hi, I'm also interested in running some online behavioural tests (if possible with psychopy) - do you have your code on github, Jeremy? is it all python?

Cheers,

Jeremy Gray

unread,
Sep 15, 2013, 6:05:32 AM9/15/13
to psychop...@googlegroups.com
Hi Horea,

The code I have is not for having people do experiments in a web browser, so its probably not what you want. I was responding to this part of the thread: "People would have to install it on their computer (not via a browser) and I would try using the packages dealing with http protocols in Python to communicate with the server to store the answers from the subject." My code for this is now in PsychoPy, in two parts. One part has a demo of how to use it, coder > misc > http_upload.py, basically its just: web.upload(url, filename)

The other part is little php scripts to receive files on the server end, i.e. the server pointed to by url in the above example. These do not have a demo, but the scripts are distributed with PsychoPy, in psychopy/contrib/http/   The main one to look at is up.php (up for "upload"), its basically receive, sanitize, and save the file.

A version of this is actually used to receive benchmark data that people upload to psychopy.org/benchmark/ There's more than just up.php running on the server. There's also event-notification using inotify to trigger a python script when a new incoming data file is saved by up.php into a given directory. The python script generates a new .html file.

--Jeremy




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.

gabri...@gmail.com

unread,
Feb 22, 2015, 6:12:44 AM2/22/15
to psychop...@googlegroups.com, olivier...@gmail.com
Hi Alexander,

I am having the exact same issue and wanted to know how it worked out using a downloadable PsychoPy file

and connecting over the Internet?

Thanks!

Adrian
Reply all
Reply to author
Forward
0 new messages