# Trigger, count images =&gt; change stimulus?

**URL:** <https://psychtoolbox.discourse.group/t/trigger-count-images-gt-change-stimulus/1233>\
**Category:** Uncategorized\
**Created:** [October 19, 2011, 9:31am UTC](https://psychtoolbox.discourse.group/t/trigger-count-images-gt-change-stimulus/1233 "2011-10-19T09:31:55Z")\
**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:** [October 19, 2011, 9:31am UTC](https://psychtoolbox.discourse.group/t/trigger-count-images-gt-change-stimulus/1233/1 "2011-10-19T09:31:55Z")

</div>

Hello,  
  
I've the following problem. I want to make several measurements at Siemens scanner.  
I use different EPI-sequences consecutively (automatically).   
  
In the different EPI-sequences I would display a different visual stimulus.   
  
1) EPI 1: FMRI Stimulus 1  
2) EPI 2: FMRI Stimulus 2  
3) EPI 1: FMRI Stimulus 1  
4) EPI 2: FMRI Stimulus 2  
and so one...   
  
As the measurement time after for --for example-- EPI1 seems to vary between 46 and 48 seconds  
(only a manual measurement with a watch, but the end of the psychtoolbox-script [the presented stimulus]  
and the measurement of the scanner doesn't seem to be the same)  
  
Furthermore the shimming time seems also to vary, therefore a fixed time value seems not so appropriate.  
  
My new idea is to use the trigger to end the presentation of "Stimulus 1" and wait for the next   
trigger/starting trigger of EPI 2.  
  
My first step was to count how often I type 6 (the trigger pulse is the key 6). I only type   
5 times '6' but the counter goes to 23... (my numer\_images was 24)  
  
----  
  
while (count\_bild \< number\_images)  
  
 if KbCheck(KbName('6'))  
 count\_image=count\_image + 1 ;  
 ['Count\_' int2str(count\_image)]  
 end  
  
end  
  
---  
  
Does anyone have the same problem, or already solved it? At which part of the documentation should I closer look?  
  
  
Thanks  
  
Andi

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [October 22, 2011, 5:43pm UTC](https://psychtoolbox.discourse.group/t/trigger-count-images-gt-change-stimulus/1233/2 "2011-10-22T17:43:47Z")

</div>

KbStrokeWait would have worked here.  
  
KbTriggerWait, maybe followed by a KbReleaseWait to avoid counting the same trigger multiple times, would also work and provide higher robustness against misdesigned or misconfigured trigger hardware on scanners. KbTriggerWait is made to wait for fast scanner keyboard triggers.  
  
-mario  
  

> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "Diederick C. Niehorster" \<dcnieho@...\> wrote:  
> \>  
> \> Dont use KbCheck, it'll report that the key is down as long as it is down,  
> \> which will be for multiple frames. See help KbCheck and check out the other  
> \> functions it mentions to see which suits you best.  
> \>   
> \> Best,  
> \> Dee  
> \>   
> \> On Wed, Oct 19, 2011 at 17:31, \<\_andi\_\_@...\> wrote:  
> \>   
> \> \> \*\*  
> \> \>  
> \> \>  
> \> \> Hello,  
> \> \>  
> \> \> I've the following problem. I want to make several measurements at Siemens  
> \> \> scanner.  
> \> \> I use different EPI-sequences consecutively (automatically).  
> \> \>  
> \> \> In the different EPI-sequences I would display a different visual stimulus.  
> \> \>  
> \> \>  
> \> \> 1) EPI 1: FMRI Stimulus 1  
> \> \> 2) EPI 2: FMRI Stimulus 2  
> \> \> 3) EPI 1: FMRI Stimulus 1  
> \> \> 4) EPI 2: FMRI Stimulus 2  
> \> \> and so one...  
> \> \>  
> \> \> As the measurement time after for --for example-- EPI1 seems to vary  
> \> \> between 46 and 48 seconds  
> \> \> (only a manual measurement with a watch, but the end of the  
> \> \> psychtoolbox-script [the presented stimulus]  
> \> \> and the measurement of the scanner doesn't seem to be the same)  
> \> \>  
> \> \> Furthermore the shimming time seems also to vary, therefore a fixed time  
> \> \> value seems not so appropriate.  
> \> \>  
> \> \> My new idea is to use the trigger to end the presentation of "Stimulus 1"  
> \> \> and wait for the next  
> \> \> trigger/starting trigger of EPI 2.  
> \> \>  
> \> \> My first step was to count how often I type 6 (the trigger pulse is the key  
> \> \> 6). I only type  
> \> \> 5 times '6' but the counter goes to 23... (my numer\_images was 24)  
> \> \>  
> \> \> ----  
> \> \>  
> \> \> while (count\_bild \< number\_images)  
> \> \>  
> \> \> if KbCheck(KbName('6'))  
> \> \> count\_image=count\_image + 1 ;  
> \> \> ['Count\_' int2str(count\_image)]  
> \> \> end  
> \> \>  
> \> \> end  
> \> \>  
> \> \> ---  
> \> \>  
> \> \> Does anyone have the same problem, or already solved it? At which part of  
> \> \> the documentation should I closer look?  
> \> \>  
> \> \> Thanks  
> \> \>  
> \> \> Andi  
> \> \>   
> \> \>  
> \>
