# Adding fMRI null events

**URL:** <https://discourse.psychopy.org/t/adding-fmri-null-events/34481>\
**Category:** Coding\
**Created:** [April 20, 2023, 2:35pm UTC](https://discourse.psychopy.org/t/adding-fmri-null-events/34481 "2023-04-20T14:35:48Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jonathan.kominsky](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jonathan.kominsky](https://discourse.psychopy.org/u/jonathan.kominsky)\
**Post date:** [April 20, 2023, 3:00pm UTC](https://discourse.psychopy.org/t/adding-fmri-null-events/34481/2 "2023-04-20T15:00:34Z")

</div>

First, you might find this thread relevant in general though not to these specific questions: [Confusion about how to implement non-slip timing for trials with known end points](https://discourse.psychopy.org/t/confusion-about-how-to-implement-non-slip-timing-for-trials-with-known-end-points/4479)

> [@Alexane\_Leclerc](#):
>
> 1. How can I make conditional timing for fixation cross? Is it possible?

Yes. You can have a code component with something like this:

**Before routine**

```auto
countdownTimer = core.Clock()
countdownTimer.addTime(thisOrder_loop['time_presentation'])

```

**Each frame**

```auto
if countdownTimer.getTime() <= 0:
    continueRoutine = False

```

That code is fairly modular, you can kind of fit it in or around your existing code without too much difficulty.

> [@Alexane\_Leclerc](#):
>
> 1. How can I do something like: if condition == happy, show the routine presentation of stimuli + rating, and if condition == NE, don’t show the routines, and only show a fixation cross for x seconds (Reminder: the excel sheet is a sequential order)!

There are a few different ways to do it.

One is to have something which sets the image autoDraw property of the images to False, which means it shouldn’t appear. You can put this in your Before Routine code but you may need to add it to the Each Frame code as well. If the fixation cross normally has an offset time, you could set the autoDraw property to True in the Each Frame code (or just call its draw() function directly in that code), which should override the duration time-out.

Another approach is to have an actual branching path where the fixation-only trial is a separate trial altogether. However, that might mess with your timing because there isn’t really a way to do it without creating an additional trial in the loop that will take up at least one frame. So I think for an fMRI experiment specifically it’s probably best to just have the one trial type and control what is or isn’t drawn in.

---

_[View the full topic](https://discourse.psychopy.org/t/adding-fmri-null-events/34481)._
