[visionegg] Re: stimulus code outputs
- From: Andrew Straw <astraw@xxxxxxxxxxx>
- To: visionegg@xxxxxxxxxxxxx
- Date: Thu, 24 Mar 2005 02:00:41 -0800
Hi Christophe,
This email is a bit afield from visual stimuli, but a colleague of mine
has recently been programming RTAI linux and found it to work very
well. RTAI runs as a kernel module which, as far as I understand it,
inserts itself between the hardware and the rest of the kernel,
allowing hard realtime-scheduled tasks to execute with higher priority
than even the kernel. IIRC, he was getting maximum latencies on the
order of 10 microseconds writing out bits on the parallel port on a 800
MHz PIII. This hard-realtime task can communicate with normal userland
programs via FIFOs (acting like a file object), shared memory, and
possibly other mechanisms. I think this is particularly interesting
because it can run on an otherwise standard linux system, allowing, for
example, visual stimuli to be drawn while the parallel port operates in
this hard-realtime fashion.
As far as I can tell, this kind of approach won't work for devices such
as USB, firewire, and video because the drivers for these things would
have to be written to have deterministic latency. As far as I know,
there are no open source drivers which do that, and I'm not even sure
about proprietary commercial solutions.
Anyhow, just some food for thought...
Finally, a question about your code -- I always read those notes about
the resolution of "ticks" in SDL/pygame and got scared away from using
them. Thus, the Vision Egg generally uses Python standard library
calls. I see you are using pygame's get_ticks(). Does this perform
differently than time.time() on linux? Also, by using a "busy wait" [I
think pygame.time.delay() is], does the kernel scheduler penalize your
process? If not, I would agree this is probably more accurate than a
time.sleep(). I'll try to test this soon myself.
Cheers!
Andrew
On Mar 24, 2005, at 1:23 AM, Christophe Pallier wrote:
Hello Darren,
Expy is an attempt to re-implement with pygame an old, (venerable ;-),
DOS experimental stimulator (EXPE: www.lscp.net/expe) which I wrote
15 years ago (and is still used nowdays in some labs, for its
"perfect" timing). Expy is extremely preliminary and we should not
have put the web page in my opinion, because the program is not really
usable. Emmanuel Dupoux and I hope to be able to recruit a programmer
to pursue this project, but we are still looking for funding. Still if
you can steal any ideas from the project, it would not have been
entirely useless.
I would really like to use python/pygame and maybe VisionEgg to
program experiments. Actually, a colleague, Mark Welxer, and I, have
experimented with python a bit and encouraged students to use it: see
http://cim.risc.cnrs.fr/cours/exphum/projects/projects.shtml), but I
need to convinced myself that I can solve some latencies problems (not
specific to python) for some experiments (I work under Linux; the
situation may be better with Windows). Just try the following very
simple minded program to see the latencies you can get:
import pygame
a= pygame.time.get_ticks()
max=-1
for i in range (1,1000):
b = pygame.time.get_ticks()
c = b-a
if c>max:
max=c
a = b
t.delay(10)
print max
(I just got max=140 msec on my system).
I know VisionEgg offers to swith to 'real-time' mode (SCHED_FIFO in
Linux), but I have had bad experience in the past with real-time
processes slowing down other threads (e.g. sound output was choppy).
But I have not tested VisionEgg enough yet.
Anyway, maybe a good idea would be to set up some repository of real
experiments programmed in python, using whatever packages (visionegg,
pygame or other). This would encourage people to try and test these
packages.
Christophe Pallier
www.pallier.org
Darren Weber wrote:
I notice that pyserial and pyparallel are used by expy - seems there
is more than one development effort in python for psychology
experiments; I wonder if some sort of integration of efforts might be
possible/useful?
http://www.ehess.fr/centres/lscp/expy/expy.html
On Wed, 23 Mar 2005 09:58:25 -0800, Darren Weber
<darrenleeweber@xxxxxxxxx> wrote:
http://pyserial.sourceforge.net/
On Wed, 23 Mar 2005 09:47:58 -0800, Darren Weber
<darrenleeweber@xxxxxxxxx> wrote:
The visionegg provides display capabilities, but what about output
of
a stimulus code event to an external device. For example, lets say
we
present an image every 2 sec and there are 5 different categories of
image. Each category is given a code, a number between 0-255. Now,
we want to send this code to an EEG | MEG | fMRI system that will
record the timing of this event code during the acquisition of
another
data timeseries. It is simple enough to save a stimulus/event log
to
a file, but it would be nice to interact with the serial/parallel
port
also. Is there a command like:
eventCode = 128 # or eventID (maybe event.id)
event.send.parallelport(eventCode)
event.send.serialport(eventCode)
I don't have any experience with sending codes to the
serial/parallel
port. Any tips or reading material would be really useful.
Best, Darren
======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html
======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html
======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html
- Follow-Ups:
- [visionegg] Re: stimulus code outputs
- From: Christophe Pallier
- References:
- [visionegg] stimulus code outputs
- From: Darren Weber
- [visionegg] Re: stimulus code outputs
- From: Darren Weber
- [visionegg] Re: stimulus code outputs
- From: Darren Weber
- [visionegg] Re: stimulus code outputs
- From: Christophe Pallier
Other related posts:
- » [visionegg] stimulus code outputs
- » [visionegg] Re: stimulus code outputs
- » [visionegg] Re: stimulus code outputs
- » [visionegg] Re: stimulus code outputs
- » [visionegg] Re: stimulus code outputs
- » [visionegg] Re: stimulus code outputs
- » [visionegg] Re: stimulus code outputs
- » [visionegg] Re: stimulus code outputs
- » [visionegg] Re: stimulus code outputs
Hello Darren,
Expy is an attempt to re-implement with pygame an old, (venerable ;-), DOS experimental stimulator (EXPE: www.lscp.net/expe) which I wrote 15 years ago (and is still used nowdays in some labs, for its "perfect" timing). Expy is extremely preliminary and we should not have put the web page in my opinion, because the program is not really usable. Emmanuel Dupoux and I hope to be able to recruit a programmer to pursue this project, but we are still looking for funding. Still if you can steal any ideas from the project, it would not have been entirely useless.
I would really like to use python/pygame and maybe VisionEgg to program experiments. Actually, a colleague, Mark Welxer, and I, have experimented with python a bit and encouraged students to use it: see http://cim.risc.cnrs.fr/cours/exphum/projects/projects.shtml), but I need to convinced myself that I can solve some latencies problems (not specific to python) for some experiments (I work under Linux; the situation may be better with Windows). Just try the following very simple minded program to see the latencies you can get:
import pygame
a= pygame.time.get_ticks()
max=-1
for i in range (1,1000):
b = pygame.time.get_ticks()
c = b-a
if c>max:
max=c
a = b
t.delay(10)
print max(I just got max=140 msec on my system).
I know VisionEgg offers to swith to 'real-time' mode (SCHED_FIFO in Linux), but I have had bad experience in the past with real-time processes slowing down other threads (e.g. sound output was choppy). But I have not tested VisionEgg enough yet.
Anyway, maybe a good idea would be to set up some repository of real experiments programmed in python, using whatever packages (visionegg, pygame or other). This would encourage people to try and test these packages.
Christophe Pallier www.pallier.org
Darren Weber wrote:
I notice that pyserial and pyparallel are used by expy - seems there is more than one development effort in python for psychology experiments; I wonder if some sort of integration of efforts might be possible/useful?
http://www.ehess.fr/centres/lscp/expy/expy.html
On Wed, 23 Mar 2005 09:58:25 -0800, Darren Weber <darrenleeweber@xxxxxxxxx> wrote:
http://pyserial.sourceforge.net/
On Wed, 23 Mar 2005 09:47:58 -0800, Darren Weber <darrenleeweber@xxxxxxxxx> wrote:
The visionegg provides display capabilities, but what about output of
a stimulus code event to an external device. For example, lets say we
present an image every 2 sec and there are 5 different categories of
image. Each category is given a code, a number between 0-255. Now,
we want to send this code to an EEG | MEG | fMRI system that will
record the timing of this event code during the acquisition of another
data timeseries. It is simple enough to save a stimulus/event log to
a file, but it would be nice to interact with the serial/parallel port
also. Is there a command like:
eventCode = 128 # or eventID (maybe event.id) event.send.parallelport(eventCode) event.send.serialport(eventCode)
I don't have any experience with sending codes to the serial/parallel
port. Any tips or reading material would be really useful.
Best, Darren
====================================== The Vision Egg mailing list Archives: http://www.freelists.org/archives/visionegg Website: http://www.visionegg.org/mailinglist.html
====================================== The Vision Egg mailing list Archives: http://www.freelists.org/archives/visionegg Website: http://www.visionegg.org/mailinglist.html
- [visionegg] Re: stimulus code outputs
- From: Christophe Pallier
- [visionegg] stimulus code outputs
- From: Darren Weber
- [visionegg] Re: stimulus code outputs
- From: Darren Weber
- [visionegg] Re: stimulus code outputs
- From: Darren Weber
- [visionegg] Re: stimulus code outputs
- From: Christophe Pallier