# MRI trigger

**URL:** <https://psychtoolbox.discourse.group/t/mri-trigger/617>\
**Category:** Uncategorized\
**Created:** [January 12, 2012, 10:01pm UTC](https://psychtoolbox.discourse.group/t/mri-trigger/617 "2012-01-12T22:01:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [January 12, 2012, 10:01pm UTC](https://psychtoolbox.discourse.group/t/mri-trigger/617/1 "2012-01-12T22:01:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![e\_flister](https://avatars.discourse-cdn.com/v4/letter/e/e36b37/32.png) [@e\_flister](https://psychtoolbox.discourse.group/u/e_flister)\
**Post date:** [January 13, 2012, 12:02am UTC](https://psychtoolbox.discourse.group/t/mri-trigger/617/2 "2012-01-13T00:02:37Z")

</div>

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](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](http://psychtoolbox.org/FaqTTLTrigger)  
  
on linux, see  
[http://tech.groups.yahoo.com/group/psychtoolbox/message/13352](http://tech.groups.yahoo.com/group/psychtoolbox/message/13352)  
  
-e  
  
  

> --- In [psychtoolbox@yahoogroups.com](mailto: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.  
> \>
