# fMRI triggers and non-slip timing issues

**URL:** https://discourse.psychopy.org/t/fmri-triggers-and-non-slip-timing-issues/39749
**Category:** Coding
**Tags:** timing, screen
**Created:** [April 23, 2024, 12:07pm UTC](https://discourse.psychopy.org/t/fmri-triggers-and-non-slip-timing-issues/39749 "2024-04-23T12:07:58Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![HuaiyuLiu](https://avatars.discourse-cdn.com/v4/letter/h/779978/32.png) [@HuaiyuLiu](https://discourse.psychopy.org/u/HuaiyuLiu)
#### Post date: [April 23, 2024, 12:07pm UTC](https://discourse.psychopy.org/t/fmri-triggers-and-non-slip-timing-issues/39749/1 "2024-04-23T12:07:58Z")

</div>

Dear PsychoPy Community,

Sorry to interrupt you. I am going to run my fMRI experiment and will use PsychoPy to present stimuli. I have two questions about **triggers** and **timing** in fMRI. Hence I would like to ask here for help.

**1.Overview of the fMRI task** : My task is a very simple block-design. There are two types of blocks: a task block and a rest block, each of them will last for 15s. In the task block a word ‘TAP’ will be presented, whereas in the rest block a fixation cross ‘+’ will be presented. There is NO need to press any buttons or give behavioral responses. People just need to watch these two words and do simple finger-tapping behavior.  
**2. My questions:**

1. The scanner will Emmulate a keypress ‘5’ to rigger my experiment at the start the task. I am unsure whether I write the correct psychopy code.
2. I need to record the start time for each block (e.g., 0, 15, 30, 45, etc). Given that a non-slip global clock timing is recommended. I am unsure whether I write the correct psychopy code.

**3. What I would like to kindly ask?**  
Could I ask someone to check my code and see whether I solved the above-mentioned two questions correctly? If NOT, might you give me some corrections?

Thank you very much in advance, any suggestions are very welcome and highly appreciated.  
[finger\_tap\_task.py](https://discourse.psychopy.org/uploads/short-url/sqA33T1pf3b1rxXotQRjqrZ0XAC.py) (2.1 KB)

---

<div class="post-metadata">

### Author: ![HuaiyuLiu](https://avatars.discourse-cdn.com/v4/letter/h/779978/32.png) [@HuaiyuLiu](https://discourse.psychopy.org/u/HuaiyuLiu)
#### Post date: [April 23, 2024, 6:36pm UTC](https://discourse.psychopy.org/t/fmri-triggers-and-non-slip-timing-issues/39749/2 "2024-04-23T18:36:46Z")

</div>

Hi @jon , sorry for the disturb, may I have your inputs?

---

<div class="post-metadata">

### Author: ![jon](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jon/32/22_2.png) [@jon](https://discourse.psychopy.org/u/jon)
#### Post date: [April 24, 2024, 10:23am UTC](https://discourse.psychopy.org/t/fmri-triggers-and-non-slip-timing-issues/39749/3 "2024-04-24T10:23:33Z")

</div>

Sorry, no. PsychoPy has 40,000 users. There’s no way I (or the community) can individually check their python scripts for errors. Please use the forum to solve specific questions.

---

<div class="post-metadata">

### Author: ![HuaiyuLiu](https://avatars.discourse-cdn.com/v4/letter/h/779978/32.png) [@HuaiyuLiu](https://discourse.psychopy.org/u/HuaiyuLiu)
#### Post date: [April 25, 2024, 10:05am UTC](https://discourse.psychopy.org/t/fmri-triggers-and-non-slip-timing-issues/39749/4 "2024-04-25T10:05:35Z")

</div>

Hi @jon , thank you for the reply.  
However, as you might notice that, I put this question on forum. But not everyone get replies. I wonder is there a mechanism or some solutions in this forum to solve this? Otherwise some people’s questions never get replies.

---

<div class="post-metadata">

### Author: ![jon](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jon/32/22_2.png) [@jon](https://discourse.psychopy.org/u/jon)
#### Post date: [April 30, 2024, 11:33am UTC](https://discourse.psychopy.org/t/fmri-triggers-and-non-slip-timing-issues/39749/5 "2024-04-30T11:33:19Z")

</div>

I think the reason you didn’t get a response is because you asked for people to “check your code”. That’s a time-consuming request so, again, not very sustainable if everybody started asking the same question

---

<div class="post-metadata">

### Author: ![pmolfese](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/pmolfese/32/35899_2.png) [@pmolfese](https://discourse.psychopy.org/u/pmolfese)
#### Post date: [May 2, 2024, 3:45pm UTC](https://discourse.psychopy.org/t/fmri-triggers-and-non-slip-timing-issues/39749/6 "2024-05-02T15:45:14Z")

</div>

Challenging to check your code without the dependencies like the `fingerTap_sequence_X.txt` files. The code _looks_ fine. But the easiest way to check is to use a stop-watch and/or write out log files with the times things start and stop. A little bit of drift in fMRI isn’t going to matter, we (fMRI folks) measure things (for the most part) in seconds, so if you’re missing a few dozen (or even hundred) milliseconds at the end of your task, it’s going to be fine.
