From c959ff8ec3b61cbe5d90ad6ee97bd5d0404c43ce Mon Sep 17 00:00:00 2001 From: Jonathan Shor <11262246+JonathanShor@users.noreply.github.com> Date: Wed, 16 Jul 2025 16:41:04 -0400 Subject: [PATCH] Update construct_stim_matrices.py Guard against v[: len(v) - temp] wrapping. This could happen in the case that len(v) < prenumlag + postnumlag. --- glmsingle/design/construct_stim_matrices.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/glmsingle/design/construct_stim_matrices.py b/glmsingle/design/construct_stim_matrices.py index 3187501..4e5cc48 100644 --- a/glmsingle/design/construct_stim_matrices.py +++ b/glmsingle/design/construct_stim_matrices.py @@ -18,7 +18,8 @@ def construct_stim_matrices(m, prenumlag=0, postnumlag=0, wantwrap=0): stimulus points in the future wantwrap (bool, optional): Defaults to False. whether to wrap - around + around. Not Implemented. + Returns: [2d matrix]: a stimulus matrix of dimensions size(m,2) x ((prenumlag+postnumlag+1)*size(m,1)). @@ -63,7 +64,8 @@ def construct_stim_matrix(v, prenumlag, postnumlag, wantwrap=0): postnumlag ([int]): this is the number of stimulus points in the future - wantwrap (int, optional): Defaults to 0. whether to wrap around + wantwrap (int, optional): Defaults to 0. whether to wrap around. Not + implemented. Returns: @@ -88,6 +90,9 @@ def construct_stim_matrix(v, prenumlag, postnumlag, wantwrap=0): # vindx = range(len(v), 1 - temp) # findx = range(len(v)+temp) # f[findx, p] = v[vindx] + elif len(v) - temp <= 0: + # no more stimulus points to add + break else: f[temp:, p] = v[: len(v) - temp] return f