MRI trigger

Hello, I am trying to receive the trigger signal from the scanner and then run the matlab script.
In my system, I will get the trigger pulse through the parallel port on my desktop. using the code below..

//////////////////////////////////////////////////////

dio = digitalio('parallel','LPT1');
addline(dio,0:8,'in');
ram=getvalue(dio);

//////////////////////////////////////////////////////

If I get the trigger pulse, is the value of "ram" changed? I tried to test this, but I can't because I don't know how to wait the trigger signal after running the matlab script.
Here are my questions

1. Is it possible to use the code to receive the trigger and then execute the script(task) ?
2. If so, how can I wait like as the function of "KbWait" until the trigger come in ?

Thanks in advance.


well you'll need to wrap getvalue with a while loop to detect a change, right? are you asking how to use an interrupt instead of polling? on windows, the lpt ports do get irq's assigned, so it would be cool to find out how to use them.

the second half of this article shows how to do it in c:
http://et.nmsu.edu/~etti/fall96/computer/printer/printer.html

matlab's daq toolbox has deprecated/removed parallel port support afaik (and it was slow anyway). on windows, you can use the methods described here:
http://psychtoolbox.org/FaqTTLTrigger

on linux, see
http://tech.groups.yahoo.com/group/psychtoolbox/message/13352

-e


--- In psychtoolbox@yahoogroups.com, Hye Young Heo <hyeyoungheo@...> wrote:
>
> Hello, I am trying to receive the trigger signal from the scanner and then
> run the matlab script.
> In my system, I will get the trigger pulse through the parallel port on my
> desktop. using the code below..
>
> //////////////////////////////////////////////////////
>
> dio = digitalio('parallel','LPT1');
> addline(dio,0:8,'in');
> ram=getvalue(dio);
>
> //////////////////////////////////////////////////////
>
> If I get the trigger pulse, is the value of "ram" changed? I tried to test
> this, but I can't because I don't know how to wait the trigger signal after
> running the matlab script.
> Here are my questions
>
> 1. Is it possible to use the code to receive the trigger and then execute
> the script(task) ?
> 2. If so, how can I wait like as the function of "KbWait" until the trigger
> come in ?
>
> Thanks in advance.
>