# Design matrix creation with different stimulus durations

**URL:** <https://mne.discourse.group/t/design-matrix-creation-with-different-stimulus-durations/6394>\
**Category:** Support & Discussions\
**Tags:** fnirs\
**Created:** [February 22, 2023, 10:28am UTC](https://mne.discourse.group/t/design-matrix-creation-with-different-stimulus-durations/6394 "2023-02-22T10:28:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeremie](https://avatars.discourse-cdn.com/v4/letter/j/e47c2d/32.png) [@Jeremie](https://mne.discourse.group/u/Jeremie)\
**Post date:** [February 22, 2023, 10:28am UTC](https://mne.discourse.group/t/design-matrix-creation-with-different-stimulus-durations/6394/1 "2023-02-22T10:28:40Z")

</div>

Hi everyone,  
I am working on an event-related design with fNIRS and I am preparing the design matrix for GLM analysis. By following the great examples given on the website, I am now at the design matrix creation step.  
The events in my design are of variable durations which are specified in the annotation object of my data (for example, the events 3,4,5 are of duration 2.9s and the events 13,14,15 of 6s etc…).  
I am then using the mne\_nirs.experimental\_design.make\_first\_level\_design\_matrix() function that requires a stim\_dur specification.  
The function thus generates a design matrix where all the events from my annotations are of the same duration.  
What I would expect is a design matrix where each event duration woud be taken into account.  
So I’m afraid that the following GLM won’t take into account the fact that my events have variable durations.  
Maybe I’m just not understanding the function properly, but if someone would be able to help with that, that would be amazing 🙂

---

<div class="post-metadata">

**Author:** ![Jeremie](https://avatars.discourse-cdn.com/v4/letter/j/e47c2d/32.png) [@Jeremie](https://mne.discourse.group/u/Jeremie)\
**Post date:** [February 23, 2023, 10:40am UTC](https://mne.discourse.group/t/design-matrix-creation-with-different-stimulus-durations/6394/2 "2023-02-23T10:40:35Z")

</div>

Hi again, I allow myself to tag @rob-luke because it is a NIRS specific question, hope I am not out of line doing this 🙂

---

<div class="post-metadata">

**Author:** ![Jeremie](https://avatars.discourse-cdn.com/v4/letter/j/e47c2d/32.png) [@Jeremie](https://mne.discourse.group/u/Jeremie)\
**Post date:** [February 23, 2023, 1:36pm UTC](https://mne.discourse.group/t/design-matrix-creation-with-different-stimulus-durations/6394/3 "2023-02-23T13:36:05Z")

</div>

Hi there,  
In the end I managed to copy and modify the make\_first\_level\_design\_matrix() function by replacing the stim\_dur argument by my data’s annotation (raw.annotation.duration) and it works perfectly, each of my design matrix regressor is specific to the annotation’s durations.  
I saw that in the native Nilearn function, it was possible to do so. Maybe it might be something that would be easy to specify as an argument in a future version?  
Sorry for disturbing you, but maybe it would be a topic that would interest people who encountered the same problem, so I’ll mark this commentary as the solution.  
Best to everyone  
Jérémie
